diff options
author | Andre McCurdy <armccurdy@gmail.com> | 2018-04-18 17:41:00 -0700 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2018-04-19 12:27:16 -0400 |
commit | ea489b8b0d89e391455689b7cc397d0c261677c9 (patch) | |
tree | a810bb435fbac14d1269bf5a5150be808cdf795f /arch | |
parent | 0c6abb58820398ac995305d88f3e6a9f0a692eb7 (diff) | |
download | musl-ea489b8b0d89e391455689b7cc397d0c261677c9.zip musl-ea489b8b0d89e391455689b7cc397d0c261677c9.tar.gz musl-ea489b8b0d89e391455689b7cc397d0c261677c9.tar.bz2 |
provide optimized a_ctz_32 for arm
Provide an ARM specific a_ctz_32 helper function for architecture
versions for which it can be implemented efficiently via the "rbit"
instruction (ie all Thumb-2 capable versions of ARM v6 and above).
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/atomic_arch.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/arm/atomic_arch.h b/arch/arm/atomic_arch.h index c5c56f8..72fcddb 100644 --- a/arch/arm/atomic_arch.h +++ b/arch/arm/atomic_arch.h @@ -91,4 +91,16 @@ static inline int a_clz_32(uint32_t x) return x; } +#if __ARM_ARCH_6T2__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7 + +#define a_ctz_32 a_ctz_32 +static inline int a_ctz_32(uint32_t x) +{ + uint32_t xr; + __asm__ ("rbit %0, %1" : "=r"(xr) : "r"(x)); + return a_clz_32(xr); +} + +#endif + #endif |