Changeset 1853


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

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

Location:
trunk/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/bitblock.hpp

    r1847 r1853  
    3636#endif
    3737
    38 template<class block_t> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes(block_t s);
    39 template<class block_t> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes(block_t s);
    40 template<> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes<unsigned long>(unsigned long s) {return cfzl(s);}
    41 //template<> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes<unsigned long long>(unsigned long long s) {return cfzll(s);}
    42 template<> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes<unsigned long>(unsigned long s) {return cbzl(s);}
    43 //template<> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes<unsigned long long>(unsigned long long s) {return cbzll(s);}
    44 
    4538IDISA_ALWAYS_INLINE bool all_true(uint64_t r);
    4639
  • trunk/lib/bitblock128.hpp

    r1826 r1853  
    8383
    8484IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes(bitblock128_t v) {
    85         union {bitblock128_t bitblock; unsigned long elems[sizeof(bitblock128_t)/sizeof(long)];} u;
     85        union {bitblock128_t bitblock; scanword_t elems[sizeof(bitblock128_t)/sizeof(scanword_t)];} u;
    8686        u.bitblock = v;
    8787  uint32_t so_far = 0;
    8888  for (int i = 0; i < sizeof(bitblock128_t)/sizeof(long); i++) {
    89     if (u.elems[i] != 0) return so_far + cfzl(u.elems[i]);
     89    if (u.elems[i] != 0) return so_far + scan_forward_zeroes(u.elems[i]);
    9090    so_far += 8 * sizeof(long);
    9191  }
     
    9494
    9595IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes(bitblock128_t v) {
    96         union {bitblock128_t bitblock; unsigned long elems[sizeof(bitblock128_t)/sizeof(long)];} u;
     96        union {bitblock128_t bitblock; scanword_t elems[sizeof(bitblock128_t)/sizeof(scanword_t)];} u;
    9797        u.bitblock = v;
    9898  uint32_t so_far = 0;
    9999  for (int i = sizeof(bitblock128_t)/sizeof(long) - 1; i >= 0; i--) {
    100     if (u.elems[i] != 0) return so_far + cbzl(u.elems[i]);
     100    if (u.elems[i] != 0) return so_far + scan_backward_zeroes(u.elems[i]);
    101101    so_far += 8 * sizeof(long);
    102102  }
  • trunk/lib/bitstream_iterator.hpp

    r1626 r1853  
    2424                                                                                         blk_pos(0),
    2525                                                                                         strm(s),
    26                                                                                          scan_blk(*((unsigned long *)s)),
     26                                                                                         scan_blk(*((scanword_t *)s)),
    2727                                                                                         scan_blk_cnt(cnt)
    2828        {
     
    9797        int blk_pos;
    9898        BitBlock * strm;
    99         unsigned long scan_blk;
     99        scanword_t scan_blk;
    100100        int scan_blk_cnt;
    101101
     
    104104                while (blk<scan_blk_cnt) {
    105105                        if(scan_blk > 0){
    106                                 pos = cfzl(scan_blk) + blk_pos;
     106                                pos = scan_forward_zeroes(scan_blk) + blk_pos;
    107107                                scan_blk = scan_blk & (scan_blk-1);  // clear rightmost bit
    108108                                return;
  • 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.