52 #pragma GCC diagnostic push 53 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" 57 #pragma GCC diagnostic pop 89 APInt::operator
bool()
const 99 return APInt(lhs) += rhs;
104 return APInt(lhs) -= rhs;
109 return APInt(lhs) *= rhs;
114 return APInt(lhs) /= rhs;
119 return APInt(lhs) %= rhs;
124 return APInt(lhs) &= rhs;
129 return APInt(lhs) |= rhs;
134 return APInt(lhs) ^= rhs;
139 return APInt(lhs) <<= rhs;
144 return APInt(lhs) >>= rhs;
197 _data <<= static_cast<bw_t>(rhs.
_data);
257 _data |= 0x1_apint << i;
262 _data &= ~(0x1_apint << i);
267 return ((
_data >> i) & 1) != 0;
276 #pragma clang diagnostic push 277 #pragma clang diagnostic ignored "-Wconversion" 278 #pragma clang diagnostic ignored "-Wsign-conversion" 280 #pragma GCC diagnostic push 281 #pragma GCC diagnostic ignored "-Wconversion" 282 #pragma GCC diagnostic ignored "-Wsign-conversion" 288 const number mask = (0x1_apint << bw) - 1;
292 _data += (-0x1_apint << bw);
300 const number mask = (0x1_apint << bw) - 1;
304 val += (-0x1_apint << bw);
346 const auto limbs =
_data.backend().limbs();
347 auto nchunks = bw / backend::limb_bits + ((bw % backend::limb_bits) ? 1 : 0);
351 if(
_data.backend().size() < nchunks)
353 lzc += bw -
_data.backend().size() * backend::limb_bits;
357 offset += (bw % backend::limb_bits) ? backend::limb_bits - (bw % backend::limb_bits) : 0;
359 for(
int i =
_data.backend().size() - 1; i >= 0; --i)
361 const auto& val = limbs[i];
364 if(backend::limb_bits == 64)
366 return lzc + __builtin_clzll(val) -
offset;
368 else if(backend::limb_bits == 32)
370 return lzc + __builtin_clz(val) -
offset;
374 THROW_ERROR(
"backend::limb_bits size not supported");
377 lzc += backend::limb_bits;
397 if(
_data.backend().isneg())
401 return std::numeric_limits<number>::digits;
403 return std::numeric_limits<number>::digits + 1 -
404 APInt(-
_data - 1).leadingZeros(std::numeric_limits<number>::digits);
406 else if(
_data.is_zero())
410 return std::numeric_limits<number>::digits -
leadingZeros(std::numeric_limits<number>::digits) +
sign;
414 #pragma clang diagnostic pop 416 #pragma GCC diagnostic pop 421 return (
APInt(1) << bw) - 1;
436 return -(
APInt(1) << (bw - 1));
APInt & extOrTrunc(bw_t bw, bool sign)
static APInt getSignedMinValue(bw_t bw)
APInt & operator|=(const APInt &rhs)
bool bit_tst(bw_t i) const
friend bool operator>=(const APInt &lhs, const APInt &rhs)
exceptions managed by PandA
APInt & operator*=(const APInt &rhs)
static APInt getSignedMaxValue(bw_t bw)
bw_t leadingOnes(bw_t bw) const
friend APInt operator*(const APInt &lhs, const APInt &rhs)
APInt & operator<<=(const APInt &rhs)
friend APInt operator/(const APInt &lhs, const APInt &rhs)
bw_t trailingZeros(bw_t bw) const
APInt & operator-=(const APInt &rhs)
bw_t minBitwidth(bool sign) const
APInt & operator &=(const APInt &rhs)
friend APInt operator>>(const APInt &lhs, const APInt &rhs)
APInt & operator+=(const APInt &rhs)
friend bool operator==(const APInt &lhs, const APInt &rhs)
friend bool operator!=(const APInt &lhs, const APInt &rhs)
friend bool operator<=(const APInt &lhs, const APInt &rhs)
static APInt getMaxValue(bw_t bw)
APInt & operator%=(const APInt &rhs)
boost::multiprecision::number< backend > number
unsigned offset[NUM_VERTICES+1]
friend bool operator<(const APInt &lhs, const APInt &rhs)
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
friend APInt operator &(const APInt &lhs, const APInt &rhs)
bw_t leadingZeros(bw_t bw) const
APInt & operator/=(const APInt &rhs)
bw_t trailingOnes(bw_t bw) const
friend APInt operator<<(const APInt &lhs, const APInt &rhs)
static APInt getMinValue(bw_t bw)
APInt & operator^=(const APInt &rhs)
friend APInt operator|(const APInt &lhs, const APInt &rhs)
APInt & operator>>=(const APInt &rhs)
friend APInt operator^(const APInt &lhs, const APInt &rhs)
friend APInt operator+(const APInt &lhs, const APInt &rhs)
friend APInt operator%(const APInt &lhs, const APInt &rhs)
friend bool operator>(const APInt &lhs, const APInt &rhs)
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...