3 #ifndef __CDS_COMPILER_GCC_SPARC_BITOP_H
4 #define __CDS_COMPILER_GCC_SPARC_BITOP_H
8 namespace bitop { namespace platform { namespace gcc { namespace Sparc {
10 // MSB - return index (1..64) of most significant bit in nArg. If nArg == 0 return 0
11 // Source: UltraSPARC Architecture 2007
13 // Test result: this variant and its variation about 100 times slower then generic implementation :-(
14 static inline int sparc_msb64( atomic64u_t nArg )
18 "neg %[nArg], %[result] \n\t"
19 "xnor %[nArg], %[result], %%g5 \n\t"
20 "popc %%g5, %[result] \n\t"
21 "movrz %[nArg], %%g0, %[result] \n\t"
22 : [result] "=r" (result)
29 // MSB - return index (1..32) of most significant bit in nArg. If nArg == 0 return 0
30 static inline int sparc_msb32( uint32_t nArg )
32 return sparc_msb64( (atomic64u_t) nArg );
35 }} // namespace gcc::Sparc
37 using namespace gcc::Sparc;
39 }}} // namespace cds::bitop::platform
42 #endif // #ifndef __CDS_COMPILER_GCC_SPARC_BITOP_H