Created
May 20, 2014 19:17
-
-
Save Kern--/11ae7fbf99955f46863b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline static s32 BITREV(s32 a) { | |
| s32 ret; | |
| asm __volatile__ ("bitrev %0, %1;" : "=r" (ret) : "r"(a)); | |
| return ret; | |
| } | |
| inline static s32 CLZ(s32 a) { | |
| s32 ret; | |
| asm __volatile__ ("clz %0, %1" : "=r"(ret) : "r" (a)); | |
| return ret; | |
| } | |
| inline static s32 lsbPosition(s32 a) { | |
| return CLZ(BITREV(a)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment