15#ifndef LLVM_ADT_APINT_H
16#define LLVM_ADT_APINT_H
28class FoldingSetNodeID;
35template <
typename T>
class SmallVectorImpl;
37template <
typename T,
typename Enable>
struct DenseMapInfo;
83 static constexpr unsigned APINT_WORD_SIZE =
sizeof(
WordType);
86 static constexpr unsigned APINT_BITS_PER_WORD = APINT_WORD_SIZE * CHAR_BIT;
111 if (isSingleWord()) {
135 APInt(
unsigned numBits,
unsigned numWords,
const uint64_t bigVal[]);
163 memcpy(&U, &that.U,
sizeof(U));
188 APInt API = getAllOnes(numBits);
198 APInt API(numBits, 0);
213 return APInt(numBits, WORDTYPE_MAX,
true);
218 APInt Res(numBits, 0);
237 APInt Res(numBits, 0);
250 APInt Res(numBits, 0);
265 APInt Res(numBits, 0);
275 APInt Res(numBits, 0);
285 APInt Res(numBits, 0);
291 static APInt getSplat(
unsigned NewLen,
const APInt &V);
345 return (*
this)[BitNo] &&
popcount() == 1;
353 return U.VAL == WORDTYPE_MAX >> (APINT_BITS_PER_WORD -
BitWidth);
354 return countTrailingOnesSlowCase() ==
BitWidth;
361 return countLeadingZerosSlowCase() ==
BitWidth;
370 return countLeadingZerosSlowCase() ==
BitWidth - 1;
384 if (isSingleWord()) {
388 return !isNegative() && countTrailingOnesSlowCase() ==
BitWidth - 1;
402 if (isSingleWord()) {
406 return isNegative() && countTrailingZerosSlowCase() ==
BitWidth - 1;
410 bool isIntN(
unsigned N)
const {
return getActiveBits() <=
N; }
419 if (isSingleWord()) {
423 return countPopulationSlowCase() == 1;
454 return ugt(Limit) ? Limit : getZExtValue();
462 bool isSplat(
unsigned SplatSizeInBits)
const;
467 assert(numBits != 0 &&
"numBits must be non-zero");
470 return U.VAL == (WORDTYPE_MAX >> (APINT_BITS_PER_WORD - numBits));
471 unsigned Ones = countTrailingOnesSlowCase();
472 return (numBits == Ones) &&
473 ((Ones + countLeadingZerosSlowCase()) ==
BitWidth);
482 unsigned Ones = countTrailingOnesSlowCase();
483 return (Ones > 0) && ((Ones + countLeadingZerosSlowCase()) ==
BitWidth);
491 unsigned Ones = countPopulationSlowCase();
492 unsigned LeadZ = countLeadingZerosSlowCase();
503 unsigned Ones = countPopulationSlowCase();
504 unsigned LeadZ = countLeadingZerosSlowCase();
505 unsigned TrailZ = countTrailingZerosSlowCase();
506 if ((Ones + LeadZ + TrailZ) !=
BitWidth)
519 APInt getHiBits(
unsigned numBits)
const;
527 APInt getLoBits(
unsigned numBits)
const;
536 return I1 == I2.
zext(I1.getBitWidth());
599 if (isSingleWord() &&
RHS.isSingleWord()) {
611#ifdef EXPENSIVE_CHECKS
616 assert(
this != &that &&
"Self-move not supported");
622 memcpy(&U, &that.U,
sizeof(U));
637 if (isSingleWord()) {
642 memset(U.pVal + 1, 0, (getNumWords() - 1) * APINT_WORD_SIZE);
657 andAssignSlowCase(
RHS);
667 if (isSingleWord()) {
672 memset(U.pVal + 1, 0, (getNumWords() - 1) * APINT_WORD_SIZE);
687 orAssignSlowCase(
RHS);
697 if (isSingleWord()) {
716 xorAssignSlowCase(
RHS);
726 if (isSingleWord()) {
765 if (isSingleWord()) {
772 shlSlowCase(ShiftAmt);
807 R.ashrInPlace(ShiftAmt);
814 if (isSingleWord()) {
817 U.VAL = SExtVAL >> (APINT_BITS_PER_WORD - 1);
819 U.VAL = SExtVAL >> ShiftAmt;
823 ashrSlowCase(ShiftAmt);
831 R.lshrInPlace(shiftAmt);
838 if (isSingleWord()) {
845 lshrSlowCase(ShiftAmt);
859 return RelativeShift > 0 ? lshr(RelativeShift) : shl(-RelativeShift);
864 return relativeLShr(-RelativeShift);
869 return RelativeShift > 0 ? ashr(RelativeShift) : shl(-RelativeShift);
874 return relativeAShr(-RelativeShift);
888 R.ashrInPlace(ShiftAmt);
893 void ashrInPlace(
const APInt &shiftAmt);
900 R.lshrInPlace(ShiftAmt);
905 void lshrInPlace(
const APInt &ShiftAmt);
928 if (NewWidth <= APINT_BITS_PER_WORD)
930 return concatSlowCase(NewLSB);
968 int64_t srem(int64_t
RHS)
const;
995 APInt sshl_ov(
const APInt &Amt,
bool &Overflow)
const;
996 APInt sshl_ov(
unsigned Amt,
bool &Overflow)
const;
997 APInt ushl_ov(
const APInt &Amt,
bool &Overflow)
const;
998 APInt ushl_ov(
unsigned Amt,
bool &Overflow)
const;
1014 APInt sshl_sat(
unsigned RHS)
const;
1016 APInt ushl_sat(
unsigned RHS)
const;
1023 return (maskBit(bitPosition) & getWord(bitPosition)) != 0;
1037 return U.VAL ==
RHS.U.VAL;
1038 return equalSlowCase(
RHS);
1048 return (isSingleWord() || getActiveBits() <= 64) && getZExtValue() == Val;
1099 return (isSingleWord() || getActiveBits() <= 64) && getZExtValue() <
RHS;
1117 return (!isSingleWord() && getSignificantBits() > 64)
1119 : getSExtValue() <
RHS;
1170 return (!isSingleWord() && getActiveBits() > 64) || getZExtValue() >
RHS;
1188 return (!isSingleWord() && getSignificantBits() > 64)
1190 : getSExtValue() >
RHS;
1230 return (U.VAL &
RHS.U.VAL) != 0;
1231 return intersectsSlowCase(
RHS);
1238 return (U.VAL & ~
RHS.U.VAL) == 0;
1239 return isSubsetOfSlowCase(
RHS);
1250 APInt trunc(
unsigned width)
const;
1256 APInt truncUSat(
unsigned width)
const;
1263 APInt truncSSat(
unsigned width)
const;
1271 APInt sext(
unsigned width)
const;
1278 APInt zext(
unsigned width)
const;
1284 APInt sextOrTrunc(
unsigned width)
const;
1290 APInt zextOrTrunc(
unsigned width)
const;
1299 U.VAL = WORDTYPE_MAX;
1302 memset(U.pVal, -1, getNumWords() * APINT_WORD_SIZE);
1310 WordType Mask = maskBit(BitPosition);
1314 U.pVal[whichWord(BitPosition)] |= Mask;
1323 setBit(BitPosition);
1325 clearBit(BitPosition);
1335 if (loBit < hiBit) {
1336 setBits(loBit, hiBit);
1348 assert(loBit <= hiBit &&
"loBit greater than hiBit");
1351 if (loBit < APINT_BITS_PER_WORD && hiBit <= APINT_BITS_PER_WORD) {
1352 uint64_t mask = WORDTYPE_MAX >> (APINT_BITS_PER_WORD - (hiBit - loBit));
1359 setBitsSlowCase(loBit, hiBit);
1379 memset(U.pVal, 0, getNumWords() * APINT_WORD_SIZE);
1387 WordType Mask = ~maskBit(BitPosition);
1391 U.pVal[whichWord(BitPosition)] &= Mask;
1413 if (isSingleWord()) {
1414 U.VAL ^= WORDTYPE_MAX;
1417 flipAllBitsSlowCase();
1425 void flipBit(
unsigned bitPosition);
1434 void insertBits(
const APInt &SubBits,
unsigned bitPosition);
1435 void insertBits(
uint64_t SubBits,
unsigned bitPosition,
unsigned numBits);
1439 uint64_t extractBitsAsZExtValue(
unsigned numBits,
unsigned bitPosition)
const;
1462 return ((
uint64_t)
BitWidth + APINT_BITS_PER_WORD - 1) / APINT_BITS_PER_WORD;
1477 unsigned numActiveBits = getActiveBits();
1478 return numActiveBits ? whichWord(numActiveBits - 1) + 1 : 1;
1490 return BitWidth - getNumSignBits() + 1;
1501 assert(getActiveBits() <= 64 &&
"Too many bits for uint64_t");
1511 return (getActiveBits() <= 64) ? std::optional<uint64_t>(getZExtValue())
1523 assert(getSignificantBits() <= 64 &&
"Too many bits for int64_t");
1524 return int64_t(U.pVal[0]);
1533 return (getSignificantBits() <= 64) ? std::optional<int64_t>(getSExtValue())
1541 static unsigned getBitsNeeded(
StringRef str, uint8_t radix);
1546 static unsigned getSufficientBitsNeeded(
StringRef Str, uint8_t Radix);
1556 if (isSingleWord()) {
1557 unsigned unusedBits = APINT_BITS_PER_WORD -
BitWidth;
1560 return countLeadingZerosSlowCase();
1573 if (isSingleWord()) {
1578 return countLeadingOnesSlowCase();
1597 if (isSingleWord()) {
1601 return countTrailingZerosSlowCase();
1616 return countTrailingOnesSlowCase();
1630 return countPopulationSlowCase();
1642 bool formatAsCLiteral =
false,
bool UpperCase =
true,
1643 bool InsertSeparators =
false)
const;
1648 toString(Str, Radix,
false,
false);
1658 APInt byteSwap()
const;
1665 double roundToDouble(
bool isSigned)
const;
1680#ifdef HAS_IEE754_FLOAT128
1681 float128 bitsToQuad()
const {
1682 __uint128_t ul = ((__uint128_t)U.pVal[1] << 64) + U.pVal[0];
1683 return llvm::bit_cast<float128>(ul);
1693 return llvm::bit_cast<float>(
static_cast<uint32_t>(getWord(0)));
1701 return APInt(
sizeof(
double) * CHAR_BIT, llvm::bit_cast<uint64_t>(V));
1709 return APInt(
sizeof(
float) * CHAR_BIT, llvm::bit_cast<uint32_t>(V));
1717 unsigned logBase2()
const {
return getActiveBits() - 1; }
1735 unsigned nearestLogBase2()
const;
1758 APInt multiplicativeInverse()
const;
1772 static void tcSet(WordType *, WordType,
unsigned);
1775 static void tcAssign(WordType *,
const WordType *,
unsigned);
1778 static bool tcIsZero(
const WordType *,
unsigned);
1781 static int tcExtractBit(
const WordType *,
unsigned bit);
1787 static void tcExtract(WordType *,
unsigned dstCount,
const WordType *,
1788 unsigned srcBits,
unsigned srcLSB);
1791 static void tcSetBit(WordType *,
unsigned bit);
1794 static void tcClearBit(WordType *,
unsigned bit);
1798 static unsigned tcLSB(
const WordType *,
unsigned n);
1799 static unsigned tcMSB(
const WordType *parts,
unsigned n);
1802 static void tcNegate(WordType *,
unsigned);
1805 static WordType tcAdd(WordType *,
const WordType *, WordType carry,
unsigned);
1807 static WordType tcAddPart(WordType *, WordType,
unsigned);
1810 static WordType tcSubtract(WordType *,
const WordType *, WordType carry,
1813 static WordType tcSubtractPart(WordType *, WordType,
unsigned);
1825 static int tcMultiplyPart(WordType *dst,
const WordType *src,
1826 WordType multiplier, WordType carry,
1827 unsigned srcParts,
unsigned dstParts,
bool add);
1833 static int tcMultiply(WordType *,
const WordType *,
const WordType *,
1838 static void tcFullMultiply(WordType *,
const WordType *,
const WordType *,
1839 unsigned,
unsigned);
1850 static int tcDivide(WordType *lhs,
const WordType *rhs, WordType *remainder,
1851 WordType *scratch,
unsigned parts);
1855 static void tcShiftLeft(WordType *,
unsigned Words,
unsigned Count);
1859 static void tcShiftRight(WordType *,
unsigned Words,
unsigned Count);
1862 static int tcCompare(
const WordType *,
const WordType *,
unsigned);
1866 return tcAddPart(dst, 1, parts);
1871 return tcSubtractPart(dst, 1, parts);
1908 static unsigned whichWord(
unsigned bitPosition) {
1909 return bitPosition / APINT_BITS_PER_WORD;
1913 static unsigned whichBit(
unsigned bitPosition) {
1914 return bitPosition % APINT_BITS_PER_WORD;
1923 static uint64_t maskBit(
unsigned bitPosition) {
1924 return 1ULL << whichBit(bitPosition);
1935 unsigned WordBits = ((
BitWidth - 1) % APINT_BITS_PER_WORD) + 1;
1938 uint64_t mask = WORDTYPE_MAX >> (APINT_BITS_PER_WORD - WordBits);
1945 U.pVal[getNumWords() - 1] &=
mask;
1951 uint64_t getWord(
unsigned bitPosition)
const {
1952 return isSingleWord() ?
U.VAL :
U.pVal[whichWord(bitPosition)];
1958 void reallocate(
unsigned NewBitWidth);
1972 void fromString(
unsigned numBits, StringRef str, uint8_t radix);
1980 static void divide(
const WordType *
LHS,
unsigned lhsWords,
1981 const WordType *
RHS,
unsigned rhsWords, WordType *Quotient,
1982 WordType *Remainder);
1988 void initFromArray(ArrayRef<uint64_t> array);
1991 void initSlowCase(
const APInt &that);
1994 void shlSlowCase(
unsigned ShiftAmt);
1997 void lshrSlowCase(
unsigned ShiftAmt);
2000 void ashrSlowCase(
unsigned ShiftAmt);
2003 void assignSlowCase(
const APInt &
RHS);
2030 void setBitsSlowCase(
unsigned loBit,
unsigned hiBit);
2033 void flipAllBitsSlowCase();
2036 APInt concatSlowCase(
const APInt &NewLSB)
const;
2039 void andAssignSlowCase(
const APInt &
RHS);
2042 void orAssignSlowCase(
const APInt &
RHS);
2045 void xorAssignSlowCase(
const APInt &
RHS);
2077 return std::move(b);
2097 return std::move(b);
2117 return std::move(b);
2147 return std::move(b);
2168 return std::move(b);
2196 return A.slt(
B) ?
A :
B;
2201 return A.sgt(
B) ?
A :
B;
2206 return A.ult(
B) ?
A :
B;
2211 return A.ugt(
B) ?
A :
B;
2216 return A.sge(
B) ? (
A -
B) : (
B -
A);
2221 return A.uge(
B) ? (
A -
B) : (
B -
A);
2281APInt RoundDoubleToAPInt(
double Double,
unsigned width);
2330 unsigned RangeWidth);
2334std::optional<unsigned> GetMostSignificantDifferentBit(
const APInt &
A,
2348APInt ScaleBitMask(
const APInt &
A,
unsigned NewBitWidth,
2349 bool MatchAllBits =
false);
2354hash_code hash_value(
const APInt &Arg);
2358void StoreIntToMemory(
const APInt &IntVal, uint8_t *Dst,
unsigned StoreBytes);
2362void LoadIntFromMemory(APInt &IntVal,
const uint8_t *Src,
unsigned LoadBytes);
2367 APInt V(
nullptr, 0);
2373 APInt V(
nullptr, 0);
2381 return LHS.getBitWidth() ==
RHS.getBitWidth() &&
LHS ==
RHS;
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
raw_ostream & operator<<(raw_ostream &OS, const binary_le_impl< value_type > &BLE)
#define LLVM_UNLIKELY(EXPR)
static bool isSigned(unsigned int Opcode)
static KnownBits extractBits(unsigned BitWidth, const KnownBits &SrcOpKnown, const KnownBits &OffsetKnown, const KnownBits &WidthKnown)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
static bool isAligned(const Value *Base, const APInt &Offset, Align Alignment, const DataLayout &DL)
static bool isSplat(Value *V)
Return true if V is a splat of a value (which is used when multiplying a matrix with a scalar).
static const char * toString(MIToken::TokenKind TokenKind)
static uint64_t clearUnusedBits(uint64_t Val, unsigned Size)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static uint64_t umul_ov(uint64_t i, uint64_t j, bool &Overflow)
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
Class for arbitrary precision integers.
std::optional< uint64_t > tryZExtValue() const
Get zero extended value if possible.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
bool slt(int64_t RHS) const
Signed less than comparison.
void clearBit(unsigned BitPosition)
Set a given bit to 0.
APInt relativeLShr(int RelativeShift) const
relative logical shift right
bool isNegatedPowerOf2() const
Check if this APInt's negated value is a power of two greater than zero.
APInt zext(unsigned width) const
Zero extend to a new width.
static APInt getSignMask(unsigned BitWidth)
Get the SignMask for a specific bit width.
bool isMinSignedValue() const
Determine if this is the smallest signed value.
APInt operator--(int)
Postfix decrement operator.
uint64_t getZExtValue() const
Get zero extended value.
uint64_t * pVal
Used to store the >64 bits integer value.
void setHighBits(unsigned hiBits)
Set the top hiBits bits.
unsigned popcount() const
Count the number of bits set.
void setBitsFrom(unsigned loBit)
Set the top bits starting from loBit.
APInt operator<<(const APInt &Bits) const
Left logical shift operator.
APInt operator<<(unsigned Bits) const
Left logical shift operator.
unsigned getActiveBits() const
Compute the number of active bits in the value.
bool sgt(int64_t RHS) const
Signed greater than comparison.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
bool operator[](unsigned bitPosition) const
Array-indexing support.
bool operator!=(const APInt &RHS) const
Inequality operator.
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.
APInt & operator&=(const APInt &RHS)
Bitwise AND assignment operator.
APInt abs() const
Get the absolute value.
unsigned ceilLogBase2() const
unsigned countLeadingOnes() const
APInt relativeLShl(int RelativeShift) const
relative logical shift left
APInt & operator=(const APInt &RHS)
Copy assignment operator.
bool sgt(const APInt &RHS) const
Signed greater than comparison.
bool isAllOnes() const
Determine if all bits are set. This is true for zero-width values.
APInt & operator^=(uint64_t RHS)
Bitwise XOR assignment operator.
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
APInt & operator|=(uint64_t RHS)
Bitwise OR assignment operator.
bool isSignMask() const
Check if the APInt's value is returned by getSignMask.
static APInt floatToBits(float V)
Converts a float to APInt bits.
void setSignBit()
Set the sign bit to 1.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool sle(uint64_t RHS) const
Signed less or equal comparison.
bool ult(const APInt &RHS) const
Unsigned less than comparison.
bool uge(uint64_t RHS) const
Unsigned greater or equal comparison.
bool operator!() const
Logical negation operation on this APInt returns true if zero, like normal integers.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
APInt & operator=(uint64_t RHS)
Assignment operator.
APInt relativeAShr(int RelativeShift) const
relative arithmetic shift right
friend hash_code hash_value(const APInt &Arg)
Overload to compute a hash_code for an APInt value.
APInt(const APInt &that)
Copy Constructor.
APInt & operator|=(const APInt &RHS)
Bitwise OR assignment operator.
bool isSingleWord() const
Determine if this APInt just has one word to store value.
bool operator==(uint64_t Val) const
Equality operator.
APInt operator++(int)
Postfix increment operator.
unsigned getNumWords() const
Get the number of words.
bool isMinValue() const
Determine if this is the smallest unsigned value.
APInt ashr(const APInt &ShiftAmt) const
Arithmetic right-shift function.
APInt(unsigned numBits, uint64_t val, bool isSigned=false)
Create a new APInt of numBits width, initialized as val.
APInt()
Default constructor that creates an APInt with a 1-bit zero value.
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
APInt(APInt &&that)
Move Constructor.
bool isNegative() const
Determine sign of this APInt.
APInt concat(const APInt &NewLSB) const
Concatenate the bits from "NewLSB" onto the bottom of *this.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
bool eq(const APInt &RHS) const
Equality comparison.
int32_t exactLogBase2() const
APInt & operator<<=(unsigned ShiftAmt)
Left-shift assignment function.
double roundToDouble() const
Converts this unsigned APInt to a double value.
void clearAllBits()
Set every bit to 0.
APInt relativeAShl(int RelativeShift) const
relative arithmetic shift left
void ashrInPlace(unsigned ShiftAmt)
Arithmetic right-shift this APInt by ShiftAmt in place.
bool sle(const APInt &RHS) const
Signed less or equal comparison.
void negate()
Negate this APInt in place.
static WordType tcDecrement(WordType *dst, unsigned parts)
Decrement a bignum in-place. Return the borrow flag.
unsigned countr_zero() const
Count the number of trailing zero bits.
bool isSignedIntN(unsigned N) const
Check if this APInt has an N-bits signed integer value.
unsigned getNumSignBits() const
Computes the number of leading bits of this APInt that are equal to its sign bit.
bool isOneBitSet(unsigned BitNo) const
Determine if this APInt Value only has the specified bit set.
unsigned countl_zero() const
The APInt version of std::countl_zero.
bool operator==(const APInt &RHS) const
Equality operator.
APInt shl(const APInt &ShiftAmt) const
Left-shift function.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
bool isShiftedMask(unsigned &MaskIdx, unsigned &MaskLen) const
Return true if this APInt value contains a non-empty sequence of ones with the remainder zero.
void setBitsWithWrap(unsigned loBit, unsigned hiBit)
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
APInt lshr(const APInt &ShiftAmt) const
Logical right-shift function.
bool isNonPositive() const
Determine if this APInt Value is non-positive (<= 0).
unsigned countTrailingZeros() const
unsigned getSignificantBits() const
Get the minimum bit size for this signed APInt.
unsigned countLeadingZeros() const
bool isStrictlyPositive() const
Determine if this APInt Value is positive.
void flipAllBits()
Toggle every bit to its opposite value.
static unsigned getNumWords(unsigned BitWidth)
Get the number of words.
bool needsCleanup() const
Returns whether this instance allocated memory.
unsigned countl_one() const
Count the number of leading one bits.
void clearLowBits(unsigned loBits)
Set bottom loBits bits to 0.
unsigned logBase2() const
static APInt getZeroWidth()
Return an APInt zero bits wide.
double signedRoundToDouble() const
Converts this signed APInt to a double value.
bool isShiftedMask() const
Return true if this APInt value contains a non-empty sequence of ones with the remainder zero.
float bitsToFloat() const
Converts APInt bits to a float.
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
bool ule(uint64_t RHS) const
Unsigned less or equal comparison.
APInt ashr(unsigned ShiftAmt) const
Arithmetic right-shift function.
void setAllBits()
Set every bit to 1.
uint64_t VAL
Used to store the <= 64 bits integer value.
bool ugt(uint64_t RHS) const
Unsigned greater than comparison.
bool sge(int64_t RHS) const
Signed greater or equal comparison.
bool getBoolValue() const
Convert APInt to a boolean value.
static APInt doubleToBits(double V)
Converts a double to APInt bits.
bool isMask(unsigned numBits) const
APInt & operator=(APInt &&that)
Move assignment operator.
static WordType tcIncrement(WordType *dst, unsigned parts)
Increment a bignum in-place. Return the carry flag.
APInt & operator^=(const APInt &RHS)
Bitwise XOR assignment operator.
bool isMaxSignedValue() const
Determine if this is the largest signed value.
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
void setBits(unsigned loBit, unsigned hiBit)
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
APInt shl(unsigned shiftAmt) const
Left-shift function.
double bitsToDouble() const
Converts APInt bits to a double.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
unsigned getActiveWords() const
Compute the number of active words in the value of this APInt.
bool ne(const APInt &RHS) const
Inequality 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!...
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
bool isSignBitSet() const
Determine if sign bit of this APInt is set.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
bool slt(const APInt &RHS) const
Signed less than comparison.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
void setLowBits(unsigned loBits)
Set the bottom loBits bits.
bool isIntN(unsigned N) const
Check if this APInt has an N-bits unsigned integer value.
unsigned countTrailingOnes() const
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
std::optional< int64_t > trySExtValue() const
Get sign extended value if possible.
APInt & operator&=(uint64_t RHS)
Bitwise AND assignment operator.
double roundToDouble(bool isSigned) const
Converts this APInt to a double value.
bool isOne() const
Determine if this is a value of 1.
static APInt getBitsSetFrom(unsigned numBits, unsigned loBit)
Constructs an APInt value that has a contiguous range of bits set.
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
void clearHighBits(unsigned hiBits)
Set top hiBits bits to 0.
int64_t getSExtValue() const
Get sign extended value.
void lshrInPlace(unsigned ShiftAmt)
Logical right-shift this APInt by ShiftAmt in place.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
unsigned countr_one() const
Count the number of trailing one bits.
static APInt getBitsSetWithWrap(unsigned numBits, unsigned loBit, unsigned hiBit)
Wrap version of getBitsSet.
bool isSignBitClear() const
Determine if sign bit of this APInt is clear.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
void setBitVal(unsigned BitPosition, bool BitValue)
Set a given bit to a given value.
void clearSignBit()
Set the sign bit to 0.
bool isMaxValue() const
Determine if this is the largest unsigned value.
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.
bool ult(uint64_t RHS) const
Unsigned less than comparison.
bool operator!=(uint64_t Val) const
Inequality operator.
An arbitrary precision integer that knows its signedness.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class provides support for dynamic arbitrary-precision arithmetic.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
An opaque object representing a hash code.
This class implements an extremely fast bulk output stream that can only output to a stream.
std::error_code fromString(StringRef String, Metadata &HSAMetadata)
Converts String to HSAMetadata.
float RoundAPIntToFloat(const APInt &APIVal)
Converts the given APInt to a float value.
const APInt abdu(const APInt &A, const APInt &B)
Determine the absolute difference of two APInts considered to be unsigned.
const APInt abds(const APInt &A, const APInt &B)
Determine the absolute difference of two APInts considered to be signed.
double RoundAPIntToDouble(const APInt &APIVal)
Converts the given APInt to a double value.
const APInt & smin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
const APInt & smax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be signed.
const APInt & umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be unsigned.
APInt RoundFloatToAPInt(float Float, unsigned width)
Converts a float value into a APInt.
APInt RoundDoubleToAPInt(double Double, unsigned width)
Converts the given double value into a APInt.
double RoundSignedAPIntToDouble(const APInt &APIVal)
Converts the given APInt to a double value.
float RoundSignedAPIntToFloat(const APInt &APIVal)
Converts the given APInt to a float value.
const APInt & umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
constexpr T rotr(T V, int R)
int popcount(T Value) noexcept
Count the number of set bits in a value.
APInt operator&(APInt a, const APInt &b)
APInt operator*(APInt a, uint64_t RHS)
int countr_one(T Value)
Count the number of ones from the least significant bit to the first zero bit.
bool operator!=(uint64_t V1, const APInt &V2)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator+=(DynamicAPInt &A, int64_t B)
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator-=(DynamicAPInt &A, int64_t B)
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
APInt operator~(APInt v)
Unary bitwise complement operator.
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
constexpr bool isShiftedMask_64(uint64_t Value)
Return true if the argument contains a non-empty sequence of ones with the remainder zero (64 bit ver...
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator*=(DynamicAPInt &A, int64_t B)
int countl_zero(T Val)
Count number of 0's from the most significant bit to the least stopping at the first 1.
APInt operator^(APInt a, const APInt &b)
constexpr bool isMask_64(uint64_t Value)
Return true if the argument is a non-empty sequence of ones starting at the least significant bit wit...
int countl_one(T Value)
Count the number of ones from the most significant bit to the first zero bit.
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
APInt operator+(APInt a, const APInt &b)
APInt operator|(APInt a, const APInt &b)
T reverseBits(T Val)
Reverse the bits in Val.
constexpr T rotl(T V, int R)
@ Keep
No function return thunk.
auto mask(ShuffFunc S, unsigned Length, OptArgs... args) -> MaskT
This struct is a compact representation of a valid (non-zero power of two) alignment.
static APInt getEmptyKey()
static APInt getTombstoneKey()
static bool isEqual(const APInt &LHS, const APInt &RHS)
static unsigned getHashValue(const APInt &Key)
An information struct used to provide DenseMap with the various necessary components for a given valu...