Changeset 2037 for trunk


Ignore:
Timestamp:
Apr 20, 2012, 10:18:00 AM (7 years ago)
Author:
cameron
Message:

Add mask_forward_zeroes/mask_reverse_zeroes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/bitblock.hpp

    r1970 r2037  
    4040static IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes(BitBlock v);
    4141static IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes(BitBlock v);
     42static IDISA_ALWAYS_INLINE BitBlock mask_forward_zeroes(uint32_t count);
     43static IDISA_ALWAYS_INLINE BitBlock mask_reverse_zeroes(uint32_t count);
    4244static IDISA_ALWAYS_INLINE uint32_t bitstream_scan(BitBlock * v, uint32_t pos);
    4345static IDISA_ALWAYS_INLINE BitBlock assert_align(BitBlock v);
     
    7981}
    8082
     83IDISA_ALWAYS_INLINE BitBlock mask_forward_zeroes(uint32_t count) {
     84        if (count >= sizeof(BitBlock) * 8) return simd<1>::constant<0>();
     85        else return bitblock::sll(simd<1>::constant<1>(), convert(count));
     86}
     87
    8188IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes(BitBlock v) {
    8289        union {BitBlock bitblock; scanword_t elems[sizeof(BitBlock)/sizeof(scanword_t)];} u;
     
    8895        }
    8996        return so_far;
     97}
     98
     99IDISA_ALWAYS_INLINE BitBlock mask_reverse_zeroes(uint32_t count) {
     100        if (count >= sizeof(BitBlock) * 8) return simd<1>::constant<0>();
     101        else return bitblock::srl(simd<1>::constant<1>(), convert(count));
    90102}
    91103
Note: See TracChangeset for help on using the changeset viewer.