28#define TWO_TO_THE_32_U64 (1ULL << 32)
31#define TWO_TO_THE_31_S64 (1LL << 31)
34#define ABS(x) ( ((x)>0)?x:-(x) )
37#define XSIGN(x) ( (x) >> 31 )
40#define LOG2_CEIL(x) ( 32 - ldz(x - 1) )
43static uint32_t
ones(uint32_t x) {
44 x -= ((x >> 1) & 0x55555555);
45 x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
46 x = (((x >> 4) + x) & 0x0f0f0f0f);
50 return x & 0x0000003f;
54static uint32_t
ldz(uint32_t x) {
66 uint32_t x = ~n & (n - 32);
83 uint64_t &
add, uint64_t &
sub) {
84 uint64_t x = multiplicand;
90 uint64_t lowbit = 1LL << low;
91 uint64_t p = x + lowbit;
101 if (low && (
add & (lowbit>>1))) {
115 assert(multiplicand ==
add -
sub);
124 sh1 = std::min( l, 1 );
125 sh2 = std::max( l-1, 0 );
130 uint64_t abs_d =
ABS( (int64_t)d );
135 int32_t l = std::max( 1U,
LOG2_CEIL((uint32_t)abs_d) );
#define TWO_TO_THE_32_U64
#define TWO_TO_THE_31_S64
#define add(name, handler, ret)
uint64_t isolateRightmostBit(uint64_t x)
unsigned indexOfSingleBit(uint64_t x)
uint64_t indexOfRightmostBit(uint64_t x)
uint64_t sub(uint64_t l, uint64_t r, unsigned inWidth)
static uint32_t ldz(uint32_t x)
void ComputeMultConstants64(uint64_t multiplicand, uint64_t &add, uint64_t &sub)
static uint32_t ones(uint32_t x)
void ComputeUDivConstants32(uint32_t d, uint32_t &mprime, uint32_t &sh1, uint32_t &sh2)
void ComputeSDivConstants32(int32_t d, int32_t &mprime, int32_t &dsign, int32_t &shpost)
static uint32_t exp_base_2(int32_t n)