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) | |
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 |
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 |
Definition at line 109 of file APInt.h.
References clearUnusedBits(), and isSigned().
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 151 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 1751 of file APInt.h.
Referenced by combineSelectOfTwoConstants(), findGCD(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::InstCombinerImpl::foldICmpBinOp(), gcd(), llvm::ScalarEvolution::getAddExpr(), llvm::ExpressionFormat::getMatchingString(), getRangeForAffineARHelper(), and llvm::InstCombinerImpl::SimplifyDemandedUseBits().
Arithmetic right-shift function.
Arithmetic right-shift this APInt by shiftAmt.
Definition at line 805 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(), llvm::SIInstrInfo::foldImmediate(), FoldValue(), llvm::AArch64TTIImpl::getIntImmCost(), llvm::X86TTIImpl::getIntImmCost(), llvm::RISCVMatInt::getIntMatCost(), isNonZeroShift(), 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 1020 of file APInt.cpp.
References ashrInPlace(), and getLimitedValue().
|
inline |
Arithmetic right-shift this APInt by ShiftAmt in place.
Definition at line 812 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::getNode().
|
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 1678 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 1692 of file APInt.h.
Referenced by llvm::detail::IEEEFloat::convertToFloat(), and llvm::ExecutionEngine::getConstantValue().
APInt APInt::byteSwap | ( | ) | const |
Definition at line 715 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 1720 of file APInt.h.
References getActiveBits().
Referenced by ComputeNumSignBitsImpl(), and llvm::InstCombinerImpl::foldICmpUsingKnownBits().
|
inline |
Set every bit to 0.
Definition at line 1375 of file APInt.h.
Referenced by 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 1385 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 1402 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 1395 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 1409 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 925 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 1572 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 1555 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 1581 of file APInt.h.
References llvm::countl_one().
Referenced by computeShlNSWWithNegLHS(), and foldNegativePower2AndShiftedMask().
|
inline |
Definition at line 1563 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 1613 of file APInt.h.
References llvm::countr_one().
Referenced by combineAndMaskToShift(), combineShiftRightLogical(), llvm::KnownBits::countMinTrailingOnes(), llvm::KnownBits::countMinTrailingZeros(), llvm::InstCombinerImpl::foldICmpEquality(), 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 1596 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 1619 of file APInt.h.
References llvm::countr_one().
|
inline |
Definition at line 1604 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 1700 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 2268 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 1057 of file APInt.h.
References RHS.
Referenced by combineShiftRightArithmetic(), llvm::omp::getBestVariantMatchForContext(), processUMulZExtIdiom(), and llvm::InstCombinerImpl::visitLShr().
|
inline |
Definition at line 1739 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 453 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 489 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 1412 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 363 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 1708 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 1470 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(), and urem().
|
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 1476 of file APInt.h.
Referenced by emitConstantRange().
Return an APInt of a specified width with all bits set.
Definition at line 212 of file APInt.h.
Referenced by llvm::analyzeKnownBitsFromAndXorOr(), llvm::ConstantRange::binaryNot(), llvm::buildSelectInst(), llvm::SelectionDAG::canCreateUndefOrPoison(), canTryToConstantAddTwoShiftAmounts(), 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::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(), getFauxShuffleMask(), getHopForBuildVector(), llvm::LoopVectorizationCostModel::getInstructionCost(), llvm::BasicTTIImplBase< T >::getInterleavedMemoryOpCost(), llvm::X86TTIImpl::getInterleavedMemoryOpCostAVX512(), llvm::GISelKnownBits::getKnownBits(), llvm::IntegerType::getMask(), 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::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(), and llvm::InstCombinerImpl::visitXor().
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 545 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 236 of file APInt.h.
References setBits().
Referenced by combineToExtendBoolVectorInReg(), computeShlNSWWithNNegLHS(), llvm::X86TTIImpl::getMemoryOpCost(), insert1BitVector(), 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 264 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 248 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 1446 of file APInt.h.
References BitWidth.
Referenced by llvm::DwarfExpression::addConstantFP(), llvm::DwarfUnit::addConstantValue(), llvm::APFixedPoint::APFixedPoint(), APIntToHexString(), llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), calculateOffsetDiff(), canonicalizeGEPOfConstGEPI8(), combineCMov(), combineConcatVectorOps(), combineConstantPoolLoads(), combineSetCCMOVMSK(), combineShiftOfShiftedLogic(), CombineVMOVDRRCandidateWithVecOp(), llvm::InstCombinerImpl::commonIDivTransforms(), CompareSCEVComplexity(), llvm::APSInt::compareValues(), computeKnownBits(), llvm::SelectionDAG::computeKnownBits(), llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), 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::BasicTTIImplBase< T >::getScalarizationOverhead(), 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(), and llvm::SCEVDivision::visitConstant().
|
inline |
Convert APInt to a boolean value.
This converts the APInt to a boolean value as a test against zero.
Definition at line 449 of file APInt.h.
References isZero().
Referenced by llvm::KnownBits::computeForAddCarry(), llvm::KnownBits::computeForSubBorrow(), llvm::APFixedPoint::getBoolValue(), getPowerOf2Factor(), getTargetConstantBitsFromNode(), llvm::ConstantRange::intrinsic(), isDereferenceableAndAlignedPointer(), 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 608 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 274 of file APInt.h.
References setHighBits().
Referenced by canEvaluateZExtd(), combineAnd(), combineCMP(), combineMulToPMADDWD(), combineMulToPMULDQ(), combineOr(), combineTargetShuffle(), combineVectorPack(), combineZext(), computeForSatAddSub(), 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(), isTruncWithZeroHighBitsInput(), LowerFunnelShift(), LowerMUL(), LowerShiftByScalarImmediate(), llvm::AMDGPUTargetLowering::LowerUDIVREM64(), matchShuffleWithPACK(), llvm::ARMTargetLowering::PerformDAGCombine(), PerformSHLSimplify(), PerformVMOVNCombine(), PerformVQMOVNCombine(), llvm::RISCVTargetLowering::ReplaceNodeResults(), SaturateWidenedDIVFIX(), selectUmullSmull(), llvm::LoongArchDAGToDAGISel::selectZExti32(), setLimitsForBinOp(), llvm::AArch64TargetLowering::shouldSinkOperands(), llvm::ConstantRange::signExtend(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::ARMTTIImpl::simplifyDemandedVectorEltsIntrinsic(), llvm::TargetLowering::SimplifySetCC(), simplifyUnaryIntrinsic(), skipExtensionForVectorMULL(), 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 453 of file APInt.h.
Referenced by adjustByValArgAlignment(), ashrInPlace(), calculateOffsetDiff(), 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 613 of file APInt.cpp.
References getLowBitsSet().
Referenced by matchRotateSub(), llvm::KnownBits::mul(), parseHexOcta(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), simplifyX86vpermilvar(), 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 284 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(), 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(), 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 184 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::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 194 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::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 1585 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 1453 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 217 of file APInt.h.
References setBit().
Referenced by BinomialCoefficient(), llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), 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(), 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::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 547 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 1520 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::SIInstrInfo::foldImmediate(), llvm::TargetTransformInfoImplCRTPBase< T >::getGEPCost(), llvm::AArch64TTIImpl::getIntImmCost(), llvm::X86TTIImpl::getIntImmCost(), llvm::RISCVMatInt::getIntMatCost(), getMinimalBaseOfPointer(), llvm::GetPointerBaseWithConstantOffset(), llvm::Value::getPointerOffsetFrom(), llvm::getPointersDiff(), llvm::getPtrStride(), getSalvageOpsForGEP(), llvm::ConstantInt::getSExtValue(), getStrideFromPointer(), llvm::remarks::Argument::getValAsInt(), getVShiftImm(), 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::selectFPImm(), 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 187 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::RecurrenceDescriptor::getRecurrenceIdentity(), llvm::MinMaxIntrinsic::getSaturationPoint(), llvm::ConstantRange::getSignedMax(), getSignedOverflowLimitForStep(), isNonZeroAdd(), isSafeIncreasingBound(), LowerADDSAT_SUBSAT(), llvm::LegalizerHelper::lowerAddSubSatToMinMax(), LowerFABSorFNEG(), LowerFCOPYSIGN(), 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(), and llvm::ScalarEvolution::willNotOverflow().
Gets minimum signed value of APInt for a specific bit width.
Definition at line 197 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::RecurrenceDescriptor::getRecurrenceIdentity(), llvm::MinMaxIntrinsic::getSaturationPoint(), llvm::ConstantRange::getSignedMin(), getSignedOverflowLimitForStep(), isSafeDecreasingBound(), LowerADDSAT_SUBSAT(), llvm::LegalizerHelper::lowerAddSubSatToAddoSubo(), llvm::LegalizerHelper::lowerAddSubSatToMinMax(), 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(), setLimitsForBinOp(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), llvm::TargetLowering::SimplifySetCC(), simplifyX86pack(), smul_sat(), sshl_sat(), ssub_sat(), truncSSat(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitSDiv(), 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 1489 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 207 of file APInt.h.
References BitWidth.
Referenced by checkSignTestSetCCCombine(), combineAVG(), combineGatherScatter(), combineMaskedLoad(), combineMaskedStore(), combinePTESTCC(), 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(), llvm::LegalizerHelper::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 620 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(), 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 513 of file APInt.cpp.
References assert().
Referenced by getBitsNeeded().
Get the '0' value for the specified bit-width.
Definition at line 178 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::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), llvm::SelectionDAG::ComputeNumSignBits(), computeShlNSW(), llvm::SelectionDAG::computeVectorKnownZeroElements(), computeZeroableShuffleElements(), llvm::ConstantFoldCastInstruction(), llvm::ConstantRange::ctlz(), llvm::ConstantRange::ctpop(), llvm::ConstantRange::cttz(), 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(), 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(), lowerShuffleAsElementInsertion(), 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 1498 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(), llvm::Interpreter::exitCalled(), llvm::extractConstantMask(), extractShiftForRotate(), foldConsecutiveLoads(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpTruncConstant(), foldLoadsRecursive(), foldSelectICmpAndZeroShl(), llvm::InstCombinerImpl::FoldShiftByConstant(), foldShiftedShift(), GenerateFixedLengthSVETBL(), llvm::generateSpecConstantInst(), getArrayComponentCount(), getConstant(), llvm::ExecutionEngine::getConstantValue(), llvm::getConstFromIntrinsic(), llvm::Function::getEntryCount(), llvm::getExpressionForConstant(), llvm::ScalarEvolution::getGEPExpr(), llvm::getObjectSize(), llvm::SPIRVGlobalRegistry::getOrCreateConstFP(), llvm::SelectionDAG::getShiftAmountConstant(), llvm::ScalarEvolution::getSmallConstantTripMultiple(), 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(), narrowIndex(), NormalizeBuildVector(), 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(), 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 368 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 426 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 1227 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::InstCombinerImpl::SimplifyDemandedUseBits(), 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 168 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 349 of file APInt.h.
References BitWidth.
Referenced by areUsedBitsDense(), bitTrackingDCE(), llvm::TargetLowering::BuildSDIV(), 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 410 of file APInt.h.
References N.
Referenced by AreMulWideOperandsDemotable(), combineVectorPack(), llvm::ScalarEvolution::getUDivExactExpr(), mustBeFiniteCountedLoop(), parseHexOcta(), llvm::LoongArchDAGToDAGISel::selectVSplatImm(), and truncUSat().
|
inline |
Definition at line 479 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 466 of file APInt.h.
References assert(), and BitWidth.
Referenced by combineAndMaskToShift(), combineSetCCMOVMSK(), combineShiftRightLogical(), combineTruncToVnclip(), combineVectorMulToSraBitcast(), detectUSatPattern(), llvm::InstCombinerImpl::foldAddWithConstant(), foldSelectICmpAndZeroShl(), 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 383 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 377 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 401 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(), 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 395 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 427 of file APInt.h.
References assert(), BitWidth, llvm::countl_one(), and llvm::countr_zero().
Referenced by llvm::PPCTargetLowering::BuildSDIVPow2(), canEvaluateShifted(), 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 307 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(), 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 312 of file APInt.h.
Referenced by llvm::TargetLowering::buildSDIVPow2WithCMov(), combineTruncToVnclip(), llvm::KnownBits::computeForAddSub(), llvm::SelectionDAG::computeKnownBits(), computePointerICmp(), computeShlNSW(), detectUSatPattern(), llvm::ConstantRange::isAllNonNegative(), 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 339 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 367 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(), 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 418 of file APInt.h.
References assert(), BitWidth, and llvm::isPowerOf2_64().
Referenced by llvm::PPCTargetLowering::BuildSDIVPow2(), combineAnd(), combineSelectOfTwoConstants(), combineSetCC(), llvm::SelectionDAG::computeKnownBits(), llvm::InstCombinerImpl::foldAddWithConstant(), foldAndOrOfSETCC(), llvm::InstCombinerImpl::foldICmpAddConstant(), llvm::InstCombinerImpl::foldICmpBinOpEqualityWithConstant(), llvm::InstCombinerImpl::foldICmpShrConstant(), llvm::InstCombinerImpl::foldICmpShrConstConst(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), foldICmpWithTruncSignExtendedVal(), llvm::InstCombinerImpl::foldICmpXorShiftConst(), foldSelectICmpAnd(), foldSelectICmpAndBinOp(), 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 531 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 488 of file APInt.h.
References BitWidth, llvm::countr_zero(), 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 500 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 326 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 319 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 413 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 444 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 300 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 334 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 1235 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::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 358 of file APInt.h.
References BitWidth.
Referenced by llvm::KnownBits::abs(), canonicalizeGEPOfConstGEPI8(), canWidenShuffleElements(), llvm::ScalarEvolution::LoopGuards::collect(), 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::foldICmpAndConstant(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpAndShift(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::InstCombinerImpl::foldICmpMulConstant(), llvm::InstCombinerImpl::foldICmpShlConstConst(), 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 1717 of file APInt.h.
Referenced by llvm::SelectionDAG::computeKnownBits(), ComputeNumSignBitsImpl(), llvm::InstCombinerImpl::foldAddWithConstant(), 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 829 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(), 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 1069 of file APInt.cpp.
References getLimitedValue(), and lshrInPlace().
|
inline |
Logical right-shift this APInt by ShiftAmt in place.
Definition at line 836 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(), simplifyX86vpermilvar(), and toString().
APInt APInt::multiplicativeInverse | ( | ) | const |
Definition at line 1244 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 1142 of file APInt.cpp.
References isZero(), and logBase2().
|
inline |
|
inline |
Negate this APInt in place.
Definition at line 1428 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 234 of file APInt.cpp.
References APInt(), assert(), getBitWidth(), getMemory(), getNumWords(), isSingleWord(), RHS, and tcMultiply().
Definition at line 268 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 177 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 197 of file APInt.cpp.
References assert(), getNumWords(), isSingleWord(), RHS, and tcAdd().
Definition at line 206 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 186 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 217 of file APInt.cpp.
References assert(), getNumWords(), isSingleWord(), RHS, and tcSubtract().
Definition at line 226 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 1081 of file APInt.cpp.
References getLimitedValue().
Left-shift assignment function.
Shifts *this left by shiftAmt and assigns the result to *this.
Definition at line 763 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 636 of file APInt.h.
References clearUnusedBits(), and RHS.
Array-indexing support.
Definition at line 1021 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 725 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 696 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 1627 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 2277 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 155 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 873 of file APInt.h.
Referenced by llvm::APFixedPoint::mul().
|
inline |
|
inline |
relative logical shift left
Definition at line 863 of file APInt.h.
Referenced by llvm::APFixedPoint::mul().
|
inline |
APInt APInt::reverseBits | ( | ) | const |
Definition at line 737 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 1107 of file APInt.cpp.
References rotateModulo(), and rotl().
Rotate left by rotateAmt.
Definition at line 1111 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 1120 of file APInt.cpp.
References rotateModulo(), and rotr().
Rotate right by rotateAmt.
Definition at line 1124 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 1668 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 849 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 1898 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 1996 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 1614 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 1625 of file APInt.cpp.
References isNegative(), RHS, and udiv().
Definition at line 1924 of file APInt.cpp.
References isMinSignedValue(), RHS, and sdiv().
Referenced by llvm::exprDiv(), llvm::detail::SlowDynamicAPInt::operator/(), and sfloordiv_ov().
|
static |
Definition at line 1860 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 1297 of file APInt.h.
References clearUnusedBits().
Referenced by llvm::KnownBits::ashr(), 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 1308 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(), 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(), and llvm::InstCombinerImpl::visitExtractElementInst().
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
This function handles case when loBit
<= hiBit
.
Definition at line 1345 of file APInt.h.
References assert(), and BitWidth.
Referenced by llvm::KnownBits::abs(), 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 1364 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(), 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 1332 of file APInt.h.
References assert(), and BitWidth.
Referenced by getBitsSetWithWrap().
Set a given bit to a given value.
Definition at line 1321 of file APInt.h.
Referenced by llvm::mca::RegisterFile::addRegisterWrite(), flipBit(), insertBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::KnownBits::smax(), and llvm::KnownBits::smin().
|
inline |
Set the top hiBits bits.
Definition at line 1370 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 1367 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 1318 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 954 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(), decodeSOPPBrTarget(), 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(), 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 1010 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 1989 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 1215 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 1179 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 851 of file APInt.h.
Referenced by llvm::APFixedPoint::compare(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), 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(), 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 1671 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 1144 of file APInt.h.
References RHS.
Referenced by llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), 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 1108 of file APInt.h.
References RHS.
Referenced by llvm::SwitchCG::SwitchLowering::buildJumpTable(), canUseSExt(), llvm::APFixedPoint::compare(), llvm::exprMax(), findGCD(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), 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 1930 of file APInt.cpp.
References isMinSignedValue(), RHS, and sdiv().
Referenced by llvm::GEPOperator::accumulateConstantOffset(), llvm::checkedMul(), llvm::exprMul(), llvm::APFixedPoint::mul(), multiplyOverflows(), MulWillOverflow(), llvm::detail::SlowDynamicAPInt::operator*(), llvm::ConstantRange::smul_fast(), and smul_sat().
Definition at line 2034 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 1706 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 1717 of file APInt.cpp.
References isNegative(), RHS, and urem().
Definition at line 1958 of file APInt.cpp.
References getBitWidth(), getLimitedValue(), and sshl_ov().
Referenced by computeShlNSWWithNegLHS(), computeShlNSWWithNNegLHS(), sshl_ov(), and sshl_sat().
Definition at line 1962 of file APInt.cpp.
References APInt(), countl_one(), countl_zero(), getBitWidth(), and isNonNegative().
Definition at line 2056 of file APInt.cpp.
References getBitWidth(), RHS, and sshl_sat().
Referenced by FoldValue(), sshl_sat(), and llvm::ConstantRange::sshl_sat().
Definition at line 2060 of file APInt.cpp.
References getSignedMaxValue(), getSignedMinValue(), isNegative(), RHS, and sshl_ov().
Definition at line 1911 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 2015 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 2412 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 2434 of file APInt.cpp.
Referenced by operator+=().
Assign one bignum to another.
Definition at line 2318 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 2343 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::makeNaN().
Comparison (unsigned) of two bignums.
Definition at line 2721 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::compareAbsoluteValue(), and tcDivide().
Decrement a bignum in-place. Return the borrow flag.
Definition at line 1870 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 2626 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 2382 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 2333 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 2601 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 1865 of file APInt.h.
Referenced by operator++(), and tcNegate().
Returns true if a bignum is zero, false otherwise.
Definition at line 2324 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 2349 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 2362 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 2583 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 2500 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 2486 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 2310 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 2338 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 2668 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 2695 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 2447 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 2472 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 2134 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 1653 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 1647 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 906 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::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::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 942 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 1532 of file APInt.h.
Referenced by llvm::getExpressionForConstant().
|
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 1510 of file APInt.h.
Referenced by mayLoopAccessLocation().
Definition at line 1905 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 2006 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 1543 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(), getRangeForAffineARHelper(), optimizeSection(), llvm::scaleProfData(), sdiv(), setLimitsForBinOp(), llvm::APIntOps::SolveQuadraticEquationWrap(), sqrt(), llvm::ConstantRange::udiv(), llvm::KnownBits::udiv(), and llvm::Interpreter::visitBinaryOperator().
Definition at line 1581 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 1728 of file APInt.cpp.
References APInt(), APINT_WORD_SIZE, assert(), llvm::BitWidth, getNumWords(), LHS, pVal, and RHS.
Referenced by extractShiftForRotate(), GEPToVectorIndex(), llvm::SignedDivisionByConstantInfo::get(), llvm::UnsignedDivisionByConstantInfo::get(), isMultiple(), llvm::APIntOps::RoundingUDiv(), sdivrem(), toString(), and llvm::InstCombinerImpl::visitGetElementPtrInst().
|
static |
Definition at line 1799 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 1199 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(), 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(), 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 1160 of file APInt.h.
References RHS.
Referenced by llvm::SelectionDAG::canCreateUndefOrPoison(), canEvaluateShiftedShift(), llvm::APFixedPoint::compare(), llvm::InstCombinerImpl::convertOrOfShiftsToFunnelShift(), extractShiftForRotate(), 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 1128 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::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), 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 1089 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(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), 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 1941 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 2047 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 1636 of file APInt.cpp.
References APInt(), assert(), isSingleWord(), and RHS.
Referenced by llvm::CombinerHelper::applyFunnelShiftConstantModulo(), llvm::ScalarEvolution::LoopGuards::collect(), combineExtractWithShuffle(), computeKnownBitsFromOperator(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), llvm::TargetLowering::expandDIVREMByConstant(), FoldValue(), 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 1674 of file APInt.cpp.
References assert(), getActiveBits(), getNumWords(), getZExtValue(), isSingleWord(), RHS, and ult().
Definition at line 1975 of file APInt.cpp.
References getBitWidth(), getLimitedValue(), and ushl_ov().
Referenced by computeShlNUW(), ushl_ov(), ushl_sat(), and llvm::InstCombinerImpl::visitUDiv().
Definition at line 1979 of file APInt.cpp.
References APInt(), countl_zero(), and getBitWidth().
Definition at line 2070 of file APInt.cpp.
References getBitWidth(), RHS, and ushl_sat().
Referenced by FoldValue(), ushl_sat(), and llvm::ConstantRange::ushl_sat().
Definition at line 2074 of file APInt.cpp.
References getMaxValue(), RHS, and ushl_ov().
Definition at line 1918 of file APInt.cpp.
Referenced by moveAddAfterMinMax(), llvm::APFixedPoint::sub(), subWithOverflow(), usub_sat(), and llvm::InstCombinerImpl::visitOr().
Definition at line 2025 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 981 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::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 1002 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(), simplifyX86vpermilvar(), skipExtensionForVectorMULL(), 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 1889 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 1888 of file APInt.h.
Referenced by APInt(), concat(), llvm::hash_value(), and insertBits().
Definition at line 94 of file APInt.h.
Referenced by insertBits().