5 #include <VP_Os/vp_os_types.h>
7 // #undef always_inline
11 #if TARGET_CPU_X86 == 1
13 static INLINE uint32_t _BitScanReverse(uint32_t* index, uint32_t mask)
15 __asm__("bsrl %[mask], %[index]" : [index] "=r" (*index) : [mask] "mr" (mask));
21 static INLINE uint32_t _byteswap_ulong(uint32_t value)
30 static inline uint32_t clz(uint32_t code)
35 _BitScanReverse(&index, code);
42 #endif // TARGET_CPU_X86
44 #if TARGET_CPU_ARM == 1
48 static INLINE uint32_t _byteswap_ulong(uint32_t value)
61 #define usat16( value, imm ) __asm __volatile( "usat16 %0, %1, %0" : "=r" (value) : "0" (value), "I" (imm) )
62 #define usat( value, imm, shift ) __asm __volatile( "usat %0, %2, %0, asr %3" :"=r" (value) :"0" (value), "I" (imm), "I" (shift) )
64 #define uxtb( ret, value, imm ) __asm __volatile ( "uxtb %0, %1, ror %2" : "=r" (ret) : "r" (value), "I" (imm) )
65 #define uxtb16( ret, value, imm ) __asm __volatile ( "uxtb16 %0, %1, ror %2" : "=r" (ret) : "r" (value), "I" (imm) )
66 #define uxth( ret, value, imm ) __asm __volatile ( "uxth %0, %1, ror %2" : "=r" (ret) : "r" (value), "I" (imm) )
70 static INLINE uint32_t _byteswap_ulong(uint32_t value)
75 "eor %1, %2, %2, ror #16\n"
76 "bic %1, %1, #0x00ff0000\n"
77 "mov %0, %2, ror #8\n"
78 "eor %0, %0, %1, lsr #8"
79 : "=r" (value), "=r" (tmp)
88 #define clz __builtin_clz
90 #endif // TARGET_CPU_ARM
92 #define bswap _byteswap_ulong
96 #endif // ! __INTRIN__H__