LLVM 20.0.0git
|
Class for arbitrary precision integers. More...
#include "llvm/ADT/APInt.h"
Public Types | |
enum class | Rounding { DOWN , TOWARD_ZERO , UP } |
typedef uint64_t | WordType |
Public Member Functions | |
Constructors | |
APInt (unsigned numBits, uint64_t val, bool isSigned=false, bool implicitTrunc=false) | |
Create a new APInt of numBits width, initialized as val. | |
APInt (unsigned numBits, ArrayRef< uint64_t > bigVal) | |
Construct an APInt of numBits width, initialized as bigVal[]. | |
APInt (unsigned numBits, unsigned numWords, const uint64_t bigVal[]) | |
Equivalent to APInt(numBits, ArrayRef<uint64_t>(bigVal, numWords)), but deprecated because this constructor is prone to ambiguity with the APInt(unsigned, uint64_t, bool) constructor. | |
APInt (unsigned numBits, StringRef str, uint8_t radix) | |
Construct an APInt from a string representation. | |
APInt () | |
Default constructor that creates an APInt with a 1-bit zero value. | |
APInt (const APInt &that) | |
Copy Constructor. | |
APInt (APInt &&that) | |
Move Constructor. | |
~APInt () | |
Destructor. | |
Unary Operators | |
APInt | operator++ (int) |
Postfix increment operator. | |
APInt & | operator++ () |
Prefix increment operator. | |
APInt | operator-- (int) |
Postfix decrement operator. | |
APInt & | operator-- () |
Prefix decrement operator. | |
bool | operator! () const |
Logical negation operation on this APInt returns true if zero, like normal integers. | |
Assignment Operators | |
APInt & | operator= (const APInt &RHS) |
Copy assignment operator. | |
APInt & | operator= (APInt &&that) |
Move assignment operator. | |
APInt & | operator= (uint64_t RHS) |
Assignment operator. | |
APInt & | operator&= (const APInt &RHS) |
Bitwise AND assignment operator. | |
APInt & | operator&= (uint64_t RHS) |
Bitwise AND assignment operator. | |
APInt & | operator|= (const APInt &RHS) |
Bitwise OR assignment operator. | |
APInt & | operator|= (uint64_t RHS) |
Bitwise OR assignment operator. | |
APInt & | operator^= (const APInt &RHS) |
Bitwise XOR assignment operator. | |
APInt & | operator^= (uint64_t RHS) |
Bitwise XOR assignment operator. | |
APInt & | operator*= (const APInt &RHS) |
Multiplication assignment operator. | |
APInt & | operator*= (uint64_t RHS) |
APInt & | operator+= (const APInt &RHS) |
Addition assignment operator. | |
APInt & | operator+= (uint64_t RHS) |
APInt & | operator-= (const APInt &RHS) |
Subtraction assignment operator. | |
APInt & | operator-= (uint64_t RHS) |
APInt & | operator<<= (unsigned ShiftAmt) |
Left-shift assignment function. | |
APInt & | operator<<= (const APInt &ShiftAmt) |
Left-shift assignment function. | |
Comparison Operators | |
bool | operator== (const APInt &RHS) const |
Equality operator. | |
bool | operator== (uint64_t Val) const |
Equality operator. | |
bool | eq (const APInt &RHS) const |
Equality comparison. | |
bool | operator!= (const APInt &RHS) const |
Inequality operator. | |
bool | operator!= (uint64_t Val) const |
Inequality operator. | |
bool | ne (const APInt &RHS) const |
Inequality comparison. | |
bool | ult (const APInt &RHS) const |
Unsigned less than comparison. | |
bool | ult (uint64_t RHS) const |
Unsigned less than comparison. | |
bool | slt (const APInt &RHS) const |
Signed less than comparison. | |
bool | slt (int64_t RHS) const |
Signed less than comparison. | |
bool | ule (const APInt &RHS) const |
Unsigned less or equal comparison. | |
bool | ule (uint64_t RHS) const |
Unsigned less or equal comparison. | |
bool | sle (const APInt &RHS) const |
Signed less or equal comparison. | |
bool | sle (uint64_t RHS) const |
Signed less or equal comparison. | |
bool | ugt (const APInt &RHS) const |
Unsigned greater than comparison. | |
bool | ugt (uint64_t RHS) const |
Unsigned greater than comparison. | |
bool | sgt (const APInt &RHS) const |
Signed greater than comparison. | |
bool | sgt (int64_t RHS) const |
Signed greater than comparison. | |
bool | uge (const APInt &RHS) const |
Unsigned greater or equal comparison. | |
bool | uge (uint64_t RHS) const |
Unsigned greater or equal comparison. | |
bool | sge (const APInt &RHS) const |
Signed greater or equal comparison. | |
bool | sge (int64_t RHS) const |
Signed greater or equal comparison. | |
bool | intersects (const APInt &RHS) const |
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are both set. | |
bool | isSubsetOf (const APInt &RHS) const |
This operation checks that all bits set in this APInt are also set in RHS. | |
Resizing Operators | |
APInt | trunc (unsigned width) const |
Truncate to new width. | |
APInt | truncUSat (unsigned width) const |
Truncate to new width with unsigned saturation. | |
APInt | truncSSat (unsigned width) const |
Truncate to new width with signed saturation. | |
APInt | sext (unsigned width) const |
Sign extend to a new width. | |
APInt | zext (unsigned width) const |
Zero extend to a new width. | |
APInt | sextOrTrunc (unsigned width) const |
Sign extend or truncate to width. | |
APInt | zextOrTrunc (unsigned width) const |
Zero extend or truncate to width. | |
Bit Manipulation Operators | |
void | setAllBits () |
Set every bit to 1. | |
void | setBit (unsigned BitPosition) |
Set the given bit to 1 whose position is given as "bitPosition". | |
void | setSignBit () |
Set the sign bit to 1. | |
void | setBitVal (unsigned BitPosition, bool BitValue) |
Set a given bit to a given value. | |
void | setBitsWithWrap (unsigned loBit, unsigned hiBit) |
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1. | |
void | setBits (unsigned loBit, unsigned hiBit) |
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1. | |
void | setBitsFrom (unsigned loBit) |
Set the top bits starting from loBit. | |
void | setLowBits (unsigned loBits) |
Set the bottom loBits bits. | |
void | setHighBits (unsigned hiBits) |
Set the top hiBits bits. | |
void | clearAllBits () |
Set every bit to 0. | |
void | clearBit (unsigned BitPosition) |
Set a given bit to 0. | |
void | clearLowBits (unsigned loBits) |
Set bottom loBits bits to 0. | |
void | clearHighBits (unsigned hiBits) |
Set top hiBits bits to 0. | |
void | clearSignBit () |
Set the sign bit to 0. | |
void | flipAllBits () |
Toggle every bit to its opposite value. | |
void | flipBit (unsigned bitPosition) |
Toggles a given bit to its opposite value. | |
void | negate () |
Negate this APInt in place. | |
void | insertBits (const APInt &SubBits, unsigned bitPosition) |
Insert the bits from a smaller APInt starting at bitPosition. | |
void | insertBits (uint64_t SubBits, unsigned bitPosition, unsigned numBits) |
APInt | extractBits (unsigned numBits, unsigned bitPosition) const |
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits). | |
uint64_t | extractBitsAsZExtValue (unsigned numBits, unsigned bitPosition) const |
Mathematics Operations | |
unsigned | logBase2 () const |
unsigned | ceilLogBase2 () const |
unsigned | nearestLogBase2 () const |
int32_t | exactLogBase2 () const |
APInt | sqrt () const |
Compute the square root. | |
APInt | abs () const |
Get the absolute value. | |
APInt | multiplicativeInverse () const |
Static Public Member Functions | |
Value Generators | |
static APInt | getZero (unsigned numBits) |
Get the '0' value for the specified bit-width. | |
static APInt | getZeroWidth () |
Return an APInt zero bits wide. | |
static APInt | getMaxValue (unsigned numBits) |
Gets maximum unsigned value of APInt for specific bit width. | |
static APInt | getSignedMaxValue (unsigned numBits) |
Gets maximum signed value of APInt for a specific bit width. | |
static APInt | getMinValue (unsigned numBits) |
Gets minimum unsigned value of APInt for a specific bit width. | |
static APInt | getSignedMinValue (unsigned numBits) |
Gets minimum signed value of APInt for a specific bit width. | |
static APInt | getSignMask (unsigned BitWidth) |
Get the SignMask for a specific bit width. | |
static APInt | getAllOnes (unsigned numBits) |
Return an APInt of a specified width with all bits set. | |
static APInt | getOneBitSet (unsigned numBits, unsigned BitNo) |
Return an APInt with exactly one bit set in the result. | |
static APInt | getBitsSet (unsigned numBits, unsigned loBit, unsigned hiBit) |
Get a value with a block of bits set. | |
static APInt | getBitsSetWithWrap (unsigned numBits, unsigned loBit, unsigned hiBit) |
Wrap version of getBitsSet. | |
static APInt | getBitsSetFrom (unsigned numBits, unsigned loBit) |
Constructs an APInt value that has a contiguous range of bits set. | |
static APInt | getHighBitsSet (unsigned numBits, unsigned hiBitsSet) |
Constructs an APInt value that has the top hiBitsSet bits set. | |
static APInt | getLowBitsSet (unsigned numBits, unsigned loBitsSet) |
Constructs an APInt value that has the bottom loBitsSet bits set. | |
static APInt | getSplat (unsigned NewLen, const APInt &V) |
Return a value containing V broadcasted over NewLen bits. | |
Static Public Attributes | |
static constexpr unsigned | APINT_WORD_SIZE = sizeof(WordType) |
Byte size of a word. | |
static constexpr unsigned | APINT_BITS_PER_WORD = APINT_WORD_SIZE * CHAR_BIT |
Bits in a word. | |
static constexpr WordType | WORDTYPE_MAX = ~WordType(0) |
Building-block Operations for APInt and APFloat | |
struct | DenseMapInfo< APInt, void > |
class | APSInt |
void | Profile (FoldingSetNodeID &id) const |
Used to insert APInt objects, or objects that contain APInt objects, into FoldingSets. | |
void | dump () const |
debug method | |
bool | needsCleanup () const |
Returns whether this instance allocated memory. | |
static void | tcSet (WordType *, WordType, unsigned) |
Sets the least significant part of a bignum to the input value, and zeroes out higher parts. | |
static void | tcAssign (WordType *, const WordType *, unsigned) |
Assign one bignum to another. | |
static bool | tcIsZero (const WordType *, unsigned) |
Returns true if a bignum is zero, false otherwise. | |
static int | tcExtractBit (const WordType *, unsigned bit) |
Extract the given bit of a bignum; returns 0 or 1. Zero-based. | |
static void | tcExtract (WordType *, unsigned dstCount, const WordType *, unsigned srcBits, unsigned srcLSB) |
Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to DST, of dstCOUNT parts, such that the bit srcLSB becomes the least significant bit of DST. | |
static void | tcSetBit (WordType *, unsigned bit) |
Set the given bit of a bignum. Zero-based. | |
static void | tcClearBit (WordType *, unsigned bit) |
Clear the given bit of a bignum. Zero-based. | |
static unsigned | tcLSB (const WordType *, unsigned n) |
Returns the bit number of the least or most significant set bit of a number. | |
static unsigned | tcMSB (const WordType *parts, unsigned n) |
Returns the bit number of the most significant set bit of a number. | |
static void | tcNegate (WordType *, unsigned) |
Negate a bignum in-place. | |
static WordType | tcAdd (WordType *, const WordType *, WordType carry, unsigned) |
DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag. | |
static WordType | tcAddPart (WordType *, WordType, unsigned) |
DST += RHS. Returns the carry flag. | |
static WordType | tcSubtract (WordType *, const WordType *, WordType carry, unsigned) |
DST -= RHS + CARRY where CARRY is zero or one. Returns the carry flag. | |
static WordType | tcSubtractPart (WordType *, WordType, unsigned) |
DST -= RHS. Returns the carry flag. | |
static int | tcMultiplyPart (WordType *dst, const WordType *src, WordType multiplier, WordType carry, unsigned srcParts, unsigned dstParts, bool add) |
DST += SRC * MULTIPLIER + PART if add is true DST = SRC * MULTIPLIER + PART if add is false. | |
static int | tcMultiply (WordType *, const WordType *, const WordType *, unsigned) |
DST = LHS * RHS, where DST has the same width as the operands and is filled with the least significant parts of the result. | |
static void | tcFullMultiply (WordType *, const WordType *, const WordType *, unsigned, unsigned) |
DST = LHS * RHS, where DST has width the sum of the widths of the operands. | |
static int | tcDivide (WordType *lhs, const WordType *rhs, WordType *remainder, WordType *scratch, unsigned parts) |
If RHS is zero LHS and REMAINDER are left unchanged, return one. | |
static void | tcShiftLeft (WordType *, unsigned Words, unsigned Count) |
Shift a bignum left Count bits. | |
static void | tcShiftRight (WordType *, unsigned Words, unsigned Count) |
Shift a bignum right Count bits. | |
static int | tcCompare (const WordType *, const WordType *, unsigned) |
Comparison (unsigned) of two bignums. | |
static WordType | tcIncrement (WordType *dst, unsigned parts) |
Increment a bignum in-place. Return the carry flag. | |
static WordType | tcDecrement (WordType *dst, unsigned parts) |
Decrement a bignum in-place. Return the borrow flag. | |
Value Tests | |
hash_code | hash_value (const APInt &Arg) |
Overload to compute a hash_code for an APInt value. | |
bool | isSingleWord () const |
Determine if this APInt just has one word to store value. | |
bool | isNegative () const |
Determine sign of this APInt. | |
bool | isNonNegative () const |
Determine if this APInt Value is non-negative (>= 0) | |
bool | isSignBitSet () const |
Determine if sign bit of this APInt is set. | |
bool | isSignBitClear () const |
Determine if sign bit of this APInt is clear. | |
bool | isStrictlyPositive () const |
Determine if this APInt Value is positive. | |
bool | isNonPositive () const |
Determine if this APInt Value is non-positive (<= 0). | |
bool | isOneBitSet (unsigned BitNo) const |
Determine if this APInt Value only has the specified bit set. | |
bool | isAllOnes () const |
Determine if all bits are set. This is true for zero-width values. | |
bool | isZero () const |
Determine if this value is zero, i.e. all bits are clear. | |
bool | isOne () const |
Determine if this is a value of 1. | |
bool | isMaxValue () const |
Determine if this is the largest unsigned value. | |
bool | isMaxSignedValue () const |
Determine if this is the largest signed value. | |
bool | isMinValue () const |
Determine if this is the smallest unsigned value. | |
bool | isMinSignedValue () const |
Determine if this is the smallest signed value. | |
bool | isIntN (unsigned N) const |
Check if this APInt has an N-bits unsigned integer value. | |
bool | isSignedIntN (unsigned N) const |
Check if this APInt has an N-bits signed integer value. | |
bool | isPowerOf2 () const |
Check if this APInt's value is a power of two greater than zero. | |
bool | isNegatedPowerOf2 () const |
Check if this APInt's negated value is a power of two greater than zero. | |
bool | isAligned (Align A) const |
Checks if this APInt -interpreted as an address- is aligned to the provided value. | |
bool | isSignMask () const |
Check if the APInt's value is returned by getSignMask. | |
bool | getBoolValue () const |
Convert APInt to a boolean value. | |
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 | isSplat (unsigned SplatSizeInBits) const |
Check if the APInt consists of a repeated bit pattern. | |
bool | isMask (unsigned numBits) const |
bool | isMask () const |
bool | isShiftedMask () const |
Return true if this APInt value contains a non-empty sequence of ones with the remainder zero. | |
bool | isShiftedMask (unsigned &MaskIdx, unsigned &MaskLen) const |
Return true if this APInt value contains a non-empty sequence of ones with the remainder zero. | |
APInt | getHiBits (unsigned numBits) const |
Compute an APInt containing numBits highbits from this APInt. | |
APInt | getLoBits (unsigned numBits) const |
Compute an APInt containing numBits lowbits from this APInt. | |
const uint64_t * | getRawData () const |
This function returns a pointer to the internal storage of the APInt. | |
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 that the bit-widths match. | |
Binary Operators | |
APInt | operator* (const APInt &RHS) const |
Multiplication operator. | |
APInt | operator<< (unsigned Bits) const |
Left logical shift operator. | |
APInt | operator<< (const APInt &Bits) const |
Left logical shift operator. | |
APInt | ashr (unsigned ShiftAmt) const |
Arithmetic right-shift function. | |
void | ashrInPlace (unsigned ShiftAmt) |
Arithmetic right-shift this APInt by ShiftAmt in place. | |
APInt | lshr (unsigned shiftAmt) const |
Logical right-shift function. | |
void | lshrInPlace (unsigned ShiftAmt) |
Logical right-shift this APInt by ShiftAmt in place. | |
APInt | shl (unsigned shiftAmt) const |
Left-shift function. | |
APInt | relativeLShr (int RelativeShift) const |
relative logical shift right | |
APInt | relativeLShl (int RelativeShift) const |
relative logical shift left | |
APInt | relativeAShr (int RelativeShift) const |
relative arithmetic shift right | |
APInt | relativeAShl (int RelativeShift) const |
relative arithmetic shift left | |
APInt | rotl (unsigned rotateAmt) const |
Rotate left by rotateAmt. | |
APInt | rotr (unsigned rotateAmt) const |
Rotate right by rotateAmt. | |
APInt | ashr (const APInt &ShiftAmt) const |
Arithmetic right-shift function. | |
void | ashrInPlace (const APInt &shiftAmt) |
Arithmetic right-shift this APInt by shiftAmt in place. | |
APInt | lshr (const APInt &ShiftAmt) const |
Logical right-shift function. | |
void | lshrInPlace (const APInt &ShiftAmt) |
Logical right-shift this APInt by ShiftAmt in place. | |
APInt | shl (const APInt &ShiftAmt) const |
Left-shift function. | |
APInt | rotl (const APInt &rotateAmt) const |
Rotate left by rotateAmt. | |
APInt | rotr (const APInt &rotateAmt) const |
Rotate right by rotateAmt. | |
APInt | concat (const APInt &NewLSB) const |
Concatenate the bits from "NewLSB" onto the bottom of *this. | |
APInt | udiv (const APInt &RHS) const |
Unsigned division operation. | |
APInt | udiv (uint64_t RHS) const |
APInt | sdiv (const APInt &RHS) const |
Signed division function for APInt. | |
APInt | sdiv (int64_t RHS) const |
APInt | urem (const APInt &RHS) const |
Unsigned remainder operation. | |
uint64_t | urem (uint64_t RHS) const |
APInt | srem (const APInt &RHS) const |
Function for signed remainder operation. | |
int64_t | srem (int64_t RHS) const |
APInt | sadd_ov (const APInt &RHS, bool &Overflow) const |
APInt | uadd_ov (const APInt &RHS, bool &Overflow) const |
APInt | ssub_ov (const APInt &RHS, bool &Overflow) const |
APInt | usub_ov (const APInt &RHS, bool &Overflow) const |
APInt | sdiv_ov (const APInt &RHS, bool &Overflow) const |
APInt | smul_ov (const APInt &RHS, bool &Overflow) const |
APInt | umul_ov (const APInt &RHS, bool &Overflow) const |
APInt | sshl_ov (const APInt &Amt, bool &Overflow) const |
APInt | sshl_ov (unsigned Amt, bool &Overflow) const |
APInt | ushl_ov (const APInt &Amt, bool &Overflow) const |
APInt | ushl_ov (unsigned Amt, bool &Overflow) const |
APInt | sfloordiv_ov (const APInt &RHS, bool &Overflow) const |
Signed integer floor division operation. | |
APInt | sadd_sat (const APInt &RHS) const |
APInt | uadd_sat (const APInt &RHS) const |
APInt | ssub_sat (const APInt &RHS) const |
APInt | usub_sat (const APInt &RHS) const |
APInt | smul_sat (const APInt &RHS) const |
APInt | umul_sat (const APInt &RHS) const |
APInt | sshl_sat (const APInt &RHS) const |
APInt | sshl_sat (unsigned RHS) const |
APInt | ushl_sat (const APInt &RHS) const |
APInt | ushl_sat (unsigned RHS) const |
bool | operator[] (unsigned bitPosition) const |
Array-indexing support. | |
static void | udivrem (const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder) |
Dual division/remainder interface. | |
static void | udivrem (const APInt &LHS, uint64_t RHS, APInt &Quotient, uint64_t &Remainder) |
static void | sdivrem (const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder) |
static void | sdivrem (const APInt &LHS, int64_t RHS, APInt &Quotient, int64_t &Remainder) |
Value Characterization Functions | |
unsigned | getBitWidth () const |
Return the number of bits in the APInt. | |
unsigned | getNumWords () const |
Get the number of words. | |
unsigned | getActiveBits () const |
Compute the number of active bits in the value. | |
unsigned | getActiveWords () const |
Compute the number of active words in the value of this APInt. | |
unsigned | getSignificantBits () const |
Get the minimum bit size for this signed APInt. | |
uint64_t | getZExtValue () const |
Get zero extended value. | |
std::optional< uint64_t > | tryZExtValue () const |
Get zero extended value if possible. | |
int64_t | getSExtValue () const |
Get sign extended value. | |
std::optional< int64_t > | trySExtValue () const |
Get sign extended value if possible. | |
unsigned | countl_zero () const |
The APInt version of std::countl_zero. | |
unsigned | countLeadingZeros () const |
unsigned | countl_one () const |
Count the number of leading one bits. | |
unsigned | countLeadingOnes () const |
unsigned | getNumSignBits () const |
Computes the number of leading bits of this APInt that are equal to its sign bit. | |
unsigned | countr_zero () const |
Count the number of trailing zero bits. | |
unsigned | countTrailingZeros () const |
unsigned | countr_one () const |
Count the number of trailing one bits. | |
unsigned | countTrailingOnes () const |
unsigned | popcount () const |
Count the number of bits set. | |
static unsigned | getNumWords (unsigned BitWidth) |
Get the number of words. | |
static unsigned | getBitsNeeded (StringRef str, uint8_t radix) |
Get bits required for string value. | |
static unsigned | getSufficientBitsNeeded (StringRef Str, uint8_t Radix) |
Get the bits that are sufficient to represent the string value. | |
Conversion Functions | |
void | print (raw_ostream &OS, bool isSigned) const |
void | toString (SmallVectorImpl< char > &Str, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false) const |
Converts an APInt to a string and append it to Str. | |
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. | |
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. | |
APInt | byteSwap () const |
APInt | reverseBits () const |
double | roundToDouble (bool isSigned) const |
Converts this APInt to a double value. | |
double | roundToDouble () const |
Converts this unsigned APInt to a double value. | |
double | signedRoundToDouble () const |
Converts this signed APInt to a double value. | |
double | bitsToDouble () const |
Converts APInt bits to a double. | |
float | bitsToFloat () const |
Converts APInt bits to a float. | |
static APInt | doubleToBits (double V) |
Converts a double to APInt bits. | |
static APInt | floatToBits (float V) |
Converts a float to APInt bits. | |
Class for arbitrary precision integers.
APInt is a functional replacement for common case unsigned integer type like "unsigned", "unsigned long" or "uint64_t", but also allows non-byte-width integer sizes and large integer value types such as 3-bits, 15-bits, or more than 64-bits of precision. APInt provides a variety of arithmetic operators and methods to manipulate integer values of any bit-width. It supports both the typical integer arithmetic and comparison operations as well as bitwise manipulation.
The class has several invariants worth noting:
typedef uint64_t llvm::APInt::WordType |
|
strong |
|
inline |
Create a new APInt of numBits width, initialized as val.
If isSigned is true then val is treated as if it were a signed value (i.e. as an int64_t) and the appropriate sign extension to the bit width will be done. Otherwise, no sign extension occurs (high order bits beyond the range of val are zero filled).
numBits | the bit width of the constructed APInt |
val | the initial value of the APInt |
isSigned | how to treat signedness of val |
implicitTrunc | allow implicit truncation of non-zero/sign bits of val beyond the range of numBits |
Definition at line 111 of file APInt.h.
References assert(), BitWidth, clearUnusedBits(), llvm::isIntN(), isSigned(), and llvm::isUIntN().
Construct an APInt of numBits width, initialized as bigVal[].
Note that bigVal.size() can be smaller or larger than the corresponding bit width but any extraneous bits will be dropped.
Equivalent to APInt(numBits, ArrayRef<uint64_t>(bigVal, numWords)), but deprecated because this constructor is prone to ambiguity with the APInt(unsigned, uint64_t, bool) constructor.
If this overload is ever deleted, care should be taken to prevent calls from being incorrectly captured by the APInt(unsigned, uint64_t, bool) constructor.
Construct an APInt from a string representation.
This constructor interprets the string str
in the given radix. The interpretation stops when the first character that is not suitable for the radix is encountered, or the end of the string. Acceptable radix values are 2, 8, 10, 16, and 36. It is an error for the value implied by the string to require more bits than numBits.
numBits | the bit width of the constructed APInt |
str | the string to be interpreted |
radix | the radix to use for the conversion |
|
inlineexplicit |
Default constructor that creates an APInt with a 1-bit zero value.
Definition at line 173 of file APInt.h.
Referenced by byteSwap(), extractBits(), operator*(), reverseBits(), sext(), sqrt(), sshl_ov(), trunc(), udiv(), udivrem(), urem(), ushl_ov(), usub_sat(), and zext().
|
inline |
|
inline |
Get the absolute value.
If *this is < 0 then return -(*this), otherwise *this. Note that the "most negative" signed number (e.g. -128 for 8 bit wide APInt) is unchanged due to how negation works.
Definition at line 1773 of file APInt.h.
Referenced by combineSelectOfTwoConstants(), findGCD(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::InstCombinerImpl::foldICmpBinOp(), gcd(), llvm::ScalarEvolution::getAddExpr(), llvm::ExpressionFormat::getMatchingString(), and getRangeForAffineARHelper().
Arithmetic right-shift function.
Arithmetic right-shift this APInt by shiftAmt.
Definition at line 827 of file APInt.h.
Referenced by llvm::ConstantRange::ashr(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), llvm::InstCombinerImpl::foldICmpAndShift(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpShrConstant(), llvm::InstCombinerImpl::foldICmpShrConstConst(), FoldValue(), llvm::AArch64TTIImpl::getIntImmCost(), llvm::X86TTIImpl::getIntImmCost(), llvm::RISCVMatInt::getIntMatCost(), isNonZeroShift(), LowerShift(), performMulCombine(), setLimitsForBinOp(), llvm::InstCombinerImpl::simplifyShrShlDemandedBits(), llvm::Interpreter::visitAShr(), and llvm::InstCombinerImpl::visitSwitchInst().
Arithmetic right-shift this APInt by shiftAmt in place.
Arithmetic right-shift this APInt by shiftAmt.
Arithmetic right-shift function.
Definition at line 1025 of file APInt.cpp.
References ashrInPlace(), and getLimitedValue().
|
inline |
Arithmetic right-shift this APInt by ShiftAmt in place.
Definition at line 834 of file APInt.h.
References assert(), BitWidth, clearUnusedBits(), and llvm::SignExtend64().
Referenced by llvm::KnownBits::ashr(), ashrInPlace(), BuildExactSDIV(), llvm::CombinerHelper::buildSDivUsingMul(), combineVectorShiftImm(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), and llvm::SelectionDAG::FoldConstantArithmetic().
|
inline |
Converts APInt bits to a double.
The conversion does not do a translation from integer to double, it just re-interprets the bits as a double. Note that it is valid to do this on any bit width. Exactly 64 bits will be translated.
Definition at line 1700 of file APInt.h.
Referenced by llvm::detail::IEEEFloat::convertToDouble(), llvm::convertToNonDenormSingle(), and llvm::ExecutionEngine::getConstantValue().
|
inline |
Converts APInt bits to a float.
The conversion does not do a translation from integer to float, it just re-interprets the bits as a float. Note that it is valid to do this on any bit width. Exactly 32 bits will be translated.
Definition at line 1714 of file APInt.h.
Referenced by llvm::detail::IEEEFloat::convertToFloat(), and llvm::ExecutionEngine::getConstantValue().
APInt APInt::byteSwap | ( | ) | const |
Definition at line 719 of file APInt.cpp.
References APInt(), APINT_BITS_PER_WORD, assert(), getNumWords(), I, and N.
Referenced by llvm::DwarfExpression::addConstantFP(), llvm::KnownBits::byteSwap(), computeKnownBitsFromOperator(), foldBitwiseLogicWithIntrinsics(), llvm::SelectionDAG::FoldConstantArithmetic(), and llvm::TargetLowering::SimplifyDemandedBits().
|
inline |
Definition at line 1742 of file APInt.h.
References getActiveBits().
Referenced by ComputeNumSignBitsImpl(), and llvm::InstCombinerImpl::foldICmpUsingKnownBits().
|
inline |
Set every bit to 0.
Definition at line 1397 of file APInt.h.
Referenced by llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), combineAnd(), combineAndnp(), computeForSatAddSub(), llvm::SelectionDAG::computeKnownBits(), llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), llvm::KnownBits::resetAll(), llvm::KnownBits::setAllOnes(), llvm::KnownBits::setAllZero(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::InstCombinerImpl::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), and llvm::InstCombinerImpl::simplifyShrShlDemandedBits().
|
inline |
Set a given bit to 0.
Set the given bit to 0 whose position is given as "bitPosition".
Definition at line 1407 of file APInt.h.
References assert(), and BitWidth.
Referenced by llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), computeKnownFPClass(), llvm::SelectionDAG::ComputeNumSignBits(), defaultComponentBroadcast(), llvm::TargetLowering::expandIS_FPCLASS(), getHopForBuildVector(), getSignedMaxValue(), isKnownNonZeroFromOperator(), llvm::possiblyDemandedEltsInMask(), llvm::recognizeBSwapOrBitReverseIdiom(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::InstCombinerImpl::SimplifyDemandedVectorElts(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), trimTrailingZerosInVector(), and llvm::ConstantRange::truncate().
|
inline |
Set top hiBits bits to 0.
Definition at line 1424 of file APInt.h.
References assert(), BitWidth, and llvm::Keep.
Referenced by llvm::TargetLowering::SimplifyDemandedBits().
|
inline |
Set bottom loBits bits to 0.
Definition at line 1417 of file APInt.h.
References assert(), BitWidth, and llvm::Keep.
Referenced by computeForSatAddSub(), llvm::SelectionDAG::computeKnownBits(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::KnownBits::makeGE(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), and llvm::ConstantRange::toKnownBits().
|
inline |
Set the sign bit to 0.
Definition at line 1431 of file APInt.h.
References BitWidth.
Referenced by llvm::KnownBits::abs(), computeForSatAddSub(), computeKnownBitsFromOperator(), foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed(), and llvm::ConstantRange::fromKnownBits().
Concatenate the bits from "NewLSB" onto the bottom of *this.
This is equivalent to: (this->zext(NewWidth) << NewLSB.getBitWidth()) | NewLSB.zext(NewWidth)
If the result will be small, then both the merged values are small.
Definition at line 947 of file APInt.h.
References getBitWidth(), getBitWidth(), and VAL.
Referenced by llvm::KnownBits::concat().
|
inline |
Count the number of leading one bits.
This function is an APInt version of std::countl_one. It counts the number of ones from the most significant bit to the first zero bit.
Definition at line 1594 of file APInt.h.
References BitWidth, llvm::countl_one(), and LLVM_UNLIKELY.
Referenced by llvm::KnownBits::computeForAddSub(), llvm::KnownBits::countMinLeadingOnes(), llvm::KnownBits::countMinLeadingZeros(), llvm::ConstantRange::ctpop(), llvm::InstCombinerImpl::foldICmpShrConstConst(), lower1BitShuffle(), lowerShuffleAsByteShiftMask(), lowerShuffleAsVALIGN(), lowerShuffleAsVTRUNCAndUnpack(), llvm::CombinerHelper::matchCombineShlOfExtend(), llvm::ConstantRange::shl(), and sshl_ov().
|
inline |
The APInt version of std::countl_zero.
It counts the number of zeros from the most significant bit to the first one bit.
Definition at line 1577 of file APInt.h.
References BitWidth, and llvm::countl_zero().
Referenced by areUsedBitsDense(), bitTrackingDCE(), llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), llvm::KnownBits::computeForAddSub(), llvm::SelectionDAG::computeKnownBits(), llvm::KnownBits::countMaxLeadingOnes(), llvm::KnownBits::countMaxLeadingZeros(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::InstCombinerImpl::foldICmpShrConstant(), llvm::InstCombinerImpl::foldICmpShrConstConst(), llvm::ShuffleVectorInst::isInsertSubvectorMask(), llvm::KnownBits::mul(), PerformBFICombine(), processUMulZExtIdiom(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(), sshl_ov(), tryBitfieldInsertOpFromOr(), umul_ov(), ushl_ov(), and llvm::InstCombinerImpl::visitAdd().
|
inline |
Definition at line 1603 of file APInt.h.
References llvm::countl_one().
Referenced by computeShlNSWWithNegLHS(), and foldNegativePower2AndShiftedMask().
|
inline |
Definition at line 1585 of file APInt.h.
References llvm::countl_zero().
Referenced by computeShlNSWWithNNegLHS(), computeShlNUW(), foldNegativePower2AndShiftedMask(), foldSelectICmpAndZeroShl(), llvm::KnownBits::sdiv(), llvm::TargetLowering::SimplifyDemandedBits(), and llvm::KnownBits::udiv().
|
inline |
Count the number of trailing one bits.
This function is an APInt version of std::countr_one. It counts the number of ones from the least significant bit to the first zero bit.
Definition at line 1635 of file APInt.h.
References llvm::countr_one().
Referenced by combineAndMaskToShift(), combineShiftRightLogical(), llvm::KnownBits::countMinTrailingOnes(), llvm::KnownBits::countMinTrailingZeros(), llvm::InstCombinerImpl::foldICmpEquality(), foldSubCtlzNot(), lowerShuffleAsByteShiftMask(), lowerShuffleAsVALIGN(), llvm::CombinerHelper::matchCombineLoadWithAndMask(), PerformMinMaxToSatCombine(), llvm::TargetLowering::SimplifySetCC(), and llvm::ConstantRange::truncate().
|
inline |
Count the number of trailing zero bits.
This function is an APInt version of std::countr_zero. It counts the number of zeros from the least significant bit to the first set bit.
Definition at line 1618 of file APInt.h.
References BitWidth, and llvm::countr_zero().
Referenced by areUsedBitsDense(), BuildExactSDIV(), BuildExactUDIV(), llvm::TargetLowering::buildSDIVPow2WithCMov(), llvm::CombinerHelper::buildSDivUsingMul(), llvm::CombinerHelper::buildUDivUsingMul(), canEvaluateShifted(), canonicalizeLogicFirst(), checkForNegativeOperand(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), llvm::KnownBits::countMaxTrailingOnes(), llvm::KnownBits::countMaxTrailingZeros(), EltsFromConsecutiveLoads(), llvm::TargetLowering::expandDIVREMByConstant(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpShlConstConst(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), getPowerOf2Factor(), llvm::BuildVectorSDNode::getSplatValue(), isAligned(), llvm::ShuffleVectorInst::isInsertSubvectorMask(), PerformBFICombine(), performMulCombine(), processUGT_ADDCST_ADD(), simplifyAMDGCNMemoryIntrinsicDemanded(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), simplifyDiv(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifySetCC(), tryBitfieldInsertOpFromOr(), llvm::InstCombinerImpl::visitAdd(), llvm::InstCombinerImpl::visitAnd(), llvm::InstCombinerImpl::visitMul(), llvm::InstCombinerImpl::visitSDiv(), and llvm::InstCombinerImpl::visitSub().
|
inline |
Definition at line 1641 of file APInt.h.
References llvm::countr_one().
|
inline |
Definition at line 1626 of file APInt.h.
References llvm::countr_zero().
Referenced by llvm::ScalarEvolution::getSmallConstantTripMultiple().
|
inlinestatic |
Converts a double to APInt bits.
The conversion does not do a translation from double to integer, it just re-interprets the bits of the double.
Definition at line 1722 of file APInt.h.
Referenced by llvm::ExecutionEngine::getConstantValue(), and llvm::detail::IEEEFloat::IEEEFloat().
LLVM_DUMP_METHOD void APInt::dump | ( | ) | const |
debug method
Definition at line 2272 of file APInt.cpp.
References llvm::dbgs(), toStringSigned(), and toStringUnsigned().
Equality comparison.
Compares this APInt with RHS for the validity of the equality relationship.
Definition at line 1079 of file APInt.h.
References RHS.
Referenced by combineShiftRightArithmetic(), llvm::omp::getBestVariantMatchForContext(), processUMulZExtIdiom(), and llvm::InstCombinerImpl::visitLShr().
|
inline |
Definition at line 1761 of file APInt.h.
Referenced by combineAnd(), foldAddToAshr(), isSaturatingMinMax(), llvm::LoongArchDAGToDAGISel::selectVSplatUimmPow2(), llvm::InstCombinerImpl::visitAnd(), and llvm::InstCombinerImpl::visitTrunc().
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
Definition at line 455 of file APInt.cpp.
References APInt(), APINT_BITS_PER_WORD, assert(), getNumWords(), and isSingleWord().
Referenced by combineX86ShufflesRecursively(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), computeZeroableShuffleElements(), EltsFromConsecutiveLoads(), llvm::KnownBits::extractBits(), llvm::extractConstantMask(), llvm::SelectionDAG::getConstant(), getConstantVector(), getExactInteger(), llvm::SelectionDAG::getNode(), llvm::X86TTIImpl::getScalarizationOverhead(), getTargetConstantBitsFromNode(), llvm::BuildVectorSDNode::isConstantSplat(), llvm::SelectionDAG::isSplatValue(), LowerBuildVectorv16i8(), lowerShuffleAsVTRUNC(), lowerShuffleWithVPMOV(), matchShuffleAsVTRUNC(), llvm::APIntOps::mulhs(), llvm::APIntOps::mulhu(), llvm::BuildVectorSDNode::recastRawBits(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), and llvm::TargetLowering::SimplifyMultipleUseDemandedBits().
Definition at line 493 of file APInt.cpp.
References APINT_BITS_PER_WORD, assert(), and isSingleWord().
Referenced by getMaxShiftAmount().
|
inline |
Toggle every bit to its opposite value.
Definition at line 1434 of file APInt.h.
References clearUnusedBits().
Referenced by getUsefulBits(), getUsefulBitsFromBFM(), and insert1BitVector().
void APInt::flipBit | ( | unsigned | bitPosition | ) |
Toggles a given bit to its opposite value.
Toggle a given bit to its opposite value whose position is given as "bitPosition".
Toggles a given bit to its opposite value.
Definition at line 365 of file APInt.cpp.
References assert(), and setBitVal().
|
inlinestatic |
Converts a float to APInt bits.
The conversion does not do a translation from float to integer, it just re-interprets the bits of the float.
Definition at line 1730 of file APInt.h.
Referenced by llvm::ExecutionEngine::getConstantValue(), and llvm::detail::IEEEFloat::IEEEFloat().
|
inline |
Compute the number of active bits in the value.
This function returns the number of active bits which is defined as the bit width minus the number of leading zeros. This is used in several computations to see how "wide" the value is.
Definition at line 1492 of file APInt.h.
References BitWidth, and llvm::countl_zero().
Referenced by llvm::APSInt::APSInt(), areUsedBitsDense(), canSafelyConvertTo16Bit(), ceilLogBase2(), llvm::TargetLowering::expandIS_FPCLASS(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), llvm::ConstantRange::getActiveBits(), llvm::getBitwiseNotOperand(), getConstantTripCount(), getPreferredVectorIndex(), llvm::ScalarEvolution::getSmallConstantTripMultiple(), llvm::LegalizerHelper::lowerISFPCLASS(), llvm::ARMTargetLowering::PerformCMOVToBFICombine(), performSETCCCombine(), rebuildExtCst(), roundToDouble(), simplifyAMDGCNMemoryIntrinsicDemanded(), simplifyAndInst(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::TargetLowering::SimplifySetCC(), sqrt(), llvm::X86TargetLowering::targetShrinkDemandedConstant(), llvm::ConstantRange::truncate(), llvm::tryPromoteCall(), udiv(), urem(), and llvm::InstCombinerImpl::visitICmpInst().
|
inline |
Compute the number of active words in the value of this APInt.
This is used in conjunction with getActiveData to extract the raw value of the APInt.
Definition at line 1498 of file APInt.h.
Referenced by emitConstantRange().
Return an APInt of a specified width with all bits set.
Definition at line 234 of file APInt.h.
Referenced by llvm::analyzeKnownBitsFromAndXorOr(), llvm::ConstantRange::binaryNot(), llvm::buildSelectInst(), llvm::SelectionDAG::canCreateUndefOrPoison(), canTryToConstantAddTwoShiftAmounts(), llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), combineAddOfPMADDWD(), combineAnd(), combineAndnp(), combineBEXTR(), combineExtractVectorElt(), combineKSHIFT(), combineMOVMSK(), combinePDEP(), combinePMULDQ(), combinePredicateReduction(), combineShuffle(), combineTESTP(), combineVectorCompare(), combineVectorInsert(), combineVectorPack(), combineVectorShiftImm(), combineVectorShiftVar(), combineVPMADD(), combineVTRUNC(), combineX86INT_TO_FP(), combineX86ShuffleChain(), llvm::computeKnownBits(), llvm::SelectionDAG::computeKnownBits(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::computeKnownFPClass(), computeKnownFPClass(), ComputeNumSignBits(), llvm::GISelKnownBits::computeNumSignBits(), llvm::SelectionDAG::ComputeNumSignBits(), computeShlNSW(), defaultComponentBroadcast(), detectSSatPattern(), llvm::TargetLowering::expandIS_FPCLASS(), findDemandedEltsByAllUsers(), findDemandedEltsBySingleUser(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), foldICmpUSubSatOrUAddSatWithConstant(), foldSelectICmpLshrAshr(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), llvm::SelectionDAG::getAllOnesConstant(), llvm::APFloat::getAllOnesValue(), llvm::Constant::getAllOnesValue(), getBitcastWiderVectorElementOffset(), llvm::DemandedBits::getDemandedBits(), getDemandedBitsLHSMask(), getDemandedSrcElements(), getFauxShuffleMask(), getHopForBuildVector(), llvm::LoopVectorizationCostModel::getInstructionCost(), llvm::BasicTTIImplBase< T >::getInterleavedMemoryOpCost(), llvm::X86TTIImpl::getInterleavedMemoryOpCostAVX512(), llvm::GISelKnownBits::getKnownBits(), llvm::X86TTIImpl::getMaskedMemoryOpCost(), getRangeForIntrinsic(), llvm::BuildVectorSDNode::getRepeatedSequence(), llvm::BasicTTIImplBase< T >::getScalarizationOverhead(), llvm::SelectionDAG::getSplatSourceVector(), llvm::BuildVectorSDNode::getSplatValue(), getTargetConstantBitsFromNode(), getTargetShuffleInputs(), llvm::SelectionDAG::getValidMaximumShiftAmount(), llvm::SelectionDAG::getValidMinimumShiftAmount(), llvm::SelectionDAG::getValidShiftAmount(), llvm::isConstOrConstSplat(), llvm::isConstOrConstSplatFP(), llvm::SelectionDAG::isGuaranteedNotToBeUndefOrPoison(), llvm::isKnownNonEqual(), llvm::isKnownNonZero(), isKnownNonZeroFromOperator(), isNonZeroShift(), llvm::SelectionDAG::isSplatValue(), llvm::slpvectorizer::BoUpSLP::isTreeTinyAndNotFullyVectorizable(), llvm::LegalizerHelper::lowerISFPCLASS(), lowerShuffleAsElementInsertion(), LowerVectorAllEqual(), llvm::detail::IEEEFloat::makeNaN(), MatchVectorAllEqualTest(), narrowSDivOrSRem(), llvm::AArch64TargetLowering::PerformDAGCombine(), llvm::PPCTargetLowering::PerformDAGCombine(), llvm::possiblyDemandedEltsInMask(), llvm::recognizeBSwapOrBitReverseIdiom(), setLimitsForBinOp(), llvm::TargetLowering::ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::ARMTargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedInstructionBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::InstCombinerImpl::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifyMultipleUseDemandedVectorElts(), llvm::InstCombinerImpl::simplifyShrShlDemandedBits(), llvm::APFixedPoint::toString(), trimTrailingZerosInVector(), llvm::LegalizationArtifactCombiner::tryCombineZExt(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitGetElementPtrInst(), llvm::InstCombinerImpl::visitInsertElementInst(), llvm::InstCombinerImpl::visitLShr(), llvm::InstCombinerImpl::visitShuffleVectorInst(), llvm::InstCombinerImpl::visitXor(), and llvm::LegalizerHelper::widenScalar().
Get bits required for string value.
This method determines how many bits are required to hold the APInt equivalent of the string given by str
.
Definition at line 549 of file APInt.cpp.
References assert(), llvm::StringRef::begin(), getSufficientBitsNeeded(), isNegative(), isPowerOf2(), logBase2(), and llvm::StringRef::size().
|
inlinestatic |
Get a value with a block of bits set.
Constructs an APInt value that has a contiguous range of bits set. The bits from loBit (inclusive) to hiBit (exclusive) will be set. All other bits will be zero. For example, with parameters(32, 0, 16) you would get 0x0000FFFF. Please call getBitsSetWithWrap if loBit
may be greater than hiBit
.
numBits | the intended bit width of the result |
loBit | the index of the lowest bit set. |
hiBit | the index of the highest bit set. |
Definition at line 258 of file APInt.h.
References setBits().
Referenced by combineToExtendBoolVectorInReg(), computeShlNSWWithNNegLHS(), llvm::X86TTIImpl::getMemoryOpCost(), insert1BitVector(), LowerShift(), llvm::AMDGPUTargetLowering::PerformDAGCombine(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), simplifyX86immShift(), tryBitfieldInsertOpFromOr(), tryToMergePartialOverlappingStores(), and llvm::RegisterBankInfo::ValueMapping::verify().
Constructs an APInt value that has a contiguous range of bits set.
The bits from loBit (inclusive) to numBits (exclusive) will be set. All other bits will be zero. For example, with parameters(32, 12) you would get 0xFFFFF000.
numBits | the intended bit width of the result |
loBit | the index of the lowest bit to set. |
Definition at line 286 of file APInt.h.
References setBitsFrom().
Referenced by canEvaluateTruncated(), combine_CC(), combineAddOfBooleanXor(), combineCMP(), combineDeMorganOfBoolean(), combineSetCC(), llvm::SelectionDAG::computeKnownBits(), llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes(), llvm::APFixedPoint::convert(), extractBits(), getDemandedBitsLHSMask(), llvm::SelectionDAG::getNode(), getTruncatedUSUBSAT(), isCTTZTable(), LowerPARITY(), llvm::RISCVTargetLowering::PerformDAGCombine(), llvm::RISCVDAGToDAGISel::selectZExtBits(), setLimitsForBinOp(), llvm::ConstantRange::shl(), llvm::TargetLowering::SimplifySetCC(), llvm::ConstantRange::truncate(), tryDemorganOfBooleanCondition(), and llvm::InstCombinerImpl::visitTrunc().
|
inlinestatic |
Wrap version of getBitsSet.
If hiBit
is bigger than loBit
, this is same with getBitsSet. If hiBit
is not bigger than loBit
, the set bits "wrap". For example, with parameters (32, 28, 4), you would get 0xF000000F. If hiBit
is equal to loBit
, you would get a result with all bits set.
Definition at line 270 of file APInt.h.
References setBitsWithWrap().
Referenced by llvm::PPCInstrInfo::combineRLWINM(), and llvm::LegalizerHelper::lowerInsert().
|
inline |
Return the number of bits in the APInt.
Definition at line 1468 of file APInt.h.
References BitWidth.
Referenced by llvm::DwarfExpression::addConstantFP(), llvm::DwarfUnit::addConstantValue(), llvm::APFixedPoint::APFixedPoint(), APIntToHexString(), llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), canonicalizeGEPOfConstGEPI8(), combineCMov(), combineConcatVectorOps(), combineConstantPoolLoads(), combineSetCCMOVMSK(), combineShiftOfShiftedLogic(), CombineVMOVDRRCandidateWithVecOp(), llvm::InstCombinerImpl::commonIDivTransforms(), CompareSCEVComplexity(), llvm::APSInt::compareValues(), llvm::ObjectSizeOffsetVisitor::compute(), computeKnownBits(), llvm::SelectionDAG::computeKnownBits(), llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), computeKnownFPClass(), llvm::SelectionDAG::ComputeNumSignBits(), ComputeNumSignBitsImpl(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), computeShlNSWWithNegLHS(), computeShlNSWWithNNegLHS(), llvm::SelectionDAG::computeVectorKnownZeroElements(), concat(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), llvm::ConstantRange::ConstantRange(), llvm::APFixedPoint::convert(), llvm::APFloat::convertToInteger(), emitGlobalConstantFP(), llvm::BinaryOperation::eval(), llvm::TargetLowering::expandDIVREMByConstant(), extractConstantWithoutWrapping(), extractShiftForRotate(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::InstCombinerImpl::foldICmpEquality(), llvm::InstCombinerImpl::foldICmpShlConstConst(), foldNoWrapAdd(), foldSelectICmpAnd(), FoldValueWithUndef(), getAVX512Node(), llvm::detail::SlowDynamicAPInt::getBitWidth(), llvm::ConstantInt::getBitWidth(), llvm::KnownBits::getBitWidth(), llvm::ExecutionEngine::getConstantValue(), getConstVector(), getFauxShuffleMask(), llvm::getHorizDemandedEltsForFirstOperand(), llvm::SwitchCG::getJumpTableRange(), getKnownUndefForVectorBinop(), llvm::SelectionDAG::getNode(), llvm::ScalarEvolution::getNonZeroConstantMultiple(), getPackDemandedElts(), llvm::getPtrStride(), GetQuadraticEquation(), getRangeForAffineARHelper(), llvm::BuildVectorSDNode::getRepeatedSequence(), llvm::BasicTTIImplBase< T >::getReplicationShuffleCost(), llvm::X86TTIImpl::getScalarizationOverhead(), getShiftAmount(), llvm::BuildVectorSDNode::getSplatValue(), llvm::SelectionDAG::getStepVector(), getStrideFromPointer(), getTargetConstantBitsFromNode(), getUsefulBits(), getUsefulBitsForUse(), getUsefulBitsFromAndWithImmediate(), getUsefulBitsFromBFM(), getUsefulBitsFromBitfieldMoveOpd(), llvm::SelectionDAG::getVScale(), insertBits(), llvm::ConstantRange::intrinsic(), llvm::TargetTransformInfoImplBase::isConstantStridedAccessLessThan(), llvm::TargetLowering::isConstTrueVal(), llvm::SelectionDAG::isGuaranteedNotToBeUndefOrPoison(), llvm::X86TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), isKnownNonZero(), isKnownNonZeroFromOperator(), isMultiple(), isPoisonShift(), isSameValue(), isSaturatingMinMax(), isSplat(), llvm::SelectionDAG::isSplatValue(), llvm::X86TargetLowering::isSplatValueForTargetNode(), LowerVectorAllEqual(), matchAndOrChain(), MatchDiv(), MatchMul(), llvm::APIntOps::mulhs(), llvm::APIntOps::mulhu(), llvm::detail::SlowDynamicAPInt::operator%(), operator*(), llvm::detail::SlowDynamicAPInt::operator-(), optimizeIncrementingWhile(), ParseBFI(), parseHexOcta(), performANDCombine(), performMulCombine(), performORCombine(), PerformORCombine(), PerformSHLSimplify(), PerformUMinFpToSatCombine(), printConstant(), processUMulZExtIdiom(), llvm::BuildVectorSDNode::recastRawBits(), resolveTargetShuffleFromZeroables(), rotateModulo(), llvm::LoongArchDAGToDAGISel::selectShiftMask(), llvm::RISCVDAGToDAGISel::selectShiftMask(), llvm::LoongArchDAGToDAGISel::selectVSplatImm(), llvm::LoongArchDAGToDAGISel::selectVSplatUimmInvPow2(), llvm::LoongArchDAGToDAGISel::selectVSplatUimmPow2(), llvm::APFixedPoint::shl(), llvm::TargetLoweringBase::shouldFoldSelectWithSingleBitTest(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetShuffle(), simplifyICmpWithBinOpOnLHS(), simplifyIntrinsic(), simplifyIRemMulShl(), llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifySetCC(), sshl_ov(), sshl_sat(), llvm::ConstantRange::subtract(), llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(), llvm::X86TargetLowering::targetShrinkDemandedConstant(), toSigned(), toString(), tryToMergePartialOverlappingStores(), ushl_ov(), ushl_sat(), llvm::InstCombinerImpl::visitAdd(), llvm::SCEVDivision::visitConstant(), and llvm::InstCombinerImpl::visitICmpInst().
|
inline |
Convert APInt to a boolean value.
This converts the APInt to a boolean value as a test against zero.
Definition at line 471 of file APInt.h.
References isZero().
Referenced by llvm::KnownBits::computeForAddCarry(), llvm::KnownBits::computeForSubBorrow(), llvm::APFixedPoint::getBoolValue(), getPowerOf2Factor(), getTargetConstantBitsFromNode(), llvm::ConstantRange::intrinsic(), isDereferenceableAndAlignedPointer(), llvm::isKnownToBeAPowerOfTwo(), provablyDisjointOr(), llvm::PPCTargetLowering::SelectAddressRegReg(), simplifyAndOfICmpsWithAdd(), simplifyOrOfICmpsWithAdd(), toString(), and walkToAllocaAndPrependOffsetDeref().
Compute an APInt containing numBits highbits from this APInt.
This function returns the high "numBits" bits of this APInt.
Get an APInt with the same BitWidth as this APInt, just zero mask the low bits and right shift to the least significant bit.
Definition at line 612 of file APInt.cpp.
References lshr().
Referenced by llvm::SelectionDAG::computeKnownBits(), parseHexOcta(), and WriteAPFloatInternal().
Constructs an APInt value that has the top hiBitsSet bits set.
numBits | the bitwidth of the result |
hiBitsSet | the number of high-order bits set in the result. |
Definition at line 296 of file APInt.h.
References setHighBits().
Referenced by canEvaluateZExtd(), combineAnd(), combineCMP(), combineMulToPMADDWD(), combineMulToPMULDQ(), combineOr(), combineTargetShuffle(), combineVectorPack(), combineZext(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::AArch64TargetLowering::computeKnownBitsForTargetNode(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), llvm::computeKnownBitsFromRangeMetadata(), computeShlNUW(), ConstantBuildVector(), EmitCmp(), llvm::TargetLowering::expandFixedPointMul(), llvm::TargetLowering::expandMUL_LOHI(), llvm::InstCombinerImpl::foldAddWithConstant(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpEqIntrinsicWithConstant(), llvm::InstCombinerImpl::foldICmpShrConstant(), llvm::InstCombinerImpl::foldICmpTruncConstant(), foldMaskAndShiftToScale(), foldShiftedShift(), getFauxShuffleMask(), isFPSatMinMaxPattern(), llvm::AArch64TTIImpl::isProfitableToSinkOperands(), isTruncWithZeroHighBitsInput(), LowerFunnelShift(), LowerMUL(), LowerShiftByScalarImmediate(), llvm::AMDGPUTargetLowering::LowerUDIVREM64(), matchShuffleWithPACK(), llvm::ARMTargetLowering::PerformDAGCombine(), PerformSHLSimplify(), PerformVMOVNCombine(), PerformVQMOVNCombine(), llvm::RISCVTargetLowering::ReplaceNodeResults(), SaturateWidenedDIVFIX(), selectUmullSmull(), llvm::LoongArchDAGToDAGISel::selectZExti32(), setLimitsForBinOp(), llvm::ConstantRange::signExtend(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::ARMTTIImpl::simplifyDemandedVectorEltsIntrinsic(), llvm::TargetLowering::SimplifySetCC(), simplifyUnaryIntrinsic(), tryLowerToSLI(), llvm::InstCombinerImpl::visitBitCast(), llvm::InstCombinerImpl::visitShl(), llvm::InstCombinerImpl::visitSub(), and llvm::InstCombinerImpl::visitZExt().
|
inline |
If this value is smaller than the specified limit, return it, otherwise return the limit value.
This causes the value to saturate to the limit.
Definition at line 475 of file APInt.h.
Referenced by adjustByValArgAlignment(), ashrInPlace(), decompose(), extractBits(), llvm::InstCombinerImpl::foldICmpEquality(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpShrConstant(), llvm::InstCombinerImpl::foldICmpXorShiftConst(), getAssignmentInfoImpl(), llvm::ConstantInt::getLimitedValue(), getMaxShiftAmount(), llvm::BlockFrequencyInfoImplBase::getProfileCountFromFreq(), getUnsigned(), isConstantSplatVectorMaskForType(), lshrInPlace(), operator<<=(), ParseBFI(), rotateModulo(), llvm::scaleProfData(), setShiftFlags(), simplifyAndInst(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), simplifySetCCWithCTPOP(), sshl_ov(), switchToLookupTable(), and ushl_ov().
Compute an APInt containing numBits lowbits from this APInt.
This function returns the low "numBits" bits of this APInt.
Get an APInt with the same BitWidth as this APInt, just zero mask the high bits.
Definition at line 617 of file APInt.cpp.
References getLowBitsSet().
Referenced by matchRotateSub(), llvm::KnownBits::mul(), parseHexOcta(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), and WriteAPFloatInternal().
Constructs an APInt value that has the bottom loBitsSet bits set.
numBits | the bitwidth of the result |
loBitsSet | the number of low-order bits set in the result. |
Definition at line 306 of file APInt.h.
References setLowBits().
Referenced by buildBitFieldInsert(), llvm::TargetLowering::buildSDIVPow2WithCMov(), llvm::MachineIRBuilder::buildZExtInReg(), canEvaluateShiftedShift(), clampDynamicVectorIndex(), clampVectorIndex(), combineBT(), combineCMP(), combineCVTPH2PS(), combineMOVMSK(), combinePredicateReduction(), combineSetCCMOVMSK(), combineVEXTRACT_STORE(), llvm::SelectionDAG::computeKnownBits(), llvm::ConstantFoldBinaryInstruction(), llvm::TargetLowering::expandDIVREMByConstant(), llvm::TargetLowering::expandFixedPointMul(), llvm::TargetLowering::expandUnalignedStore(), extractBits(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpEqIntrinsicWithConstant(), llvm::InstCombinerImpl::foldICmpEquality(), llvm::InstCombinerImpl::foldICmpIntrinsicWithConstant(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpTruncConstant(), foldShiftedShift(), llvm::TargetLowering::forceExpandWideMUL(), llvm::UnsignedDivisionByConstantInfo::get(), getLoBits(), getShiftedValue(), getTruncatedUSUBSAT(), llvm::SelectionDAG::getVPZeroExtendInReg(), llvm::SelectionDAG::getZeroExtendInReg(), llvm::ARMTTIImpl::instCombineIntrinsic(), llvm::X86TTIImpl::instCombineIntrinsic(), lowerBuildVectorViaPacking(), LowerEXTEND_VECTOR_INREG(), llvm::LegalizerHelper::lowerFCopySign(), LowerFunnelShift(), LowerMUL(), LowerShiftByScalarImmediate(), matchRotateSub(), MatchVectorAllEqualTest(), ParseBFI(), llvm::ARMTargetLowering::PerformDAGCombine(), llvm::RISCVTargetLowering::PerformDAGCombine(), llvm::ARMTargetLowering::PerformIntrinsicCombine(), PerformPREDICATE_CASTCombine(), performTBISimplification(), performTruncateCombine(), performVectorShiftCombine(), PerformVMOVhrCombine(), PerformVMOVNCombine(), PerformVQMOVNCombine(), performZExtUZPCombine(), processUGT_ADDCST_ADD(), SaturateWidenedDIVFIX(), llvm::TargetLowering::scalarizeVectorLoad(), llvm::ConstantRange::signExtend(), simplifyAndInst(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::ARMTTIImpl::simplifyDemandedVectorEltsIntrinsic(), simplifyMul24(), llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(), llvm::TargetLowering::SimplifySetCC(), simplifyX86insertq(), simplifyX86pack(), simplifyX86VPERMMask(), llvm::X86TargetLowering::targetShrinkDemandedConstant(), tryLowerToSLI(), llvm::InstCombinerImpl::visitAnd(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitLShr(), llvm::InstCombinerImpl::visitSwitchInst(), and llvm::InstCombinerImpl::visitZExt().
Gets maximum unsigned value of APInt for specific bit width.
Definition at line 206 of file APInt.h.
Referenced by llvm::calculateUpperBound(), llvm::cannotBeMaxInLoop(), llvm::ConstantRange::castOp(), computeForSatAddSub(), detectSSatUPattern(), detectUSatUPattern(), llvm::TargetLowering::expandFixedPointMul(), llvm::TargetLowering::expandFP_TO_INT_SAT(), llvm::TargetLowering::expandShlSat(), foldBoxMultiply(), llvm::InstCombinerImpl::foldFCmpIntToFPConst(), llvm::InstCombinerImpl::foldICmpAddOpConst(), llvm::SCEVExpander::generateOverflowCheck(), getIdentityValueForAtomicOp(), llvm::getMinMaxLimit(), getRangeForAffineARHelper(), getRangeForIntrinsic(), llvm::MinMaxIntrinsic::getSaturationPoint(), llvm::ScalarEvolution::getTripCountFromExitCount(), llvm::ConstantRange::getUnsignedMax(), llvm::ScalarEvolution::getZeroExtendExprImpl(), isSafeIncreasingBound(), llvm::ConstantRange::isSizeLargerThan(), llvm::LegalizerHelper::lowerFPTOINT_SAT(), llvm::LegalizerHelper::lowerShlSat(), llvm::fuzzerop::makeConstantsWithType(), makeExactMulNUWRegion(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), llvm::X86InstrInfo::optimizeCompareInstr(), processUMulZExtIdiom(), setLimitsForBinOp(), llvm::TargetLowering::SimplifySetCC(), llvm::ConstantRange::truncate(), truncUSat(), uadd_sat(), umul_sat(), ushl_sat(), and llvm::ScalarEvolution::willNotOverflow().
Gets minimum unsigned value of APInt for a specific bit width.
Definition at line 216 of file APInt.h.
Referenced by llvm::cannotBeMinInLoop(), llvm::ConstantRange::castOp(), computeForSatAddSub(), llvm::TargetLowering::expandFP_TO_INT_SAT(), llvm::InstCombinerImpl::foldFCmpIntToFPConst(), getIdentityValueForAtomicOp(), llvm::getMinMaxLimit(), llvm::MinMaxIntrinsic::getSaturationPoint(), llvm::ConstantRange::getUnsignedMin(), getUnsignedOverflowLimitForStep(), isSafeDecreasingBound(), llvm::LegalizerHelper::lowerFPTOINT_SAT(), llvm::ConstantRange::makeAllowedICmpRegion(), llvm::fuzzerop::makeConstantsWithType(), makeExactMulNUWRegion(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), llvm::TargetLowering::SimplifySetCC(), and llvm::ScalarEvolution::willNotOverflow().
|
inline |
Computes the number of leading bits of this APInt that are equal to its sign bit.
Definition at line 1607 of file APInt.h.
References llvm::countl_one(), and llvm::countl_zero().
Referenced by llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), computeNumSignBitsFromRangeMetadata(), ComputeNumSignBitsImpl(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), and llvm::X86TargetLowering::targetShrinkDemandedConstant().
|
inline |
Get the number of words.
Here one word's bitwidth equals to that of uint64_t.
Definition at line 1475 of file APInt.h.
References BitWidth, and getNumWords().
Referenced by byteSwap(), llvm::detail::IEEEFloat::convertFromAPInt(), llvm::APFloat::convertToInteger(), emitGlobalConstantFP(), extractBits(), getNumWords(), llvm::hash_value(), llvm::detail::IEEEFloat::makeNaN(), operator*(), operator*=(), operator++(), operator+=(), operator--(), operator-=(), printConstant(), Profile(), sext(), trunc(), udiv(), udivrem(), urem(), writeFunctionTypeMetadataRecords(), and zext().
Return an APInt with exactly one bit set in the result.
Definition at line 239 of file APInt.h.
References setBit().
Referenced by BinomialCoefficient(), llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), combineCMP(), combineShiftAnd1ToBitTest(), llvm::InstCombinerImpl::commonIDivTransforms(), llvm::SelectionDAG::computeKnownBits(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), computeKnownFPClass(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::SelectionDAG::computeVectorKnownZeroElements(), llvm::TargetLowering::expandBITREVERSE(), llvm::TargetLowering::expandDIVREMByConstant(), llvm::TargetLowering::expandIS_FPCLASS(), extractShiftForRotate(), findDemandedEltsBySingleUser(), llvm::InstCombinerImpl::foldICmpEqIntrinsicWithConstant(), llvm::InstCombinerImpl::foldICmpEquality(), llvm::InstCombinerImpl::foldICmpIntrinsicWithConstant(), llvm::InstCombinerImpl::foldICmpShlConstant(), foldSelectICmpAndBinOp(), llvm::ScalarEvolution::getPowerOfTwo(), getStrideAndModOffsetOfGEP(), llvm::ARMTTIImpl::instCombineIntrinsic(), isKnownNonZeroFromOperator(), llvm::SelectionDAG::isSplatValue(), lowerFTRUNC_FCEIL_FFLOOR_FROUND(), llvm::LegalizerHelper::lowerISFPCLASS(), LowerShift(), lowerVectorFTRUNC_FCEIL_FFLOOR_FROUND(), lowerVectorStrictFTRUNC_FCEIL_FFLOOR_FROUND(), llvm::fuzzerop::makeConstantsWithType(), llvm::ConstantRange::makeMaskNotEqualRange(), matchBinaryOp(), MatchBinaryOp(), matchBinaryShuffle(), performSETCCCombine(), processUMulZExtIdiom(), scalarizeMaskedCompressStore(), scalarizeMaskedExpandLoad(), scalarizeMaskedGather(), scalarizeMaskedLoad(), scalarizeMaskedScatter(), scalarizeMaskedStore(), setLimitsForBinOp(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), simplifyIntrinsic(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), simplifyX86immShift(), SolveLinEquationWithOverflow(), llvm::APIntOps::SolveQuadraticEquationWrap(), llvm::InstCombinerImpl::visitICmpInst(), llvm::LegalizerHelper::widenScalar(), and llvm::ConstantRange::zeroExtend().
This function returns a pointer to the internal storage of the APInt.
This is useful for writing out the APInt in binary form without any conversions.
Definition at line 569 of file APInt.h.
Referenced by llvm::DwarfUnit::addConstantValue(), llvm::detail::IEEEFloat::convertFromAPInt(), llvm::detail::IEEEFloat::convertFromZeroExtendedInteger(), emitGlobalConstantFP(), emitGlobalConstantLargeInt(), llvm::getExpressionForConstant(), llvm::HexagonLowerToMC(), insertBits(), llvm::detail::IEEEFloat::makeNaN(), printConstant(), sext(), llvm::ExecutionEngine::StoreValueToMemory(), toString(), trunc(), writeFunctionTypeMetadataRecords(), and zext().
|
inline |
Get sign extended value.
This method attempts to return the value of this APInt as a sign extended int64_t. The bit width must be <= 64 or the value must fit within an int64_t. Otherwise an assertion will result.
Definition at line 1542 of file APInt.h.
References assert(), BitWidth, and llvm::SignExtend64().
Referenced by llvm::DwarfUnit::addConstantValue(), llvm::InterleavedAccessInfo::analyzeInterleaving(), llvm::TargetLowering::BuildSDIV(), checkIfSafeAddSequence(), combineAndOrForCcmpCtest(), combineX86SubCmpForFlags(), emitConstantRange(), llvm::TargetTransformInfoImplCRTPBase< T >::getGEPCost(), llvm::CoroSubFnInst::getIndex(), llvm::AArch64TTIImpl::getIntImmCost(), llvm::X86TTIImpl::getIntImmCost(), llvm::RISCVMatInt::getIntMatCost(), getMinimalBaseOfPointer(), llvm::GetPointerBaseWithConstantOffset(), llvm::getPointersDiff(), llvm::getPtrStride(), getSalvageOpsForGEP(), llvm::ConstantInt::getSExtValue(), getStrideFromPointer(), llvm::remarks::Argument::getValAsInt(), getVShiftImm(), instCombineSVESDIV(), llvm::TargetTransformInfoImplBase::isConstantStridedAccessLessThan(), llvm::RISCVTargetLowering::isDesirableToCommuteWithShift(), llvm::SIInstrInfo::isInlineConstant(), llvm::AArch64TargetLowering::isMulAddWithConstProfitable(), llvm::ARMTargetLowering::isMulAddWithConstProfitable(), isSimpleVIDSequence(), LLVMGenericValueToInt(), llvm::AsmPrinter::lowerConstant(), llvm::CombinerHelper::matchPtrAddImmedChain(), rotateSign(), llvm::RISCVDAGToDAGISel::Select(), llvm::RISCVDAGToDAGISel::selectScalarFPAsInt(), llvm::LoongArchDAGToDAGISel::selectVSplatImm(), selectVSplatImmHelper(), llvm::LoopVectorizationCostModel::setVectorizedCallDecision(), llvm::TargetLowering::SimplifySetCC(), toString(), tryCombineShiftImm(), and tryFoldHelper().
Gets maximum signed value of APInt for a specific bit width.
Definition at line 209 of file APInt.h.
References clearBit().
Referenced by llvm::calculateUpperBound(), llvm::cannotBeMaxInLoop(), llvm::ConstantRange::castOp(), combineMinMaxReduction(), combineTruncToVnclip(), computeForSatAddSub(), detectSSatPattern(), detectSSatSPattern(), llvm::TargetLowering::expandAddSubSat(), llvm::TargetLowering::expandFixedPointMul(), llvm::TargetLowering::expandFP_TO_INT_SAT(), llvm::TargetLowering::expandIS_FPCLASS(), llvm::TargetLowering::expandRoundInexactToOdd(), llvm::TargetLowering::expandShlSat(), llvm::InstCombinerImpl::foldFCmpIntToFPConst(), llvm::InstCombinerImpl::foldICmpAddConstant(), llvm::InstCombinerImpl::foldICmpAddOpConst(), foldICmpXNegX(), llvm::UnsignedDivisionByConstantInfo::get(), getIdentityValueForAtomicOp(), llvm::ConstantExpr::getIntrinsicIdentity(), llvm::getMinMaxLimit(), llvm::SelectionDAG::getNeutralElement(), getRangeForIntrinsic(), getRangeForSelectPattern(), llvm::MinMaxIntrinsic::getSaturationPoint(), llvm::ConstantRange::getSignedMax(), getSignedOverflowLimitForStep(), isNonZeroAdd(), isSafeIncreasingBound(), LowerADDSAT_SUBSAT(), llvm::LegalizerHelper::lowerAddSubSatToMinMax(), llvm::LegalizerHelper::lowerFAbs(), LowerFABSorFNEG(), lowerFABSorFNEG(), LowerFCOPYSIGN(), lowerFCOPYSIGN(), llvm::LegalizerHelper::lowerFPTOINT_SAT(), llvm::LegalizerHelper::lowerISFPCLASS(), llvm::LegalizerHelper::lowerShlSat(), llvm::fuzzerop::makeConstantsWithType(), makeExactMulNSWRegion(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), llvm::X86InstrInfo::optimizeCompareInstr(), sadd_sat(), llvm::KnownBits::sdiv(), setLimitsForBinOp(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), llvm::TargetLowering::SimplifySetCC(), simplifyX86pack(), smul_sat(), sshl_sat(), ssub_sat(), truncSSat(), llvm::LegalizerHelper::widenScalar(), and llvm::ScalarEvolution::willNotOverflow().
Gets minimum signed value of APInt for a specific bit width.
Definition at line 219 of file APInt.h.
References setBit().
Referenced by llvm::ConstantRange::abs(), llvm::cannotBeMinInLoop(), canonicalizeForInvariantConditionInjection(), llvm::ConstantRange::castOp(), combineMinMaxReduction(), combineTruncToVnclip(), computeForSatAddSub(), detectSSatPattern(), detectSSatSPattern(), llvm::TargetLowering::expandAddSubSat(), llvm::TargetLowering::expandFixedPointMul(), llvm::TargetLowering::expandFP_TO_INT_SAT(), llvm::TargetLowering::expandShlSat(), foldAddToAshr(), llvm::InstCombinerImpl::foldFCmpIntToFPConst(), llvm::InstCombinerImpl::foldICmpAddConstant(), llvm::InstCombinerImpl::foldICmpAndConstant(), llvm::InstCombinerImpl::foldICmpCommutative(), foldMinimumOverTrailingOrLeadingZeroCount(), llvm::SignedDivisionByConstantInfo::get(), llvm::UnsignedDivisionByConstantInfo::get(), getIdentityValueForAtomicOp(), llvm::ConstantExpr::getIntrinsicIdentity(), llvm::getMinMaxLimit(), llvm::ScalarEvolution::getMulExpr(), llvm::SelectionDAG::getNeutralElement(), getRangeForIntrinsic(), getRangeForSelectPattern(), llvm::MinMaxIntrinsic::getSaturationPoint(), llvm::RecurrenceDescriptor::getSentinelValue(), llvm::ConstantRange::getSignedMin(), getSignedOverflowLimitForStep(), llvm::RecurrenceDescriptor::isFindLastIVPattern(), isSafeDecreasingBound(), LowerADDSAT_SUBSAT(), llvm::LegalizerHelper::lowerAddSubSatToAddoSubo(), llvm::LegalizerHelper::lowerAddSubSatToMinMax(), llvm::LegalizerHelper::lowerFPTOINT_SAT(), llvm::LegalizerHelper::lowerShlSat(), llvm::ConstantRange::makeAllowedICmpRegion(), llvm::fuzzerop::makeConstantsWithType(), makeExactMulNSWRegion(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), llvm::ConstantRange::multiplyWithNoWrap(), narrowSDivOrSRem(), llvm::X86InstrInfo::optimizeCompareInstr(), processAbsIntrinsic(), sadd_sat(), llvm::ConstantRange::sdiv(), llvm::RISCVDAGToDAGISel::Select(), setLimitsForBinOp(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), llvm::TargetLowering::SimplifySetCC(), simplifyX86pack(), smul_sat(), sshl_sat(), ssub_sat(), truncSSat(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitSDiv(), llvm::LegalizerHelper::widenScalar(), and llvm::ScalarEvolution::willNotOverflow().
|
inline |
Get the minimum bit size for this signed APInt.
Computes the minimum bit width for this APInt while considering it to be a signed (and probably negative) value. If the value is not negative, this function returns the same value as getActiveBits()+1. Otherwise, it returns the smallest bit width that will retain the negative value. For example, -1 can be written as 0b1 or 0xFFFFFFFFFF. 0b1 is shorter and so for -1, this function will always return 1.
Definition at line 1511 of file APInt.h.
References BitWidth.
Referenced by llvm::APSInt::APSInt(), canFoldIVIncExpr(), combineShiftRightLogical(), eliminateDeadSwitchCases(), llvm::RISCVTargetLowering::isDesirableToCommuteWithShift(), rebuildExtCst(), llvm::TargetLowering::SimplifySetCC(), llvm::RISCVTargetLowering::targetShrinkDemandedConstant(), and llvm::InstCombinerImpl::visitSDiv().
Get the SignMask for a specific bit width.
This is just a wrapper function of getSignedMinValue(), and it helps code readability when we want to get a SignMask.
Definition at line 229 of file APInt.h.
References BitWidth.
Referenced by checkSignTestSetCCCombine(), combineAVG(), combineGatherScatter(), combineMaskedLoad(), combineMaskedStore(), combinePTESTCC(), combineStore(), combineVSelectToBLENDV(), combineX86GatherScatter(), computeShlNSWWithNegLHS(), llvm::decomposeBitTestICmp(), llvm::TargetLowering::expandFP_TO_SINT(), llvm::TargetLowering::expandFP_TO_UINT(), llvm::TargetLowering::expandIS_FPCLASS(), llvm::TargetLowering::expandRoundInexactToOdd(), foldAndToUsubsat(), llvm::InstCombinerImpl::foldICmpSRemConstant(), getDemandedBitsLHSMask(), llvm::LegalizerHelper::lower(), LowerFABSorFNEG(), lowerFABSorFNEG(), llvm::LegalizerHelper::lowerFCopySign(), LowerFCOPYSIGN(), lowerFCOPYSIGN(), llvm::LegalizerHelper::lowerFPTOSI(), llvm::LegalizerHelper::lowerFPTOUI(), llvm::LegalizerHelper::lowerISFPCLASS(), LowerShift(), LowerVSETCC(), llvm::RISCVTargetLowering::PerformDAGCombine(), llvm::GISelKnownBits::signBitIsZero(), llvm::SelectionDAG::SignBitIsZero(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::InstCombinerImpl::visitAShr(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitShl(), and llvm::InstCombinerImpl::visitSRem().
Return a value containing V broadcasted over NewLen bits.
Definition at line 624 of file APInt.cpp.
Referenced by combineAddOfPMADDWD(), combineSubShiftToOrcB(), computeKnownBitsForPMADDUBSW(), computeKnownBitsForPMADDWD(), llvm::TargetLowering::expandBITREVERSE(), llvm::TargetLowering::expandCTPOP(), llvm::TargetLowering::expandVPBITREVERSE(), llvm::TargetLowering::expandVPCTPOP(), extractConstantBits(), getAvailableLoadStore(), llvm::VNCoercion::getConstantMemInstValueForLoad(), getMemsetValue(), getTargetConstantBitsFromNode(), llvm::X86TTIImpl::instCombineIntrinsic(), llvm::SelectionDAG::isSplatValue(), llvm::LegalizerHelper::lowerBitCount(), llvm::LegalizerHelper::lowerBitreverse(), LowerShift(), PerformVMOVNCombine(), PerformVQMOVNCombine(), llvm::InstCombinerImpl::SimplifyAnyMemSet(), llvm::ARMTTIImpl::simplifyDemandedVectorEltsIntrinsic(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), and tryToRecognizePopCount().
Get the bits that are sufficient to represent the string value.
This may over estimate the amount of bits required, but it does not require parsing the value in the string.
Definition at line 517 of file APInt.cpp.
References assert().
Referenced by getBitsNeeded().
Get the '0' value for the specified bit-width.
Definition at line 200 of file APInt.h.
Referenced by llvm::ConstantRange::abs(), adjustByValArgAlignment(), llvm::ConstantRange::binaryAnd(), llvm::ConstantRange::binaryOr(), llvm::SwitchCG::SwitchLowering::buildBitTests(), llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), cmpExcludesZero(), combineCONCAT_VECTORS(), combineConcatVectorOps(), combineMOVMSK(), combineOr(), combineShuffleToZeroExtendVectorInReg(), combineVectorCompare(), combineVectorPack(), combineX86ShuffleChain(), combineX86ShufflesConstants(), combineX86ShufflesRecursively(), llvm::ObjectSizeOffsetVisitor::compute(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), llvm::SelectionDAG::ComputeNumSignBits(), computeShlNSW(), llvm::SelectionDAG::computeVectorKnownZeroElements(), computeZeroableShuffleElements(), llvm::ConstantFoldCastInstruction(), llvm::ConstantRange::ctlz(), llvm::ConstantRange::ctpop(), llvm::ConstantRange::cttz(), llvm::decomposeBitTestICmp(), detectSSatPattern(), EltsFromConsecutiveLoads(), llvm::TargetLowering::expandFP_TO_UINT(), extractConstantBits(), llvm::SelectionDAG::FoldConstantArithmetic(), foldCtpop(), foldICmpUSubSatOrUAddSatWithConstant(), foldSelectICmpLshrAshr(), foldSwitchToSelect(), FoldValueWithUndef(), llvm::SCEVExpander::generateOverflowCheck(), llvm::BuildVectorSDNode::getConstantRawBits(), getConstVector(), getDomain(), getElementIndex(), getExtractedDemandedElts(), llvm::getHorizDemandedEltsForFirstOperand(), llvm::TargetTransformInfoImplCRTPBase< T >::getInstructionCost(), llvm::BasicTTIImplBase< T >::getInterleavedMemoryOpCost(), llvm::X86TTIImpl::getInterleavedMemoryOpCostAVX512(), llvm::APFixedPoint::getIntPart(), llvm::BasicTTIImplBase< T >::getIntrinsicInstrCost(), getKnownUndefForVectorBinop(), getPackDemandedElts(), getRangeForIntrinsic(), getRangeForSelectPattern(), llvm::getShuffleDemandedElts(), getSizeWithOverflow(), getSplatableConstant(), getTargetConstantBitsFromNode(), getTargetShuffleAndZeroables(), llvm::slpvectorizer::BoUpSLP::getTreeCost(), getUnsignedCountTrailingZerosRange(), llvm::getVScaleRange(), isCompletePermute(), llvm::X86TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(), llvm::ShuffleVectorInst::isInsertSubvectorMask(), isKnownNonZeroFromOperator(), llvm::SelectionDAG::isSplatValue(), llvm::X86TargetLowering::isSplatValueForTargetNode(), isTargetShuffleEquivalent(), LowerFMINIMUM_FMAXIMUM(), llvm::LegalizerHelper::lowerFPTOUI(), LowerShift(), lowerShuffleAsElementInsertion(), lowerShuffleAsLanePermuteAndPermute(), llvm::ConstantRange::makeAllowedICmpRegion(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), llvm::detail::IEEEFloat::makeNaN(), matchBinaryShuffle(), matchScalarReduction(), MatchVectorAllEqualTest(), llvm::ConstantRange::multiply(), llvm::ConstantRange::multiplyWithNoWrap(), rebuildExtCst(), llvm::BuildVectorSDNode::recastRawBits(), resolveZeroablesFromTargetShuffle(), scalarConstantToHexString(), llvm::APIntOps::ScaleBitMask(), llvm::ConstantRange::sdiv(), llvm::ConstantRange::shl(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), simplifyX86pack(), llvm::ConstantRange::srem(), stripAndComputeConstantOffsets(), llvm::ConstantRange::urem(), and llvm::reassociate::XorOpnd::XorOpnd().
|
inlinestatic |
|
inline |
Get zero extended value.
This method attempts to return the value of this APInt as a zero extended uint64_t. The bitwidth must be <= 64 or the value must fit within a uint64_t. Otherwise an assertion will result.
Definition at line 1520 of file APInt.h.
References assert().
Referenced by llvm::DwarfExpression::addConstantFP(), llvm::DwarfUnit::addConstantValue(), llvm::CombinerHelper::applyFunnelShiftConstantModulo(), llvm::buildSelectInst(), canEvaluateShiftedShift(), canEvaluateZExtd(), collectBitParts(), combineCMov(), combineCMP(), combineExtractWithShuffle(), llvm::PPCInstrInfo::combineRLWINM(), combineTargetShuffle(), CombineVMOVDRRCandidateWithVecOp(), llvm::InstCombinerImpl::commonIDivTransforms(), llvm::ProfileSummaryBuilder::computeDetailedSummary(), computeFlagsForAddressComputation(), llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), llvm::X86TargetLowering::ComputeNumSignBitsForTargetNode(), ComputeNumSignBitsImpl(), convertIntToDoubleImm(), llvm::TargetLowering::CTTZTableLookup(), DecodeXR32RegisterClass(), llvm::Interpreter::exitCalled(), llvm::extractConstantMask(), extractShiftForRotate(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpTruncConstant(), foldLoadsRecursive(), foldSelectICmpAndZeroShl(), llvm::InstCombinerImpl::FoldShiftByConstant(), foldShiftedShift(), foldSubCtlzNot(), foldVecExtTruncToExtElt(), llvm::generateSpecConstantInst(), getArrayComponentCount(), getConstant(), llvm::ExecutionEngine::getConstantValue(), llvm::getConstFromIntrinsic(), llvm::getExpressionForConstant(), llvm::getObjectSize(), llvm::SelectionDAG::getShiftAmountConstant(), llvm::ScalarEvolution::getSmallConstantTripMultiple(), llvm::GStepVector::getStep(), llvm::AArch64TargetMachine::getSubtargetImpl(), getVariantMatchScore(), llvm::ConstantInt::getZExtValue(), llvm::mca::initializeUsedResources(), llvm::GCNTTIImpl::instCombineIntrinsic(), isEXTMask(), llvm::AArch64TargetLowering::isFPImmLegal(), isKnownTypeIdMember(), llvm::AArch64TargetLowering::isMulAddWithConstProfitable(), llvm::ARMTargetLowering::isMulAddWithConstProfitable(), llvm::SystemZVectorConstantInfo::isVectorConstantLegal(), LLVMGenericValueToInt(), LowerShiftByScalarImmediate(), matchAndOrChain(), matchIntPart(), matchPMADDWD(), matchPMADDWD_2(), narrowIndex(), optimizeIncrementingWhile(), optimizeLogicalImm(), parseHexOcta(), parseJumpTable(), PerformANDCombine(), llvm::AMDGPUTargetLowering::PerformDAGCombine(), performDSPShiftCombine(), performMulCombine(), PerformORCombine(), PerformSHLSimplify(), llvm::X86TargetLowering::preferedOpcodeForCmpEqPiecesOfOperand(), printConstant(), llvm::NVPTXFloatMCExpr::printImpl(), llvm::ExecutionEngine::runFunctionAsMain(), llvm::PPCTargetLowering::SelectAddressRegImm(), llvm::PPCTargetLowering::SelectAddressRegImm34(), llvm::LoopVectorizationPlanner::selectEpilogueVectorizationFactor(), selectI64ImmDirect(), selectI64ImmDirectPrefix(), llvm::LoongArchDAGToDAGISel::selectVSplatImm(), llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(), llvm::InstCombinerImpl::simplifyShrShlDemandedBits(), simplifyX86extrq(), simplifyX86insertq(), simplifyX86varShift(), splitGlobal(), llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(), toString(), toString(), tryBitfieldInsertOpFromOrAndImm(), tryCombineToBSL(), llvm::tryPromoteCall(), urem(), llvm::Interpreter::visitAllocaInst(), llvm::InstCombinerImpl::visitAnd(), llvm::Interpreter::visitAShr(), llvm::InstCombinerImpl::visitAShr(), llvm::Interpreter::visitExtractElementInst(), llvm::Interpreter::visitInsertElementInst(), llvm::Interpreter::visitLShr(), llvm::InstCombinerImpl::visitLShr(), llvm::Interpreter::visitShl(), llvm::InstCombinerImpl::visitShl(), walkToAllocaAndPrependOffsetDeref(), and WriteAPFloatInternal().
Insert the bits from a smaller APInt starting at bitPosition.
Definition at line 370 of file APInt.cpp.
References APINT_BITS_PER_WORD, APINT_WORD_SIZE, assert(), getBitWidth(), getRawData(), isSingleWord(), setBitVal(), VAL, and WORDTYPE_MAX.
Referenced by combineConcatVectorOps(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::extractConstantMask(), getDemandedSrcElements(), getSplatableConstant(), getTargetConstantBitsFromNode(), llvm::KnownBits::insertBits(), llvm::BuildVectorSDNode::isConstantSplat(), llvm::RISCVTargetLowering::PerformDAGCombine(), rebuildExtCst(), llvm::BuildVectorSDNode::recastRawBits(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), and llvm::TargetLowering::SimplifyMultipleUseDemandedBits().
Definition at line 428 of file APInt.cpp.
References isSingleWord().
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are both set.
Definition at line 1249 of file APInt.h.
References assert(), BitWidth, and RHS.
Referenced by bitTrackingDCE(), combineBlendOfPermutes(), eliminateDeadSwitchCases(), llvm::InstCombinerImpl::foldICmpAndConstant(), foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed(), foldSignedTruncationCheck(), llvm::KnownBits::hasConflict(), isKnownNonEqual(), isNonZeroAdd(), simplifyAndInst(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::TargetLowering::SimplifySetCC(), and llvm::KnownBits::srem().
Checks if this APInt -interpreted as an address- is aligned to the provided value.
Definition at line 169 of file APInt.cpp.
References A, countr_zero(), isZero(), and llvm::Log2().
|
inline |
Determine if all bits are set. This is true for zero-width values.
Definition at line 371 of file APInt.h.
References BitWidth.
Referenced by areUsedBitsDense(), bitTrackingDCE(), llvm::TargetLowering::BuildSDIV(), llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), combineX86ShufflesRecursively(), llvm::InstCombinerImpl::commonIDivTransforms(), createAndInstr(), EltsFromConsecutiveLoads(), EmitVectorComparison(), llvm::extractConstantMask(), findDemandedEltsByAllUsers(), foldAndOrOfSETCC(), foldBinOpIntoSelectIfProfitable(), llvm::InstCombinerImpl::foldICmpAddConstant(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::InstCombinerImpl::foldICmpMulConstant(), llvm::InstCombinerImpl::foldICmpShrConstConst(), llvm::X86TTIImpl::getScalarizationOverhead(), getTargetConstantBitsFromNode(), llvm::KnownBits::isAllOnes(), llvm::SelectionDAG::isBoolConstant(), isCompletePermute(), llvm::ISD::isConstantSplatVectorAllOnes(), llvm::TargetLowering::isConstTrueVal(), llvm::ConstantInt::isMinusOne(), isMultiple(), llvm::isSafeToSpeculativelyExecuteWithOpcode(), isSelect01(), isVectorAllOnes(), llvm::KnownBits::isZero(), lowerShuffleAsVTRUNC(), lowerShuffleWithVPMOV(), lowerVECTOR_SHUFFLE(), llvm::SDPatternMatch::m_True(), matchMinMax(), matchShuffleAsEXTRQ(), matchShuffleAsVTRUNC(), PerformReduceShuffleCombine(), llvm::recognizeBSwapOrBitReverseIdiom(), llvm::ConstantRange::sdiv(), llvm::KnownBits::sdiv(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::InstCombinerImpl::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetShuffle(), llvm::RegisterBankInfo::ValueMapping::verify(), llvm::InstCombinerImpl::visitExtractElementInst(), llvm::InstCombinerImpl::visitGetElementPtrInst(), llvm::InstCombinerImpl::visitMul(), and llvm::InstCombinerImpl::visitOr().
Check if this APInt has an N-bits unsigned integer value.
Definition at line 432 of file APInt.h.
References N.
Referenced by AreMulWideOperandsDemotable(), combineVectorPack(), llvm::ScalarEvolution::getUDivExactExpr(), mustBeFiniteCountedLoop(), parseHexOcta(), llvm::LoongArchDAGToDAGISel::selectVSplatImm(), and truncUSat().
|
inline |
Definition at line 501 of file APInt.h.
References BitWidth, and llvm::isMask_64().
numBits | ones starting at the least significant bit with the remainder zero. |
Definition at line 488 of file APInt.h.
References assert(), and BitWidth.
Referenced by combineAndMaskToShift(), combineSetCCMOVMSK(), combineShiftRightLogical(), combineTruncToVnclip(), combineVectorMulToSraBitcast(), detectUSatPattern(), llvm::InstCombinerImpl::foldAddWithConstant(), llvm::InstCombinerImpl::foldICmpAndConstant(), foldSelectICmpAndZeroShl(), foldSubCtlzNot(), llvm::CombinerHelper::matchCombineLoadWithAndMask(), performMulVectorCmpZeroCombine(), performSubsToAndsCombine(), simplifyAMDGCNMemoryIntrinsicDemanded(), simplifyOrInst(), and llvm::InstCombinerImpl::visitSub().
|
inline |
Determine if this is the largest signed value.
This checks to see if the value of this APInt is the maximum signed value for the APInt's bit width.
Definition at line 405 of file APInt.h.
References assert(), and BitWidth.
Referenced by llvm::InstCombinerImpl::foldICmpXorConstant(), incDecVectorConstant(), llvm::ConstantInt::isMaxValue(), LowerVSETCC(), matchMinMax(), llvm::TargetLowering::SimplifySetCC(), and simplifySubInst().
|
inline |
Determine if this is the largest unsigned value.
This checks to see if the value of this APInt is the maximum unsigned value for the APInt's bit width.
Definition at line 399 of file APInt.h.
Referenced by llvm::ConstantRange::ConstantRange(), incDecVectorConstant(), llvm::ConstantRange::isFullSet(), and llvm::ConstantInt::isMaxValue().
|
inline |
Determine if this is the smallest signed value.
This checks to see if the value of this APInt is the minimum signed value for the APInt's bit width.
Definition at line 423 of file APInt.h.
References assert(), and BitWidth.
Referenced by llvm::KnownBits::abs(), cannotBeIntMin(), combineSetCC(), llvm::InstCombinerImpl::commonIRemTransforms(), llvm::ConstantFoldBinaryInstruction(), llvm::InstCombinerImpl::foldAddWithConstant(), llvm::InstCombinerImpl::foldICmpXorShiftConst(), llvm::InstCombinerImpl::FoldShiftByConstant(), llvm::ConstantRange::getEquivalentICmp(), llvm::ScalarEvolution::getMinusSCEV(), llvm::ScalarEvolution::getUDivExpr(), incDecVectorConstant(), llvm::ConstantInt::isMinValue(), isMultiple(), llvm::isSafeToSpeculativelyExecuteWithOpcode(), llvm::ConstantRange::isSignWrappedSet(), LowerVSETCC(), matchMinMax(), llvm::ConstantRange::multiply(), llvm::APFixedPoint::negate(), llvm::detail::SlowDynamicAPInt::operator-(), llvm::ConstantRange::sdiv(), llvm::KnownBits::sdiv(), sdiv_ov(), llvm::ConstantRange::signExtend(), llvm::TargetLowering::SimplifySetCC(), smul_ov(), tryFactorization(), and llvm::InstCombinerImpl::visitSDiv().
|
inline |
Determine if this is the smallest unsigned value.
This checks to see if the value of this APInt is the minimum unsigned value for the APInt's bit width.
Definition at line 417 of file APInt.h.
References isZero().
Referenced by llvm::InstCombinerImpl::commonIRemTransforms(), llvm::ConstantRange::ConstantRange(), llvm::ConstantRange::isEmptySet(), llvm::ConstantInt::isMinValue(), and isMultiple().
|
inline |
Check if this APInt's negated value is a power of two greater than zero.
Definition at line 449 of file APInt.h.
References assert(), BitWidth, llvm::countl_one(), and llvm::countr_zero().
Referenced by llvm::PPCTargetLowering::BuildSDIVPow2(), canEvaluateShifted(), llvm::decomposeBitTestICmp(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::SystemZTTIImpl::getArithmeticInstrCost(), instCombineSVESDIV(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifySetCC(), and llvm::InstCombinerImpl::visitSub().
|
inline |
Determine sign of this APInt.
This tests the high bit of this APInt to determine if it is set.
Definition at line 329 of file APInt.h.
References BitWidth.
Referenced by llvm::TargetLowering::BuildSDIV(), combineShiftRightArithmetic(), combineVectorPack(), llvm::InstCombinerImpl::commonShiftTransforms(), llvm::KnownBits::computeForAddSub(), llvm::SelectionDAG::computeKnownBits(), computeShlNSW(), llvm::detail::IEEEFloat::convertFromAPInt(), foldAddToAshr(), foldAndOrOfSETCC(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpAndShift(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::InstCombinerImpl::foldICmpMulConstant(), llvm::InstCombinerImpl::foldICmpShrConstant(), llvm::InstCombinerImpl::foldICmpShrConstConst(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), llvm::InstCombinerImpl::foldICmpXorConstant(), foldNoWrapAdd(), llvm::InstCombinerImpl::FoldShiftByConstant(), getAssignmentInfoImpl(), getBitsNeeded(), llvm::ExpressionFormat::getMatchingString(), getRangeForAffineARHelper(), getStrideAndModOffsetOfGEP(), llvm::ScalarEvolution::getUDivExpr(), isConstantPowerOfTwo(), llvm::ScalarEvolution::isKnownNegative(), llvm::ScalarEvolution::isKnownNonNegative(), llvm::ConstantInt::isNegative(), isNonEqualPointersWithRecursiveGEP(), isNonZeroRecurrence(), performMulCombine(), llvm::APIntOps::RoundingSDiv(), sadd_sat(), sdiv(), sext(), sfloordiv_ov(), shouldTransformMulToShiftsAddsSubs(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), llvm::TargetLowering::SimplifySetCC(), smul_sat(), llvm::APIntOps::SolveQuadraticEquationWrap(), srem(), sshl_sat(), ssub_sat(), llvm::RISCVTargetLowering::targetShrinkDemandedConstant(), toString(), toString(), truncSSat(), and umul_ov().
|
inline |
Determine if this APInt Value is non-negative (>= 0)
This tests the high bit of the APInt to determine if it is unset.
Definition at line 334 of file APInt.h.
Referenced by llvm::TargetLowering::buildSDIVPow2WithCMov(), combineTruncToVnclip(), llvm::KnownBits::computeForAddSub(), llvm::SelectionDAG::computeKnownBits(), computePointerICmp(), computeShlNSW(), detectUSatPattern(), llvm::ConstantRange::isAllNonNegative(), llvm::isKnownInversion(), llvm::ConstantRange::multiply(), performMulCombine(), sadd_ov(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), simplifyICmpWithBinOp(), simplifyIntrinsic(), llvm::TargetLowering::SimplifySetCC(), llvm::ConstantRange::srem(), sshl_ov(), llvm::ConstantRange::sshl_sat(), ssub_ov(), trySimplifyICmpWithAdds(), llvm::InstCombinerImpl::visitCallInst(), and llvm::InstCombinerImpl::visitGetElementPtrInst().
|
inline |
Determine if this APInt Value is non-positive (<= 0).
Definition at line 361 of file APInt.h.
Referenced by processAbsIntrinsic(), and trySimplifyICmpWithAdds().
|
inline |
Determine if this is a value of 1.
This checks to see if the value of this APInt is one.
Definition at line 389 of file APInt.h.
References BitWidth.
Referenced by llvm::TargetLowering::BuildSDIV(), llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), combineSelectOfTwoConstants(), llvm::TargetLowering::expandDIVREMByConstant(), llvm::InstCombinerImpl::foldICmpAndShift(), llvm::InstCombinerImpl::foldICmpDivConstant(), foldICmpShlLHSC(), llvm::SelectionDAG::isBoolConstant(), llvm::TargetLowering::isConstTrueVal(), llvm::ConstantInt::isOne(), isSelect01(), llvm::SDPatternMatch::m_True(), multiplicativeInverse(), performVSelectCombine(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), simplifyGEPInst(), and llvm::TargetLowering::SimplifySetCC().
|
inline |
Check if this APInt's value is a power of two greater than zero.
Definition at line 440 of file APInt.h.
References assert(), BitWidth, and llvm::isPowerOf2_64().
Referenced by llvm::PPCTargetLowering::BuildSDIVPow2(), combineAnd(), combineSelectOfTwoConstants(), combineSetCC(), llvm::SelectionDAG::computeKnownBits(), llvm::decomposeBitTestICmp(), llvm::InstCombinerImpl::foldAddWithConstant(), foldAndOrOfSETCC(), llvm::InstCombinerImpl::foldICmpAddConstant(), llvm::InstCombinerImpl::foldICmpBinOpEqualityWithConstant(), foldICmpShlLHSC(), llvm::InstCombinerImpl::foldICmpShrConstant(), llvm::InstCombinerImpl::foldICmpShrConstConst(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), foldICmpWithTruncSignExtendedVal(), llvm::InstCombinerImpl::foldICmpXorShiftConst(), foldSelectICmpAnd(), foldSignedTruncationCheck(), llvm::SystemZTTIImpl::getArithmeticInstrCost(), getBitsNeeded(), llvm::ConstantExpr::getExactLogBase2(), getMaskedICmpType(), instCombineSVESDIV(), isAllocSiteRemovable(), isConstantPowerOfTwo(), llvm::isKnownToBeAPowerOfTwo(), isPowerOf2Constant(), isSaturatingMinMax(), LowerVSETCC(), optimizeBranch(), performMulCombine(), performSubsToAndsCombine(), processUGT_ADDCST_ADD(), shouldTransformMulToShiftsAddsSubs(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), simplifyDiv(), llvm::TargetLowering::SimplifySetCC(), useInversedSetcc(), llvm::InstCombinerImpl::visitAdd(), and llvm::InstCombinerImpl::visitAnd().
Determine if two APInts have the same value, after zero-extending one of them (if needed!) to ensure that the bit-widths match.
Definition at line 553 of file APInt.h.
References getBitWidth(), and zext().
Referenced by llvm::SDPatternMatch::SpecificInt_match::match(), llvm::PatternMatch::specific_intval< AllowPoison >::match(), and llvm::VPlanPatternMatch::specific_intval< BitWidth >::match().
|
inline |
Return true if this APInt value contains a non-empty sequence of ones with the remainder zero.
Definition at line 510 of file APInt.h.
References BitWidth, and llvm::isShiftedMask_64().
Return true if this APInt value contains a non-empty sequence of ones with the remainder zero.
If true, MaskIdx
will specify the index of the lowest set bit and MaskLen
is updated to specify the length of the mask, else neither are updated.
Definition at line 522 of file APInt.h.
References BitWidth, and llvm::isShiftedMask_64().
|
inline |
Determine if sign bit of this APInt is clear.
This tests the high bit of this APInt to determine if it is clear.
Definition at line 348 of file APInt.h.
Referenced by llvm::KnownBits::getSignedMaxValue(), and llvm::KnownBits::getSignedMinValue().
|
inline |
Determine if sign bit of this APInt is set.
This tests the high bit of this APInt to determine if it is set.
Definition at line 341 of file APInt.h.
References BitWidth.
Referenced by combineSetCC(), llvm::APFixedPoint::compare(), llvm::ScalarEvolution::getAddExpr(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::KnownBits::isSignUnknown(), llvm::KnownBits::isStrictlyPositive(), simplifyShift(), and toSigned().
Check if this APInt has an N-bits signed integer value.
Definition at line 435 of file APInt.h.
References N.
Referenced by AreMulWideOperandsDemotable(), combineSubOfBoolean(), computeFlagsForAddressComputation(), INITIALIZE_PASS(), llvm::NVPTXTargetLowering::isLegalAddressingMode(), llvm::RISCVTargetLowering::isMulAddWithConstProfitable(), llvm::LoongArchDAGToDAGISel::selectVSplatImm(), llvm::RISCVTargetLowering::targetShrinkDemandedConstant(), truncSSat(), and useInversedSetcc().
|
inline |
Check if the APInt's value is returned by getSignMask.
Definition at line 466 of file APInt.h.
Referenced by foldAddToAshr(), llvm::InstCombinerImpl::foldAddWithConstant(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpXorConstant(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), and llvm::InstCombinerImpl::visitXor().
|
inline |
Determine if this APInt just has one word to store value.
Definition at line 322 of file APInt.h.
References BitWidth.
Referenced by extractBits(), extractBitsAsZExtValue(), llvm::hash_value(), insertBits(), operator*(), operator*=(), operator++(), operator+=(), operator--(), operator-=(), Profile(), roundToDouble(), sqrt(), llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(), toString(), udiv(), and urem().
|
inline |
Determine if this APInt Value is positive.
This tests if the value of this APInt is positive (> 0). Note that 0 is not a positive value.
Definition at line 356 of file APInt.h.
References isZero().
Referenced by llvm::ConstantRange::abs(), llvm::TargetLowering::BuildSDIV(), ComputeNumSignBitsImpl(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::ConstantRange::isAllNegative(), llvm::ConstantRange::isAllPositive(), llvm::ScalarEvolution::isKnownNonPositive(), llvm::ScalarEvolution::isKnownPositive(), isNonEqualPointersWithRecursiveGEP(), simplifyAndOfICmpsWithAdd(), and simplifyOrOfICmpsWithAdd().
This operation checks that all bits set in this APInt are also set in RHS.
Definition at line 1257 of file APInt.h.
References assert(), BitWidth, and RHS.
Referenced by bitTrackingDCE(), llvm::SelectionDAGISel::CheckAndMask(), llvm::SelectionDAGISel::CheckOrMask(), eliminateDeadSwitchCases(), foldLogOpOfMaskedICmps(), foldSignedTruncationCheck(), getMaskedICmpType(), llvm::SelectionDAG::getSplatSourceVector(), llvm::X86TTIImpl::instCombineIntrinsic(), LowerMUL(), performORCombine(), llvm::LoongArchDAGToDAGISel::selectShiftMask(), llvm::RISCVDAGToDAGISel::selectShiftMask(), simplifyAndInst(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::ARMTargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), simplifyICmpWithBinOp(), llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifySetCC(), llvm::KnownBits::srem(), llvm::RISCVTargetLowering::targetShrinkDemandedConstant(), llvm::X86TargetLowering::targetShrinkDemandedConstant(), and llvm::InstCombinerImpl::visitSub().
|
inline |
Determine if this value is zero, i.e. all bits are clear.
Definition at line 380 of file APInt.h.
References BitWidth.
Referenced by llvm::KnownBits::abs(), canonicalizeGEPOfConstGEPI8(), llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), canWidenShuffleElements(), llvm::GEPOperator::collectOffset(), combineBlendOfPermutes(), llvm::PPCInstrInfo::combineRLWINM(), combineSetCCMOVMSK(), combineX86ShufflesRecursively(), llvm::InstCombinerImpl::commonIDivTransforms(), computeKnownBitsForHorizontalOperation(), computeKnownBitsFromOperator(), computeKnownFPClass(), createAndInstr(), llvm::ConstantRange::cttz(), llvm::APFixedPoint::div(), EltsFromConsecutiveLoads(), llvm::exprDiv(), foldAndOrOfICmpEqConstantAndICmp(), foldAndOrOfSETCC(), foldBinOpIntoSelectIfProfitable(), foldCttzCtlz(), llvm::InstCombinerImpl::foldICmpAddConstant(), llvm::InstCombinerImpl::foldICmpAndConstant(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpAndShift(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::InstCombinerImpl::foldICmpMulConstant(), llvm::InstCombinerImpl::foldICmpShlConstConst(), foldICmpShlLHSC(), llvm::InstCombinerImpl::foldICmpShrConstConst(), llvm::InstCombinerImpl::foldICmpWithZero(), foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed(), foldNoWrapAdd(), foldSelectICmpAnd(), llvm::InstCombinerImpl::FoldShiftByConstant(), foldSignedTruncationCheck(), GEPToVectorIndex(), llvm::SignedDivisionByConstantInfo::get(), llvm::UnsignedDivisionByConstantInfo::get(), getFauxShuffleMask(), getKnownBitsFromAndXorOr(), llvm::X86TTIImpl::getScalarizationOverhead(), llvm::getShuffleDemandedElts(), incDecVectorConstant(), isAligned(), llvm::SelectionDAG::isBoolConstant(), llvm::BuildVectorSDNode::isConstantSequence(), llvm::ISD::isConstantSplatVectorAllZeros(), llvm::SelectionDAG::isGuaranteedNotToBeUndefOrPoison(), llvm::ShuffleVectorInst::isInsertSubvectorMask(), llvm::SelectionDAG::isKnownNeverZero(), isKnownNonZeroFromOperator(), isMultiple(), llvm::KnownBits::isNonZero(), isNonZeroRecurrence(), isSelect01(), llvm::SelectionDAG::isSplatValue(), llvm::KnownBits::isStrictlyPositive(), isTargetShuffleEquivalent(), llvm::KnownBits::isUnknown(), llvm::ConstantRange::isWrappedSet(), llvm::ConstantInt::isZero(), LowerBuildVectorv16i8(), LowerVSETCC(), llvm::SDPatternMatch::m_False(), matchMinMax(), llvm::LegalizerHelper::narrowScalarShiftByConstant(), nearestLogBase2(), parseJumpTable(), llvm::APIntOps::RoundingSDiv(), llvm::APIntOps::RoundingUDiv(), llvm::ConstantRange::sdiv(), llvm::KnownBits::sdiv(), llvm::TargetLowering::ShrinkDemandedConstant(), llvm::InstCombinerImpl::SimplifyAddWithRemainder(), llvm::InstCombinerImpl::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TTIImpl::simplifyDemandedUseBitsIntrinsic(), llvm::InstCombinerImpl::SimplifyDemandedVectorElts(), simplifyGEPInst(), simplifyIntrinsic(), simplifyIRemMulShl(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), llvm::TargetLowering::SimplifySetCC(), simplifyX86immShift(), sinkAndCmp0Expression(), llvm::APIntOps::SolveQuadraticEquationWrap(), llvm::ConstantRange::srem(), toString(), llvm::ConstantRange::udiv(), llvm::KnownBits::udiv(), and llvm::InstCombinerImpl::visitMul().
|
inline |
Definition at line 1739 of file APInt.h.
Referenced by llvm::SelectionDAG::computeKnownBits(), ComputeNumSignBitsImpl(), llvm::InstCombinerImpl::foldAddWithConstant(), foldICmpShlLHSC(), llvm::InstCombinerImpl::foldICmpShrConstConst(), foldSelectICmpAnd(), foldSelectICmpAndBinOp(), getBitsNeeded(), llvm::ConstantExpr::getExactLogBase2(), instCombineSVESDIV(), isEXTMask(), LowerVSETCC(), nearestLogBase2(), optimizeBranch(), llvm::ARMTargetLowering::PerformCMOVCombine(), llvm::ARMTargetLowering::PerformCMOVToBFICombine(), performMulCombine(), shouldTransformMulToShiftsAddsSubs(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifySetCC(), llvm::InstCombinerImpl::visitAShr(), and llvm::InstCombinerImpl::visitLShr().
Logical right-shift function.
Logical right-shift this APInt by shiftAmt.
Definition at line 851 of file APInt.h.
Referenced by llvm::DwarfExpression::addConstantFP(), areUsedBitsDense(), combineShiftRightLogical(), computeKnownBitsFromOperator(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), llvm::TargetLowering::CTTZTableLookup(), llvm::InstCombinerImpl::foldICmpAndShift(), llvm::InstCombinerImpl::foldICmpShrConstant(), llvm::InstCombinerImpl::foldICmpShrConstConst(), foldICmpWithTruncSignExtendedVal(), FoldValue(), getDemandedSrcElements(), getHiBits(), getHopForBuildVector(), llvm::APFixedPoint::getMax(), llvm::BlockFrequencyInfoImplBase::getProfileCountFromFreq(), llvm::X86TTIImpl::instCombineIntrinsic(), llvm::SelectionDAG::isKnownNeverZero(), isNonZeroShift(), llvm::SystemZVectorConstantInfo::isVectorConstantLegal(), lowerMSABinaryBitImmIntr(), LowerShift(), llvm::ConstantRange::lshr(), llvm::CombinerHelper::matchCombineUnmergeConstant(), llvm::LegalizerHelper::narrowScalar(), rotl(), rotr(), setLimitsForBinOp(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::InstCombinerImpl::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), llvm::TargetLowering::SimplifySetCC(), llvm::InstCombinerImpl::simplifyShrShlDemandedBits(), llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(), umul_ov(), llvm::Interpreter::visitLShr(), llvm::InstCombinerImpl::visitLShr(), llvm::InstCombinerImpl::visitSwitchInst(), and llvm::InstCombinerImpl::visitXor().
Logical right-shift this APInt by ShiftAmt in place.
Logical right-shift this APInt by shiftAmt.
Logical right-shift function.
Definition at line 1073 of file APInt.cpp.
References getLimitedValue(), and lshrInPlace().
|
inline |
Logical right-shift this APInt by ShiftAmt in place.
Definition at line 858 of file APInt.h.
References assert(), and BitWidth.
Referenced by BuildExactUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), checkSignTestSetCCCombine(), combineVectorShiftImm(), llvm::SelectionDAG::computeKnownBits(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromCmp(), emitGlobalConstantLargeInt(), llvm::TargetLowering::expandDIVREMByConstant(), getDemandedSrcElements(), getUsefulBitsFromBitfieldMoveOpd(), llvm::KnownBits::lshr(), lshrInPlace(), PerformSHLSimplify(), reverseBits(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::TargetLowering::SimplifySetCC(), simplifyX86extrq(), and toString().
APInt APInt::multiplicativeInverse | ( | ) | const |
Definition at line 1248 of file APInt.cpp.
References assert(), and isOne().
Referenced by BinomialCoefficient(), BuildExactSDIV(), BuildExactUDIV(), llvm::CombinerHelper::buildSDivUsingMul(), llvm::CombinerHelper::buildUDivUsingMul(), llvm::TargetLowering::expandDIVREMByConstant(), and SolveLinEquationWithOverflow().
unsigned APInt::nearestLogBase2 | ( | ) | const |
NOTE: When we have a BitWidth of 1, we define:
log2(0) = UINT32_MAX log2(1) = 0
to get around any mathematical concerns resulting from referencing 2 in a space where 2 does no exist.
Definition at line 1146 of file APInt.cpp.
References isZero(), and logBase2().
|
inline |
|
inline |
Negate this APInt in place.
Definition at line 1450 of file APInt.h.
Referenced by llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::SignedDivisionByConstantInfo::get(), llvm::LegalizerHelper::getDynStackAllocTargetPtr(), instCombineSVESDIV(), sdivrem(), and toString().
|
inline |
|
inline |
|
inline |
Multiplication operator.
Multiplies this APInt by RHS and returns the result.
Definition at line 235 of file APInt.cpp.
References APInt(), assert(), getBitWidth(), getMemory(), getNumWords(), isSingleWord(), RHS, and tcMultiply().
Definition at line 270 of file APInt.cpp.
References getNumWords(), isSingleWord(), RHS, and tcMultiplyPart().
APInt & APInt::operator++ | ( | ) |
Prefix increment operator.
Prefix increment operator. Increments the APInt by one.
Definition at line 178 of file APInt.cpp.
References getNumWords(), isSingleWord(), and tcIncrement().
|
inline |
Addition assignment operator.
Adds the RHS APInt to this APInt.
Adds RHS to *this and assigns the result to *this.
Definition at line 198 of file APInt.cpp.
References assert(), getNumWords(), isSingleWord(), RHS, and tcAdd().
Definition at line 207 of file APInt.cpp.
References getNumWords(), isSingleWord(), RHS, and tcAddPart().
APInt & APInt::operator-- | ( | ) |
Prefix decrement operator.
Prefix decrement operator. Decrements the APInt by one.
Definition at line 187 of file APInt.cpp.
References getNumWords(), isSingleWord(), and tcDecrement().
|
inline |
Subtraction assignment operator.
Subtracts the RHS APInt from this APInt.
Subtracts RHS from *this and assigns the result to *this.
Definition at line 218 of file APInt.cpp.
References assert(), getNumWords(), isSingleWord(), RHS, and tcSubtract().
Definition at line 227 of file APInt.cpp.
References getNumWords(), isSingleWord(), RHS, and tcSubtractPart().
Left-shift assignment function.
Left-shift this APInt by shiftAmt.
Shifts *this left by shiftAmt and assigns the result to *this.
Left-shift function.
Definition at line 1085 of file APInt.cpp.
References getLimitedValue().
Left-shift assignment function.
Shifts *this left by shiftAmt and assigns the result to *this.
Definition at line 785 of file APInt.h.
References assert(), BitWidth, and clearUnusedBits().
Assignment operator.
The RHS value is assigned to *this. If the significant bits in RHS exceed the bit width, the excess bits are truncated. If the bit width is larger than 64, the value is zero filled in the unspecified high order bits.
Definition at line 658 of file APInt.h.
References clearUnusedBits(), and RHS.
Array-indexing support.
Definition at line 1043 of file APInt.h.
References assert(), and getBitWidth().
Bitwise XOR assignment operator.
Performs a bitwise XOR operation on this APInt and RHS. RHS is logically zero-extended or truncated to match the bit-width of the LHS.
Definition at line 747 of file APInt.h.
References clearUnusedBits(), and RHS.
Bitwise OR assignment operator.
Performs a bitwise OR operation on this APInt and RHS. RHS is logically zero-extended or truncated to match the bit-width of the LHS.
Definition at line 718 of file APInt.h.
References clearUnusedBits(), and RHS.
|
inline |
Count the number of bits set.
This function is an APInt version of std::popcount. It counts the number of 1 bits in the APInt value.
Definition at line 1649 of file APInt.h.
References llvm::popcount().
Referenced by llvm::KnownBits::abs(), collectBitParts(), combineShuffleOfSplatVal(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), llvm::KnownBits::countMaxPopulation(), llvm::KnownBits::countMinPopulation(), EltsFromConsecutiveLoads(), llvm::SelectionDAG::FoldConstantArithmetic(), foldSwitchToSelect(), llvm::X86TTIImpl::getMemoryOpCost(), llvm::X86TTIImpl::getReplicationShuffleCost(), llvm::AArch64TTIImpl::getScalarizationOverhead(), llvm::X86TTIImpl::getScalarizationOverhead(), llvm::KnownBits::isConstant(), ParseBFI(), llvm::ARMTargetLowering::PerformCMOVToBFICombine(), simplifyAMDGCNMemoryIntrinsicDemanded(), llvm::InstCombinerImpl::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), tryBitfieldInsertOpFromOr(), and tryBitfieldInsertOpFromOrAndImm().
void APInt::print | ( | raw_ostream & | OS, |
bool | isSigned | ||
) | const |
Definition at line 2281 of file APInt.cpp.
References isSigned(), OS, and toString().
void APInt::Profile | ( | FoldingSetNodeID & | id | ) | const |
Used to insert APInt objects, or objects that contain APInt objects, into FoldingSets.
This method 'profiles' an APInt for use with FoldingSet.
Definition at line 156 of file APInt.cpp.
References getNumWords(), and isSingleWord().
Referenced by llvm::Attribute::get(), llvm::APSInt::Profile(), and llvm::AttributeImpl::Profile().
|
inline |
relative arithmetic shift left
Definition at line 895 of file APInt.h.
Referenced by llvm::APFixedPoint::mul().
|
inline |
|
inline |
relative logical shift left
Definition at line 885 of file APInt.h.
Referenced by llvm::APFixedPoint::mul().
|
inline |
APInt APInt::reverseBits | ( | ) | const |
Definition at line 741 of file APInt.cpp.
References APInt(), and lshrInPlace().
Referenced by computeKnownBitsFromOperator(), computeKnownFPClass(), determineLiveOperandBitsAddCarry(), foldBitwiseLogicWithIntrinsics(), llvm::SelectionDAG::FoldConstantArithmetic(), isKnownNonZeroFromOperator(), llvm::KnownBits::reverseBits(), and llvm::TargetLowering::SimplifyDemandedBits().
Rotate left by rotateAmt.
Definition at line 1111 of file APInt.cpp.
References rotateModulo(), and rotl().
Rotate left by rotateAmt.
Definition at line 1115 of file APInt.cpp.
References LLVM_UNLIKELY, lshr(), and shl().
Referenced by llvm::PPCInstrInfo::combineRLWINM(), FoldValue(), isSplat(), and rotl().
Rotate right by rotateAmt.
Definition at line 1124 of file APInt.cpp.
References rotateModulo(), and rotr().
Rotate right by rotateAmt.
Definition at line 1128 of file APInt.cpp.
Referenced by FoldValue(), llvm::RISCVLegalizerInfo::legalizeCustom(), rotr(), selectI64ImmDirect(), and selectI64ImmDirectPrefix().
|
inline |
Converts this unsigned APInt to a double value.
Definition at line 1690 of file APInt.h.
References roundToDouble().
Referenced by roundToDouble().
double APInt::roundToDouble | ( | bool | isSigned | ) | const |
Converts this APInt to a double value.
This function converts this APInt to a double.
Sign Exponent Fraction Bias |
---|
1[63] 11[62-52] 52[51-00] 1023 |
Definition at line 853 of file APInt.cpp.
References APINT_BITS_PER_WORD, assert(), getActiveBits(), I, isNeg(), isSigned(), isSingleWord(), pVal, sext(), and llvm::SignExtend64().
Referenced by llvm::ExecutionEngine::getConstantValue(), and llvm::APIntOps::RoundAPIntToDouble().
Definition at line 1902 of file APInt.cpp.
References isNonNegative(), and RHS.
Referenced by llvm::APFixedPoint::add(), addWithOverflow(), llvm::checkedAdd(), llvm::exprAdd(), maintainNoSignedWrap(), llvm::detail::SlowDynamicAPInt::operator+(), optimizeIncrementingWhile(), sadd_sat(), llvm::simplifyLoopAfterUnroll(), llvm::InstCombinerImpl::visitCallInst(), and llvm::InstCombinerImpl::visitOr().
Definition at line 2000 of file APInt.cpp.
References getSignedMaxValue(), getSignedMinValue(), isNegative(), RHS, and sadd_ov().
Referenced by llvm::APFixedPoint::add(), FoldValue(), and llvm::ConstantRange::sadd_sat().
Signed division function for APInt.
Signed divide this APInt by APInt RHS.
The result is rounded towards zero.
Definition at line 1618 of file APInt.cpp.
References isNegative(), RHS, and udiv().
Referenced by llvm::ProfileSummaryBuilder::computeDetailedSummary(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), findGCD(), llvm::InstCombinerImpl::foldICmpDivConstant(), FoldValue(), getExactSDiv(), isSimpleVIDSequence(), llvm::ConstantRange::sdiv(), llvm::KnownBits::sdiv(), sdiv_ov(), setLimitsForBinOp(), smul_ov(), and llvm::Interpreter::visitBinaryOperator().
APInt APInt::sdiv | ( | int64_t | RHS | ) | const |
Definition at line 1629 of file APInt.cpp.
References isNegative(), RHS, and udiv().
Definition at line 1928 of file APInt.cpp.
References isMinSignedValue(), RHS, and sdiv().
Referenced by llvm::exprDiv(), llvm::detail::SlowDynamicAPInt::operator/(), and sfloordiv_ov().
|
static |
Definition at line 1864 of file APInt.cpp.
References LHS, negate(), RHS, and udivrem().
Referenced by ceilingOfQuotient(), llvm::APFixedPoint::div(), findGCD(), floorOfQuotient(), isMultiple(), performMulCombine(), llvm::APIntOps::RoundingSDiv(), llvm::APIntOps::SolveQuadraticEquationWrap(), llvm::SCEVDivision::visitConstant(), llvm::InstCombinerImpl::visitGetElementPtrInst(), and llvm::InstCombinerImpl::visitMul().
|
inline |
Set every bit to 1.
Definition at line 1319 of file APInt.h.
References clearUnusedBits().
Referenced by llvm::KnownBits::ashr(), llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), computeKnownBits(), llvm::SelectionDAG::computeKnownBits(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), llvm::computeKnownBitsFromRangeMetadata(), llvm::GISelKnownBits::computeKnownBitsImpl(), getExtractedDemandedElts(), llvm::KnownBits::lshr(), llvm::KnownBits::setAllOnes(), llvm::KnownBits::setAllZero(), llvm::KnownBits::shl(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), and llvm::ConstantRange::truncate().
|
inline |
Set the given bit to 1 whose position is given as "bitPosition".
Definition at line 1330 of file APInt.h.
References assert(), and BitWidth.
Referenced by llvm::KnownBits::abs(), llvm::KnownBits::blsi(), combineAnd(), combineAndnp(), combineOr(), combineShuffleOfSplatVal(), combineVectorPack(), combineX86ShuffleChain(), combineX86ShufflesConstants(), combineX86ShufflesRecursively(), llvm::SelectionDAG::computeKnownBits(), llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), llvm::SelectionDAG::computeVectorKnownZeroElements(), computeZeroableShuffleElements(), divComputeLowBit(), EltsFromConsecutiveLoads(), llvm::TargetLowering::expandIS_FPCLASS(), llvm::extractConstantMask(), findDemandedEltsBySingleUser(), getDemandedSrcElements(), llvm::APFixedPoint::getEpsilon(), getExtractedDemandedElts(), llvm::getHorizDemandedEltsForFirstOperand(), llvm::TargetTransformInfoImplCRTPBase< T >::getInstructionCost(), llvm::BasicTTIImplBase< T >::getInterleavedMemoryOpCost(), llvm::X86TTIImpl::getInterleavedMemoryOpCostAVX512(), getKnownBitsFromAndXorOr(), getKnownUndefForVectorBinop(), getOneBitSet(), getPackDemandedElts(), llvm::getShuffleDemandedElts(), getSignedMinValue(), getTargetConstantBitsFromNode(), getTargetShuffleAndZeroables(), llvm::mca::initializeUsedResources(), isCompletePermute(), llvm::ShuffleVectorInst::isInsertSubvectorMask(), llvm::SelectionDAG::isSplatValue(), isTargetShuffleEquivalent(), lowerShuffleAsLanePermuteAndPermute(), matchAndOrChain(), matchBinaryShuffle(), llvm::KnownBits::mul(), PerformReduceShuffleCombine(), resolveZeroablesFromTargetShuffle(), llvm::APIntOps::ScaleBitMask(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::InstCombinerImpl::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), llvm::InstCombinerImpl::visitExtractElementInst(), and llvm::InstCombinerImpl::visitICmpInst().
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
This function handles case when loBit
<= hiBit
.
Definition at line 1367 of file APInt.h.
References assert(), and BitWidth.
Referenced by llvm::KnownBits::abs(), llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), llvm::KnownBits::computeForAddSub(), llvm::LanaiTargetLowering::computeKnownBitsForTargetNode(), llvm::extractConstantMask(), getBitsSet(), getTargetConstantBitsFromNode(), llvm::BuildVectorSDNode::isConstantSplat(), matchBinaryShuffle(), llvm::APIntOps::ScaleBitMask(), and llvm::TargetLowering::SimplifyDemandedVectorElts().
|
inline |
Set the top bits starting from loBit.
Definition at line 1386 of file APInt.h.
References BitWidth.
Referenced by llvm::KnownBits::blsi(), llvm::KnownBits::blsmsk(), llvm::SelectionDAG::computeKnownBits(), llvm::SITargetLowering::computeKnownBitsForTargetInstr(), llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::SITargetLowering::computeKnownBitsForTargetNode(), llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), getBitsSetFrom(), isTruncateOf(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TTIImpl::simplifyDemandedUseBitsIntrinsic(), llvm::RISCVTargetLowering::targetShrinkDemandedConstant(), and llvm::KnownBits::zext().
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
This function handles "wrap" case when loBit
>= hiBit
, and calls setBits when loBit
< hiBit
. For loBit
== hiBit
wrap case, set every bit to 1.
Definition at line 1354 of file APInt.h.
References assert(), and BitWidth.
Referenced by getBitsSetWithWrap().
Set a given bit to a given value.
Definition at line 1343 of file APInt.h.
Referenced by llvm::mca::RegisterFile::addRegisterWrite(), flipBit(), insertBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), and llvm::KnownBits::smin().
|
inline |
Set the top hiBits bits.
Definition at line 1392 of file APInt.h.
References BitWidth.
Referenced by llvm::KnownBits::computeForAddSub(), llvm::SelectionDAG::computeKnownBits(), llvm::SITargetLowering::computeKnownBitsForFrameIndex(), llvm::SITargetLowering::computeKnownBitsForTargetInstr(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromCmp(), computeKnownBitsFromOperator(), getHighBitsSet(), knownBitsForWorkitemID(), llvm::KnownBits::lshr(), llvm::KnownBits::mul(), llvm::KnownBits::sdiv(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), llvm::KnownBits::srem(), llvm::KnownBits::udiv(), and llvm::KnownBits::urem().
|
inline |
Set the bottom loBits bits.
Definition at line 1389 of file APInt.h.
Referenced by llvm::KnownBits::abs(), llvm::KnownBits::blsmsk(), computeKnownBits(), llvm::SelectionDAG::computeKnownBits(), llvm::GISelKnownBits::computeKnownBitsForAlignment(), llvm::TargetLowering::computeKnownBitsForFrameIndex(), llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), llvm::computeKnownBitsFromContext(), computeKnownBitsFromOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), divComputeLowBit(), getLowBitsSet(), llvm::KnownBits::shl(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), and llvm::InstCombinerImpl::simplifyShrShlDemandedBits().
|
inline |
Set the sign bit to 1.
Definition at line 1340 of file APInt.h.
References BitWidth.
Referenced by llvm::KnownBits::abs(), llvm::KnownBits::computeForAddSub(), computeForSatAddSub(), llvm::KnownBits::getSignedMinValue(), LowerFMINIMUM_FMAXIMUM(), llvm::KnownBits::makeNegative(), llvm::KnownBits::makeNonNegative(), llvm::KnownBits::shl(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), and simplifyShift().
Sign extend to a new width.
This operation sign extends the APInt to a new width. If the high order bit is set, the fill on the left will be done with 1 bits, otherwise zero. It is an error to specify a width that is less than the current width.
Definition at line 959 of file APInt.cpp.
References APInt(), APINT_BITS_PER_WORD, APINT_WORD_SIZE, assert(), getMemory(), getNumWords(), getRawData(), isNegative(), and llvm::SignExtend64().
Referenced by combineTruncToVnclip(), combineVPMADD(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), detectSSatPattern(), detectSSatSPattern(), llvm::APFixedPoint::div(), llvm::BinaryOperation::eval(), llvm::TargetLowering::expandFP_TO_INT_SAT(), llvm::InstCombinerImpl::foldAddWithConstant(), foldNoWrapAdd(), llvm::ExecutionEngine::getConstantValue(), llvm::SelectionDAG::getNode(), isSaturatingMinMax(), lowerFCOPYSIGN(), llvm::APFixedPoint::mul(), llvm::APIntOps::mulhs(), llvm::ConstantRange::multiply(), narrowSDivOrSRem(), llvm::detail::SlowDynamicAPInt::operator!=(), llvm::detail::SlowDynamicAPInt::operator%(), llvm::detail::SlowDynamicAPInt::operator-(), llvm::detail::SlowDynamicAPInt::operator<(), llvm::detail::SlowDynamicAPInt::operator<=(), llvm::detail::SlowDynamicAPInt::operator==(), llvm::detail::SlowDynamicAPInt::operator>(), llvm::detail::SlowDynamicAPInt::operator>=(), llvm::RISCVTargetLowering::PerformDAGCombine(), performSETCCCombine(), printExtend(), roundToDouble(), selectI64ImmDirectPrefix(), llvm::KnownBits::sext(), sextOrTrunc(), llvm::APFixedPoint::shl(), llvm::ConstantRange::signExtend(), simplifyX86pack(), SolveQuadraticAddRecRange(), llvm::SCEVDivision::visitConstant(), and llvm::LegalizerHelper::widenScalar().
Sign extend or truncate to width.
Make this APInt have the bit width given by width
. The value is sign extended, truncated, or left alone to make it that width.
Definition at line 1015 of file APInt.cpp.
References sext(), and trunc().
Referenced by llvm::detail::PtrUseVisitorBase::adjustOffsetForGEP(), computeKnownBitsFromOperator(), llvm::DIExpression::constantFold(), llvm::ConstantFoldBinOp(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::SelectionDAG::getConstant(), llvm::TargetTransformInfoImplCRTPBase< T >::getGEPCost(), llvm::AArch64TTIImpl::getIntImmCost(), llvm::X86TTIImpl::getIntImmCost(), llvm::RISCVMatInt::getIntMatCost(), llvm::getPointersDiff(), hasNearbyPairedStore(), llvm::CombinerHelper::matchCombineConstPtrAddToI2P(), and simplifyRelativeLoad().
Signed integer floor division operation.
Rounds towards negative infinity, i.e. 5 / -2 = -3. Iff minimum value divided by -1 set Overflow to true.
Definition at line 1993 of file APInt.cpp.
References isNegative(), RHS, and sdiv_ov().
Signed greater or equal comparison.
Regards both *this and RHS as signed quantities and compares them for validity of the greater-or-equal relationship.
Definition at line 1237 of file APInt.h.
References RHS.
Referenced by computeKnownFPClass(), llvm::InstCombinerImpl::foldICmpOrConstant(), foldNoWrapAdd(), FoldValue(), llvm::ConstantRange::icmp(), isNonEqualPointersWithRecursiveGEP(), llvm::ConstantRangeList::isOrderedRanges(), llvm::detail::SlowDynamicAPInt::operator>=(), performMulCombine(), llvm::ConstantRangeList::subtract(), and TryMULWIDECombine().
|
inline |
Signed greater than comparison.
Regards both *this and RHS as signed quantities and compares them for the validity of the greater-than relationship.
Definition at line 1201 of file APInt.h.
References RHS.
Referenced by canUseSExt(), llvm::APFixedPoint::compare(), llvm::InstCombinerImpl::foldICmpBinOpEqualityWithConstant(), llvm::InstCombinerImpl::foldICmpOrConstant(), llvm::InstCombinerImpl::foldICmpShrConstConst(), llvm::BasicTTIImplBase< T >::getEstimatedNumberOfCaseClusters(), llvm::ConstantRange::icmp(), llvm::isDereferenceableAndAlignedInLoop(), llvm::ConstantRange::isSignWrappedSet(), llvm::ConstantRange::isUpperSignWrapped(), matchClamp(), llvm::detail::SlowDynamicAPInt::operator>(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), llvm::APIntOps::SolveQuadraticEquationWrap(), and switchToLookupTable().
|
inline |
Left-shift function.
Left-shift this APInt by shiftAmt.
Definition at line 873 of file APInt.h.
Referenced by llvm::APFixedPoint::compare(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::SelectionDAG::ComputeNumSignBits(), computeShlNSWWithNegLHS(), llvm::ConstantFoldBinaryInstruction(), convertShiftLeftToScale(), llvm::TargetLowering::CTTZTableLookup(), llvm::APFixedPoint::div(), llvm::TargetLowering::expandIS_FPCLASS(), llvm::InstCombinerImpl::foldICmpAndShift(), llvm::InstCombinerImpl::foldICmpShlConstConst(), foldICmpWithTruncSignExtendedVal(), foldSignedTruncationCheck(), llvm::SelectionDAG::isKnownNeverZero(), isNonZeroShift(), llvm::SelectionDAG::isSplatValue(), llvm::LegalizerHelper::lowerISFPCLASS(), LowerShift(), llvm::CombinerHelper::matchShlOfVScale(), rotl(), rotr(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), simplifyX86insertq(), sqrt(), llvm::InstCombinerImpl::visitLShr(), llvm::Interpreter::visitShl(), llvm::InstCombinerImpl::visitShl(), and llvm::InstCombinerImpl::visitXor().
|
inline |
Converts this signed APInt to a double value.
Definition at line 1693 of file APInt.h.
Referenced by llvm::ExecutionEngine::getConstantValue(), llvm::APIntOps::RoundSignedAPIntToDouble(), and llvm::APIntOps::RoundSignedAPIntToFloat().
Signed less or equal comparison.
Regards both *this and RHS as signed quantities and compares them for validity of the less-or-equal relationship.
Definition at line 1166 of file APInt.h.
References RHS.
Referenced by llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), FoldValue(), llvm::ConstantRange::icmp(), llvm::ConstantRangeList::insert(), isNonEqualPointersWithRecursiveGEP(), isSignedMinMaxClamp(), isSignedMinMaxIntrinsicClamp(), isTruePredicate(), llvm::detail::SlowDynamicAPInt::operator<=(), performMulCombine(), and llvm::ConstantRangeList::subtract().
Signed less than comparison.
Regards both *this and RHS as signed quantities and compares them for validity of the less-than relationship.
Definition at line 1130 of file APInt.h.
References RHS.
Referenced by llvm::SwitchCG::SwitchLowering::buildJumpTable(), canUseSExt(), llvm::APFixedPoint::compare(), llvm::exprMax(), findGCD(), foldLoadsRecursive(), getBoundsCheckCond(), llvm::BasicTTIImplBase< T >::getEstimatedNumberOfCaseClusters(), llvm::MDNode::getMostGenericRange(), llvm::ConstantRange::icmp(), llvm::ConstantRangeList::insert(), llvm::ConstantRangeList::intersectWith(), matchClamp(), MinOptional(), llvm::detail::SlowDynamicAPInt::operator<(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), llvm::ConstantRangeList::subtract(), switchToLookupTable(), TryMULWIDECombine(), trySimplifyICmpWithAdds(), and llvm::ConstantRangeList::unionWith().
|
inline |
Definition at line 1934 of file APInt.cpp.
References isMinSignedValue(), RHS, and sdiv().
Referenced by llvm::checkedMul(), llvm::exprMul(), llvm::APFixedPoint::mul(), multiplyOverflows(), MulWillOverflow(), llvm::detail::SlowDynamicAPInt::operator*(), llvm::ConstantRange::smul_fast(), and smul_sat().
Definition at line 2038 of file APInt.cpp.
References getSignedMaxValue(), getSignedMinValue(), isNegative(), RHS, and smul_ov().
Referenced by llvm::ConstantRange::smul_sat().
APInt APInt::sqrt | ( | ) | const |
Function for signed remainder operation.
Signed remainder operation on APInt.
Note that this is a true remainder operation and not a modulo operation because the sign follows the sign of the dividend which is *this.
Definition at line 1710 of file APInt.cpp.
References isNegative(), RHS, and urem().
Referenced by llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), findGCD(), FoldValue(), getExactSDiv(), getStrideAndModOffsetOfGEP(), isRemainderZero(), isSimpleVIDSequence(), llvm::detail::SlowDynamicAPInt::operator%(), simplifyRelativeLoad(), and llvm::Interpreter::visitBinaryOperator().
int64_t APInt::srem | ( | int64_t | RHS | ) | const |
Definition at line 1721 of file APInt.cpp.
References isNegative(), RHS, and urem().
Definition at line 1962 of file APInt.cpp.
References getBitWidth(), getLimitedValue(), and sshl_ov().
Referenced by computeShlNSWWithNegLHS(), computeShlNSWWithNNegLHS(), sshl_ov(), and sshl_sat().
Definition at line 1966 of file APInt.cpp.
References APInt(), countl_one(), countl_zero(), getBitWidth(), and isNonNegative().
Definition at line 2060 of file APInt.cpp.
References getBitWidth(), RHS, and sshl_sat().
Referenced by FoldValue(), sshl_sat(), and llvm::ConstantRange::sshl_sat().
Definition at line 2064 of file APInt.cpp.
References getSignedMaxValue(), getSignedMinValue(), isNegative(), RHS, and sshl_ov().
Definition at line 1915 of file APInt.cpp.
References isNonNegative(), and RHS.
Referenced by llvm::checkedSub(), llvm::exprSub(), maintainNoSignedWrap(), moveAddAfterMinMax(), llvm::detail::SlowDynamicAPInt::operator-(), ssub_sat(), llvm::APFixedPoint::sub(), subWithOverflow(), switchToLookupTable(), and llvm::InstCombinerImpl::visitOr().
Definition at line 2019 of file APInt.cpp.
References getSignedMaxValue(), getSignedMinValue(), isNegative(), RHS, and ssub_ov().
Referenced by FoldValue(), llvm::ConstantRange::ssub_sat(), and llvm::APFixedPoint::sub().
|
static |
DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag.
Definition at line 2416 of file APInt.cpp.
References assert().
Referenced by operator+=().
|
static |
DST += RHS. Returns the carry flag.
This function adds a single "word" integer, src, to the multiple "word" integer array, dst[].
dst[] is modified to reflect the addition and 1 is returned if there is a carry out, otherwise 0 is returned.
Definition at line 2438 of file APInt.cpp.
Referenced by operator+=().
Assign one bignum to another.
Definition at line 2322 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::convertFromSignExtendedInteger(), llvm::detail::IEEEFloat::makeNaN(), llvm::powerOf5(), tcDivide(), and tcExtract().
Clear the given bit of a bignum. Zero-based.
Clears the given bit of a bignum.
Definition at line 2347 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::makeNaN().
Comparison (unsigned) of two bignums.
Definition at line 2725 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::compareAbsoluteValue(), and tcDivide().
Decrement a bignum in-place. Return the borrow flag.
Definition at line 1892 of file APInt.h.
Referenced by llvm::detail::IEEEFloat::next(), and operator--().
|
static |
If RHS is zero LHS and REMAINDER are left unchanged, return one.
Otherwise set LHS to LHS / RHS with the fractional part discarded, set REMAINDER to the remainder, return zero. i.e.
OLD_LHS = RHS * LHS + REMAINDER
SCRATCH is a bignum of the same size as the operands and result for use by the routine; its contents need not be initialized and are destroyed. LHS, REMAINDER and SCRATCH must be distinct.
Definition at line 2630 of file APInt.cpp.
References APINT_BITS_PER_WORD, assert(), tcAssign(), tcCompare(), tcMSB(), tcSet(), tcShiftLeft(), tcShiftRight(), and tcSubtract().
|
static |
Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to DST, of dstCOUNT parts, such that the bit srcLSB becomes the least significant bit of DST.
All high bits above srcBITS in DST are zero-filled.
All high bits above srcBITS in DST are zero-filled. */
Definition at line 2386 of file APInt.cpp.
References APINT_BITS_PER_WORD, assert(), lowBitMask(), tcAssign(), and tcShiftRight().
Extract the given bit of a bignum; returns 0 or 1. Zero-based.
Extract the given bit of a bignum; returns 0 or 1.
Definition at line 2337 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::convertFromSignExtendedInteger(), llvm::detail::IEEEFloat::convertFromZeroExtendedInteger(), llvm::detail::IEEEFloat::isDenormal(), llvm::detail::IEEEFloat::isSignaling(), and llvm::lostFractionThroughTruncation().
|
static |
DST = LHS * RHS, where DST has width the sum of the widths of the operands.
No overflow occurs. DST must be disjoint from both operands.
Definition at line 2605 of file APInt.cpp.
References assert(), tcFullMultiply(), and tcMultiplyPart().
Referenced by llvm::powerOf5(), and tcFullMultiply().
Increment a bignum in-place. Return the carry flag.
Definition at line 1887 of file APInt.h.
Referenced by operator++(), and tcNegate().
Returns true if a bignum is zero, false otherwise.
Definition at line 2328 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::makeNaN().
Returns the bit number of the least or most significant set bit of a number.
Returns the bit number of the least significant set bit of a number.
If the input number has no bits set -1U is returned.
If the input number has no bits set UINT_MAX is returned.
Definition at line 2353 of file APInt.cpp.
References APINT_BITS_PER_WORD, and llvm::countr_zero().
Referenced by llvm::lostFractionThroughTruncation().
Returns the bit number of the most significant set bit of a number.
If the input number has no bits set UINT_MAX is returned.
Definition at line 2366 of file APInt.cpp.
References APINT_BITS_PER_WORD, and llvm::Log2_64().
Referenced by tcDivide().
|
static |
DST = LHS * RHS, where DST has the same width as the operands and is filled with the least significant parts of the result.
Returns one if overflow occurred, otherwise zero. DST must be disjoint from both operands.
Definition at line 2587 of file APInt.cpp.
References assert(), and tcMultiplyPart().
Referenced by operator*().
|
static |
DST += SRC * MULTIPLIER + PART if add is true DST = SRC * MULTIPLIER + PART if add is false.
DST += SRC * MULTIPLIER + CARRY if add is true DST = SRC * MULTIPLIER + CARRY if add is false Requires 0 <= DSTPARTS <= SRCPARTS + 1.
Requires 0 <= DSTPARTS <= SRCPARTS + 1. If DST overlaps SRC they must start at the same point, i.e. DST == SRC.
If DSTPARTS == SRC_PARTS + 1 no overflow occurs and zero is returned. Otherwise DST is filled with the least significant DSTPARTS parts of the result, and if all of the omitted higher parts were zero return zero, otherwise overflow occurred and return one.
If DST overlaps SRC they must start at the same point, i.e. DST == SRC. If DSTPARTS == SRCPARTS + 1 no overflow occurs and zero is returned. Otherwise DST is filled with the least significant DSTPARTS parts of the result, and if all of the omitted higher parts were zero return zero, otherwise overflow occurred and return one.
Definition at line 2504 of file APInt.cpp.
References APINT_BITS_PER_WORD, assert(), highHalf(), and lowHalf().
Referenced by operator*=(), tcFullMultiply(), and tcMultiply().
Negate a bignum in-place.
Definition at line 2490 of file APInt.cpp.
References tcComplement(), and tcIncrement().
Referenced by llvm::detail::IEEEFloat::convertFromSignExtendedInteger().
Sets the least significant part of a bignum to the input value, and zeroes out higher parts.
Definition at line 2314 of file APInt.cpp.
References assert().
Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::makeInf(), llvm::detail::IEEEFloat::makeNaN(), llvm::detail::IEEEFloat::makeSmallest(), llvm::detail::IEEEFloat::makeZero(), llvm::detail::IEEEFloat::next(), and tcDivide().
Set the given bit of a bignum. Zero-based.
Set the given bit of a bignum.
Definition at line 2342 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::makeNaN(), llvm::detail::IEEEFloat::makeQuiet(), llvm::detail::IEEEFloat::makeSmallestNormalized(), and llvm::detail::IEEEFloat::next().
Shift a bignum left Count bits.
Shift a bignum left Count bits in-place.
Shifted in bits are zero. There are no restrictions on Count.
Definition at line 2672 of file APInt.cpp.
References APINT_BITS_PER_WORD, and APINT_WORD_SIZE.
Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::convertToInteger(), and tcDivide().
Shift a bignum right Count bits.
Shift a bignum right Count bits in-place.
Shifted in bits are zero. There are no restrictions on Count.
Definition at line 2699 of file APInt.cpp.
References APINT_BITS_PER_WORD, and APINT_WORD_SIZE.
Referenced by llvm::shiftRight(), tcDivide(), and tcExtract().
|
static |
DST -= RHS + CARRY where CARRY is zero or one. Returns the carry flag.
DST -= RHS + C where C is zero or one. Returns the carry flag.
Definition at line 2451 of file APInt.cpp.
References assert().
Referenced by operator-=(), and tcDivide().
|
static |
DST -= RHS. Returns the carry flag.
This function subtracts a single "word" (64-bit word), src, from the multi-word integer array, dst[], propagating the borrowed 1 value until no further borrowing is needed or it runs out of "words" in dst.
The result is 1 if "borrowing" exhausted the digits in dst, or 0 if dst was not exhausted. In other words, if src > dst then this function returns 1, otherwise 0.
Definition at line 2476 of file APInt.cpp.
Referenced by operator-=().
void APInt::toString | ( | SmallVectorImpl< char > & | Str, |
unsigned | Radix, | ||
bool | Signed, | ||
bool | formatAsCLiteral = false , |
||
bool | UpperCase = true , |
||
bool | InsertSeparators = false |
||
) | const |
Converts an APInt to a string and append it to Str.
Str is commonly a SmallString. If Radix > 10, UpperCase determine the case of letter digits.
Definition at line 2138 of file APInt.cpp.
References assert(), getBoolValue(), getRawData(), getSExtValue(), getZExtValue(), I, isNegative(), isSingleWord(), isZero(), llvm_unreachable, lshrInPlace(), N, negate(), Signed, and udivrem().
Referenced by llvm::ExpressionFormat::getMatchingString(), and print().
|
inline |
Considers the APInt to be signed and converts it into a string in the radix given.
The radix can be 2, 8, 10, 16, or 36.
Definition at line 1675 of file APInt.h.
References toString().
Referenced by dump().
|
inline |
Considers the APInt to be unsigned and converts it into a string in the radix given.
The radix can be 2, 8, 10 16, or 36.
Definition at line 1669 of file APInt.h.
References toString().
Referenced by dump().
Truncate to new width.
Truncate the APInt to a specified width. It is an error to specify a width that is greater than the current width.
Definition at line 910 of file APInt.cpp.
References APInt(), APINT_BITS_PER_WORD, assert(), getMemory(), getNumWords(), and getRawData().
Referenced by llvm::APSInt::APSInt(), areUsedBitsDense(), combineVectorPack(), combineX86ShufflesRecursively(), llvm::KnownBits::computeForAddSub(), llvm::TargetLowering::expandDIVREMByConstant(), extractConstantWithoutWrapping(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::InstCombinerImpl::foldICmpShlConstant(), foldNoWrapAdd(), llvm::ExecutionEngine::getConstantValue(), getDemandedSrcElements(), llvm::SelectionDAG::getNode(), llvm::GCNTTIImpl::instCombineIntrinsic(), llvm::BuildVectorSDNode::isConstantSequence(), llvm::ISD::isConstantSplatVector(), llvm::TargetLowering::isConstTrueVal(), isSaturatingMinMax(), llvm::SelectionDAG::isSplatValue(), llvm::SystemZVectorConstantInfo::isVectorConstantLegal(), lowerMSABinaryBitImmIntr(), llvm::CombinerHelper::matchCastOfInteger(), llvm::CombinerHelper::matchCombineUnmergeConstant(), llvm::LegalizerHelper::narrowScalar(), llvm::RISCVTargetLowering::PerformDAGCombine(), performSETCCCombine(), processUMulZExtIdiom(), rebuildExtCst(), sextOrTrunc(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::TargetLowering::SimplifySetCC(), llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(), llvm::X86TargetLowering::targetShrinkDemandedConstant(), llvm::KnownBits::trunc(), llvm::ConstantRange::truncate(), truncSSat(), truncUSat(), llvm::InstCombinerImpl::visitAnd(), llvm::InstCombinerImpl::visitICmpInst(), llvm::InstCombinerImpl::visitSwitchInst(), and zextOrTrunc().
Truncate to new width with signed saturation.
If this APInt, treated as signed integer, can be losslessly truncated to the new bitwidth, then return truncated APInt. Else, return either signed min value if the APInt was negative, or signed max value.
Definition at line 947 of file APInt.cpp.
References assert(), getSignedMaxValue(), getSignedMinValue(), isNegative(), isSignedIntN(), and trunc().
Referenced by combineVectorPack().
|
inline |
Get sign extended value if possible.
This method attempts to return the value of this APInt as a sign extended int64_t. The bitwidth must be <= 64 or the value must fit within an int64_t. Otherwise no value is returned.
Definition at line 1554 of file APInt.h.
Referenced by llvm::getExpressionForConstant(), and simplifySwitchOfCmpIntrinsic().
|
inline |
Get zero extended value if possible.
This method attempts to return the value of this APInt as a zero extended uint64_t. The bitwidth must be <= 64 or the value must fit within a uint64_t. Otherwise no value is returned.
Definition at line 1532 of file APInt.h.
Referenced by mayLoopAccessLocation().
Definition at line 1909 of file APInt.cpp.
Referenced by llvm::APFixedPoint::add(), addWithOverflow(), llvm::checkedAddUnsigned(), combineShiftOfShiftedLogic(), llvm::isDereferenceableAndAlignedInLoop(), optimizeIncrementingWhile(), uadd_sat(), llvm::InstCombinerImpl::visitCallInst(), and llvm::InstCombinerImpl::visitOr().
Definition at line 2010 of file APInt.cpp.
References getMaxValue(), RHS, and uadd_ov().
Referenced by llvm::APFixedPoint::add(), FoldValue(), llvm::ConstantRange::uadd_sat(), and llvm::InstCombinerImpl::visitCallInst().
Unsigned division operation.
Perform an unsigned divide operation on this APInt by RHS. Both this and RHS are treated as unsigned quantities for purposes of this division.
Definition at line 1547 of file APInt.cpp.
References APInt(), assert(), getActiveBits(), getNumWords(), isSingleWord(), pVal, RHS, and ult().
Referenced by llvm::InstCombinerImpl::commonIDivTransforms(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), llvm::APFixedPoint::div(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::InstCombinerImpl::foldICmpUDivConstant(), FoldValue(), foldVecExtTruncToExtElt(), getRangeForAffineARHelper(), optimizeSection(), replaceTypedBufferAccess(), llvm::scaleProfData(), sdiv(), setLimitsForBinOp(), llvm::APIntOps::SolveQuadraticEquationWrap(), sqrt(), llvm::ConstantRange::udiv(), llvm::KnownBits::udiv(), and llvm::Interpreter::visitBinaryOperator().
Definition at line 1585 of file APInt.cpp.
References APInt(), assert(), getActiveBits(), getNumWords(), isSingleWord(), pVal, RHS, and ult().
|
static |
Dual division/remainder interface.
Sometimes it is convenient to divide two APInt values and obtain both the quotient and remainder. This function does both operations in the same computation making it a little more efficient. The pair of input arguments may overlap with the pair of output arguments. It is safe to call udivrem(X, Y, X, Y), for example.
Definition at line 1732 of file APInt.cpp.
References APInt(), APINT_WORD_SIZE, assert(), llvm::BitWidth, getNumWords(), LHS, pVal, and RHS.
Referenced by extractShiftForRotate(), foldICmpShlLHSC(), GEPToVectorIndex(), llvm::SignedDivisionByConstantInfo::get(), llvm::UnsignedDivisionByConstantInfo::get(), isMultiple(), llvm::APIntOps::RoundingUDiv(), sdivrem(), toString(), and llvm::InstCombinerImpl::visitGetElementPtrInst().
|
static |
Definition at line 1803 of file APInt.cpp.
References APInt(), APINT_WORD_SIZE, assert(), llvm::BitWidth, getNumWords(), LHS, pVal, and RHS.
Unsigned greater or equal comparison.
Regards both *this and RHS as unsigned quantities and compares them for validity of the greater-or-equal relationship.
Definition at line 1221 of file APInt.h.
References RHS.
Referenced by llvm::SelectionDAG::canCreateUndefOrPoison(), canTryToConstantAddTwoShiftAmounts(), collectBitParts(), combineAnd(), combineExtractWithShuffle(), combineShiftOfShiftedLogic(), combineTruncToVnclip(), llvm::X86TargetLowering::ComputeNumSignBitsForTargetNode(), ComputeNumSignBitsImpl(), llvm::InstCombinerImpl::convertOrOfShiftsToFunnelShift(), detectUSatPattern(), Expand64BitShift(), llvm::TargetLowering::expandDIVREMByConstant(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpShrConstant(), llvm::InstCombinerImpl::FoldShiftByConstant(), FoldValue(), foldVecExtTruncToExtElt(), llvm::SignedDivisionByConstantInfo::get(), llvm::UnsignedDivisionByConstantInfo::get(), llvm::SelectionDAG::getValidShiftAmountRange(), getVariantMatchScore(), llvm::ConstantRange::icmp(), isDereferenceableAndAlignedPointer(), isNonZeroShift(), isPoisonShift(), LowerShiftByScalarImmediate(), matchAndOrChain(), llvm::CombinerHelper::matchCombineTruncOfShift(), PerformSHLSimplify(), llvm::X86TargetLowering::preferedOpcodeForCmpEqPiecesOfOperand(), simplifyAndCommutative(), simplifyLShrInst(), simplifyShift(), llvm::InstCombinerImpl::simplifyShrShlDemandedBits(), simplifyX86immShift(), simplifyX86varShift(), splitGlobal(), llvm::ConstantInt::uge(), llvm::ConstantRange::unionWith(), llvm::InstCombinerImpl::visitICmpInst(), and llvm::InstCombinerImpl::visitLShr().
Unsigned greater than comparison.
Regards both *this and RHS as unsigned quantities and compares them for the validity of the greater-than relationship.
Definition at line 1182 of file APInt.h.
References RHS.
Referenced by llvm::SelectionDAG::canCreateUndefOrPoison(), canEvaluateShiftedShift(), llvm::APFixedPoint::compare(), llvm::InstCombinerImpl::convertOrOfShiftsToFunnelShift(), extractShiftForRotate(), foldICmpShlLHSC(), foldICmpWithTruncSignExtendedVal(), llvm::SelectionDAG::getValidShiftAmountRange(), llvm::ConstantRange::icmp(), llvm::ConstantRange::isSizeLargerThan(), llvm::ConstantRange::isUpperWrapped(), llvm::ConstantRange::isWrappedSet(), matchClamp(), llvm::CombinerHelper::matchCombineTruncOfShift(), llvm::LegalizerHelper::narrowScalarShiftByConstant(), llvm::ConstantRange::shl(), simplifySetCCWithCTPOP(), llvm::ConstantRange::srem(), llvm::ConstantRange::unionWith(), llvm::ConstantRange::unsignedAddMayOverflow(), usub_ov(), and llvm::InstCombinerImpl::visitLShr().
Unsigned less or equal comparison.
Regards both *this and RHS as unsigned quantities and compares them for validity of the less-or-equal relationship.
Definition at line 1150 of file APInt.h.
References RHS.
Referenced by llvm::SCEVAAResult::alias(), combineArithReduction(), llvm::InstCombinerImpl::commonIDivTransforms(), llvm::ConstantRange::contains(), llvm::InstCombinerImpl::convertOrOfShiftsToFunnelShift(), llvm::TargetLowering::expandDIVREMByConstant(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpBinOp(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), FoldValue(), llvm::ScalarEvolution::getAddExpr(), llvm::ConstantRange::icmp(), llvm::ConstantRange::intersectWith(), isTruePredicate(), matchIntPart(), llvm::AMDGPUTargetLowering::performTruncateCombine(), processAnd(), llvm::ConstantRange::shl(), simplifyICmpWithBinOpOnLHS(), sqrt(), llvm::ConstantRange::unionWith(), and llvm::InstCombinerImpl::visitGetElementPtrInst().
Unsigned less than comparison.
Regards both *this and RHS as unsigned quantities and compares them for the validity of the less-than relationship.
Definition at line 1111 of file APInt.h.
References RHS.
Referenced by canEvaluateShiftedShift(), canEvaluateTruncated(), cheapToScalarize(), combineCMov(), combineCMP(), combineExtractWithShuffle(), combineShiftRightArithmetic(), llvm::InstCombinerImpl::commonIDivTransforms(), llvm::APFixedPoint::compare(), CompareSCEVComplexity(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromShiftOperator(), llvm::SelectionDAG::computeOverflowForUnsignedAdd(), computePointerICmp(), llvm::InstCombinerImpl::convertOrOfShiftsToFunnelShift(), findDemandedEltsBySingleUser(), foldICmpWithTruncSignExtendedVal(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), llvm::SignedDivisionByConstantInfo::get(), llvm::UnsignedDivisionByConstantInfo::get(), llvm::omp::getBestVariantMatchForContext(), getRangeForAffineARHelper(), llvm::SelectionDAG::getShiftAmountConstant(), llvm::SelectionDAG::getValidShiftAmountRange(), llvm::ConstantRange::icmp(), llvm::ConstantRange::intersectWith(), llvm::SelectionDAG::isKnownNeverZero(), matchClamp(), llvm::X86TargetLowering::preferedOpcodeForCmpEqPiecesOfOperand(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(), simplifyX86immShift(), simplifyX86varShift(), sqrt(), llvm::ConstantRange::truncate(), uadd_ov(), udiv(), umul_ov(), llvm::ConstantRange::unionWith(), llvm::ConstantRange::unsignedSubMayOverflow(), urem(), llvm::InstCombinerImpl::visitAnd(), llvm::InstCombinerImpl::visitAShr(), llvm::InstCombinerImpl::visitLShr(), and llvm::InstCombinerImpl::visitShl().
Definition at line 1945 of file APInt.cpp.
References countl_zero(), isNegative(), lshr(), RHS, and ult().
Referenced by llvm::checkedMulUnsigned(), llvm::SelectionDAG::computeKnownBits(), llvm::ScalarEvolution::getUDivExpr(), llvm::APFixedPoint::mul(), llvm::KnownBits::mul(), multiplyOverflows(), MulWillOverflow(), umul_sat(), and llvm::ConstantRange::unsignedMulMayOverflow().
Definition at line 2051 of file APInt.cpp.
References getMaxValue(), RHS, and umul_ov().
Referenced by llvm::ConstantRange::umul_sat().
Unsigned remainder operation.
Perform an unsigned remainder operation on this APInt with RHS being the divisor. Both this and RHS are treated as unsigned quantities for purposes of this operation.
Definition at line 1640 of file APInt.cpp.
References APInt(), assert(), getActiveBits(), getNumWords(), isSingleWord(), RHS, and ult().
Referenced by llvm::CombinerHelper::applyFunnelShiftConstantModulo(), combineExtractWithShuffle(), computeKnownBitsFromOperator(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), llvm::TargetLowering::expandDIVREMByConstant(), FoldValue(), foldVecExtTruncToExtElt(), llvm::ScalarEvolution::getUDivExpr(), llvm::isDereferenceableAndAlignedInLoop(), isLoadCombineCandidateImpl(), isNonZeroModBitWidthOrUndef(), LowerFunnelShift(), LowerRotate(), rotateModulo(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), simplifyIntrinsic(), srem(), llvm::ScalarEvolution::verify(), and llvm::Interpreter::visitBinaryOperator().
Definition at line 1678 of file APInt.cpp.
References assert(), getActiveBits(), getNumWords(), getZExtValue(), isSingleWord(), RHS, and ult().
Definition at line 1979 of file APInt.cpp.
References getBitWidth(), getLimitedValue(), and ushl_ov().
Referenced by computeShlNUW(), ushl_ov(), ushl_sat(), and llvm::InstCombinerImpl::visitUDiv().
Definition at line 1983 of file APInt.cpp.
References APInt(), countl_zero(), and getBitWidth().
Definition at line 2074 of file APInt.cpp.
References getBitWidth(), RHS, and ushl_sat().
Referenced by FoldValue(), ushl_sat(), and llvm::ConstantRange::ushl_sat().
Definition at line 2078 of file APInt.cpp.
References getMaxValue(), RHS, and ushl_ov().
Definition at line 1922 of file APInt.cpp.
Referenced by moveAddAfterMinMax(), llvm::APFixedPoint::sub(), subWithOverflow(), usub_sat(), and llvm::InstCombinerImpl::visitOr().
Definition at line 2029 of file APInt.cpp.
References APInt(), RHS, and usub_ov().
Referenced by FoldValue(), llvm::APFixedPoint::sub(), and llvm::ConstantRange::usub_sat().
Zero extend to a new width.
This operation zero extends the APInt to a new width. The high order bits are filled with 0 bits. It is an error to specify a width that is less than the current width.
Definition at line 986 of file APInt.cpp.
References APInt(), APINT_BITS_PER_WORD, APINT_WORD_SIZE, assert(), getMemory(), getNumWords(), and getRawData().
Referenced by llvm::KnownBits::anyext(), llvm::ConstantRange::castOp(), combineVPMADD(), combineX86ShufflesRecursively(), llvm::SelectionDAG::computeKnownBits(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), ConstantBuildVector(), detectSSatPattern(), detectSSatUPattern(), detectUSatUPattern(), llvm::APFixedPoint::div(), llvm::TargetLowering::expandFP_TO_INT_SAT(), extractConstantWithoutWrapping(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpEquality(), foldSignedTruncationCheck(), llvm::SCEVExpander::generateOverflowCheck(), llvm::getAllocSize(), llvm::ExecutionEngine::getConstantValue(), llvm::SelectionDAG::getNode(), llvm::X86TTIImpl::getReplicationShuffleCost(), llvm::X86TTIImpl::getScalarizationOverhead(), isObjectSizeLessThanOrEq(), isSameValue(), llvm::SelectionDAG::isSplatValue(), llvm::RISCVLegalizerInfo::legalizeCustom(), llvm::APFixedPoint::mul(), llvm::APIntOps::mulhu(), llvm::ConstantRange::multiply(), performANDCombine(), llvm::PPCTargetLowering::PerformDAGCombine(), PerformUMinFpToSatCombine(), printExtend(), processUMulZExtIdiom(), rotateModulo(), llvm::APFixedPoint::shl(), llvm::ConstantRange::signExtend(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), SolveLinEquationWithOverflow(), toSigned(), llvm::APFixedPoint::toString(), llvm::LegalizationArtifactCombiner::tryCombineZExt(), tryToMergePartialOverlappingStores(), llvm::InstCombinerImpl::visitAnd(), llvm::LegalizerHelper::widenScalar(), llvm::ConstantRange::zeroExtend(), llvm::KnownBits::zext(), and zextOrTrunc().
Zero extend or truncate to width.
Make this APInt have the bit width given by width
. The value is zero extended, truncated, or left alone to make it that width.
Definition at line 1007 of file APInt.cpp.
References trunc(), and zext().
Referenced by llvm::computeKnownBitsFromRangeMetadata(), llvm::X86TargetLowering::ComputeNumSignBitsForTargetNode(), llvm::DIExpression::constantFold(), llvm::Interpreter::exitCalled(), extractShiftForRotate(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::SelectionDAG::getConstant(), llvm::ExecutionEngine::getConstantValue(), getFauxShuffleMask(), getPreferredVectorIndex(), llvm::ScalarEvolution::getSmallConstantTripMultiple(), llvm::X86TTIImpl::instCombineIntrinsic(), isBitfieldDstMask(), llvm::isKnownToBeAPowerOfTwo(), llvm::CombinerHelper::matchCombineConstPtrAddToI2P(), resolveBuildVector(), llvm::simplifyBinaryIntrinsic(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::X86TTIImpl::simplifyDemandedUseBitsIntrinsic(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::InstCombinerImpl::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), simplifyX86extrq(), simplifyX86immShift(), simplifyX86insertq(), SkipExtensionForVMULL(), llvm::APFixedPoint::toString(), and tryLowerToSLI().
|
friend |
|
staticconstexpr |
Bits in a word.
Definition at line 86 of file APInt.h.
Referenced by byteSwap(), extractBits(), extractBitsAsZExtValue(), llvm::detail::IEEEFloat::getExactLog2Abs(), highHalf(), insertBits(), lowBitMask(), lowHalf(), nextAPIntBitWidth(), roundToDouble(), sext(), tcDivide(), tcExtract(), tcLSB(), tcMSB(), tcMultiplyPart(), llvm::detail::tcSetLeastSignificantBits(), tcShiftLeft(), tcShiftRight(), trunc(), and zext().
Byte size of a word.
Definition at line 83 of file APInt.h.
Referenced by insertBits(), sext(), tcShiftLeft(), tcShiftRight(), udivrem(), and zext().
uint64_t* llvm::APInt::pVal |
Used to store the >64 bits integer value.
Definition at line 1911 of file APInt.h.
Referenced by llvm::hash_value(), roundToDouble(), udiv(), and udivrem().
uint64_t llvm::APInt::VAL |
Used to store the <= 64 bits integer value.
Definition at line 1910 of file APInt.h.
Referenced by APInt(), concat(), llvm::hash_value(), and insertBits().
Definition at line 94 of file APInt.h.
Referenced by insertBits().