14#include "llvm/Support/DataTypes.h"
25 return (UINT32_C(-1)) >> (32 - N);
30 assert(N > 0 && N <= 32);
31 return x&((UINT32_C(-1)) >> (32 - N));
52 if (x&0xFFFF0000) res += 16;
53 if (x&0xFF00FF00) res += 8;
54 if (x&0xF0F0F0F0) res += 4;
55 if (x&0xCCCCCCCC) res += 2;
56 if (x&0xAAAAAAAA) res += 1;
58 assert((UINT32_C(1) << res) == x);
74 return ((UINT64_C(-1)) >> (64 - N));
79 assert(N > 0 && N <= 64);
80 return x&((UINT64_C(-1)) >> (64 - N));
99 assert((x & (x - 1)) == 0);
101 if (x & (UINT64_C(0xFFFFFFFF) << 32))
104 assert((UINT64_C(1) << res) == x);
unsigned indexOfRightmostBit(unsigned x)
unsigned withoutRightmostBit(unsigned x)
unsigned maxValueOfNBits(unsigned N)
unsigned indexOfSingleBit(unsigned x)
unsigned isolateRightmostBit(unsigned x)
unsigned isPowerOfTwo(unsigned x)
unsigned truncateToNBits(unsigned x, unsigned N)
uint64_t truncateToNBits(uint64_t x, unsigned N)
uint64_t isolateRightmostBit(uint64_t x)
uint64_t maxValueOfNBits(unsigned N)
unsigned indexOfSingleBit(uint64_t x)
uint64_t indexOfRightmostBit(uint64_t x)
uint64_t withoutRightmostBit(uint64_t x)
uint64_t isPowerOfTwo(uint64_t x)