Ignore:
Timestamp:
Jan 19, 2012, 7:46:17 PM (8 years ago)
Author:
ksherdy
Message:

Removed count forward, count reverse wrappers, and introduced
scan_word_t type for compile time architecture dependent scans.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/builtins.hpp

    r1850 r1853  
    2929        }
    3030
    31         #include <intrin.h>
    32         #pragma intrinsic(_BitScanForward)
    33         IDISA_ALWAYS_INLINE unsigned long cfzl(unsigned long x) { // Precondition: x > 0
    34                 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 - test
    46 //              unsigned __int64 zeroes;
    47 //              _BitScanForward(&zeroes, x);
    48 //              return zeroes;
    49 //      }
    50 
    51 //      IDISA_ALWAYS_INLINE unsigned long cbzll(unsigned long long x) { // TODO - test
    52 //              unsigned __int64 zeroes;
    53 //              _BitScanReverse(&zeroes, x);
    54 //              return zeroes;
    55 //      }
    56 
    5731#elif defined (__GNUC__)
    5832
     
    6438                return __builtin_expect(x, 0);
    6539        }
    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 //      }
    8240
    8341#endif
     
    11371        }
    11472
     73        #undef ScanForwardIntrinsic
     74        #undef ScanReverseIntrinsic
     75
    11576#elif defined (__GNUC__)
    11677
     
    12687        #endif
    12788
    128 
    12989        IDISA_ALWAYS_INLINE uint32_t scan_forward_zeroes(scanword_t x) { // Precondition: x > 0
    13090                return (uint32_t) ScanForwardIntrinsic((scanword_t) x);
     
    13494                return (uint32_t) ScanBackwardIntrinsic((scanword_t) x);
    13595        }
     96
     97        #undef ScanForwardIntrinsic
     98        #undef ScanReverseIntrinsic
    13699
    137100#else
Note: See TracChangeset for help on using the changeset viewer.