16 #ifndef LLVM_ADT_APINT_H
17 #define LLVM_ADT_APINT_H
27 class FoldingSetNodeID;
32 template <
typename T>
class SmallVectorImpl;
91 static_cast<unsigned int>(
sizeof(uint64_t)) * CHAR_BIT,
93 APINT_WORD_SIZE =
static_cast<unsigned int>(
sizeof(uint64_t))
102 APInt(uint64_t *val,
unsigned bits) : BitWidth(bits), pVal(val) {}
107 bool isSingleWord()
const {
return BitWidth <= APINT_BITS_PER_WORD; }
112 static unsigned whichWord(
unsigned bitPosition) {
113 return bitPosition / APINT_BITS_PER_WORD;
120 static unsigned whichBit(
unsigned bitPosition) {
121 return bitPosition % APINT_BITS_PER_WORD;
130 static uint64_t maskBit(
unsigned bitPosition) {
131 return 1ULL << whichBit(bitPosition);
140 APInt &clearUnusedBits() {
142 unsigned wordBits = BitWidth % APINT_BITS_PER_WORD;
150 uint64_t mask = ~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - wordBits);
154 pVal[getNumWords() - 1] &= mask;
160 uint64_t getWord(
unsigned bitPosition)
const {
161 return isSingleWord() ? VAL : pVal[whichWord(bitPosition)];
176 void fromString(
unsigned numBits, StringRef str, uint8_t radix);
184 static void divide(
const APInt &LHS,
unsigned lhsWords,
const APInt &RHS,
185 unsigned rhsWords, APInt *Quotient, APInt *Remainder);
188 void initSlowCase(uint64_t val,
bool isSigned);
191 void initFromArray(ArrayRef<uint64_t>
array);
194 void initSlowCase(
const APInt &that);
197 APInt shlSlowCase(
unsigned shiftAmt)
const;
200 APInt AndSlowCase(
const APInt &RHS)
const;
203 APInt OrSlowCase(
const APInt &RHS)
const;
206 APInt XorSlowCase(
const APInt &RHS)
const;
209 APInt &AssignSlowCase(
const APInt &RHS);
212 bool EqualSlowCase(
const APInt &RHS)
const;
215 bool EqualSlowCase(uint64_t Val)
const;
218 unsigned countLeadingZerosSlowCase()
const;
221 unsigned countTrailingOnesSlowCase()
const;
224 unsigned countPopulationSlowCase()
const;
240 APInt(
unsigned numBits, uint64_t val,
bool isSigned =
false)
241 : BitWidth(numBits), VAL(0) {
242 assert(BitWidth &&
"bitwidth too small");
246 initSlowCase(val, isSigned);
266 APInt(
unsigned numBits,
unsigned numWords,
const uint64_t bigVal[]);
291 APInt(
APInt &&that) : BitWidth(that.BitWidth), VAL(that.VAL) {
306 explicit APInt() : BitWidth(1), VAL(0) {}
344 return VAL == ~
integerPart(0) >> (APINT_BITS_PER_WORD - BitWidth);
345 return countPopulationSlowCase() == BitWidth;
373 return isNegative() && isPowerOf2();
378 assert(N &&
"N == 0 ???");
379 return getActiveBits() <=
N;
384 assert(N &&
"N == 0 ???");
385 return getMinSignedBits() <=
N;
394 return countPopulationSlowCase() == 1;
410 return (getActiveBits() > 64 || getZExtValue() > Limit) ? Limit
419 bool isSplat(
unsigned SplatSizeInBits)
const;
427 return getAllOnesValue(numBits);
432 APInt API = getAllOnesValue(numBits);
442 APInt API(numBits, 0);
452 return getSignedMinValue(BitWidth);
459 return APInt(numBits, UINT64_MAX,
true);
473 APInt getHiBits(
unsigned numBits)
const;
481 APInt getLoBits(
unsigned numBits)
const;
485 APInt Res(numBits, 0);
504 assert(hiBit <= numBits &&
"hiBit out of range");
505 assert(loBit < numBits &&
"loBit out of range");
507 return getLowBitsSet(numBits, hiBit) |
508 getHighBitsSet(numBits, numBits - loBit);
509 return getLowBitsSet(numBits, hiBit - loBit).shl(loBit);
519 assert(hiBitsSet <= numBits &&
"Too many bits to set!");
522 return APInt(numBits, 0);
523 unsigned shiftAmt = numBits - hiBitsSet;
525 if (numBits <= APINT_BITS_PER_WORD)
526 return APInt(numBits, ~0ULL << shiftAmt);
527 return getAllOnesValue(numBits).shl(shiftAmt);
537 assert(loBitsSet <= numBits &&
"Too many bits to set!");
540 return APInt(numBits, 0);
541 if (loBitsSet == APINT_BITS_PER_WORD)
542 return APInt(numBits, UINT64_MAX);
544 if (loBitsSet <= APINT_BITS_PER_WORD)
545 return APInt(numBits, UINT64_MAX >> (APINT_BITS_PER_WORD - loBitsSet));
546 return getAllOnesValue(numBits).lshr(numBits - loBitsSet);
636 for (
unsigned i = 0;
i != getNumWords(); ++
i)
651 if (isSingleWord() && RHS.isSingleWord()) {
653 BitWidth = RHS.BitWidth;
654 return clearUnusedBits();
657 return AssignSlowCase(RHS);
662 if (!isSingleWord()) {
673 memcpy(&VAL, &that.VAL,
sizeof(uint64_t));
677 unsigned ThatBitWidth = that.BitWidth;
679 BitWidth = ThatBitWidth;
691 APInt &operator=(uint64_t RHS);
715 if (isSingleWord()) {
753 APInt &operator-=(uint64_t RHS);
761 *
this =
shl(shiftAmt);
775 assert(BitWidth == RHS.BitWidth &&
"Bit widths must be the same");
778 return AndSlowCase(RHS);
788 assert(BitWidth == RHS.BitWidth &&
"Bit widths must be the same");
791 return OrSlowCase(RHS);
808 assert(BitWidth == RHS.BitWidth &&
"Bit widths must be the same");
810 return APInt(BitWidth, VAL ^ RHS.
VAL);
811 return XorSlowCase(RHS);
851 assert(shiftAmt <= BitWidth &&
"Invalid shift amount");
852 if (isSingleWord()) {
853 if (shiftAmt >= BitWidth)
854 return APInt(BitWidth, 0);
855 return APInt(BitWidth, VAL << shiftAmt);
857 return shlSlowCase(shiftAmt);
861 APInt rotl(
unsigned rotateAmt)
const;
864 APInt rotr(
unsigned rotateAmt)
const;
923 static void udivrem(
const APInt &LHS,
const APInt &RHS,
APInt &Quotient,
926 static void sdivrem(
const APInt &LHS,
const APInt &RHS,
APInt &Quotient,
930 APInt sadd_ov(
const APInt &RHS,
bool &Overflow)
const;
931 APInt uadd_ov(
const APInt &RHS,
bool &Overflow)
const;
932 APInt ssub_ov(
const APInt &RHS,
bool &Overflow)
const;
933 APInt usub_ov(
const APInt &RHS,
bool &Overflow)
const;
934 APInt sdiv_ov(
const APInt &RHS,
bool &Overflow)
const;
935 APInt smul_ov(
const APInt &RHS,
bool &Overflow)
const;
937 APInt sshl_ov(
const APInt &Amt,
bool &Overflow)
const;
938 APInt ushl_ov(
const APInt &Amt,
bool &Overflow)
const;
945 return (maskBit(bitPosition) &
946 (isSingleWord() ? VAL : pVal[whichWord(bitPosition)])) !=
959 assert(BitWidth == RHS.BitWidth &&
"Comparison requires equal bit widths");
961 return VAL == RHS.
VAL;
962 return EqualSlowCase(RHS);
974 return EqualSlowCase(Val);
983 bool eq(
const APInt &RHS)
const {
return (*
this) == RHS; }
999 bool operator!=(uint64_t Val)
const {
return !((*this) == Val); }
1007 bool ne(
const APInt &RHS)
const {
return !((*this) == RHS); }
1015 bool ult(
const APInt &RHS)
const;
1023 bool ult(uint64_t RHS)
const {
1024 return getActiveBits() > 64 ?
false : getZExtValue() < RHS;
1033 bool slt(
const APInt &RHS)
const;
1042 return getMinSignedBits() > 64 ? isNegative() : getSExtValue() < RHS;
1051 bool ule(
const APInt &RHS)
const {
return ult(RHS) || eq(RHS); }
1059 bool ule(uint64_t RHS)
const {
return !ugt(RHS); }
1067 bool sle(
const APInt &RHS)
const {
return slt(RHS) || eq(RHS); }
1075 bool sle(uint64_t RHS)
const {
return !sgt(RHS); }
1083 bool ugt(
const APInt &RHS)
const {
return !ult(RHS) && !eq(RHS); }
1091 bool ugt(uint64_t RHS)
const {
1092 return getActiveBits() > 64 ?
true : getZExtValue() > RHS;
1101 bool sgt(
const APInt &RHS)
const {
return !slt(RHS) && !eq(RHS); }
1110 return getMinSignedBits() > 64 ? !isNegative() : getSExtValue() > RHS;
1127 bool uge(uint64_t RHS)
const {
return !ult(RHS); }
1143 bool sge(int64_t RHS)
const {
return !slt(RHS); }
1157 APInt trunc(
unsigned width)
const;
1165 APInt sext(
unsigned width)
const;
1172 APInt zext(
unsigned width)
const;
1178 APInt sextOrTrunc(
unsigned width)
const;
1184 APInt zextOrTrunc(
unsigned width)
const;
1190 APInt sextOrSelf(
unsigned width)
const;
1196 APInt zextOrSelf(
unsigned width)
const;
1208 for (
unsigned i = 0;
i < getNumWords(); ++
i)
1209 pVal[
i] = UINT64_MAX;
1218 void setBit(
unsigned bitPosition);
1225 memset(pVal, 0, getNumWords() * APINT_WORD_SIZE);
1231 void clearBit(
unsigned bitPosition);
1238 for (
unsigned i = 0;
i < getNumWords(); ++
i)
1239 pVal[
i] ^= UINT64_MAX;
1248 void flipBit(
unsigned bitPosition);
1271 return ((uint64_t)BitWidth + APINT_BITS_PER_WORD - 1) / APINT_BITS_PER_WORD;
1286 unsigned numActiveBits = getActiveBits();
1287 return numActiveBits ? whichWord(numActiveBits - 1) + 1 : 1;
1301 return getActiveBits() + 1;
1312 assert(getActiveBits() <= 64 &&
"Too many bits for uint64_t");
1323 return int64_t(VAL << (APINT_BITS_PER_WORD - BitWidth)) >>
1324 (APINT_BITS_PER_WORD - BitWidth);
1325 assert(getMinSignedBits() <= 64 &&
"Too many bits for int64_t");
1326 return int64_t(pVal[0]);
1333 static unsigned getBitsNeeded(
StringRef str, uint8_t radix);
1344 if (isSingleWord()) {
1345 unsigned unusedBits = APINT_BITS_PER_WORD - BitWidth;
1348 return countLeadingZerosSlowCase();
1388 return countTrailingOnesSlowCase();
1400 return countPopulationSlowCase();
1411 bool formatAsCLiteral =
false)
const;
1416 toString(Str, Radix,
false,
false);
1440 double roundToDouble(
bool isSigned)
const;
1458 T.I = (isSingleWord() ? VAL : pVal[0]);
1472 T.I =
unsigned((isSingleWord() ? VAL : pVal[0]));
1486 return APInt(
sizeof T * CHAR_BIT,
T.I);
1499 return APInt(
sizeof T * CHAR_BIT,
T.I);
1533 if (!getBoolValue())
1542 return lg +
unsigned((*
this)[lg - 1]);
1566 APInt multiplicativeInverse(
const APInt &modulo)
const;
1578 mu magicu(
unsigned LeadingZeros = 0)
const;
1598 static bool tcIsZero(
const integerPart *,
unsigned int);
1601 static int tcExtractBit(
const integerPart *,
unsigned int bit);
1607 static void tcExtract(
integerPart *,
unsigned int dstCount,
1609 unsigned int srcLSB);
1612 static void tcSetBit(
integerPart *,
unsigned int bit);
1615 static void tcClearBit(
integerPart *,
unsigned int bit);
1619 static unsigned int tcLSB(
const integerPart *,
unsigned int);
1620 static unsigned int tcMSB(
const integerPart *parts,
unsigned int n);
1623 static void tcNegate(
integerPart *,
unsigned int);
1645 unsigned int srcParts,
unsigned int dstParts,
1672 unsigned int parts);
1676 static void tcShiftLeft(
integerPart *,
unsigned int parts,
1677 unsigned int count);
1681 static void tcShiftRight(
integerPart *,
unsigned int parts,
1682 unsigned int count);
1688 static void tcComplement(
integerPart *,
unsigned int);
1700 static void tcSetLeastSignificantBits(
integerPart *,
unsigned int,
1744 return std::move(b);
1765 return std::move(b);
1780 namespace APIntOps {
1784 return A.
slt(B) ? A :
B;
1789 return A.
sgt(B) ? A :
B;
1794 return A.
ult(B) ? A :
B;
1799 return A.
ugt(B) ? A :
B;
1821 return (Value != 0) && ((Value + 1) & Value) == 0;
1827 return isMask(numBits, (APIVal -
APInt(numBits, 1)) | APIVal);
1886 return LHS.
ashr(shiftAmt);
1893 return LHS.
lshr(shiftAmt);
1900 return LHS.
shl(shiftAmt);
APInt operator|(const APInt &RHS) const
Bitwise OR operator.
void clearAllBits()
Set every bit to 0.
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type (if unknown returns 0).
APInt ashr(unsigned shiftAmt) const
Arithmetic right-shift function.
std::string & operator+=(std::string &buffer, StringRef string)
static APInt getSignBit(unsigned BitWidth)
Get the SignBit for a specific bit width.
double signedRoundToDouble() const
Converts this signed APInt to a double value.
void flipAllBits()
Toggle every bit to its opposite value.
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
uint64_t getZExtValue() const
Get zero extended value.
APInt operator+(APInt a, const APInt &b)
double RoundAPIntToDouble(const APInt &APIVal)
Converts the given APInt to a double value.
APInt GreatestCommonDivisor(const APInt &Val1, const APInt &Val2)
Compute GCD of two APInt values.
float RoundAPIntToFloat(const APInt &APIVal)
Converts the given APInt to a float vlalue.
bool operator!() const
Logical negation operator.
APInt byteSwap(const APInt &APIVal)
Returns a byte-swapped representation of the specified APInt Value.
void setBit(unsigned bitPosition)
Set a given bit to 1.
void print(raw_ostream &OS, bool isSigned) const
bool ule(uint64_t RHS) const
Unsigned less or equal comparison.
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
SmallBitVector operator&(const SmallBitVector &LHS, const SmallBitVector &RHS)
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Get a value with low bits set.
unsigned getActiveWords() const
Compute the number of active words in the value of this APInt.
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
If this value is smaller than the specified limit, return it, otherwise return the limit value...
bool isMask(unsigned numBits, const APInt &APIVal)
void setAllBits()
Set every bit to 1.
APInt mul(const APInt &LHS, const APInt &RHS)
Function for multiplication operation.
bool slt(int64_t RHS) const
Signed less than comparison.
double roundToDouble(bool isSigned) const
Converts this APInt to a double value.
bool operator!=(uint64_t Val) const
Inequality operator.
unsigned getNumSignBits() const
Computes the number of leading bits of this APInt that are equal to its sign bit. ...
std::size_t countLeadingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the most significant bit to the least stopping at the first 1...
bool uge(uint64_t RHS) const
Unsigned greater or equal comparison.
Magic data for optimising unsigned division by a constant.
void toStringUnsigned(SmallVectorImpl< char > &Str, unsigned Radix=10) const
Considers the APInt to be unsigned and converts it into a string in the radix given.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
APInt add(const APInt &LHS, const APInt &RHS)
Function for addition operation.
APInt Not(const APInt &APIVal)
Bitwise complement function.
bool isNegative() const
Determine sign of this APInt.
APInt urem(const APInt &RHS) const
Unsigned remainder operation.
bool sgt(int64_t RHS) const
Signed greater than comparison.
std::string toString(Error E)
Write all error messages (if any) in E to a string.
bool isSignedIntN(unsigned N, const APInt &APIVal)
Check if the specified APInt has a N-bits signed integer value.
APInt urem(const APInt &LHS, const APInt &RHS)
Function for unsigned remainder operation.
static APInt doubleToBits(double V)
Converts a double to APInt bits.
APInt()
Default constructor that creates an uninteresting APInt representing a 1-bit zero value...
std::size_t countTrailingOnes(T Value, ZeroBehavior ZB=ZB_Width)
Count the number of ones from the least significant bit to the first zero bit.
uint64_t VAL
Used to store the <= 64 bits integer value.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
unsigned logBase2(const APInt &APIVal)
Returns the floor log base 2 of the specified APInt value.
SmallBitVector operator|(const SmallBitVector &LHS, const SmallBitVector &RHS)
bool isShiftedMask(unsigned numBits, const APInt &APIVal)
Return true if the argument APInt value contains a sequence of ones with the remainder zero...
bool isIntN(unsigned N) const
Check if this APInt has an N-bits unsigned integer value.
bool getBoolValue() const
Convert APInt to a boolean value.
APInt lshr(const APInt &LHS, unsigned shiftAmt)
Logical right-shift function.
const APInt & smax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be signed.
APInt shl(unsigned shiftAmt) const
Left-shift function.
const APInt & smin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
bool isIntN(unsigned N, const APInt &APIVal)
Check if the specified APInt has a N-bits unsigned integer value.
APInt zextOrSelf(unsigned width) const
Zero extend or truncate to width.
APInt sub(const APInt &LHS, const APInt &RHS)
Function for subtraction operation.
APInt udiv(const APInt &LHS, const APInt &RHS)
Unsigned division function for APInt.
static bool add(uint64_t *dest, const uint64_t *x, const uint64_t *y, unsigned len)
This function adds the integer array x to the integer array Y and places the result in dest...
bool sgt(const APInt &RHS) const
Signed greather than comparison.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getActiveBits() const
Compute the number of active bits in the value.
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
APInt sdiv(const APInt &LHS, const APInt &RHS)
Signed division function for APInt.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(std::begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
float RoundSignedAPIntToFloat(const APInt &APIVal)
Converts the given APInt to a float value.
APInt ashr(const APInt &LHS, unsigned shiftAmt)
Arithmetic right-shift function.
E & operator^=(E &LHS, E RHS)
unsigned getMinSignedBits() const
Get the minimum bit size for this signed APInt.
APInt Or(const APInt &RHS) const
Bitwise OR function.
bool ult(const APInt &RHS) const
Unsigned less than comparison.
bool operator==(uint64_t Val) const
Equality operator.
bool needsCleanup() const
Returns whether this instance allocated memory.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
bool operator==(const APInt &RHS) const
Equality operator.
bool operator|=(SparseBitVector< ElementSize > &LHS, const SparseBitVector< ElementSize > *RHS)
bool eq(const APInt &RHS) const
Equality comparison.
bool ugt(uint64_t RHS) const
Unsigned greater than comparison.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
APInt srem(const APInt &LHS, const APInt &RHS)
Function for signed remainder operation.
std::size_t countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1...
APInt operator<<(const APInt &Bits) const
Left logical shift operator.
bool sge(const APInt &RHS) const
Signed greather or equal comparison.
bool isMaxSignedValue() const
Determine if this is the largest signed value.
int64_t getSExtValue() const
Get sign extended value.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
const unsigned int integerPartWidth
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
APInt & operator=(const APInt &RHS)
Copy assignment operator.
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
bool sle(const APInt &RHS) const
Signed less or equal comparison.
constexpr bool isPowerOf2_64(uint64_t Value)
isPowerOf2_64 - This function returns true if the argument is a power of two 0 (64 bit edition...
APInt(APInt &&that)
Move Constructor.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
bool isMaxValue() const
Determine if this is the largest unsigned value.
APInt sdiv(const APInt &RHS) const
Signed division function for APInt.
static unsigned getNumWords(unsigned BitWidth)
Get the number of words.
unsigned countPopulation() const
Count the number of bits set.
bool sge(int64_t RHS) const
Signed greater or equal comparison.
static bool isSameValue(const APInt &I1, const APInt &I2)
Determine if two APInts have the same value, after zero-extending one of them (if needed!) to ensure ...
BlockMass operator*(BlockMass L, BranchProbability R)
static uint64_t umul_ov(uint64_t i, uint64_t j, bool &Overflow)
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
APInt srem(const APInt &RHS) const
Function for signed remainder operation.
const APInt & umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
bool ugt(const APInt &RHS) const
Unsigned greather than comparison.
double roundToDouble() const
Converts this unsigned APInt to a double value.
unsigned countPopulation(T Value)
Count the number of set bits in a value.
bool slt(const APInt &RHS) const
Signed less than comparison.
unsigned logBase2() const
APInt Xor(const APInt &RHS) const
Bitwise XOR function.
APInt(const APInt &that)
Simply makes *this a copy of that.
bool isStrictlyPositive() const
Determine if this APInt Value is positive.
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
int32_t exactLogBase2() const
APInt operator^(const APInt &RHS) const
Bitwise XOR operator.
unsigned ceilLogBase2() const
static APInt getSplat(unsigned NewLen, const APInt &V)
Return a value containing V broadcasted over NewLen bits.
Class for arbitrary precision integers.
bool isSignedIntN(unsigned N) const
Check if this APInt has an N-bits signed integer value.
APInt operator<<(unsigned Bits) const
Left logical shift operator.
An opaque object representing a hash code.
const APInt & umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
bool isMinValue() const
Determine if this is the smallest unsigned value.
double bitsToDouble() const
Converts APInt bits to a double.
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
APInt RoundFloatToAPInt(float Float, unsigned width)
Converts a float value into a APInt.
bool sle(uint64_t RHS) const
Signed less or equal comparison.
bool ult(uint64_t RHS) const
Unsigned less than comparison.
bool operator!=(uint64_t V1, const APInt &V2)
bool isAllOnesValue() const
Determine if all bits are set.
bool operator!=(const APInt &RHS) const
Inequality operator.
APInt And(const APInt &RHS) const
Magic data for optimising signed division by a constant.
bool isMinSignedValue() const
Determine if this is the smallest signed value.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
APInt operator~() const
Unary bitwise complement operator.
APInt udiv(const APInt &RHS) const
Unsigned division operation.
const unsigned int host_char_bit
APInt & operator|=(uint64_t RHS)
Bitwise OR assignment operator.
void clearBit(unsigned bitPosition)
Set a given bit to 0.
APInt(unsigned numBits, uint64_t val, bool isSigned=false)
Create a new APInt of numBits width, initialized as val.
bool isSignBit() const
Check if the APInt's value is returned by getSignBit.
SmallBitVector operator^(const SmallBitVector &LHS, const SmallBitVector &RHS)
unsigned countTrailingOnes() const
Count the number of trailing one bits.
APInt & operator<<=(unsigned shiftAmt)
Left-shift assignment function.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
static bool isSplat(ArrayRef< Value * > VL)
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
bool operator[](unsigned bitPosition) const
Array-indexing support.
APInt operator&(const APInt &RHS) const
Bitwise AND operator.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
LLVM Value Representation.
APInt shl(const APInt &LHS, unsigned shiftAmt)
Left-shift function.
const APInt operator--(int)
Postfix decrement operator.
void toStringSigned(SmallVectorImpl< char > &Str, unsigned Radix=10) const
Considers the APInt to be signed and converts it into a string in the radix given.
This class implements an extremely fast bulk output stream that can only output to a stream...
unsigned countLeadingZeros() const
The APInt version of the countLeadingZeros functions in MathExtras.h.
APInt & operator=(APInt &&that)
Move assignment operator.
const APInt operator++(int)
Postfix increment operator.
StringRef - Represent a constant reference to a string, i.e.
APInt zext(unsigned width) const
Zero extend to a new width.
bool operator==(uint64_t V1, const APInt &V2)
static APInt getNullValue(unsigned numBits)
Get the '0' value.
APInt abs() const
Get the absolute value;.
APInt RoundDoubleToAPInt(double Double, unsigned width)
Converts the given double value into a APInt.
T reverseBits(T Val)
Reverse the bits in Val.
unsigned nearestLogBase2() const
static APInt floatToBits(float V)
Converts a float to APInt bits.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
bool operator&=(SparseBitVector< ElementSize > *LHS, const SparseBitVector< ElementSize > &RHS)
double RoundSignedAPIntToDouble(const APInt &APIVal)
Converts the given APInt to a double value.
std::size_t countLeadingOnes(T Value, ZeroBehavior ZB=ZB_Width)
Count the number of ones from the most significant bit to the first zero bit.
uint64_t * pVal
Used to store the >64 bits integer value.
bool ne(const APInt &RHS) const
Inequality comparison.
float bitsToFloat() const
Converts APInt bits to a double.
unsigned getNumWords() const
Get the number of words.