15#ifndef LLVM_ADT_APINT_H
16#define LLVM_ADT_APINT_H
37template <
typename T,
typename Enable>
struct DenseMapInfo;
112 bool implicitTrunc =
false)
113 : BitWidth(numBits) {
114 if (!implicitTrunc) {
118 "Value must be 0 or -1 for signed 0-bit APInt");
121 "Value is not an N-bit signed value");
125 assert(val == 0 &&
"Value must be zero for unsigned 0-bit APInt");
128 "Value is not an N-bit unsigned value");
153 APInt(
unsigned numBits,
unsigned numWords,
const uint64_t bigVal[]) =
delete;
181 memcpy(&U, &that.U,
sizeof(U));
216 APInt API(numBits, 0);
236 APInt Res(numBits, 0);
255 APInt Res(numBits, 0);
268 APInt Res(numBits, 0);
283 APInt Res(numBits, 0);
293 APInt Res(numBits, 0);
303 APInt Res(numBits, 0);
363 return (*
this)[BitNo] &&
popcount() == 1;
372 return countTrailingOnesSlowCase() == BitWidth;
379 return countLeadingZerosSlowCase() == BitWidth;
388 return countLeadingZerosSlowCase() == BitWidth - 1;
403 assert(BitWidth &&
"zero width values not allowed");
404 return U.VAL == ((
WordType(1) << (BitWidth - 1)) - 1);
406 return !
isNegative() && countTrailingOnesSlowCase() == BitWidth - 1;
421 assert(BitWidth &&
"zero width values not allowed");
422 return U.VAL == (
WordType(1) << (BitWidth - 1));
424 return isNegative() && countTrailingZerosSlowCase() == BitWidth - 1;
438 assert(BitWidth &&
"zero width values not allowed");
441 return isPowerOf2SlowCase();
446 assert(BitWidth &&
"zero width values not allowed");
452 return (LO + TZ) == BitWidth;
485 assert(numBits != 0 &&
"numBits must be non-zero");
486 assert(numBits <= BitWidth &&
"numBits out of range");
489 unsigned Ones = countTrailingOnesSlowCase();
490 return (numBits == Ones) &&
491 ((Ones + countLeadingZerosSlowCase()) == BitWidth);
500 unsigned Ones = countTrailingOnesSlowCase();
501 return (Ones > 0) && ((Ones + countLeadingZerosSlowCase()) == BitWidth);
509 unsigned Ones = countPopulationSlowCase();
510 unsigned LeadZ = countLeadingZerosSlowCase();
511 return (Ones + LeadZ + countTrailingZerosSlowCase()) == BitWidth;
521 unsigned Ones = countPopulationSlowCase();
522 unsigned LeadZ = countLeadingZerosSlowCase();
523 unsigned TrailZ = countTrailingZerosSlowCase();
524 if ((Ones + LeadZ + TrailZ) != BitWidth)
551 bool SignedCompare =
false) {
555 auto ZExtOrSExt = [SignedCompare](
const APInt &
I,
unsigned BitWidth) {
556 return SignedCompare ?
I.sext(BitWidth) :
I.zext(BitWidth);
560 return I1 == ZExtOrSExt(I2, I1.getBitWidth());
625 BitWidth =
RHS.BitWidth;
635#ifdef EXPENSIVE_CHECKS
640 assert(
this != &that &&
"Self-move not supported");
646 memcpy(&U, &that.U,
sizeof(U));
648 BitWidth = that.BitWidth;
677 assert(BitWidth ==
RHS.BitWidth &&
"Bit widths must be the same");
681 andAssignSlowCase(
RHS);
707 assert(BitWidth ==
RHS.BitWidth &&
"Bit widths must be the same");
711 orAssignSlowCase(
RHS);
736 assert(BitWidth ==
RHS.BitWidth &&
"Bit widths must be the same");
740 xorAssignSlowCase(
RHS);
788 assert(ShiftAmt <= BitWidth &&
"Invalid shift amount");
790 if (ShiftAmt == BitWidth)
796 shlSlowCase(ShiftAmt);
831 R.ashrInPlace(ShiftAmt);
837 assert(ShiftAmt <= BitWidth &&
"Invalid shift amount");
840 if (ShiftAmt == BitWidth)
843 U.VAL = SExtVAL >> ShiftAmt;
847 ashrSlowCase(ShiftAmt);
855 R.lshrInPlace(shiftAmt);
861 assert(ShiftAmt <= BitWidth &&
"Invalid shift amount");
863 if (ShiftAmt == BitWidth)
869 lshrSlowCase(ShiftAmt);
883 return RelativeShift > 0 ?
lshr(RelativeShift) :
shl(-RelativeShift);
893 return RelativeShift > 0 ?
ashr(RelativeShift) :
shl(-RelativeShift);
912 R.ashrInPlace(ShiftAmt);
924 R.lshrInPlace(ShiftAmt);
956 return concatSlowCase(NewLSB);
1011 int64_t &Remainder);
1049 return (maskBit(bitPosition) & getWord(bitPosition)) != 0;
1061 assert(BitWidth ==
RHS.BitWidth &&
"Comparison requires equal bit widths");
1063 return U.VAL ==
RHS.U.VAL;
1064 return equalSlowCase(
RHS);
1254 assert(BitWidth ==
RHS.BitWidth &&
"Bit widths must be the same");
1256 return (U.VAL &
RHS.U.VAL) != 0;
1257 return intersectsSlowCase(
RHS);
1262 assert(BitWidth ==
RHS.BitWidth &&
"Bit widths must be the same");
1264 return (U.VAL & ~
RHS.U.VAL) == 0;
1265 return isSubsetOfSlowCase(
RHS);
1270 assert(BitWidth ==
RHS.BitWidth &&
"Bit widths must be the same");
1273 return isInverseOfSlowCase(
RHS);
1351 assert(BitPosition < BitWidth &&
"BitPosition out of range");
1352 WordType Mask = maskBit(BitPosition);
1356 U.pVal[whichWord(BitPosition)] |= Mask;
1375 assert(hiBit <= BitWidth &&
"hiBit out of range");
1376 assert(loBit <= BitWidth &&
"loBit out of range");
1377 if (loBit < hiBit) {
1388 assert(hiBit <= BitWidth &&
"hiBit out of range");
1389 assert(loBit <= hiBit &&
"loBit greater than hiBit");
1400 setBitsSlowCase(loBit, hiBit);
1412 return setBits(BitWidth - hiBits, BitWidth);
1427 assert(BitPosition < BitWidth &&
"BitPosition out of range");
1428 WordType Mask = ~maskBit(BitPosition);
1432 U.pVal[whichWord(BitPosition)] &= Mask;
1438 assert(HiBit <= BitWidth &&
"HiBit out of range");
1439 assert(LoBit <= HiBit &&
"LoBit greater than HiBit");
1444 Mask = ~(Mask << LoBit);
1450 clearBitsSlowCase(LoBit, HiBit);
1456 assert(loBits <= BitWidth &&
"More bits than bitwidth");
1463 assert(hiBits <= BitWidth &&
"More bits than bitwidth");
1477 flipAllBitsSlowCase();
1485 LLVM_ABI void flipBit(
unsigned bitPosition);
1494 LLVM_ABI void insertBits(
const APInt &SubBits,
unsigned bitPosition);
1501 unsigned bitPosition)
const;
1540 return numActiveBits ? whichWord(numActiveBits - 1) + 1 : 1;
1586 return int64_t(U.pVal[0]);
1623 return countLeadingZerosSlowCase();
1641 return countLeadingOnesSlowCase();
1662 return (TrailingZeros > BitWidth ? BitWidth : TrailingZeros);
1664 return countTrailingZerosSlowCase();
1679 return countTrailingOnesSlowCase();
1693 return countPopulationSlowCase();
1705 bool Signed,
bool formatAsCLiteral =
false,
1706 bool UpperCase =
true,
1707 bool InsertSeparators =
false)
const;
1712 toString(Str, Radix,
false,
false);
1744#ifdef HAS_IEE754_FLOAT128
1745 float128 bitsToQuad()
const {
1746 __uint128_t ul = ((__uint128_t)U.pVal[1] << 64) + U.pVal[0];
1799 LLVM_ABI unsigned nearestLogBase2()
const;
1836 LLVM_ABI static void tcSet(WordType *, WordType,
unsigned);
1839 LLVM_ABI static void tcAssign(WordType *,
const WordType *,
unsigned);
1842 LLVM_ABI static bool tcIsZero(
const WordType *,
unsigned);
1845 LLVM_ABI static int tcExtractBit(
const WordType *,
unsigned bit);
1851 LLVM_ABI static void tcExtract(WordType *,
unsigned dstCount,
1852 const WordType *,
unsigned srcBits,
1856 LLVM_ABI static void tcSetBit(WordType *,
unsigned bit);
1859 LLVM_ABI static void tcClearBit(WordType *,
unsigned bit);
1863 LLVM_ABI static unsigned tcLSB(
const WordType *,
unsigned n);
1864 LLVM_ABI static unsigned tcMSB(
const WordType *parts,
unsigned n);
1867 LLVM_ABI static void tcNegate(WordType *,
unsigned);
1870 LLVM_ABI static WordType tcAdd(WordType *,
const WordType *, WordType carry,
1873 LLVM_ABI static WordType tcAddPart(WordType *, WordType,
unsigned);
1876 LLVM_ABI static WordType tcSubtract(WordType *,
const WordType *,
1877 WordType carry,
unsigned);
1879 LLVM_ABI static WordType tcSubtractPart(WordType *, WordType,
unsigned);
1891 LLVM_ABI static int tcMultiplyPart(WordType *dst,
const WordType *src,
1892 WordType multiplier, WordType carry,
1893 unsigned srcParts,
unsigned dstParts,
1900 LLVM_ABI static int tcMultiply(WordType *,
const WordType *,
const WordType *,
1905 LLVM_ABI static void tcFullMultiply(WordType *,
const WordType *,
1906 const WordType *,
unsigned,
unsigned);
1917 LLVM_ABI static int tcDivide(WordType *lhs,
const WordType *rhs,
1918 WordType *remainder, WordType *scratch,
1923 LLVM_ABI static void tcShiftLeft(WordType *,
unsigned Words,
unsigned Count);
1927 LLVM_ABI static void tcShiftRight(WordType *,
unsigned Words,
unsigned Count);
1930 LLVM_ABI static int tcCompare(
const WordType *,
const WordType *,
unsigned);
1946#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1962 unsigned BitWidth = 1;
1968 friend DynamicAPInt;
1973 APInt(
uint64_t *val,
unsigned bits) : BitWidth(bits) { U.pVal = val; }
1978 static unsigned whichWord(
unsigned bitPosition) {
1979 return bitPosition / APINT_BITS_PER_WORD;
1983 static unsigned whichBit(
unsigned bitPosition) {
1984 return bitPosition % APINT_BITS_PER_WORD;
1993 static uint64_t maskBit(
unsigned bitPosition) {
1994 return 1ULL << whichBit(bitPosition);
2005 unsigned WordBits = ((
BitWidth - 1) % APINT_BITS_PER_WORD) + 1;
2008 uint64_t mask = WORDTYPE_MAX >> (APINT_BITS_PER_WORD - WordBits);
2015 U.pVal[getNumWords() - 1] &=
mask;
2021 uint64_t getWord(
unsigned bitPosition)
const {
2022 return LLVM_LIKELY(isSingleWord()) ?
U.VAL :
U.pVal[whichWord(bitPosition)];
2028 void reallocate(
unsigned NewBitWidth);
2042 void fromString(
unsigned numBits, StringRef str, uint8_t radix);
2050 static void divide(
const WordType *
LHS,
unsigned lhsWords,
2051 const WordType *
RHS,
unsigned rhsWords, WordType *Quotient,
2052 WordType *Remainder);
2058 void initFromArray(ArrayRef<uint64_t> array);
2061 LLVM_ABI void initSlowCase(
const APInt &that);
2064 LLVM_ABI void shlSlowCase(
unsigned ShiftAmt);
2067 LLVM_ABI void lshrSlowCase(
unsigned ShiftAmt);
2070 LLVM_ABI void ashrSlowCase(
unsigned ShiftAmt);
2106 LLVM_ABI void setBitsSlowCase(
unsigned loBit,
unsigned hiBit);
2109 LLVM_ABI void clearBitsSlowCase(
unsigned LoBit,
unsigned HiBit);
2112 LLVM_ABI void flipAllBitsSlowCase();
2156 return std::move(b);
2176 return std::move(b);
2196 return std::move(b);
2226 return std::move(b);
2247 return std::move(b);
2275 return A.slt(
B) ?
A :
B;
2280 return A.sgt(
B) ?
A :
B;
2285 return A.ult(
B) ?
A :
B;
2290 return A.ugt(
B) ?
A :
B;
2295 return A.sge(
B) ? (
A -
B) : (
B -
A);
2300 return A.uge(
B) ? (
A -
B) : (
B -
A);
2372LLVM_ABI APInt RoundDoubleToAPInt(
double Double,
unsigned width);
2425LLVM_ABI std::optional<unsigned> GetMostSignificantDifferentBit(
const APInt &
A,
2440 bool MatchAllBits =
false);
2515LLVM_ABI hash_code hash_value(
const APInt &Arg);
2520 unsigned StoreBytes);
2525 unsigned LoadBytes);
2532 return LHS.getBitWidth() ==
RHS.getBitWidth() &&
LHS ==
RHS;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static const MCExpr * setBits(const MCExpr *Dst, const MCExpr *Value, uint32_t Mask, uint32_t Shift, MCContext &Ctx)
Set bits in a kernel descriptor MCExpr field: return ((Dst & ~Mask) | (Value << Shift))
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static constexpr unsigned long long mask(BlockVerifier::State S)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_UNLIKELY(EXPR)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
#define LLVM_LIKELY(EXPR)
static bool isSigned(unsigned Opcode)
static KnownBits extractBits(unsigned BitWidth, const KnownBits &SrcOpKnown, const KnownBits &OffsetKnown, const KnownBits &WidthKnown)
static raw_ostream & operator<<(raw_ostream &OS, const MatchPosition &Pos)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
static bool isAligned(const Value *Base, 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)
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.
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.
bool isInverseOf(const APInt &RHS) const
This operation checks if all bits are set in either this or RHS.
APInt(unsigned numBits, uint64_t val, bool isSigned=false, bool implicitTrunc=false)
Create a new APInt of numBits width, initialized as val.
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.
static constexpr unsigned APINT_WORD_SIZE
Byte size of a word.
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
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()
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.
LLVM_ABI friend hash_code hash_value(const APInt &Arg)
Overload to compute a hash_code for an APInt value.
bool isShiftedMask(unsigned &MaskIdx, unsigned &MaskLen) const
Return true if this APInt value contains a non-empty sequence of ones with the remainder zero.
static constexpr WordType WORDTYPE_MAX
APInt(unsigned numBits, unsigned numWords, const uint64_t bigVal[])=delete
Was equivalent to APInt(numBits, ArrayRef<uint64_t>(bigVal, numWords)) historically,...
static LLVM_ABI WordType tcSubtractPart(WordType *, WordType, unsigned)
DST -= RHS. Returns the carry flag.
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.
static bool isSameValue(const APInt &I1, const APInt &I2, bool SignedCompare=false)
Determine if two APInts have the same value, after zero-extending or sign-extending (if SignedCompare...
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.
static constexpr unsigned APINT_BITS_PER_WORD
Bits in a word.
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 APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
void clearBits(unsigned LoBit, unsigned HiBit)
Clear the bits from LoBit (inclusive) to HiBit (exclusive) to 0.
bool isSignBitSet() const
Determine if sign bit of this APInt is set.
static LLVM_ABI WordType tcAddPart(WordType *, WordType, unsigned)
DST += RHS. Returns the carry flag.
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.
LLVM_ABI 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.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class provides support for dynamic arbitrary-precision arithmetic.
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...
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.
LLVM_ABI 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.
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.
LLVM_ABI APInt RoundDoubleToAPInt(double Double, unsigned width)
Converts the given double value into a APInt.
APInt abds(const APInt &A, const APInt &B)
Determine the absolute difference of two APInts considered to be signed.
double RoundSignedAPIntToDouble(const APInt &APIVal)
Converts the given APInt to a double value.
APInt abdu(const APInt &A, const APInt &B)
Determine the absolute difference of two APInts considered to be unsigned.
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)
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)
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
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.
constexpr int popcount(T Value) noexcept
Count the number of set bits in a value.
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.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
To bit_cast(const From &from) noexcept
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
constexpr T reverseBits(T Val)
Reverse the bits in Val.
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)
constexpr T maskTrailingOnes(unsigned N)
Create a bitmask with the N right-most bits set to 1, and all other bits set to 0.
constexpr T rotl(T V, int R)
@ Keep
No function return thunk.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static bool isEqual(const APInt &LHS, const APInt &RHS)
static LLVM_ABI unsigned getHashValue(const APInt &Key)
An information struct used to provide DenseMap with the various necessary components for a given valu...