Changeset 1853 for trunk/lib/builtins.hpp
 Timestamp:
 Jan 19, 2012, 7:46:17 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/lib/builtins.hpp
r1850 r1853 29 29 } 30 30 31 #include <intrin.h>32 #pragma intrinsic(_BitScanForward)33 IDISA_ALWAYS_INLINE unsigned long cfzl(unsigned long x) { // Precondition: x > 034 unsigned long zeroes;35 _BitScanForward(&zeroes, x);36 return zeroes;37 }38 39 IDISA_ALWAYS_INLINE unsigned long cbzl(unsigned long x) {40 unsigned long zeroes;41 _BitScanReverse(&zeroes, x);42 return zeroes;43 }44 45 // IDISA_ALWAYS_INLINE unsigned long cfzll(unsigned long long x) { // TODO  test46 // unsigned __int64 zeroes;47 // _BitScanForward(&zeroes, x);48 // return zeroes;49 // }50 51 // IDISA_ALWAYS_INLINE unsigned long cbzll(unsigned long long x) { // TODO  test52 // unsigned __int64 zeroes;53 // _BitScanReverse(&zeroes, x);54 // return zeroes;55 // }56 57 31 #elif defined (__GNUC__) 58 32 … … 64 38 return __builtin_expect(x, 0); 65 39 } 66 67 IDISA_ALWAYS_INLINE unsigned long cfzl(unsigned long x) {68 return __builtin_ctzl(x);69 }70 71 IDISA_ALWAYS_INLINE unsigned long cbzl(unsigned long x) {72 return __builtin_clzl(x);73 }74 75 // IDISA_ALWAYS_INLINE unsigned long cfzll(unsigned long long x) {76 // return __builtin_ctzll(x);77 // }78 79 // IDISA_ALWAYS_INLINE unsigned long cbzll(unsigned long long x) {80 // return __builtin_clzll(x);81 // }82 40 83 41 #endif … … 113 71 } 114 72 73 #undef ScanForwardIntrinsic 74 #undef ScanReverseIntrinsic 75 115 76 #elif defined (__GNUC__) 116 77 … … 126 87 #endif 127 88 128 129 89 IDISA_ALWAYS_INLINE uint32_t scan_forward_zeroes(scanword_t x) { // Precondition: x > 0 130 90 return (uint32_t) ScanForwardIntrinsic((scanword_t) x); … … 134 94 return (uint32_t) ScanBackwardIntrinsic((scanword_t) x); 135 95 } 96 97 #undef ScanForwardIntrinsic 98 #undef ScanReverseIntrinsic 136 99 137 100 #else
Note: See TracChangeset
for help on using the changeset viewer.