Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Public Types |Static Public Attributes |List of all members
llvm::APInt Class Reference

Class for arbitrary precision integers.More...

#include "llvm/ADT/APInt.h"

Inheritance diagram for llvm::APInt:
Inheritance graph
[legend]

Public Types

enum class  Rounding {DOWN,TOWARD_ZERO,UP }
 
typedefuint64_t WordType
 

Public Member Functions

Constructors
 APInt (unsigned numBits,uint64_t val,boolisSigned=false,bool implicitTrunc=false)
 Create a newAPInt of numBits width, initialized as val.
 
 APInt (unsigned numBits,ArrayRef<uint64_t > bigVal)
 Construct anAPInt of numBits width, initialized as bigVal[].
 
 APInt (unsigned numBits,unsigned numWords,constuint64_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 anAPInt from a string representation.
 
 APInt ()
 Default constructor that creates anAPInt with a 1-bit zero value.
 
 APInt (constAPInt &that)
 Copy Constructor.
 
 APInt (APInt &&that)
 Move Constructor.
 
 ~APInt ()
 Destructor.
 
Unary Operators
APInt operator++ (int)
 Postfix increment operator.
 
APIntoperator++ ()
 Prefix increment operator.
 
APInt operator-- (int)
 Postfix decrement operator.
 
APIntoperator-- ()
 Prefix decrement operator.
 
bool operator! ()const
 Logical negation operation on thisAPInt returns true if zero, like normal integers.
 
Assignment Operators
APIntoperator= (constAPInt &RHS)
 Copy assignment operator.
 
APIntoperator= (APInt &&that)
 Move assignment operator.
 
APIntoperator= (uint64_tRHS)
 Assignment operator.
 
APIntoperator&= (constAPInt &RHS)
 Bitwise AND assignment operator.
 
APIntoperator&= (uint64_tRHS)
 Bitwise AND assignment operator.
 
APIntoperator|= (constAPInt &RHS)
 Bitwise OR assignment operator.
 
APIntoperator|= (uint64_tRHS)
 Bitwise OR assignment operator.
 
APIntoperator^= (constAPInt &RHS)
 Bitwise XOR assignment operator.
 
APIntoperator^= (uint64_tRHS)
 Bitwise XOR assignment operator.
 
APIntoperator*= (constAPInt &RHS)
 Multiplication assignment operator.
 
APIntoperator*= (uint64_tRHS)
 
APIntoperator+= (constAPInt &RHS)
 Addition assignment operator.
 
APIntoperator+= (uint64_tRHS)
 
APIntoperator-= (constAPInt &RHS)
 Subtraction assignment operator.
 
APIntoperator-= (uint64_tRHS)
 
APIntoperator<<= (unsigned ShiftAmt)
 Left-shift assignment function.
 
APIntoperator<<= (constAPInt &ShiftAmt)
 Left-shift assignment function.
 
Comparison Operators
bool operator== (constAPInt &RHS)const
 Equality operator.
 
bool operator== (uint64_t Val)const
 Equality operator.
 
bool eq (constAPInt &RHS)const
 Equality comparison.
 
bool operator!= (constAPInt &RHS)const
 Inequality operator.
 
bool operator!= (uint64_t Val)const
 Inequality operator.
 
bool ne (constAPInt &RHS)const
 Inequality comparison.
 
bool ult (constAPInt &RHS)const
 Unsigned less than comparison.
 
bool ult (uint64_tRHS)const
 Unsigned less than comparison.
 
bool slt (constAPInt &RHS)const
 Signed less than comparison.
 
bool slt (int64_tRHS)const
 Signed less than comparison.
 
bool ule (constAPInt &RHS)const
 Unsigned less or equal comparison.
 
bool ule (uint64_tRHS)const
 Unsigned less or equal comparison.
 
bool sle (constAPInt &RHS)const
 Signed less or equal comparison.
 
bool sle (uint64_tRHS)const
 Signed less or equal comparison.
 
bool ugt (constAPInt &RHS)const
 Unsigned greater than comparison.
 
bool ugt (uint64_tRHS)const
 Unsigned greater than comparison.
 
bool sgt (constAPInt &RHS)const
 Signed greater than comparison.
 
bool sgt (int64_tRHS)const
 Signed greater than comparison.
 
bool uge (constAPInt &RHS)const
 Unsigned greater or equal comparison.
 
bool uge (uint64_tRHS)const
 Unsigned greater or equal comparison.
 
bool sge (constAPInt &RHS)const
 Signed greater or equal comparison.
 
bool sge (int64_tRHS)const
 Signed greater or equal comparison.
 
bool intersects (constAPInt &RHS)const
 This operation tests if there are any pairs of corresponding bits between thisAPInt and RHS that are both set.
 
bool isSubsetOf (constAPInt &RHS)const
 This operation checks that all bits set in thisAPInt 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 thisAPInt in place.
 
void insertBits (constAPInt &SubBits,unsigned bitPosition)
 Insert the bits from a smallerAPInt starting at bitPosition.
 
void insertBits (uint64_t SubBits,unsigned bitPosition,unsigned numBits)
 
APInt extractBits (unsigned numBits,unsigned bitPosition)const
 Return anAPInt 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
staticAPInt getZero (unsigned numBits)
 Get the '0' value for the specified bit-width.
 
staticAPInt getZeroWidth ()
 Return anAPInt zero bits wide.
 
staticAPInt getMaxValue (unsigned numBits)
 Gets maximum unsigned value ofAPInt for specific bit width.
 
staticAPInt getSignedMaxValue (unsigned numBits)
 Gets maximum signed value ofAPInt for a specific bit width.
 
staticAPInt getMinValue (unsigned numBits)
 Gets minimum unsigned value ofAPInt for a specific bit width.
 
staticAPInt getSignedMinValue (unsigned numBits)
 Gets minimum signed value ofAPInt for a specific bit width.
 
staticAPInt getSignMask (unsigned BitWidth)
 Get the SignMask for a specific bit width.
 
staticAPInt getAllOnes (unsigned numBits)
 Return anAPInt of a specified width with all bits set.
 
staticAPInt getOneBitSet (unsigned numBits,unsigned BitNo)
 Return anAPInt with exactly one bit set in the result.
 
staticAPInt getBitsSet (unsigned numBits,unsigned loBit,unsigned hiBit)
 Get a value with a block of bits set.
 
staticAPInt getBitsSetWithWrap (unsigned numBits,unsigned loBit,unsigned hiBit)
 Wrap version of getBitsSet.
 
staticAPInt getBitsSetFrom (unsigned numBits,unsigned loBit)
 Constructs anAPInt value that has a contiguous range of bits set.
 
staticAPInt getHighBitsSet (unsigned numBits,unsigned hiBitsSet)
 Constructs anAPInt value that has the top hiBitsSet bits set.
 
staticAPInt getLowBitsSet (unsigned numBits,unsigned loBitsSet)
 Constructs anAPInt value that has the bottom loBitsSet bits set.
 
staticAPInt getSplat (unsigned NewLen,constAPInt &V)
 Return a value containing V broadcasted over NewLen bits.
 

Static Public Attributes

static constexprunsigned APINT_WORD_SIZE = sizeof(WordType)
 Byte size of a word.
 
static constexprunsigned APINT_BITS_PER_WORD =APINT_WORD_SIZE * CHAR_BIT
 Bits in a word.
 
static constexprWordType WORDTYPE_MAX = ~WordType(0)
 

Building-block Operations for APInt and APFloat

struct DenseMapInfo< APInt, void >
 
class APSInt
 
void Profile (FoldingSetNodeID &id)const
 Used to insertAPInt objects, or objects that containAPInt 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 *,constWordType *,unsigned)
 Assign one bignum to another.
 
staticbool tcIsZero (constWordType *,unsigned)
 Returns true if a bignum is zero, false otherwise.
 
static int tcExtractBit (constWordType *,unsigned bit)
 Extract the given bit of a bignum; returns 0 or 1. Zero-based.
 
static void tcExtract (WordType *,unsigned dstCount,constWordType *,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.
 
staticunsigned tcLSB (constWordType *,unsigned n)
 Returns the bit number of the least or most significant set bit of a number.
 
staticunsigned tcMSB (constWordType *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.
 
staticWordType tcAdd (WordType *,constWordType *,WordType carry,unsigned)
 DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag.
 
staticWordType tcAddPart (WordType *,WordType,unsigned)
 DST += RHS. Returns the carry flag.
 
staticWordType tcSubtract (WordType *,constWordType *,WordType carry,unsigned)
 DST -= RHS + CARRY where CARRY is zero or one. Returns the carry flag.
 
staticWordType tcSubtractPart (WordType *,WordType,unsigned)
 DST -= RHS. Returns the carry flag.
 
static int tcMultiplyPart (WordType *dst,constWordType *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 *,constWordType *,constWordType *,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 *,constWordType *,constWordType *,unsigned,unsigned)
 DST = LHS * RHS, where DST has width the sum of the widths of the operands.
 
static int tcDivide (WordType *lhs,constWordType *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 (constWordType *,constWordType *,unsigned)
 Comparison (unsigned) of two bignums.
 
staticWordType tcIncrement (WordType *dst,unsigned parts)
 Increment a bignum in-place. Return the carry flag.
 
staticWordType tcDecrement (WordType *dst,unsigned parts)
 Decrement a bignum in-place. Return the borrow flag.
 

Value Tests

hash_code hash_value (constAPInt &Arg)
 Overload to compute ahash_code for anAPInt value.
 
bool isSingleWord ()const
 Determine if thisAPInt just has one word to store value.
 
bool isNegative ()const
 Determine sign of thisAPInt.
 
bool isNonNegative ()const
 Determine if thisAPIntValue is non-negative (>= 0)
 
bool isSignBitSet ()const
 Determine if sign bit of thisAPInt is set.
 
bool isSignBitClear ()const
 Determine if sign bit of thisAPInt is clear.
 
bool isStrictlyPositive ()const
 Determine if thisAPIntValue is positive.
 
bool isNonPositive ()const
 Determine if thisAPIntValue is non-positive (<= 0).
 
bool isOneBitSet (unsigned BitNo)const
 Determine if thisAPIntValue 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 (unsignedN)const
 Check if thisAPInt has an N-bits unsigned integer value.
 
bool isSignedIntN (unsignedN)const
 Check if thisAPInt has an N-bits signed integer value.
 
bool isPowerOf2 ()const
 Check if thisAPInt's value is a power of two greater than zero.
 
bool isNegatedPowerOf2 ()const
 Check if thisAPInt's negated value is a power of two greater than zero.
 
bool isAligned (AlignA)const
 Checks if thisAPInt -interpreted as an address- is aligned to the provided value.
 
bool isSignMask ()const
 Check if theAPInt's value is returned by getSignMask.
 
bool getBoolValue ()const
 ConvertAPInt 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 theAPInt consists of a repeated bit pattern.
 
bool isMask (unsigned numBits)const
 
bool isMask ()const
 
bool isShiftedMask ()const
 Return true if thisAPInt value contains a non-empty sequence of ones with the remainder zero.
 
bool isShiftedMask (unsigned &MaskIdx,unsigned &MaskLen)const
 Return true if thisAPInt value contains a non-empty sequence of ones with the remainder zero.
 
APInt getHiBits (unsigned numBits)const
 Compute anAPInt containing numBits highbits from thisAPInt.
 
APInt getLoBits (unsigned numBits)const
 Compute anAPInt containing numBits lowbits from thisAPInt.
 
constuint64_tgetRawData ()const
 This function returns a pointer to the internal storage of theAPInt.
 
staticbool isSameValue (constAPInt &I1,constAPInt &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* (constAPInt &RHS)const
 Multiplication operator.
 
APInt operator<< (unsigned Bits)const
 Left logical shift operator.
 
APInt operator<< (constAPInt &Bits)const
 Left logical shift operator.
 
APInt ashr (unsigned ShiftAmt)const
 Arithmetic right-shift function.
 
void ashrInPlace (unsigned ShiftAmt)
 Arithmetic right-shift thisAPInt by ShiftAmt in place.
 
APInt lshr (unsigned shiftAmt)const
 Logical right-shift function.
 
void lshrInPlace (unsigned ShiftAmt)
 Logical right-shift thisAPInt 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 (constAPInt &ShiftAmt)const
 Arithmetic right-shift function.
 
void ashrInPlace (constAPInt &shiftAmt)
 Arithmetic right-shift thisAPInt by shiftAmt in place.
 
APInt lshr (constAPInt &ShiftAmt)const
 Logical right-shift function.
 
void lshrInPlace (constAPInt &ShiftAmt)
 Logical right-shift thisAPInt by ShiftAmt in place.
 
APInt shl (constAPInt &ShiftAmt)const
 Left-shift function.
 
APInt rotl (constAPInt &rotateAmt)const
 Rotate left by rotateAmt.
 
APInt rotr (constAPInt &rotateAmt)const
 Rotate right by rotateAmt.
 
APInt concat (constAPInt &NewLSB)const
 Concatenate the bits from "NewLSB" onto the bottom of *this.
 
APInt udiv (constAPInt &RHS)const
 Unsigned division operation.
 
APInt udiv (uint64_tRHS)const
 
APInt sdiv (constAPInt &RHS)const
 Signed division function forAPInt.
 
APInt sdiv (int64_tRHS)const
 
APInt urem (constAPInt &RHS)const
 Unsigned remainder operation.
 
uint64_t urem (uint64_tRHS)const
 
APInt srem (constAPInt &RHS)const
 Function for signed remainder operation.
 
int64_t srem (int64_tRHS)const
 
APInt sadd_ov (constAPInt &RHS,bool &Overflow)const
 
APInt uadd_ov (constAPInt &RHS,bool &Overflow)const
 
APInt ssub_ov (constAPInt &RHS,bool &Overflow)const
 
APInt usub_ov (constAPInt &RHS,bool &Overflow)const
 
APInt sdiv_ov (constAPInt &RHS,bool &Overflow)const
 
APInt smul_ov (constAPInt &RHS,bool &Overflow)const
 
APInt umul_ov (constAPInt &RHS,bool &Overflow)const
 
APInt sshl_ov (constAPInt &Amt,bool &Overflow)const
 
APInt sshl_ov (unsigned Amt,bool &Overflow)const
 
APInt ushl_ov (constAPInt &Amt,bool &Overflow)const
 
APInt ushl_ov (unsigned Amt,bool &Overflow)const
 
APInt sfloordiv_ov (constAPInt &RHS,bool &Overflow)const
 Signed integer floor division operation.
 
APInt sadd_sat (constAPInt &RHS)const
 
APInt uadd_sat (constAPInt &RHS)const
 
APInt ssub_sat (constAPInt &RHS)const
 
APInt usub_sat (constAPInt &RHS)const
 
APInt smul_sat (constAPInt &RHS)const
 
APInt umul_sat (constAPInt &RHS)const
 
APInt sshl_sat (constAPInt &RHS)const
 
APInt sshl_sat (unsignedRHS)const
 
APInt ushl_sat (constAPInt &RHS)const
 
APInt ushl_sat (unsignedRHS)const
 
bool operator[] (unsigned bitPosition)const
 Array-indexing support.
 
static void udivrem (constAPInt &LHS,constAPInt &RHS,APInt &Quotient,APInt &Remainder)
 Dual division/remainder interface.
 
static void udivrem (constAPInt &LHS,uint64_tRHS,APInt &Quotient,uint64_t &Remainder)
 
static void sdivrem (constAPInt &LHS,constAPInt &RHS,APInt &Quotient,APInt &Remainder)
 
static void sdivrem (constAPInt &LHS, int64_tRHS,APInt &Quotient, int64_t &Remainder)
 

Value Characterization Functions

unsigned getBitWidth ()const
 Return the number of bits in theAPInt.
 
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 thisAPInt.
 
unsigned getSignificantBits ()const
 Get the minimum bit size for this signedAPInt.
 
uint64_t getZExtValue ()const
 Get zero extended value.
 
std::optional<uint64_ttryZExtValue ()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
 TheAPInt 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 thisAPInt 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.
 
staticunsigned getNumWords (unsigned BitWidth)
 Get the number of words.
 
staticunsigned getBitsNeeded (StringRef str,uint8_t radix)
 Get bits required for string value.
 
staticunsigned getSufficientBitsNeeded (StringRef Str,uint8_t Radix)
 Get the bits that are sufficient to represent the string value.
 

Conversion Functions

void print (raw_ostream &OS,boolisSigned)const
 
void toString (SmallVectorImpl<char > &Str,unsigned Radix,boolSigned,bool formatAsCLiteral=false,bool UpperCase=true,bool InsertSeparators=false)const
 Converts anAPInt to a string and append it to Str.
 
void toStringUnsigned (SmallVectorImpl<char > &Str,unsigned Radix=10)const
 Considers theAPInt to be unsigned and converts it into a string in the radix given.
 
void toStringSigned (SmallVectorImpl<char > &Str,unsigned Radix=10)const
 Considers theAPInt to be signed and converts it into a string in the radix given.
 
APInt byteSwap ()const
 
APInt reverseBits ()const
 
double roundToDouble (boolisSigned)const
 Converts thisAPInt to a double value.
 
double roundToDouble ()const
 Converts this unsignedAPInt to a double value.
 
double signedRoundToDouble ()const
 Converts this signedAPInt to a double value.
 
double bitsToDouble ()const
 ConvertsAPInt bits to a double.
 
float bitsToFloat ()const
 ConvertsAPInt bits to a float.
 
staticAPInt doubleToBits (double V)
 Converts a double toAPInt bits.
 
staticAPInt floatToBits (float V)
 Converts a float toAPInt bits.
 

Detailed Description

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:

Definition at line78 of fileAPInt.h.

Member Typedef Documentation

◆ WordType

typedefuint64_tllvm::APInt::WordType

Definition at line80 of fileAPInt.h.

Member Enumeration Documentation

◆ Rounding

enum classllvm::APInt::Rounding
strong
Enumerator
DOWN 
TOWARD_ZERO 
UP 

Definition at line88 of fileAPInt.h.

Constructor & Destructor Documentation

◆ APInt()[1/7]

llvm::APInt::APInt(unsigned numBits,
uint64_t val,
bool isSigned =false,
bool implicitTrunc =false 
)
inline

Create a newAPInt 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).

Parameters
numBitsthe bit width of the constructedAPInt
valthe initial value of theAPInt
isSignedhow to treat signedness of val
implicitTruncallow implicit truncation of non-zero/sign bits of val beyond the range of numBits

Definition at line111 of fileAPInt.h.

Referencesassert(),BitWidth,clearUnusedBits(),llvm::isIntN(),isSigned(), andllvm::isUIntN().

◆ APInt()[2/7]

APInt::APInt(unsigned numBits,
ArrayRef<uint64_tbigVal 
)

Construct anAPInt 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.

Parameters
numBitsthe bit width of the constructedAPInt
bigVala sequence of words to form the initial value of theAPInt

Definition at line107 of fileAPInt.cpp.

◆ APInt()[3/7]

APInt::APInt(unsigned numBits,
unsigned numWords,
constuint64_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.

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.

Definition at line111 of fileAPInt.cpp.

◆ APInt()[4/7]

APInt::APInt(unsigned numBits,
StringRef str,
uint8_t radix 
)

Construct anAPInt from a string representation.

This constructor interprets the stringstr 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.

Parameters
numBitsthe bit width of the constructedAPInt
strthe string to be interpreted
radixthe radix to use for the conversion

Definition at line116 of fileAPInt.cpp.

◆ APInt()[5/7]

llvm::APInt::APInt()
inlineexplicit

Default constructor that creates anAPInt with a 1-bit zero value.

Definition at line173 of fileAPInt.h.

Referenced bybyteSwap(),extractBits(),operator*(),reverseBits(),sext(),sqrt(),sshl_ov(),trunc(),udiv(),udivrem(),urem(),ushl_ov(),usub_sat(), andzext().

◆ APInt()[6/7]

llvm::APInt::APInt(constAPIntthat)
inline

Copy Constructor.

Definition at line176 of fileAPInt.h.

ReferencesVAL.

◆ APInt()[7/7]

llvm::APInt::APInt(APInt && that)
inline

Move Constructor.

Definition at line184 of fileAPInt.h.

◆ ~APInt()

llvm::APInt::~APInt()
inline

Destructor.

Definition at line190 of fileAPInt.h.

Member Function Documentation

◆ abs()

APInt llvm::APInt::abs() const
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 wideAPInt) is unchanged due to how negation works.

Definition at line1773 of fileAPInt.h.

Referenced bycombineSelectOfTwoConstants(),findGCD(),llvm::SelectionDAG::FoldConstantArithmetic(),llvm::InstCombinerImpl::foldICmpBinOp(),llvm::InstCombinerImpl::foldICmpSRemConstant(),gcd(),llvm::ScalarEvolution::getAddExpr(),llvm::ExpressionFormat::getMatchingString(), andgetRangeForAffineARHelper().

◆ ashr()[1/2]

APInt llvm::APInt::ashr(constAPIntShiftAmt) const
inline

Arithmetic right-shift function.

Arithmetic right-shift thisAPInt by shiftAmt.

Definition at line908 of fileAPInt.h.

◆ ashr()[2/2]

APInt llvm::APInt::ashr(unsigned ShiftAmt) const
inline

Arithmetic right-shift function.

Arithmetic right-shift thisAPInt by shiftAmt.

Definition at line827 of fileAPInt.h.

Referenced byllvm::ConstantRange::ashr(),llvm::ConstantFoldBinaryInstruction(),llvm::ConstantFoldBinOp(),llvm::InstCombinerImpl::foldICmpAndShift(),llvm::InstCombinerImpl::foldICmpShlConstant(),llvm::InstCombinerImpl::foldICmpShrConstant(),llvm::InstCombinerImpl::foldICmpShrConstConst(),FoldValue(),llvm::AArch64TTIImpl::getIntImmCost(),llvm::X86TTIImpl::getIntImmCost(),llvm::RISCVMatInt::getIntMatCost(),isNonZeroShift(),LowerShift(),performMulCombine(),setLimitsForBinOp(),llvm::InstCombinerImpl::simplifyShrShlDemandedBits(),llvm::Interpreter::visitAShr(), andllvm::InstCombinerImpl::visitSwitchInst().

◆ ashrInPlace()[1/2]

void APInt::ashrInPlace(constAPIntshiftAmt)

Arithmetic right-shift thisAPInt by shiftAmt in place.

Arithmetic right-shift thisAPInt by shiftAmt.

Arithmetic right-shift function.

Definition at line1025 of fileAPInt.cpp.

ReferencesashrInPlace(), andgetLimitedValue().

◆ ashrInPlace()[2/2]

void llvm::APInt::ashrInPlace(unsigned ShiftAmt)
inline

Arithmetic right-shift thisAPInt by ShiftAmt in place.

Definition at line834 of fileAPInt.h.

Referencesassert(),BitWidth,clearUnusedBits(), andllvm::SignExtend64().

Referenced byllvm::KnownBits::ashr(),ashrInPlace(),BuildExactSDIV(),llvm::CombinerHelper::buildSDivUsingMul(),combineVectorShiftImm(),llvm::X86TargetLowering::computeKnownBitsForTargetNode(), andllvm::SelectionDAG::FoldConstantArithmetic().

◆ bitsToDouble()

double llvm::APInt::bitsToDouble() const
inline

ConvertsAPInt 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 line1700 of fileAPInt.h.

Referenced byllvm::detail::IEEEFloat::convertToDouble(),llvm::convertToNonDenormSingle(), andllvm::ExecutionEngine::getConstantValue().

◆ bitsToFloat()

float llvm::APInt::bitsToFloat() const
inline

ConvertsAPInt 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 line1714 of fileAPInt.h.

Referenced byllvm::detail::IEEEFloat::convertToFloat(), andllvm::ExecutionEngine::getConstantValue().

◆ byteSwap()

APInt APInt::byteSwap() const
Returns
a byte-swapped representation of thisAPIntValue.

Definition at line719 of fileAPInt.cpp.

ReferencesAPInt(),APINT_BITS_PER_WORD,assert(),getNumWords(),I, andN.

Referenced byllvm::DwarfExpression::addConstantFP(),llvm::KnownBits::byteSwap(),computeKnownBitsFromOperator(),foldBitwiseLogicWithIntrinsics(),llvm::SelectionDAG::FoldConstantArithmetic(), andllvm::TargetLowering::SimplifyDemandedBits().

◆ ceilLogBase2()

unsigned llvm::APInt::ceilLogBase2() const
inline
Returns
the ceil log base 2 of thisAPInt.

Definition at line1742 of fileAPInt.h.

ReferencesgetActiveBits().

Referenced byComputeNumSignBitsImpl(), andllvm::InstCombinerImpl::foldICmpUsingKnownBits().

◆ clearAllBits()

void llvm::APInt::clearAllBits()
inline

Set every bit to 0.

Definition at line1397 of fileAPInt.h.

Referenced byllvm::slpvectorizer::BoUpSLP::canVectorizeLoads(),combineAnd(),combineAndnp(),computeForSatAddSub(),llvm::SelectionDAG::computeKnownBits(),llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(),llvm::X86TargetLowering::computeKnownBitsForTargetNode(),computeKnownBitsFromOperator(),llvm::KnownBits::resetAll(),llvm::KnownBits::setAllOnes(),llvm::KnownBits::setAllZero(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::TargetLowering::SimplifyDemandedVectorElts(),llvm::InstCombinerImpl::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), andllvm::InstCombinerImpl::simplifyShrShlDemandedBits().

◆ clearBit()

void llvm::APInt::clearBit(unsigned BitPosition)
inline

Set a given bit to 0.

Set the given bit to 0 whose position is given as "bitPosition".

Definition at line1407 of fileAPInt.h.

Referencesassert(), andBitWidth.

Referenced byllvm::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(), andllvm::ConstantRange::truncate().

◆ clearHighBits()

void llvm::APInt::clearHighBits(unsigned hiBits)
inline

Set top hiBits bits to 0.

Definition at line1424 of fileAPInt.h.

Referencesassert(),BitWidth, andllvm::Keep.

Referenced byllvm::TargetLowering::SimplifyDemandedBits().

◆ clearLowBits()

void llvm::APInt::clearLowBits(unsigned loBits)
inline

Set bottom loBits bits to 0.

Definition at line1417 of fileAPInt.h.

Referencesassert(),BitWidth, andllvm::Keep.

Referenced bycomputeForSatAddSub(),llvm::SelectionDAG::computeKnownBits(),llvm::GISelKnownBits::computeKnownBitsImpl(),llvm::KnownBits::makeGE(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), andllvm::ConstantRange::toKnownBits().

◆ clearSignBit()

void llvm::APInt::clearSignBit()
inline

Set the sign bit to 0.

Definition at line1431 of fileAPInt.h.

ReferencesBitWidth.

Referenced byllvm::KnownBits::abs(),computeForSatAddSub(),computeKnownBitsFromOperator(),foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed(), andllvm::ConstantRange::fromKnownBits().

◆ concat()

APInt llvm::APInt::concat(constAPIntNewLSB) const
inline

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 line947 of fileAPInt.h.

ReferencesgetBitWidth(),getBitWidth(), andVAL.

Referenced byllvm::KnownBits::concat().

◆ countl_one()

unsigned llvm::APInt::countl_one() const
inline

Count the number of leading one bits.

This function is anAPInt version of std::countl_one. It counts the number of ones from the most significant bit to the first zero bit.

Returns
0 if the high order bit is not set, otherwise returns the number of 1 bits from the most significant to the least

Definition at line1594 of fileAPInt.h.

ReferencesBitWidth,llvm::countl_one(), andLLVM_UNLIKELY.

Referenced byllvm::KnownBits::computeForAddSub(),llvm::KnownBits::countMinLeadingOnes(),llvm::KnownBits::countMinLeadingZeros(),llvm::ConstantRange::ctpop(),llvm::InstCombinerImpl::foldICmpShrConstConst(),lower1BitShuffle(),lowerShuffleAsByteShiftMask(),lowerShuffleAsVALIGN(),lowerShuffleAsVTRUNCAndUnpack(),llvm::CombinerHelper::matchCombineShlOfExtend(),llvm::ConstantRange::shl(), andsshl_ov().

◆ countl_zero()

unsigned llvm::APInt::countl_zero() const
inline

TheAPInt version of std::countl_zero.

It counts the number of zeros from the most significant bit to the first one bit.

Returns
BitWidth if the value is zero, otherwise returns the number of zeros from the most significant bit to the first one bits.

Definition at line1577 of fileAPInt.h.

ReferencesBitWidth, andllvm::countl_zero().

Referenced byareUsedBitsDense(),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(), andllvm::InstCombinerImpl::visitAdd().

◆ countLeadingOnes()

unsigned llvm::APInt::countLeadingOnes() const
inline

Definition at line1603 of fileAPInt.h.

Referencesllvm::countl_one().

Referenced bycomputeShlNSWWithNegLHS(), andfoldNegativePower2AndShiftedMask().

◆ countLeadingZeros()

unsigned llvm::APInt::countLeadingZeros() const
inline

Definition at line1585 of fileAPInt.h.

Referencesllvm::countl_zero().

Referenced bycomputeShlNSWWithNNegLHS(),computeShlNUW(),foldNegativePower2AndShiftedMask(),foldSelectICmpAndZeroShl(),llvm::KnownBits::sdiv(),llvm::TargetLowering::SimplifyDemandedBits(), andllvm::KnownBits::udiv().

◆ countr_one()

unsigned llvm::APInt::countr_one() const
inline

Count the number of trailing one bits.

This function is anAPInt version of std::countr_one. It counts the number of ones from the least significant bit to the first zero bit.

Returns
BitWidth if the value is all ones, otherwise returns the number of ones from the least significant bit to the first zero bit.

Definition at line1635 of fileAPInt.h.

Referencesllvm::countr_one().

Referenced bycombineAndMaskToShift(),combineShiftRightLogical(),llvm::KnownBits::countMinTrailingOnes(),llvm::KnownBits::countMinTrailingZeros(),llvm::InstCombinerImpl::foldICmpEquality(),foldSubCtlzNot(),lowerShuffleAsByteShiftMask(),lowerShuffleAsVALIGN(),llvm::CombinerHelper::matchCombineLoadWithAndMask(),PerformMinMaxToSatCombine(),llvm::TargetLowering::SimplifySetCC(), andllvm::ConstantRange::truncate().

◆ countr_zero()

unsigned llvm::APInt::countr_zero() const
inline

Count the number of trailing zero bits.

This function is anAPInt version of std::countr_zero. It counts the number of zeros from the least significant bit to the first set bit.

Returns
BitWidth if the value is zero, otherwise returns the number of zeros from the least significant bit to the first one bit.

Definition at line1618 of fileAPInt.h.

ReferencesBitWidth, andllvm::countr_zero().

Referenced byareUsedBitsDense(),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(), andllvm::InstCombinerImpl::visitSub().

◆ countTrailingOnes()

unsigned llvm::APInt::countTrailingOnes() const
inline

Definition at line1641 of fileAPInt.h.

Referencesllvm::countr_one().

◆ countTrailingZeros()

unsigned llvm::APInt::countTrailingZeros() const
inline

Definition at line1626 of fileAPInt.h.

Referencesllvm::countr_zero().

Referenced byllvm::ScalarEvolution::getSmallConstantTripMultiple().

◆ doubleToBits()

staticAPInt llvm::APInt::doubleToBits(double V)
inlinestatic

Converts a double toAPInt bits.

The conversion does not do a translation from double to integer, it just re-interprets the bits of the double.

Definition at line1722 of fileAPInt.h.

Referenced byllvm::ExecutionEngine::getConstantValue(), andllvm::detail::IEEEFloat::IEEEFloat().

◆ dump()

LLVM_DUMP_METHOD void APInt::dump() const

debug method

Definition at line2272 of fileAPInt.cpp.

Referencesllvm::dbgs(),toStringSigned(), andtoStringUnsigned().

◆ eq()

bool llvm::APInt::eq(constAPIntRHS) const
inline

Equality comparison.

Compares thisAPInt with RHS for the validity of the equality relationship.

Returns
true if *this == Val

Definition at line1079 of fileAPInt.h.

ReferencesRHS.

Referenced bycombineShiftRightArithmetic(),llvm::omp::getBestVariantMatchForContext(),processUMulZExtIdiom(), andllvm::InstCombinerImpl::visitLShr().

◆ exactLogBase2()

int32_t llvm::APInt::exactLogBase2() const
inline
Returns
the log base 2 of thisAPInt if its an exact power of two, -1 otherwise

Definition at line1761 of fileAPInt.h.

Referenced bycombineAnd(),foldAddToAshr(),isSaturatingMinMax(),llvm::LoongArchDAGToDAGISel::selectVSplatUimmPow2(),llvm::InstCombinerImpl::visitAnd(), andllvm::InstCombinerImpl::visitTrunc().

◆ extractBits()

APInt APInt::extractBits(unsigned numBits,
unsigned bitPosition 
) const

Return anAPInt with the extracted bits [bitPosition,bitPosition+numBits).

Definition at line455 of fileAPInt.cpp.

ReferencesAPInt(),APINT_BITS_PER_WORD,assert(),getNumWords(), andisSingleWord().

Referenced bycombineX86ShufflesRecursively(),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(), andllvm::TargetLowering::SimplifyMultipleUseDemandedBits().

◆ extractBitsAsZExtValue()

uint64_t APInt::extractBitsAsZExtValue(unsigned numBits,
unsigned bitPosition 
) const

Definition at line493 of fileAPInt.cpp.

ReferencesAPINT_BITS_PER_WORD,assert(), andisSingleWord().

Referenced bygetMaxShiftAmount().

◆ flipAllBits()

void llvm::APInt::flipAllBits()
inline

Toggle every bit to its opposite value.

Definition at line1434 of fileAPInt.h.

ReferencesclearUnusedBits().

Referenced byllvm::InstCombinerImpl::foldICmpSRemConstant(),getUsefulBits(),getUsefulBitsFromBFM(), andinsert1BitVector().

◆ flipBit()

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 line365 of fileAPInt.cpp.

Referencesassert(), andsetBitVal().

◆ floatToBits()

staticAPInt llvm::APInt::floatToBits(float V)
inlinestatic

Converts a float toAPInt bits.

The conversion does not do a translation from float to integer, it just re-interprets the bits of the float.

Definition at line1730 of fileAPInt.h.

Referenced byllvm::ExecutionEngine::getConstantValue(), andllvm::detail::IEEEFloat::IEEEFloat().

◆ getActiveBits()

unsigned llvm::APInt::getActiveBits() const
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 line1492 of fileAPInt.h.

ReferencesBitWidth, andllvm::countl_zero().

Referenced byllvm::APSInt::APSInt(),areUsedBitsDense(),canSafelyConvertTo16Bit(),ceilLogBase2(),llvm::TargetLowering::expandIS_FPCLASS(),llvm::InstCombinerImpl::foldICmpUsingKnownBits(),llvm::ConstantRange::getActiveBits(),llvm::getBitwiseNotOperand(),getConstantTripCount(),getPreferredVectorIndex(),llvm::ScalarEvolution::getSmallConstantTripMultiple(),llvm::LegalizerHelper::lowerISFPCLASS(),llvm::ARMTargetLowering::PerformCMOVToBFICombine(),performSETCCCombine(),rebuildExtCst(),roundToDouble(),simplifyAMDGCNMemoryIntrinsicDemanded(),simplifyAndInst(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::TargetLowering::SimplifySetCC(),sqrt(),llvm::X86TargetLowering::targetShrinkDemandedConstant(),llvm::ConstantRange::truncate(),llvm::tryPromoteCall(),udiv(),urem(), andllvm::InstCombinerImpl::visitICmpInst().

◆ getActiveWords()

unsigned llvm::APInt::getActiveWords() const
inline

Compute the number of active words in the value of thisAPInt.

This is used in conjunction with getActiveData to extract the raw value of theAPInt.

Definition at line1498 of fileAPInt.h.

Referenced byemitConstantRange().

◆ getAllOnes()

staticAPInt llvm::APInt::getAllOnes(unsigned numBits)
inlinestatic

Return anAPInt of a specified width with all bits set.

Definition at line234 of fileAPInt.h.

Referenced byllvm::analyzeKnownBitsFromAndXorOr(),llvm::ConstantRange::binaryNot(),llvm::buildSelectInst(),llvm::SelectionDAG::canCreateUndefOrPoison(),canTryToConstantAddTwoShiftAmounts(),llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(),combineAddOfPMADDWD(),combineAnd(),combineAndnp(),combineBEXTR(),combineExtractVectorElt(),combineKSHIFT(),combineMOVMSK(),combinePDEP(),combinePMULDQ(),combinePredicateReduction(),combineShuffle(),combineTESTP(),combineVectorCompare(),combineVectorInsert(),combineVectorPack(),combineVectorShiftImm(),combineVectorShiftVar(),combineVPMADD(),combineVTRUNC(),combineX86INT_TO_FP(),combineX86ShuffleChain(),llvm::computeKnownBits(),llvm::SelectionDAG::computeKnownBits(),llvm::ARMTargetLowering::computeKnownBitsForTargetNode(),llvm::X86TargetLowering::computeKnownBitsForTargetNode(),computeKnownBitsFromOperator(),llvm::GISelKnownBits::computeKnownBitsImpl(),llvm::computeKnownFPClass(),computeKnownFPClass(),ComputeNumSignBits(),llvm::GISelKnownBits::computeNumSignBits(),llvm::SelectionDAG::ComputeNumSignBits(),computeShlNSW(),defaultComponentBroadcast(),detectSSatPattern(),llvm::TargetLowering::expandIS_FPCLASS(),findDemandedEltsByAllUsers(),findDemandedEltsBySingleUser(),llvm::InstCombinerImpl::foldICmpUsingKnownBits(),foldICmpUSubSatOrUAddSatWithConstant(),foldSelectICmpLshrAshr(),foldShiftIntoShiftInAnotherHandOfAndInICmp(),llvm::SelectionDAG::getAllOnesConstant(),llvm::APFloat::getAllOnesValue(),llvm::Constant::getAllOnesValue(),getBitcastWiderVectorElementOffset(),llvm::DemandedBits::getDemandedBits(),getDemandedBitsLHSMask(),getDemandedSrcElements(),getFauxShuffleMask(),getHopForBuildVector(),llvm::LoopVectorizationCostModel::getInstructionCost(),llvm::BasicTTIImplBase< T >::getInterleavedMemoryOpCost(),llvm::X86TTIImpl::getInterleavedMemoryOpCostAVX512(),llvm::GISelKnownBits::getKnownBits(),llvm::X86TTIImpl::getMaskedMemoryOpCost(),getRangeForIntrinsic(),llvm::BuildVectorSDNode::getRepeatedSequence(),llvm::BasicTTIImplBase< T >::getScalarizationOverhead(),llvm::SelectionDAG::getSplatSourceVector(),llvm::BuildVectorSDNode::getSplatValue(),getTargetConstantBitsFromNode(),getTargetShuffleInputs(),llvm::SelectionDAG::getValidMaximumShiftAmount(),llvm::SelectionDAG::getValidMinimumShiftAmount(),llvm::SelectionDAG::getValidShiftAmount(),llvm::isConstOrConstSplat(),llvm::isConstOrConstSplatFP(),llvm::SelectionDAG::isGuaranteedNotToBeUndefOrPoison(),llvm::isKnownNonEqual(),llvm::isKnownNonZero(),isKnownNonZeroFromOperator(),isNonZeroShift(),llvm::SelectionDAG::isSplatValue(),llvm::slpvectorizer::BoUpSLP::isTreeTinyAndNotFullyVectorizable(),llvm::LegalizerHelper::lowerISFPCLASS(),lowerShuffleAsElementInsertion(),LowerVectorAllEqual(),llvm::detail::IEEEFloat::makeNaN(),MatchVectorAllEqualTest(),narrowSDivOrSRem(),llvm::AArch64TargetLowering::PerformDAGCombine(),llvm::PPCTargetLowering::PerformDAGCombine(),llvm::possiblyDemandedEltsInMask(),llvm::recognizeBSwapOrBitReverseIdiom(),setLimitsForBinOp(),llvm::TargetLowering::ShrinkDemandedConstant(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::ARMTargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::InstCombinerImpl::SimplifyDemandedInstructionBits(),llvm::TargetLowering::SimplifyDemandedVectorElts(),llvm::InstCombinerImpl::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),llvm::TargetLowering::SimplifyMultipleUseDemandedBits(),llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(),llvm::TargetLowering::SimplifyMultipleUseDemandedVectorElts(),llvm::InstCombinerImpl::simplifyShrShlDemandedBits(),llvm::APFixedPoint::toString(),trimTrailingZerosInVector(),llvm::LegalizationArtifactCombiner::tryCombineZExt(),llvm::InstCombinerImpl::visitCallInst(),llvm::InstCombinerImpl::visitGetElementPtrInst(),llvm::InstCombinerImpl::visitInsertElementInst(),llvm::InstCombinerImpl::visitLShr(),llvm::InstCombinerImpl::visitShuffleVectorInst(),llvm::InstCombinerImpl::visitXor(), andllvm::LegalizerHelper::widenScalar().

◆ getBitsNeeded()

unsigned APInt::getBitsNeeded(StringRef str,
uint8_t radix 
)
static

Get bits required for string value.

This method determines how many bits are required to hold theAPInt equivalent of the string given bystr.

Definition at line549 of fileAPInt.cpp.

Referencesassert(),llvm::StringRef::begin(),getSufficientBitsNeeded(),isNegative(),isPowerOf2(),logBase2(), andllvm::StringRef::size().

◆ getBitsSet()

staticAPInt llvm::APInt::getBitsSet(unsigned numBits,
unsigned loBit,
unsigned hiBit 
)
inlinestatic

Get a value with a block of bits set.

Constructs anAPInt 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 ifloBit may be greater thanhiBit.

Parameters
numBitsthe intended bit width of the result
loBitthe index of the lowest bit set.
hiBitthe index of the highest bit set.
Returns
AnAPInt value with the requested bits set.

Definition at line258 of fileAPInt.h.

ReferencessetBits().

Referenced bycombineToExtendBoolVectorInReg(),computeShlNSWWithNNegLHS(),llvm::X86TTIImpl::getMemoryOpCost(),insert1BitVector(),LowerShift(),llvm::AMDGPUTargetLowering::PerformDAGCombine(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),simplifyX86immShift(),tryBitfieldInsertOpFromOr(),tryToMergePartialOverlappingStores(), andllvm::RegisterBankInfo::ValueMapping::verify().

◆ getBitsSetFrom()

staticAPInt llvm::APInt::getBitsSetFrom(unsigned numBits,
unsigned loBit 
)
inlinestatic

Constructs anAPInt 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.

Parameters
numBitsthe intended bit width of the result
loBitthe index of the lowest bit to set.
Returns
AnAPInt value with the requested bits set.

Definition at line286 of fileAPInt.h.

ReferencessetBitsFrom().

Referenced bycanEvaluateTruncated(),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(), andllvm::InstCombinerImpl::visitTrunc().

◆ getBitsSetWithWrap()

staticAPInt llvm::APInt::getBitsSetWithWrap(unsigned numBits,
unsigned loBit,
unsigned hiBit 
)
inlinestatic

Wrap version of getBitsSet.

IfhiBit is bigger thanloBit, this is same with getBitsSet. IfhiBit is not bigger thanloBit, the set bits "wrap". For example, with parameters (32, 28, 4), you would get 0xF000000F. IfhiBit is equal toloBit, you would get a result with all bits set.

Definition at line270 of fileAPInt.h.

ReferencessetBitsWithWrap().

Referenced byllvm::PPCInstrInfo::combineRLWINM(), andllvm::LegalizerHelper::lowerInsert().

◆ getBitWidth()

unsigned llvm::APInt::getBitWidth() const
inline

Return the number of bits in theAPInt.

Definition at line1468 of fileAPInt.h.

ReferencesBitWidth.

Referenced byllvm::DwarfExpression::addConstantFP(),llvm::DwarfUnit::addConstantValue(),llvm::APFixedPoint::APFixedPoint(),APIntToHexString(),llvm::TargetLowering::BuildUDIV(),llvm::CombinerHelper::buildUDivUsingMul(),canonicalizeGEPOfConstGEPI8(),combineCMov(),combineConcatVectorOps(),combineConstantPoolLoads(),combineSetCCMOVMSK(),combineShiftOfShiftedLogic(),CombineVMOVDRRCandidateWithVecOp(),llvm::InstCombinerImpl::commonIDivTransforms(),CompareSCEVComplexity(),llvm::APSInt::compareValues(),llvm::ObjectSizeOffsetVisitor::compute(),computeKnownBits(),llvm::SelectionDAG::computeKnownBits(),llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(),llvm::X86TargetLowering::computeKnownBitsForTargetNode(),computeKnownBitsFromOperator(),llvm::GISelKnownBits::computeKnownBitsImpl(),computeKnownFPClass(),llvm::SelectionDAG::ComputeNumSignBits(),ComputeNumSignBitsImpl(),llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(),computeShlNSWWithNegLHS(),computeShlNSWWithNNegLHS(),llvm::SelectionDAG::computeVectorKnownZeroElements(),concat(),llvm::ConstantFoldBinaryInstruction(),llvm::ConstantFoldBinOp(),llvm::ConstantRange::ConstantRange(),llvm::APFixedPoint::convert(),llvm::APFloat::convertToInteger(),emitGlobalConstantFP(),llvm::BinaryOperation::eval(),llvm::TargetLowering::expandDIVREMByConstant(),extractConstantWithoutWrapping(),extractShiftForRotate(),llvm::InstCombinerImpl::foldAddLikeCommutative(),llvm::SelectionDAG::FoldConstantArithmetic(),llvm::InstCombinerImpl::foldICmpAndConstConst(),llvm::InstCombinerImpl::foldICmpDivConstant(),llvm::InstCombinerImpl::foldICmpEquality(),llvm::InstCombinerImpl::foldICmpShlConstConst(),foldNoWrapAdd(),foldSelectICmpAnd(),FoldValueWithUndef(),getAVX512Node(),llvm::detail::SlowDynamicAPInt::getBitWidth(),llvm::ConstantInt::getBitWidth(),llvm::KnownBits::getBitWidth(),llvm::ExecutionEngine::getConstantValue(),getConstVector(),getFauxShuffleMask(),llvm::getHorizDemandedEltsForFirstOperand(),llvm::SwitchCG::getJumpTableRange(),getKnownUndefForVectorBinop(),llvm::SelectionDAG::getNode(),llvm::ScalarEvolution::getNonZeroConstantMultiple(),getPackDemandedElts(),llvm::getPtrStride(),GetQuadraticEquation(),getRangeForAffineARHelper(),llvm::BuildVectorSDNode::getRepeatedSequence(),llvm::BasicTTIImplBase< T >::getReplicationShuffleCost(),llvm::X86TTIImpl::getScalarizationOverhead(),getShiftAmount(),llvm::BuildVectorSDNode::getSplatValue(),llvm::SelectionDAG::getStepVector(),getStrideFromPointer(),getTargetConstantBitsFromNode(),getUsefulBits(),getUsefulBitsForUse(),getUsefulBitsFromAndWithImmediate(),getUsefulBitsFromBFM(),getUsefulBitsFromBitfieldMoveOpd(),llvm::SelectionDAG::getVScale(),insertBits(),llvm::ConstantRange::intrinsic(),llvm::TargetTransformInfoImplBase::isConstantStridedAccessLessThan(),llvm::TargetLowering::isConstTrueVal(),llvm::SelectionDAG::isGuaranteedNotToBeUndefOrPoison(),llvm::X86TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(),llvm::ARMTTIImpl::isHardwareLoopProfitable(),isKnownNonZero(),isKnownNonZeroFromOperator(),isMultiple(),isPoisonShift(),isSameValue(),isSaturatingMinMax(),isSplat(),llvm::SelectionDAG::isSplatValue(),llvm::X86TargetLowering::isSplatValueForTargetNode(),LowerVectorAllEqual(),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::SCEVDivision::visitConstant(), andllvm::InstCombinerImpl::visitICmpInst().

◆ getBoolValue()

bool llvm::APInt::getBoolValue() const
inline

ConvertAPInt to a boolean value.

This converts theAPInt to a boolean value as a test against zero.

Definition at line471 of fileAPInt.h.

ReferencesisZero().

Referenced byllvm::KnownBits::computeForAddCarry(),llvm::KnownBits::computeForSubBorrow(),llvm::APFixedPoint::getBoolValue(),getPowerOf2Factor(),getTargetConstantBitsFromNode(),llvm::ConstantRange::intrinsic(),isDereferenceableAndAlignedPointer(),llvm::isKnownToBeAPowerOfTwo(),provablyDisjointOr(),llvm::PPCTargetLowering::SelectAddressRegReg(),simplifyAndOfICmpsWithAdd(),simplifyOrOfICmpsWithAdd(),toString(), andwalkToAllocaAndPrependOffsetDeref().

◆ getHiBits()

APInt APInt::getHiBits(unsigned numBits) const

Compute anAPInt containing numBits highbits from thisAPInt.

This function returns the high "numBits" bits of thisAPInt.

Get anAPInt with the same BitWidth as thisAPInt, just zero mask the low bits and right shift to the least significant bit.

Returns
the high "numBits" bits of thisAPInt.

Definition at line612 of fileAPInt.cpp.

Referenceslshr().

Referenced byllvm::SelectionDAG::computeKnownBits(),parseHexOcta(), andWriteAPFloatInternal().

◆ getHighBitsSet()

staticAPInt llvm::APInt::getHighBitsSet(unsigned numBits,
unsigned hiBitsSet 
)
inlinestatic

Constructs anAPInt value that has the top hiBitsSet bits set.

Parameters
numBitsthe bitwidth of the result
hiBitsSetthe number of high-order bits set in the result.

Definition at line296 of fileAPInt.h.

ReferencessetHighBits().

Referenced bycanEvaluateZExtd(),combineAnd(),combineCMP(),combineMulToPMADDWD(),combineMulToPMULDQ(),combineOr(),combineTargetShuffle(),combineVectorPack(),combineZext(),llvm::ARMTargetLowering::computeKnownBitsForTargetNode(),llvm::AArch64TargetLowering::computeKnownBitsForTargetNode(),llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(),llvm::X86TargetLowering::computeKnownBitsForTargetNode(),llvm::computeKnownBitsFromRangeMetadata(),computeShlNUW(),ConstantBuildVector(),EmitCmp(),llvm::TargetLowering::expandFixedPointMul(),llvm::TargetLowering::expandMUL_LOHI(),llvm::InstCombinerImpl::foldAddWithConstant(),llvm::InstCombinerImpl::foldICmpAndConstConst(),llvm::InstCombinerImpl::foldICmpEqIntrinsicWithConstant(),llvm::InstCombinerImpl::foldICmpShrConstant(),llvm::InstCombinerImpl::foldICmpTruncConstant(),foldMaskAndShiftToScale(),foldShiftedShift(),getFauxShuffleMask(),getValueFromICmpCtpop(),isFPSatMinMaxPattern(),llvm::AArch64TTIImpl::isProfitableToSinkOperands(),isTruncWithZeroHighBitsInput(),LowerFunnelShift(),LowerMUL(),LowerShiftByScalarImmediate(),llvm::AMDGPUTargetLowering::LowerUDIVREM64(),matchShuffleWithPACK(),llvm::ARMTargetLowering::PerformDAGCombine(),PerformSHLSimplify(),PerformVMOVNCombine(),PerformVQMOVNCombine(),llvm::RISCVTargetLowering::ReplaceNodeResults(),SaturateWidenedDIVFIX(),selectUmullSmull(),llvm::LoongArchDAGToDAGISel::selectZExti32(),setLimitsForBinOp(),llvm::ConstantRange::signExtend(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),llvm::ARMTTIImpl::simplifyDemandedVectorEltsIntrinsic(),llvm::TargetLowering::SimplifySetCC(),simplifyUnaryIntrinsic(),tryLowerToSLI(),llvm::InstCombinerImpl::visitBitCast(),llvm::InstCombinerImpl::visitShl(),llvm::InstCombinerImpl::visitSub(), andllvm::InstCombinerImpl::visitZExt().

◆ getLimitedValue()

uint64_t llvm::APInt::getLimitedValue(uint64_t Limit =UINT64_MAX) const
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 line475 of fileAPInt.h.

Referenced byadjustByValArgAlignment(),ashrInPlace(),decompose(),extractBits(),llvm::InstCombinerImpl::foldICmpEquality(),llvm::InstCombinerImpl::foldICmpShlConstant(),llvm::InstCombinerImpl::foldICmpShrConstant(),llvm::InstCombinerImpl::foldICmpXorShiftConst(),getAssignmentInfoImpl(),llvm::ConstantInt::getLimitedValue(),getMaxShiftAmount(),llvm::BlockFrequencyInfoImplBase::getProfileCountFromFreq(),getUnsigned(),getValueFromICmpCtpop(),isConstantSplatVectorMaskForType(),lshrInPlace(),operator<<=(),ParseBFI(),rotateModulo(),llvm::scaleProfData(),setShiftFlags(),simplifyAndInst(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),simplifySetCCWithCTPOP(),sshl_ov(),switchToLookupTable(), andushl_ov().

◆ getLoBits()

APInt APInt::getLoBits(unsigned numBits) const

Compute anAPInt containing numBits lowbits from thisAPInt.

This function returns the low "numBits" bits of thisAPInt.

Get anAPInt with the same BitWidth as thisAPInt, just zero mask the high bits.

Returns
the low "numBits" bits of thisAPInt.

Definition at line617 of fileAPInt.cpp.

ReferencesgetLowBitsSet().

Referenced bymatchRotateSub(),llvm::KnownBits::mul(),parseHexOcta(),llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), andWriteAPFloatInternal().

◆ getLowBitsSet()

staticAPInt llvm::APInt::getLowBitsSet(unsigned numBits,
unsigned loBitsSet 
)
inlinestatic

Constructs anAPInt value that has the bottom loBitsSet bits set.

Parameters
numBitsthe bitwidth of the result
loBitsSetthe number of low-order bits set in the result.

Definition at line306 of fileAPInt.h.

ReferencessetLowBits().

Referenced bybuildBitFieldInsert(),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::forceExpandMultiply(),llvm::UnsignedDivisionByConstantInfo::get(),getLoBits(),getShiftedValue(),getTruncatedUSUBSAT(),getValueFromICmpCtpop(),llvm::SelectionDAG::getVPZeroExtendInReg(),llvm::SelectionDAG::getZeroExtendInReg(),llvm::ARMTTIImpl::instCombineIntrinsic(),llvm::X86TTIImpl::instCombineIntrinsic(),lowerBuildVectorViaPacking(),LowerEXTEND_VECTOR_INREG(),llvm::LegalizerHelper::lowerFCopySign(),LowerFunnelShift(),LowerMUL(),LowerShiftByScalarImmediate(),matchRotateSub(),MatchVectorAllEqualTest(),ParseBFI(),llvm::ARMTargetLowering::PerformDAGCombine(),llvm::RISCVTargetLowering::PerformDAGCombine(),llvm::ARMTargetLowering::PerformIntrinsicCombine(),PerformPREDICATE_CASTCombine(),performTBISimplification(),performTruncateCombine(),performVectorShiftCombine(),PerformVMOVhrCombine(),PerformVMOVNCombine(),PerformVQMOVNCombine(),performZExtUZPCombine(),processUGT_ADDCST_ADD(),SaturateWidenedDIVFIX(),llvm::TargetLowering::scalarizeVectorLoad(),llvm::ConstantRange::signExtend(),simplifyAndInst(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),llvm::ARMTTIImpl::simplifyDemandedVectorEltsIntrinsic(),simplifyMul24(),llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(),llvm::TargetLowering::SimplifySetCC(),simplifyX86insertq(),simplifyX86pack(),simplifyX86VPERMMask(),llvm::X86TargetLowering::targetShrinkDemandedConstant(),tryLowerToSLI(),llvm::InstCombinerImpl::visitAnd(),llvm::InstCombinerImpl::visitCallInst(),llvm::InstCombinerImpl::visitLShr(),llvm::InstCombinerImpl::visitSwitchInst(), andllvm::InstCombinerImpl::visitZExt().

◆ getMaxValue()

staticAPInt llvm::APInt::getMaxValue(unsigned numBits)
inlinestatic

Gets maximum unsigned value ofAPInt for specific bit width.

Definition at line206 of fileAPInt.h.

Referenced byllvm::calculateUpperBound(),llvm::cannotBeMaxInLoop(),llvm::ConstantRange::castOp(),computeForSatAddSub(),detectSSatUPattern(),detectUSatUPattern(),llvm::TargetLowering::expandFixedPointMul(),llvm::TargetLowering::expandFP_TO_INT_SAT(),llvm::TargetLowering::expandShlSat(),foldBoxMultiply(),llvm::InstCombinerImpl::foldFCmpIntToFPConst(),llvm::InstCombinerImpl::foldICmpAddOpConst(),llvm::SCEVExpander::generateOverflowCheck(),getIdentityValueForAtomicOp(),llvm::getMinMaxLimit(),getRangeForAffineARHelper(),getRangeForIntrinsic(),llvm::MinMaxIntrinsic::getSaturationPoint(),llvm::ScalarEvolution::getTripCountFromExitCount(),llvm::ConstantRange::getUnsignedMax(),llvm::ScalarEvolution::getZeroExtendExprImpl(),isSafeIncreasingBound(),llvm::ConstantRange::isSizeLargerThan(),llvm::LegalizerHelper::lowerFPTOINT_SAT(),llvm::LegalizerHelper::lowerShlSat(),llvm::fuzzerop::makeConstantsWithType(),makeExactMulNUWRegion(),llvm::ConstantRange::makeGuaranteedNoWrapRegion(),llvm::X86InstrInfo::optimizeCompareInstr(),processUMulZExtIdiom(),setLimitsForBinOp(),llvm::TargetLowering::SimplifySetCC(),llvm::ConstantRange::truncate(),truncUSat(),uadd_sat(),umul_sat(),ushl_sat(), andllvm::ScalarEvolution::willNotOverflow().

◆ getMinValue()

staticAPInt llvm::APInt::getMinValue(unsigned numBits)
inlinestatic

Gets minimum unsigned value ofAPInt for a specific bit width.

Definition at line216 of fileAPInt.h.

Referenced byllvm::cannotBeMinInLoop(),llvm::ConstantRange::castOp(),computeForSatAddSub(),llvm::TargetLowering::expandFP_TO_INT_SAT(),llvm::InstCombinerImpl::foldFCmpIntToFPConst(),getIdentityValueForAtomicOp(),llvm::getMinMaxLimit(),llvm::MinMaxIntrinsic::getSaturationPoint(),llvm::ConstantRange::getUnsignedMin(),getUnsignedOverflowLimitForStep(),isSafeDecreasingBound(),llvm::LegalizerHelper::lowerFPTOINT_SAT(),llvm::ConstantRange::makeAllowedICmpRegion(),llvm::fuzzerop::makeConstantsWithType(),makeExactMulNUWRegion(),llvm::ConstantRange::makeGuaranteedNoWrapRegion(),llvm::TargetLowering::SimplifySetCC(), andllvm::ScalarEvolution::willNotOverflow().

◆ getNumSignBits()

unsigned llvm::APInt::getNumSignBits() const
inline

Computes the number of leading bits of thisAPInt that are equal to its sign bit.

Definition at line1607 of fileAPInt.h.

Referencesllvm::countl_one(), andllvm::countl_zero().

Referenced byllvm::SelectionDAG::computeKnownBits(),llvm::SelectionDAG::ComputeNumSignBits(),computeNumSignBitsFromRangeMetadata(),ComputeNumSignBitsImpl(),llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), andllvm::X86TargetLowering::targetShrinkDemandedConstant().

◆ getNumWords()[1/2]

unsigned llvm::APInt::getNumWords() const
inline

Get the number of words.

Here one word's bitwidth equals to that of uint64_t.

Returns
the number of words to hold the integer value of thisAPInt.

Definition at line1475 of fileAPInt.h.

ReferencesBitWidth, andgetNumWords().

Referenced bybyteSwap(),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(), andzext().

◆ getNumWords()[2/2]

staticunsigned llvm::APInt::getNumWords(unsigned BitWidth)
inlinestatic

Get the number of words.

NOTE Here one word's bitwidth equals to that of uint64_t.

Returns
the number of words to hold the integer value with a given bit width.

Definition at line1483 of fileAPInt.h.

ReferencesBitWidth.

◆ getOneBitSet()

staticAPInt llvm::APInt::getOneBitSet(unsigned numBits,
unsigned BitNo 
)
inlinestatic

Return anAPInt with exactly one bit set in the result.

Definition at line239 of fileAPInt.h.

ReferencessetBit().

Referenced byBinomialCoefficient(),llvm::TargetLowering::BuildUDIV(),llvm::CombinerHelper::buildUDivUsingMul(),llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(),combineCMP(),combineShiftAnd1ToBitTest(),llvm::InstCombinerImpl::commonIDivTransforms(),llvm::SelectionDAG::computeKnownBits(),llvm::ARMTargetLowering::computeKnownBitsForTargetNode(),llvm::X86TargetLowering::computeKnownBitsForTargetNode(),computeKnownBitsFromOperator(),computeKnownFPClass(),llvm::SelectionDAG::ComputeNumSignBits(),llvm::SelectionDAG::computeVectorKnownZeroElements(),llvm::TargetLowering::expandBITREVERSE(),llvm::TargetLowering::expandDIVREMByConstant(),llvm::TargetLowering::expandIS_FPCLASS(),extractShiftForRotate(),findDemandedEltsBySingleUser(),llvm::InstCombinerImpl::foldICmpEqIntrinsicWithConstant(),llvm::InstCombinerImpl::foldICmpEquality(),llvm::InstCombinerImpl::foldICmpIntrinsicWithConstant(),llvm::InstCombinerImpl::foldICmpShlConstant(),foldSelectICmpAndBinOp(),llvm::ScalarEvolution::getPowerOfTwo(),getStrideAndModOffsetOfGEP(),llvm::ARMTTIImpl::instCombineIntrinsic(),isKnownNonZeroFromOperator(),llvm::SelectionDAG::isSplatValue(),lowerFTRUNC_FCEIL_FFLOOR_FROUND(),llvm::LegalizerHelper::lowerISFPCLASS(),LowerShift(),lowerVectorFTRUNC_FCEIL_FFLOOR_FROUND(),lowerVectorStrictFTRUNC_FCEIL_FFLOOR_FROUND(),llvm::fuzzerop::makeConstantsWithType(),llvm::ConstantRange::makeMaskNotEqualRange(),matchBinaryOp(),MatchBinaryOp(),matchBinaryShuffle(),performSETCCCombine(),processUMulZExtIdiom(),scalarizeMaskedCompressStore(),scalarizeMaskedExpandLoad(),scalarizeMaskedGather(),scalarizeMaskedLoad(),scalarizeMaskedScatter(),scalarizeMaskedStore(),setLimitsForBinOp(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::TargetLowering::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),simplifyIntrinsic(),llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(),simplifyX86immShift(),SolveLinEquationWithOverflow(),llvm::APIntOps::SolveQuadraticEquationWrap(),llvm::InstCombinerImpl::visitICmpInst(),llvm::LegalizerHelper::widenScalar(), andllvm::ConstantRange::zeroExtend().

◆ getRawData()

constuint64_t * llvm::APInt::getRawData() const
inline

This function returns a pointer to the internal storage of theAPInt.

This is useful for writing out theAPInt in binary form without any conversions.

Definition at line569 of fileAPInt.h.

Referenced byllvm::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(), andzext().

◆ getSExtValue()

int64_t llvm::APInt::getSExtValue() const
inline

Get sign extended value.

This method attempts to return the value of thisAPInt 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 line1542 of fileAPInt.h.

Referencesassert(),BitWidth, andllvm::SignExtend64().

Referenced byllvm::DwarfUnit::addConstantValue(),llvm::InterleavedAccessInfo::analyzeInterleaving(),llvm::TargetLowering::BuildSDIV(),checkIfSafeAddSequence(),combineAndOrForCcmpCtest(),combineX86SubCmpForFlags(),emitConstantRange(),llvm::TargetTransformInfoImplCRTPBase< T >::getGEPCost(),llvm::CoroSubFnInst::getIndex(),llvm::AArch64TTIImpl::getIntImmCost(),llvm::X86TTIImpl::getIntImmCost(),llvm::RISCVMatInt::getIntMatCost(),getMinimalBaseOfPointer(),llvm::GetPointerBaseWithConstantOffset(),llvm::getPointersDiff(),llvm::getPtrStride(),getSalvageOpsForGEP(),llvm::ConstantInt::getSExtValue(),getStrideFromPointer(),llvm::remarks::Argument::getValAsInt(),getVShiftImm(),instCombineSVESDIV(),llvm::TargetTransformInfoImplBase::isConstantStridedAccessLessThan(),llvm::RISCVTargetLowering::isDesirableToCommuteWithShift(),llvm::SIInstrInfo::isInlineConstant(),llvm::AArch64TargetLowering::isMulAddWithConstProfitable(),llvm::ARMTargetLowering::isMulAddWithConstProfitable(),isSimpleVIDSequence(),LLVMGenericValueToInt(),llvm::AsmPrinter::lowerConstant(),llvm::CombinerHelper::matchPtrAddImmedChain(),rotateSign(),llvm::RISCVDAGToDAGISel::Select(),llvm::RISCVDAGToDAGISel::selectScalarFPAsInt(),llvm::LoongArchDAGToDAGISel::selectVSplatImm(),selectVSplatImmHelper(),llvm::LoopVectorizationCostModel::setVectorizedCallDecision(),llvm::TargetLowering::SimplifySetCC(),toString(),tryCombineShiftImm(), andtryFoldHelper().

◆ getSignedMaxValue()

staticAPInt llvm::APInt::getSignedMaxValue(unsigned numBits)
inlinestatic

Gets maximum signed value ofAPInt for a specific bit width.

Definition at line209 of fileAPInt.h.

ReferencesclearBit().

Referenced byllvm::calculateUpperBound(),llvm::cannotBeMaxInLoop(),llvm::ConstantRange::castOp(),combineMinMaxReduction(),combineTruncToVnclip(),computeForSatAddSub(),detectSSatPattern(),detectSSatSPattern(),llvm::TargetLowering::expandAddSubSat(),llvm::TargetLowering::expandFixedPointMul(),llvm::TargetLowering::expandFP_TO_INT_SAT(),llvm::TargetLowering::expandIS_FPCLASS(),llvm::TargetLowering::expandRoundInexactToOdd(),llvm::TargetLowering::expandShlSat(),llvm::InstCombinerImpl::foldFCmpIntToFPConst(),llvm::InstCombinerImpl::foldICmpAddConstant(),llvm::InstCombinerImpl::foldICmpAddOpConst(),foldICmpXNegX(),llvm::UnsignedDivisionByConstantInfo::get(),getIdentityValueForAtomicOp(),llvm::ConstantExpr::getIntrinsicIdentity(),llvm::getMinMaxLimit(),llvm::SelectionDAG::getNeutralElement(),getRangeForIntrinsic(),getRangeForSelectPattern(),llvm::MinMaxIntrinsic::getSaturationPoint(),llvm::ConstantRange::getSignedMax(),getSignedOverflowLimitForStep(),isNonZeroAdd(),isSafeIncreasingBound(),LowerADDSAT_SUBSAT(),llvm::LegalizerHelper::lowerAddSubSatToMinMax(),llvm::LegalizerHelper::lowerFAbs(),LowerFABSorFNEG(),lowerFABSorFNEG(),LowerFCOPYSIGN(),lowerFCOPYSIGN(),llvm::LegalizerHelper::lowerFPTOINT_SAT(),llvm::LegalizerHelper::lowerISFPCLASS(),llvm::LegalizerHelper::lowerShlSat(),llvm::fuzzerop::makeConstantsWithType(),makeExactMulNSWRegion(),llvm::ConstantRange::makeGuaranteedNoWrapRegion(),llvm::X86InstrInfo::optimizeCompareInstr(),sadd_sat(),llvm::KnownBits::sdiv(),setLimitsForBinOp(),llvm::ConstantRange::signedAddMayOverflow(),llvm::ConstantRange::signedSubMayOverflow(),llvm::TargetLowering::SimplifySetCC(),simplifyX86pack(),smul_sat(),sshl_sat(),ssub_sat(),truncSSat(),llvm::LegalizerHelper::widenScalar(), andllvm::ScalarEvolution::willNotOverflow().

◆ getSignedMinValue()

staticAPInt llvm::APInt::getSignedMinValue(unsigned numBits)
inlinestatic

Gets minimum signed value ofAPInt for a specific bit width.

Definition at line219 of fileAPInt.h.

ReferencessetBit().

Referenced byllvm::ConstantRange::abs(),llvm::cannotBeMinInLoop(),canonicalizeForInvariantConditionInjection(),llvm::ConstantRange::castOp(),combineMinMaxReduction(),combineTruncToVnclip(),computeForSatAddSub(),detectSSatPattern(),detectSSatSPattern(),llvm::TargetLowering::expandAddSubSat(),llvm::TargetLowering::expandFixedPointMul(),llvm::TargetLowering::expandFP_TO_INT_SAT(),llvm::TargetLowering::expandShlSat(),foldAddToAshr(),llvm::InstCombinerImpl::foldFCmpIntToFPConst(),llvm::InstCombinerImpl::foldICmpAddConstant(),llvm::InstCombinerImpl::foldICmpAndConstant(),llvm::InstCombinerImpl::foldICmpCommutative(),foldMinimumOverTrailingOrLeadingZeroCount(),llvm::SignedDivisionByConstantInfo::get(),llvm::UnsignedDivisionByConstantInfo::get(),getIdentityValueForAtomicOp(),llvm::ConstantExpr::getIntrinsicIdentity(),llvm::getMinMaxLimit(),llvm::ScalarEvolution::getMulExpr(),llvm::SelectionDAG::getNeutralElement(),getRangeForIntrinsic(),getRangeForSelectPattern(),llvm::MinMaxIntrinsic::getSaturationPoint(),llvm::RecurrenceDescriptor::getSentinelValue(),llvm::ConstantRange::getSignedMin(),getSignedOverflowLimitForStep(),llvm::RecurrenceDescriptor::isFindLastIVPattern(),isSafeDecreasingBound(),LowerADDSAT_SUBSAT(),llvm::LegalizerHelper::lowerAddSubSatToAddoSubo(),llvm::LegalizerHelper::lowerAddSubSatToMinMax(),llvm::LegalizerHelper::lowerFPTOINT_SAT(),llvm::LegalizerHelper::lowerShlSat(),llvm::ConstantRange::makeAllowedICmpRegion(),llvm::fuzzerop::makeConstantsWithType(),makeExactMulNSWRegion(),llvm::ConstantRange::makeGuaranteedNoWrapRegion(),llvm::ConstantRange::multiplyWithNoWrap(),narrowSDivOrSRem(),llvm::X86InstrInfo::optimizeCompareInstr(),processAbsIntrinsic(),sadd_sat(),llvm::ConstantRange::sdiv(),llvm::RISCVDAGToDAGISel::Select(),setLimitsForBinOp(),llvm::ConstantRange::signedAddMayOverflow(),llvm::ConstantRange::signedSubMayOverflow(),llvm::TargetLowering::SimplifySetCC(),simplifyX86pack(),smul_sat(),sshl_sat(),ssub_sat(),truncSSat(),llvm::InstCombinerImpl::visitCallInst(),llvm::InstCombinerImpl::visitSDiv(),llvm::LegalizerHelper::widenScalar(), andllvm::ScalarEvolution::willNotOverflow().

◆ getSignificantBits()

unsigned llvm::APInt::getSignificantBits() const
inline

Get the minimum bit size for this signedAPInt.

Computes the minimum bit width for thisAPInt while considering it to be a signed (and probably negative) value. If the value is not negative, this function returns the same value asgetActiveBits()+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 line1511 of fileAPInt.h.

ReferencesBitWidth.

Referenced byllvm::APSInt::APSInt(),canFoldIVIncExpr(),combineShiftRightLogical(),eliminateDeadSwitchCases(),llvm::RISCVTargetLowering::isDesirableToCommuteWithShift(),rebuildExtCst(),llvm::TargetLowering::SimplifySetCC(),llvm::RISCVTargetLowering::targetShrinkDemandedConstant(), andllvm::InstCombinerImpl::visitSDiv().

◆ getSignMask()

staticAPInt llvm::APInt::getSignMask(unsigned BitWidth)
inlinestatic

Get the SignMask for a specific bit width.

This is just a wrapper function ofgetSignedMinValue(), and it helps code readability when we want to get a SignMask.

Definition at line229 of fileAPInt.h.

ReferencesBitWidth.

Referenced bycheckSignTestSetCCCombine(),combineAVG(),combineGatherScatter(),combineMaskedLoad(),combineMaskedStore(),combinePTESTCC(),combineStore(),combineVSelectToBLENDV(),combineX86GatherScatter(),computeShlNSWWithNegLHS(),llvm::decomposeBitTestICmp(),llvm::TargetLowering::expandFP_TO_SINT(),llvm::TargetLowering::expandFP_TO_UINT(),llvm::TargetLowering::expandIS_FPCLASS(),llvm::TargetLowering::expandRoundInexactToOdd(),foldAndToUsubsat(),llvm::InstCombinerImpl::foldICmpSRemConstant(),getDemandedBitsLHSMask(),llvm::LegalizerHelper::lower(),LowerFABSorFNEG(),lowerFABSorFNEG(),llvm::LegalizerHelper::lowerFCopySign(),LowerFCOPYSIGN(),lowerFCOPYSIGN(),llvm::LegalizerHelper::lowerFPTOSI(),llvm::LegalizerHelper::lowerFPTOUI(),llvm::LegalizerHelper::lowerISFPCLASS(),LowerShift(),LowerVSETCC(),llvm::RISCVTargetLowering::PerformDAGCombine(),llvm::GISelKnownBits::signBitIsZero(),llvm::SelectionDAG::SignBitIsZero(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::InstCombinerImpl::visitAShr(),llvm::InstCombinerImpl::visitCallInst(),llvm::InstCombinerImpl::visitShl(), andllvm::InstCombinerImpl::visitSRem().

◆ getSplat()

APInt APInt::getSplat(unsigned NewLen,
constAPIntV 
)
static

Return a value containing V broadcasted over NewLen bits.

Definition at line624 of fileAPInt.cpp.

Referencesassert(), andI.

Referenced bycombineAddOfPMADDWD(),combineSubShiftToOrcB(),computeKnownBitsForPMADDUBSW(),computeKnownBitsForPMADDWD(),llvm::TargetLowering::expandBITREVERSE(),llvm::TargetLowering::expandCTPOP(),llvm::TargetLowering::expandVPBITREVERSE(),llvm::TargetLowering::expandVPCTPOP(),extractConstantBits(),getAvailableLoadStore(),llvm::VNCoercion::getConstantMemInstValueForLoad(),getMemsetValue(),getTargetConstantBitsFromNode(),llvm::X86TTIImpl::instCombineIntrinsic(),llvm::SelectionDAG::isSplatValue(),llvm::LegalizerHelper::lowerBitCount(),llvm::LegalizerHelper::lowerBitreverse(),LowerShift(),PerformVMOVNCombine(),PerformVQMOVNCombine(),llvm::InstCombinerImpl::SimplifyAnyMemSet(),llvm::ARMTTIImpl::simplifyDemandedVectorEltsIntrinsic(),llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), andtryToRecognizePopCount().

◆ getSufficientBitsNeeded()

unsigned APInt::getSufficientBitsNeeded(StringRef Str,
uint8_t Radix 
)
static

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 line517 of fileAPInt.cpp.

Referencesassert().

Referenced bygetBitsNeeded().

◆ getZero()

staticAPInt llvm::APInt::getZero(unsigned numBits)
inlinestatic

Get the '0' value for the specified bit-width.

Definition at line200 of fileAPInt.h.

Referenced byllvm::ConstantRange::abs(),adjustByValArgAlignment(),llvm::SwitchCG::SwitchLowering::buildBitTests(),llvm::TargetLowering::BuildUDIV(),llvm::CombinerHelper::buildUDivUsingMul(),cmpExcludesZero(),combineCONCAT_VECTORS(),combineConcatVectorOps(),combineMOVMSK(),combineOr(),combineShuffleToZeroExtendVectorInReg(),combineVectorCompare(),combineVectorPack(),combineX86ShuffleChain(),combineX86ShufflesConstants(),combineX86ShufflesRecursively(),llvm::ObjectSizeOffsetVisitor::compute(),llvm::SelectionDAG::computeKnownBits(),computeKnownBitsFromOperator(),llvm::SelectionDAG::ComputeNumSignBits(),computeShlNSW(),llvm::SelectionDAG::computeVectorKnownZeroElements(),computeZeroableShuffleElements(),llvm::ConstantFoldCastInstruction(),llvm::ConstantRange::ctlz(),llvm::ConstantRange::ctpop(),llvm::ConstantRange::cttz(),llvm::decomposeBitTestICmp(),detectSSatPattern(),EltsFromConsecutiveLoads(),estimateBitMaskedAndLowerBound(),llvm::TargetLowering::expandFP_TO_UINT(),extractConstantBits(),llvm::SelectionDAG::FoldConstantArithmetic(),foldCtpop(),foldICmpUSubSatOrUAddSatWithConstant(),foldSelectICmpLshrAshr(),foldSwitchToSelect(),FoldValueWithUndef(),llvm::SCEVExpander::generateOverflowCheck(),llvm::BuildVectorSDNode::getConstantRawBits(),getConstVector(),getDomain(),getElementIndex(),getExtractedDemandedElts(),llvm::getHorizDemandedEltsForFirstOperand(),llvm::TargetTransformInfoImplCRTPBase< T >::getInstructionCost(),llvm::BasicTTIImplBase< T >::getInterleavedMemoryOpCost(),llvm::X86TTIImpl::getInterleavedMemoryOpCostAVX512(),llvm::APFixedPoint::getIntPart(),llvm::BasicTTIImplBase< T >::getIntrinsicInstrCost(),getKnownUndefForVectorBinop(),getPackDemandedElts(),getRangeForIntrinsic(),getRangeForSelectPattern(),llvm::getShuffleDemandedElts(),getSizeWithOverflow(),getSplatableConstant(),getTargetConstantBitsFromNode(),getTargetShuffleAndZeroables(),llvm::slpvectorizer::BoUpSLP::getTreeCost(),getUnsignedCountTrailingZerosRange(),llvm::getVScaleRange(),isCompletePermute(),llvm::X86TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(),llvm::ShuffleVectorInst::isInsertSubvectorMask(),isKnownNonZeroFromOperator(),llvm::SelectionDAG::isSplatValue(),llvm::X86TargetLowering::isSplatValueForTargetNode(),isTargetShuffleEquivalent(),LowerFMINIMUM_FMAXIMUM(),llvm::LegalizerHelper::lowerFPTOUI(),LowerShift(),lowerShuffleAsElementInsertion(),lowerShuffleAsLanePermuteAndPermute(),llvm::ConstantRange::makeAllowedICmpRegion(),llvm::ConstantRange::makeGuaranteedNoWrapRegion(),llvm::detail::IEEEFloat::makeNaN(),matchBinaryShuffle(),matchScalarReduction(),MatchVectorAllEqualTest(),llvm::ConstantRange::multiply(),llvm::ConstantRange::multiplyWithNoWrap(),rebuildExtCst(),llvm::BuildVectorSDNode::recastRawBits(),resolveZeroablesFromTargetShuffle(),scalarConstantToHexString(),llvm::APIntOps::ScaleBitMask(),llvm::ConstantRange::sdiv(),llvm::ConstantRange::shl(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::TargetLowering::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),llvm::TargetLowering::SimplifyMultipleUseDemandedBits(),simplifyX86pack(),llvm::ConstantRange::srem(),stripAndComputeConstantOffsets(),llvm::ConstantRange::urem(), andllvm::reassociate::XorOpnd::XorOpnd().

◆ getZeroWidth()

staticAPInt llvm::APInt::getZeroWidth()
inlinestatic

Return anAPInt zero bits wide.

Definition at line203 of fileAPInt.h.

◆ getZExtValue()

uint64_t llvm::APInt::getZExtValue() const
inline

Get zero extended value.

This method attempts to return the value of thisAPInt 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 line1520 of fileAPInt.h.

Referencesassert().

Referenced byllvm::DwarfExpression::addConstantFP(),llvm::DwarfUnit::addConstantValue(),llvm::CombinerHelper::applyFunnelShiftConstantModulo(),llvm::buildSelectInst(),canEvaluateShiftedShift(),canEvaluateZExtd(),collectBitParts(),combineCMov(),combineCMP(),combineExtractWithShuffle(),llvm::PPCInstrInfo::combineRLWINM(),combineTargetShuffle(),CombineVMOVDRRCandidateWithVecOp(),llvm::InstCombinerImpl::commonIDivTransforms(),llvm::ProfileSummaryBuilder::computeDetailedSummary(),computeFlagsForAddressComputation(),llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(),llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(),computeKnownBitsFromOperator(),llvm::X86TargetLowering::ComputeNumSignBitsForTargetNode(),ComputeNumSignBitsImpl(),convertIntToDoubleImm(),llvm::TargetLowering::CTTZTableLookup(),DecodeXR32RegisterClass(),llvm::Interpreter::exitCalled(),llvm::extractConstantMask(),extractShiftForRotate(),llvm::InstCombinerImpl::foldICmpShlConstant(),llvm::InstCombinerImpl::foldICmpTruncConstant(),foldLoadsRecursive(),foldSelectICmpAndZeroShl(),llvm::InstCombinerImpl::FoldShiftByConstant(),foldShiftedShift(),foldSubCtlzNot(),foldVecExtTruncToExtElt(),llvm::generateSpecConstantInst(),getArrayComponentCount(),getConstant(),llvm::ExecutionEngine::getConstantValue(),llvm::getConstFromIntrinsic(),llvm::getExpressionForConstant(),llvm::getObjectSize(),llvm::SelectionDAG::getShiftAmountConstant(),llvm::ScalarEvolution::getSmallConstantTripMultiple(),llvm::GStepVector::getStep(),llvm::AArch64TargetMachine::getSubtargetImpl(),getVariantMatchScore(),llvm::ConstantInt::getZExtValue(),llvm::mca::initializeUsedResources(),llvm::GCNTTIImpl::instCombineIntrinsic(),isEXTMask(),llvm::AArch64TargetLowering::isFPImmLegal(),isKnownTypeIdMember(),llvm::AArch64TargetLowering::isMulAddWithConstProfitable(),llvm::ARMTargetLowering::isMulAddWithConstProfitable(),llvm::SystemZVectorConstantInfo::isVectorConstantLegal(),LLVMGenericValueToInt(),LowerShiftByScalarImmediate(),matchAndOrChain(),matchIntPart(),matchPMADDWD(),matchPMADDWD_2(),narrowIndex(),optimizeIncrementingWhile(),optimizeLogicalImm(),parseHexOcta(),parseJumpTable(),PerformANDCombine(),llvm::AMDGPUTargetLowering::PerformDAGCombine(),performDSPShiftCombine(),performMulCombine(),PerformORCombine(),PerformSHLSimplify(),llvm::X86TargetLowering::preferedOpcodeForCmpEqPiecesOfOperand(),printConstant(),llvm::NVPTXFloatMCExpr::printImpl(),llvm::ExecutionEngine::runFunctionAsMain(),llvm::PPCTargetLowering::SelectAddressRegImm(),llvm::PPCTargetLowering::SelectAddressRegImm34(),llvm::LoopVectorizationPlanner::selectEpilogueVectorizationFactor(),selectI64ImmDirect(),selectI64ImmDirectPrefix(),llvm::LoongArchDAGToDAGISel::selectVSplatImm(),llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(),llvm::InstCombinerImpl::simplifyShrShlDemandedBits(),simplifyX86extrq(),simplifyX86insertq(),simplifyX86varShift(),splitGlobal(),llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(),toString(),toString(),tryBitfieldInsertOpFromOrAndImm(),tryCombineToBSL(),llvm::tryPromoteCall(),urem(),llvm::Interpreter::visitAllocaInst(),llvm::InstCombinerImpl::visitAnd(),llvm::Interpreter::visitAShr(),llvm::InstCombinerImpl::visitAShr(),llvm::Interpreter::visitExtractElementInst(),llvm::Interpreter::visitInsertElementInst(),llvm::Interpreter::visitLShr(),llvm::InstCombinerImpl::visitLShr(),llvm::Interpreter::visitShl(),llvm::InstCombinerImpl::visitShl(),walkToAllocaAndPrependOffsetDeref(), andWriteAPFloatInternal().

◆ insertBits()[1/2]

void APInt::insertBits(constAPIntSubBits,
unsigned bitPosition 
)

Insert the bits from a smallerAPInt starting at bitPosition.

Definition at line370 of fileAPInt.cpp.

ReferencesAPINT_BITS_PER_WORD,APINT_WORD_SIZE,assert(),getBitWidth(),getRawData(),isSingleWord(),setBitVal(),VAL, andWORDTYPE_MAX.

Referenced bycombineConcatVectorOps(),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(), andllvm::TargetLowering::SimplifyMultipleUseDemandedBits().

◆ insertBits()[2/2]

void APInt::insertBits(uint64_t SubBits,
unsigned bitPosition,
unsigned numBits 
)

Definition at line428 of fileAPInt.cpp.

ReferencesisSingleWord().

◆ intersects()

bool llvm::APInt::intersects(constAPIntRHS) const
inline

This operation tests if there are any pairs of corresponding bits between thisAPInt and RHS that are both set.

Definition at line1249 of fileAPInt.h.

Referencesassert(),BitWidth, andRHS.

Referenced bybitTrackingDCE(),combineBlendOfPermutes(),eliminateDeadSwitchCases(),llvm::InstCombinerImpl::foldICmpAndConstant(),foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed(),foldSignedTruncationCheck(),llvm::KnownBits::hasConflict(),isKnownNonEqual(),isNonZeroAdd(),simplifyAndInst(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),llvm::TargetLowering::SimplifySetCC(), andllvm::KnownBits::srem().

◆ isAligned()

bool APInt::isAligned(Align A) const

Checks if thisAPInt -interpreted as an address- is aligned to the provided value.

Definition at line169 of fileAPInt.cpp.

ReferencesA,countr_zero(),isZero(), andllvm::Log2().

◆ isAllOnes()

bool llvm::APInt::isAllOnes() const
inline

Determine if all bits are set. This is true for zero-width values.

Definition at line371 of fileAPInt.h.

ReferencesBitWidth.

Referenced byareUsedBitsDense(),bitTrackingDCE(),llvm::TargetLowering::BuildSDIV(),llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(),combineX86ShufflesRecursively(),llvm::InstCombinerImpl::commonIDivTransforms(),createAndInstr(),EltsFromConsecutiveLoads(),EmitVectorComparison(),llvm::extractConstantMask(),findDemandedEltsByAllUsers(),foldAndOrOfSETCC(),foldBinOpIntoSelectIfProfitable(),llvm::InstCombinerImpl::foldICmpAddConstant(),llvm::InstCombinerImpl::foldICmpDivConstant(),llvm::InstCombinerImpl::foldICmpMulConstant(),llvm::InstCombinerImpl::foldICmpShrConstConst(),llvm::X86TTIImpl::getScalarizationOverhead(),getTargetConstantBitsFromNode(),llvm::KnownBits::isAllOnes(),llvm::SelectionDAG::isBoolConstant(),isCompletePermute(),llvm::ISD::isConstantSplatVectorAllOnes(),llvm::TargetLowering::isConstTrueVal(),llvm::ConstantInt::isMinusOne(),isMultiple(),llvm::isSafeToSpeculativelyExecuteWithOpcode(),isSelect01(),isVectorAllOnes(),llvm::KnownBits::isZero(),lowerShuffleAsVTRUNC(),lowerShuffleWithVPMOV(),lowerVECTOR_SHUFFLE(),llvm::SDPatternMatch::m_True(),matchMinMax(),matchShuffleAsEXTRQ(),matchShuffleAsVTRUNC(),PerformReduceShuffleCombine(),llvm::recognizeBSwapOrBitReverseIdiom(),llvm::ConstantRange::sdiv(),llvm::KnownBits::sdiv(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::TargetLowering::SimplifyDemandedVectorElts(),llvm::InstCombinerImpl::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetShuffle(),llvm::RegisterBankInfo::ValueMapping::verify(),llvm::InstCombinerImpl::visitExtractElementInst(),llvm::InstCombinerImpl::visitGetElementPtrInst(),llvm::InstCombinerImpl::visitMul(), andllvm::InstCombinerImpl::visitOr().

◆ isIntN()

bool llvm::APInt::isIntN(unsigned N) const
inline

Check if thisAPInt has an N-bits unsigned integer value.

Definition at line432 of fileAPInt.h.

ReferencesN.

Referenced byAreMulWideOperandsDemotable(),combineVectorPack(),llvm::ScalarEvolution::getUDivExactExpr(),mustBeFiniteCountedLoop(),parseHexOcta(),llvm::LoongArchDAGToDAGISel::selectVSplatImm(), andtruncUSat().

◆ isMask()[1/2]

bool llvm::APInt::isMask() const
inline
Returns
true if thisAPInt is a non-empty sequence of ones starting at the least significant bit with the remainder zero. Ex. isMask(0x0000FFFFU) == true.

Definition at line501 of fileAPInt.h.

ReferencesBitWidth, andllvm::isMask_64().

◆ isMask()[2/2]

bool llvm::APInt::isMask(unsigned numBits) const
inline
Returns
true if thisAPInt value is a sequence of
Parameters
numBitsones starting at the least significant bit with the remainder zero.

Definition at line488 of fileAPInt.h.

Referencesassert(), andBitWidth.

Referenced bycombineAndMaskToShift(),combineSetCCMOVMSK(),combineShiftRightLogical(),combineTruncToVnclip(),combineVectorMulToSraBitcast(),detectUSatPattern(),llvm::InstCombinerImpl::foldAddWithConstant(),llvm::InstCombinerImpl::foldICmpAndConstant(),foldSelectICmpAndZeroShl(),foldSubCtlzNot(),llvm::CombinerHelper::matchCombineLoadWithAndMask(),performMulVectorCmpZeroCombine(),performSubsToAndsCombine(),simplifyAMDGCNMemoryIntrinsicDemanded(),simplifyOrInst(), andllvm::InstCombinerImpl::visitSub().

◆ isMaxSignedValue()

bool llvm::APInt::isMaxSignedValue() const
inline

Determine if this is the largest signed value.

This checks to see if the value of thisAPInt is the maximum signed value for theAPInt's bit width.

Definition at line405 of fileAPInt.h.

Referencesassert(), andBitWidth.

Referenced byllvm::InstCombinerImpl::foldICmpXorConstant(),incDecVectorConstant(),llvm::ConstantInt::isMaxValue(),LowerVSETCC(),matchMinMax(),llvm::TargetLowering::SimplifySetCC(), andsimplifySubInst().

◆ isMaxValue()

bool llvm::APInt::isMaxValue() const
inline

Determine if this is the largest unsigned value.

This checks to see if the value of thisAPInt is the maximum unsigned value for theAPInt's bit width.

Definition at line399 of fileAPInt.h.

Referenced byllvm::ConstantRange::ConstantRange(),incDecVectorConstant(),llvm::ConstantRange::isFullSet(), andllvm::ConstantInt::isMaxValue().

◆ isMinSignedValue()

bool llvm::APInt::isMinSignedValue() const
inline

Determine if this is the smallest signed value.

This checks to see if the value of thisAPInt is the minimum signed value for theAPInt's bit width.

Definition at line423 of fileAPInt.h.

Referencesassert(), andBitWidth.

Referenced byllvm::KnownBits::abs(),cannotBeIntMin(),combineSetCC(),llvm::InstCombinerImpl::commonIRemTransforms(),llvm::ConstantFoldBinaryInstruction(),llvm::InstCombinerImpl::foldAddWithConstant(),llvm::InstCombinerImpl::foldICmpXorShiftConst(),llvm::InstCombinerImpl::FoldShiftByConstant(),llvm::ConstantRange::getEquivalentICmp(),llvm::ScalarEvolution::getMinusSCEV(),llvm::ScalarEvolution::getUDivExpr(),incDecVectorConstant(),llvm::ConstantInt::isMinValue(),isMultiple(),llvm::isSafeToSpeculativelyExecuteWithOpcode(),llvm::ConstantRange::isSignWrappedSet(),LowerVSETCC(),matchMinMax(),llvm::ConstantRange::multiply(),llvm::APFixedPoint::negate(),llvm::detail::SlowDynamicAPInt::operator-(),llvm::ConstantRange::sdiv(),llvm::KnownBits::sdiv(),sdiv_ov(),llvm::ConstantRange::signExtend(),llvm::TargetLowering::SimplifySetCC(),smul_ov(),tryFactorization(), andllvm::InstCombinerImpl::visitSDiv().

◆ isMinValue()

bool llvm::APInt::isMinValue() const
inline

Determine if this is the smallest unsigned value.

This checks to see if the value of thisAPInt is the minimum unsigned value for theAPInt's bit width.

Definition at line417 of fileAPInt.h.

ReferencesisZero().

Referenced byllvm::InstCombinerImpl::commonIRemTransforms(),llvm::ConstantRange::ConstantRange(),llvm::ConstantRange::isEmptySet(),llvm::ConstantInt::isMinValue(), andisMultiple().

◆ isNegatedPowerOf2()

bool llvm::APInt::isNegatedPowerOf2() const
inline

Check if thisAPInt's negated value is a power of two greater than zero.

Definition at line449 of fileAPInt.h.

Referencesassert(),BitWidth,llvm::countl_one(), andllvm::countr_zero().

Referenced byllvm::PPCTargetLowering::BuildSDIVPow2(),canEvaluateShifted(),llvm::decomposeBitTestICmp(),llvm::InstCombinerImpl::foldICmpAndConstConst(),llvm::SystemZTTIImpl::getArithmeticInstrCost(),instCombineSVESDIV(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::TargetLowering::SimplifySetCC(), andllvm::InstCombinerImpl::visitSub().

◆ isNegative()

bool llvm::APInt::isNegative() const
inline

Determine sign of thisAPInt.

This tests the high bit of thisAPInt to determine if it is set.

Returns
true if thisAPInt is negative, false otherwise

Definition at line329 of fileAPInt.h.

ReferencesBitWidth.

Referenced byllvm::TargetLowering::BuildSDIV(),combineShiftRightArithmetic(),combineVectorPack(),llvm::InstCombinerImpl::commonShiftTransforms(),llvm::KnownBits::computeForAddSub(),llvm::SelectionDAG::computeKnownBits(),computeShlNSW(),llvm::detail::IEEEFloat::convertFromAPInt(),foldAddToAshr(),foldAndOrOfSETCC(),llvm::InstCombinerImpl::foldICmpAndConstConst(),llvm::InstCombinerImpl::foldICmpAndShift(),llvm::InstCombinerImpl::foldICmpBinOp(),llvm::InstCombinerImpl::foldICmpDivConstant(),llvm::InstCombinerImpl::foldICmpMulConstant(),llvm::InstCombinerImpl::foldICmpShrConstant(),llvm::InstCombinerImpl::foldICmpShrConstConst(),llvm::InstCombinerImpl::foldICmpUsingKnownBits(),llvm::InstCombinerImpl::foldICmpXorConstant(),foldNoWrapAdd(),llvm::InstCombinerImpl::FoldShiftByConstant(),getAssignmentInfoImpl(),getBitsNeeded(),llvm::ExpressionFormat::getMatchingString(),getRangeForAffineARHelper(),getStrideAndModOffsetOfGEP(),llvm::ScalarEvolution::getUDivExpr(),isConstantPowerOfTwo(),llvm::ScalarEvolution::isKnownNegative(),llvm::ScalarEvolution::isKnownNonNegative(),llvm::ConstantInt::isNegative(),isNonEqualPointersWithRecursiveGEP(),isNonZeroRecurrence(),performMulCombine(),llvm::APIntOps::RoundingSDiv(),sadd_sat(),sdiv(),sext(),sfloordiv_ov(),shouldTransformMulToShiftsAddsSubs(),llvm::ConstantRange::signedAddMayOverflow(),llvm::ConstantRange::signedSubMayOverflow(),llvm::TargetLowering::SimplifySetCC(),smul_sat(),llvm::APIntOps::SolveQuadraticEquationWrap(),srem(),sshl_sat(),ssub_sat(),llvm::RISCVTargetLowering::targetShrinkDemandedConstant(),toString(),toString(),truncSSat(), andumul_ov().

◆ isNonNegative()

bool llvm::APInt::isNonNegative() const
inline

Determine if thisAPIntValue is non-negative (>= 0)

This tests the high bit of theAPInt to determine if it is unset.

Definition at line334 of fileAPInt.h.

Referenced byllvm::TargetLowering::buildSDIVPow2WithCMov(),combineTruncToVnclip(),llvm::KnownBits::computeForAddSub(),llvm::SelectionDAG::computeKnownBits(),computePointerICmp(),computeShlNSW(),detectUSatPattern(),llvm::ConstantRange::isAllNonNegative(),llvm::isKnownInversion(),llvm::ConstantRange::multiply(),performMulCombine(),sadd_ov(),llvm::ConstantRange::signedAddMayOverflow(),llvm::ConstantRange::signedSubMayOverflow(),simplifyICmpWithBinOp(),simplifyIntrinsic(),llvm::TargetLowering::SimplifySetCC(),llvm::ConstantRange::srem(),sshl_ov(),llvm::ConstantRange::sshl_sat(),ssub_ov(),trySimplifyICmpWithAdds(),llvm::InstCombinerImpl::visitCallInst(), andllvm::InstCombinerImpl::visitGetElementPtrInst().

◆ isNonPositive()

bool llvm::APInt::isNonPositive() const
inline

Determine if thisAPIntValue is non-positive (<= 0).

Returns
true if thisAPInt is non-positive.

Definition at line361 of fileAPInt.h.

Referenced byprocessAbsIntrinsic(), andtrySimplifyICmpWithAdds().

◆ isOne()

bool llvm::APInt::isOne() const
inline

Determine if this is a value of 1.

This checks to see if the value of thisAPInt is one.

Definition at line389 of fileAPInt.h.

ReferencesBitWidth.

Referenced byllvm::TargetLowering::BuildSDIV(),llvm::TargetLowering::BuildUDIV(),llvm::CombinerHelper::buildUDivUsingMul(),combineSelectOfTwoConstants(),llvm::TargetLowering::expandDIVREMByConstant(),llvm::InstCombinerImpl::foldICmpAndShift(),llvm::InstCombinerImpl::foldICmpDivConstant(),foldICmpShlLHSC(),llvm::SelectionDAG::isBoolConstant(),llvm::TargetLowering::isConstTrueVal(),llvm::ConstantInt::isOne(),isSelect01(),llvm::SDPatternMatch::m_True(),multiplicativeInverse(),performVSelectCombine(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),simplifyGEPInst(), andllvm::TargetLowering::SimplifySetCC().

◆ isOneBitSet()

bool llvm::APInt::isOneBitSet(unsigned BitNo) const
inline

Determine if thisAPIntValue only has the specified bit set.

Returns
true if thisAPInt only has the specified bit set.

Definition at line366 of fileAPInt.h.

Referencesllvm::popcount().

◆ isPowerOf2()

bool llvm::APInt::isPowerOf2() const
inline

Check if thisAPInt's value is a power of two greater than zero.

Returns
true if the argumentAPInt value is a power of two > 0.

Definition at line440 of fileAPInt.h.

Referencesassert(),BitWidth, andllvm::isPowerOf2_64().

Referenced byllvm::PPCTargetLowering::BuildSDIVPow2(),combineAnd(),combineSelectOfTwoConstants(),combineSetCC(),llvm::SelectionDAG::computeKnownBits(),llvm::decomposeBitTestICmp(),llvm::InstCombinerImpl::foldAddWithConstant(),foldAndOrOfSETCC(),llvm::InstCombinerImpl::foldICmpAddConstant(),llvm::InstCombinerImpl::foldICmpBinOpEqualityWithConstant(),foldICmpShlLHSC(),llvm::InstCombinerImpl::foldICmpShrConstant(),llvm::InstCombinerImpl::foldICmpShrConstConst(),llvm::InstCombinerImpl::foldICmpUsingKnownBits(),foldICmpWithTruncSignExtendedVal(),llvm::InstCombinerImpl::foldICmpXorShiftConst(),foldSelectICmpAnd(),foldSignedTruncationCheck(),llvm::SystemZTTIImpl::getArithmeticInstrCost(),getBitsNeeded(),llvm::ConstantExpr::getExactLogBase2(),getMaskedICmpType(),instCombineSVESDIV(),isAllocSiteRemovable(),isConstantPowerOfTwo(),llvm::isKnownToBeAPowerOfTwo(),isPowerOf2Constant(),isSaturatingMinMax(),LowerVSETCC(),optimizeBranch(),performMulCombine(),performSubsToAndsCombine(),processUGT_ADDCST_ADD(),shouldTransformMulToShiftsAddsSubs(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),simplifyDiv(),llvm::TargetLowering::SimplifySetCC(),useInversedSetcc(),llvm::InstCombinerImpl::visitAdd(), andllvm::InstCombinerImpl::visitAnd().

◆ isSameValue()

staticbool llvm::APInt::isSameValue(constAPIntI1,
constAPIntI2 
)
inlinestatic

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 line553 of fileAPInt.h.

ReferencesgetBitWidth(), andzext().

Referenced byllvm::SDPatternMatch::SpecificInt_match::match(),llvm::PatternMatch::specific_intval< AllowPoison >::match(), andllvm::VPlanPatternMatch::specific_intval< BitWidth >::match().

◆ isShiftedMask()[1/2]

bool llvm::APInt::isShiftedMask() const
inline

Return true if thisAPInt value contains a non-empty sequence of ones with the remainder zero.

Definition at line510 of fileAPInt.h.

ReferencesBitWidth, andllvm::isShiftedMask_64().

◆ isShiftedMask()[2/2]

bool llvm::APInt::isShiftedMask(unsignedMaskIdx,
unsignedMaskLen 
) const
inline

Return true if thisAPInt value contains a non-empty sequence of ones with the remainder zero.

If true,MaskIdx will specify the index of the lowest set bit andMaskLen is updated to specify the length of the mask, else neither are updated.

Definition at line522 of fileAPInt.h.

ReferencesBitWidth, andllvm::isShiftedMask_64().

◆ isSignBitClear()

bool llvm::APInt::isSignBitClear() const
inline

Determine if sign bit of thisAPInt is clear.

This tests the high bit of thisAPInt to determine if it is clear.

Returns
true if thisAPInt has its sign bit clear, false otherwise.

Definition at line348 of fileAPInt.h.

Referenced byllvm::KnownBits::getSignedMaxValue(), andllvm::KnownBits::getSignedMinValue().

◆ isSignBitSet()

bool llvm::APInt::isSignBitSet() const
inline

Determine if sign bit of thisAPInt is set.

This tests the high bit of thisAPInt to determine if it is set.

Returns
true if thisAPInt has its sign bit set, false otherwise.

Definition at line341 of fileAPInt.h.

ReferencesBitWidth.

Referenced bycombineSetCC(),llvm::APFixedPoint::compare(),llvm::ScalarEvolution::getAddExpr(),llvm::KnownBits::isNegative(),llvm::KnownBits::isNonNegative(),llvm::KnownBits::isSignUnknown(),llvm::KnownBits::isStrictlyPositive(),simplifyShift(), andtoSigned().

◆ isSignedIntN()

bool llvm::APInt::isSignedIntN(unsigned N) const
inline

Check if thisAPInt has an N-bits signed integer value.

Definition at line435 of fileAPInt.h.

ReferencesN.

Referenced byAreMulWideOperandsDemotable(),combineSubOfBoolean(),computeFlagsForAddressComputation(),INITIALIZE_PASS(),llvm::NVPTXTargetLowering::isLegalAddressingMode(),llvm::RISCVTargetLowering::isMulAddWithConstProfitable(),llvm::LoongArchDAGToDAGISel::selectVSplatImm(),llvm::RISCVTargetLowering::targetShrinkDemandedConstant(),truncSSat(), anduseInversedSetcc().

◆ isSignMask()

bool llvm::APInt::isSignMask() const
inline

Check if theAPInt's value is returned by getSignMask.

Returns
true if this is the value returned by getSignMask.

Definition at line466 of fileAPInt.h.

Referenced byfoldAddToAshr(),llvm::InstCombinerImpl::foldAddWithConstant(),llvm::InstCombinerImpl::foldICmpAndConstConst(),llvm::InstCombinerImpl::foldICmpXorConstant(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), andllvm::InstCombinerImpl::visitXor().

◆ isSingleWord()

bool llvm::APInt::isSingleWord() const
inline

Determine if thisAPInt just has one word to store value.

Returns
true if the number of bits <= 64, false otherwise.

Definition at line322 of fileAPInt.h.

ReferencesBitWidth.

Referenced byextractBits(),extractBitsAsZExtValue(),llvm::hash_value(),insertBits(),operator*(),operator*=(),operator++(),operator+=(),operator--(),operator-=(),Profile(),roundToDouble(),sqrt(),llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(),toString(),udiv(), andurem().

◆ isSplat()

bool APInt::isSplat(unsigned SplatSizeInBits) const

Check if theAPInt consists of a repeated bit pattern.

e.g. 0x01010101 satisfies isSplat(8).

Parameters
SplatSizeInBitsThe size of the pattern in bits. Must divide bit width without remainder.

Definition at line603 of fileAPInt.cpp.

Referencesassert(),getBitWidth(), androtl().

◆ isStrictlyPositive()

bool llvm::APInt::isStrictlyPositive() const
inline

Determine if thisAPIntValue is positive.

This tests if the value of thisAPInt is positive (> 0). Note that 0 is not a positive value.

Returns
true if thisAPInt is positive.

Definition at line356 of fileAPInt.h.

ReferencesisZero().

Referenced byllvm::ConstantRange::abs(),llvm::TargetLowering::BuildSDIV(),ComputeNumSignBitsImpl(),llvm::InstCombinerImpl::foldICmpDivConstant(),llvm::ConstantRange::isAllNegative(),llvm::ConstantRange::isAllPositive(),llvm::ScalarEvolution::isKnownNonPositive(),llvm::ScalarEvolution::isKnownPositive(),isNonEqualPointersWithRecursiveGEP(),simplifyAndOfICmpsWithAdd(), andsimplifyOrOfICmpsWithAdd().

◆ isSubsetOf()

bool llvm::APInt::isSubsetOf(constAPIntRHS) const
inline

This operation checks that all bits set in thisAPInt are also set in RHS.

Definition at line1257 of fileAPInt.h.

Referencesassert(),BitWidth, andRHS.

Referenced bybitTrackingDCE(),llvm::SelectionDAGISel::CheckAndMask(),llvm::SelectionDAGISel::CheckOrMask(),eliminateDeadSwitchCases(),foldLogOpOfMaskedICmps(),foldSignedTruncationCheck(),getMaskedICmpType(),llvm::SelectionDAG::getSplatSourceVector(),llvm::X86TTIImpl::instCombineIntrinsic(),LowerMUL(),performORCombine(),llvm::LoongArchDAGToDAGISel::selectShiftMask(),llvm::RISCVDAGToDAGISel::selectShiftMask(),simplifyAndInst(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::ARMTargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::TargetLowering::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(),simplifyICmpWithBinOp(),llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(),llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(),llvm::TargetLowering::SimplifySetCC(),llvm::KnownBits::srem(),llvm::RISCVTargetLowering::targetShrinkDemandedConstant(),llvm::X86TargetLowering::targetShrinkDemandedConstant(), andllvm::InstCombinerImpl::visitSub().

◆ isZero()

bool llvm::APInt::isZero() const
inline

Determine if this value is zero, i.e. all bits are clear.

Definition at line380 of fileAPInt.h.

ReferencesBitWidth.

Referenced byllvm::KnownBits::abs(),canonicalizeGEPOfConstGEPI8(),llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(),canWidenShuffleElements(),llvm::GEPOperator::collectOffset(),combineBlendOfPermutes(),llvm::PPCInstrInfo::combineRLWINM(),combineSetCCMOVMSK(),combineX86ShufflesRecursively(),llvm::InstCombinerImpl::commonIDivTransforms(),computeKnownBitsForHorizontalOperation(),computeKnownBitsFromOperator(),computeKnownFPClass(),createAndInstr(),llvm::ConstantRange::cttz(),llvm::APFixedPoint::div(),EltsFromConsecutiveLoads(),llvm::exprDiv(),foldAndOrOfICmpEqConstantAndICmp(),foldAndOrOfSETCC(),foldBinOpIntoSelectIfProfitable(),foldCttzCtlz(),llvm::InstCombinerImpl::foldICmpAddConstant(),llvm::InstCombinerImpl::foldICmpAndConstant(),llvm::InstCombinerImpl::foldICmpAndConstConst(),llvm::InstCombinerImpl::foldICmpAndShift(),llvm::InstCombinerImpl::foldICmpBinOp(),llvm::InstCombinerImpl::foldICmpDivConstant(),llvm::InstCombinerImpl::foldICmpMulConstant(),llvm::InstCombinerImpl::foldICmpShlConstConst(),foldICmpShlLHSC(),llvm::InstCombinerImpl::foldICmpShrConstConst(),llvm::InstCombinerImpl::foldICmpSRemConstant(),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(), andllvm::InstCombinerImpl::visitMul().

◆ logBase2()

unsigned llvm::APInt::logBase2() const
inline
Returns
the floor log base 2 of thisAPInt.

Definition at line1739 of fileAPInt.h.

Referenced byllvm::SelectionDAG::computeKnownBits(),ComputeNumSignBitsImpl(),llvm::InstCombinerImpl::foldAddWithConstant(),foldICmpShlLHSC(),llvm::InstCombinerImpl::foldICmpShrConstConst(),foldSelectICmpAnd(),foldSelectICmpAndBinOp(),getBitsNeeded(),llvm::ConstantExpr::getExactLogBase2(),instCombineSVESDIV(),isEXTMask(),LowerVSETCC(),nearestLogBase2(),optimizeBranch(),llvm::ARMTargetLowering::PerformCMOVCombine(),llvm::ARMTargetLowering::PerformCMOVToBFICombine(),performMulCombine(),shouldTransformMulToShiftsAddsSubs(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::TargetLowering::SimplifySetCC(),llvm::InstCombinerImpl::visitAShr(), andllvm::InstCombinerImpl::visitLShr().

◆ lshr()[1/2]

APInt llvm::APInt::lshr(constAPIntShiftAmt) const
inline

Logical right-shift function.

Logical right-shift thisAPInt by shiftAmt.

Definition at line920 of fileAPInt.h.

◆ lshr()[2/2]

APInt llvm::APInt::lshr(unsigned shiftAmt) const
inline

Logical right-shift function.

Logical right-shift thisAPInt by shiftAmt.

Definition at line851 of fileAPInt.h.

Referenced byllvm::DwarfExpression::addConstantFP(),areUsedBitsDense(),combineShiftRightLogical(),computeKnownBitsFromOperator(),llvm::ConstantFoldBinaryInstruction(),llvm::ConstantFoldBinOp(),llvm::TargetLowering::CTTZTableLookup(),llvm::InstCombinerImpl::foldICmpAndShift(),llvm::InstCombinerImpl::foldICmpShrConstant(),llvm::InstCombinerImpl::foldICmpShrConstConst(),foldICmpWithTruncSignExtendedVal(),FoldValue(),getDemandedSrcElements(),getHiBits(),getHopForBuildVector(),llvm::APFixedPoint::getMax(),llvm::BlockFrequencyInfoImplBase::getProfileCountFromFreq(),llvm::X86TTIImpl::instCombineIntrinsic(),llvm::SelectionDAG::isKnownNeverZero(),isNonZeroShift(),llvm::SystemZVectorConstantInfo::isVectorConstantLegal(),lowerMSABinaryBitImmIntr(),LowerShift(),llvm::ConstantRange::lshr(),llvm::CombinerHelper::matchCombineUnmergeConstant(),llvm::LegalizerHelper::narrowScalar(),rotl(),rotr(),setLimitsForBinOp(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::InstCombinerImpl::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(),llvm::TargetLowering::SimplifySetCC(),llvm::InstCombinerImpl::simplifyShrShlDemandedBits(),llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(),umul_ov(),llvm::Interpreter::visitLShr(),llvm::InstCombinerImpl::visitLShr(),llvm::InstCombinerImpl::visitSwitchInst(), andllvm::InstCombinerImpl::visitXor().

◆ lshrInPlace()[1/2]

void APInt::lshrInPlace(constAPIntshiftAmt)

Logical right-shift thisAPInt by ShiftAmt in place.

Logical right-shift thisAPInt by shiftAmt.

Logical right-shift function.

Definition at line1073 of fileAPInt.cpp.

ReferencesgetLimitedValue(), andlshrInPlace().

◆ lshrInPlace()[2/2]

void llvm::APInt::lshrInPlace(unsigned ShiftAmt)
inline

Logical right-shift thisAPInt by ShiftAmt in place.

Definition at line858 of fileAPInt.h.

Referencesassert(), andBitWidth.

Referenced byBuildExactUDIV(),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(), andtoString().

◆ multiplicativeInverse()

APInt APInt::multiplicativeInverse() const
Returns
the multiplicative inverse of an oddAPInt modulo 2^BitWidth.

Definition at line1248 of fileAPInt.cpp.

Referencesassert(), andisOne().

Referenced byBinomialCoefficient(),BuildExactSDIV(),BuildExactUDIV(),llvm::CombinerHelper::buildSDivUsingMul(),llvm::CombinerHelper::buildUDivUsingMul(),llvm::TargetLowering::expandDIVREMByConstant(), andSolveLinEquationWithOverflow().

◆ ne()

bool llvm::APInt::ne(constAPIntRHS) const
inline

Inequality comparison.

Compares thisAPInt with RHS for the validity of the inequality relationship.

Returns
true if *this != Val

Definition at line1103 of fileAPInt.h.

ReferencesRHS.

◆ nearestLogBase2()

unsigned APInt::nearestLogBase2() const
Returns
the nearest log base 2 of thisAPInt. Ties round up.

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 line1146 of fileAPInt.cpp.

ReferencesisZero(), andlogBase2().

◆ needsCleanup()

bool llvm::APInt::needsCleanup() const
inline

Returns whether this instance allocated memory.

Definition at line1904 of fileAPInt.h.

◆ negate()

void llvm::APInt::negate()
inline

Negate thisAPInt in place.

Definition at line1450 of fileAPInt.h.

Referenced byllvm::InstCombinerImpl::foldICmpDivConstant(),llvm::SignedDivisionByConstantInfo::get(),llvm::LegalizerHelper::getDynStackAllocTargetPtr(),instCombineSVESDIV(),sdivrem(), andtoString().

◆ operator!()

bool llvm::APInt::operator!() const
inline

Logical negation operation on thisAPInt returns true if zero, like normal integers.

Definition at line609 of fileAPInt.h.

ReferencesisZero().

◆ operator!=()[1/2]

boolllvm::APInt::operator!=(constAPIntRHS) const
inline

Inequality operator.

Compares thisAPInt with RHS for the validity of the inequality relationship.

Returns
true if *this != Val

Definition at line1087 of fileAPInt.h.

ReferencesRHS.

◆ operator!=()[2/2]

boolllvm::APInt::operator!=(uint64_t Val) const
inline

Inequality operator.

Compares thisAPInt with a uint64_t for the validity of the inequality relationship.

Returns
true if *this != Val

Definition at line1095 of fileAPInt.h.

◆ operator&=()[1/2]

APInt & llvm::APInt::operator&=(constAPIntRHS)
inline

Bitwise AND assignment operator.

Performs a bitwise AND operation on thisAPInt and RHS. The result is assigned to *this.

Returns
*this after ANDing with RHS.

Definition at line674 of fileAPInt.h.

Referencesassert(),BitWidth, andRHS.

◆ operator&=()[2/2]

APInt & llvm::APInt::operator&=(uint64_t RHS)
inline

Bitwise AND assignment operator.

Performs a bitwise AND operation on thisAPInt and RHS. RHS is logically zero-extended or truncated to match the bit-width of the LHS.

Definition at line688 of fileAPInt.h.

ReferencesRHS.

◆ operator*()

APInt APInt::operator*(constAPIntRHS) const

Multiplication operator.

Multiplies thisAPInt by RHS and returns the result.

Definition at line235 of fileAPInt.cpp.

ReferencesAPInt(),assert(),getBitWidth(),getMemory(),getNumWords(),isSingleWord(),RHS, andtcMultiply().

◆ operator*=()[1/2]

APInt & APInt::operator*=(constAPIntRHS)

Multiplication assignment operator.

Multiplies thisAPInt by RHS and assigns the result to *this.

Returns
*this

Definition at line265 of fileAPInt.cpp.

ReferencesRHS.

◆ operator*=()[2/2]

APInt & APInt::operator*=(uint64_t RHS)

Definition at line270 of fileAPInt.cpp.

ReferencesgetNumWords(),isSingleWord(),RHS, andtcMultiplyPart().

◆ operator++()[1/2]

APInt & APInt::operator++()

Prefix increment operator.

Prefix increment operator. Increments theAPInt by one.

Returns
*this incremented by one

Definition at line178 of fileAPInt.cpp.

ReferencesgetNumWords(),isSingleWord(), andtcIncrement().

◆ operator++()[2/2]

APInt llvm::APInt::operator++(int )
inline

Postfix increment operator.

Increment *this by 1.

Returns
a newAPInt value representing the original value of *this.

Definition at line582 of fileAPInt.h.

◆ operator+=()[1/2]

APInt & APInt::operator+=(constAPIntRHS)

Addition assignment operator.

Adds the RHSAPInt to thisAPInt.

Adds RHS to *this and assigns the result to *this.

Returns
*this
this, after addition of RHS. Addition assignment operator.

Definition at line198 of fileAPInt.cpp.

Referencesassert(),getNumWords(),isSingleWord(),RHS, andtcAdd().

◆ operator+=()[2/2]

APInt & APInt::operator+=(uint64_t RHS)

Definition at line207 of fileAPInt.cpp.

ReferencesgetNumWords(),isSingleWord(),RHS, andtcAddPart().

◆ operator--()[1/2]

APInt & APInt::operator--()

Prefix decrement operator.

Prefix decrement operator. Decrements theAPInt by one.

Returns
*this decremented by one.

Definition at line187 of fileAPInt.cpp.

ReferencesgetNumWords(),isSingleWord(), andtcDecrement().

◆ operator--()[2/2]

APInt llvm::APInt::operator--(int )
inline

Postfix decrement operator.

Decrement *this by 1.

Returns
a newAPInt value representing the original value of *this.

Definition at line596 of fileAPInt.h.

◆ operator-=()[1/2]

APInt & APInt::operator-=(constAPIntRHS)

Subtraction assignment operator.

Subtracts the RHSAPInt from thisAPInt.

Subtracts RHS from *this and assigns the result to *this.

Returns
*this
this, after subtraction Subtraction assignment operator.

Definition at line218 of fileAPInt.cpp.

Referencesassert(),getNumWords(),isSingleWord(),RHS, andtcSubtract().

◆ operator-=()[2/2]

APInt & APInt::operator-=(uint64_t RHS)

Definition at line227 of fileAPInt.cpp.

ReferencesgetNumWords(),isSingleWord(),RHS, andtcSubtractPart().

◆ operator<<()[1/2]

APInt llvm::APInt::operator<<(constAPIntBits) const
inline

Left logical shift operator.

Shifts thisAPInt left byBits and returns the result.

Definition at line822 of fileAPInt.h.

◆ operator<<()[2/2]

APInt llvm::APInt::operator<<(unsigned Bits) const
inline

Left logical shift operator.

Shifts thisAPInt left byBits and returns the result.

Definition at line817 of fileAPInt.h.

◆ operator<<=()[1/2]

APInt & APInt::operator<<=(constAPIntshiftAmt)

Left-shift assignment function.

Left-shift thisAPInt by shiftAmt.

Shifts *this left by shiftAmt and assigns the result to *this.

Returns
*this after shifting left by ShiftAmt

Left-shift function.

Definition at line1085 of fileAPInt.cpp.

ReferencesgetLimitedValue().

◆ operator<<=()[2/2]

APInt & llvm::APInt::operator<<=(unsigned ShiftAmt)
inline

Left-shift assignment function.

Shifts *this left by shiftAmt and assigns the result to *this.

Returns
*this after shifting left by ShiftAmt

Definition at line785 of fileAPInt.h.

Referencesassert(),BitWidth, andclearUnusedBits().

◆ operator=()[1/3]

APInt & llvm::APInt::operator=(APInt && that)
inline

Move assignment operator.

Definition at line632 of fileAPInt.h.

Referencesassert(), andBitWidth.

◆ operator=()[2/3]

APInt & llvm::APInt::operator=(constAPIntRHS)
inline

Copy assignment operator.

Returns
*this after assignment of RHS.

Definition at line618 of fileAPInt.h.

ReferencesBitWidth, andRHS.

◆ operator=()[3/3]

APInt & llvm::APInt::operator=(uint64_t RHS)
inline

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.

Returns
*this after assignment of RHS value.

Definition at line658 of fileAPInt.h.

ReferencesclearUnusedBits(), andRHS.

◆ operator==()[1/2]

bool llvm::APInt::operator==(constAPIntRHS) const
inline

Equality operator.

Compares thisAPInt with RHS for the validity of the equality relationship.

Definition at line1056 of fileAPInt.h.

Referencesassert(),BitWidth, andRHS.

◆ operator==()[2/2]

bool llvm::APInt::operator==(uint64_t Val) const
inline

Equality operator.

Compares thisAPInt with a uint64_t for the validity of the equality relationship.

Returns
true if *this == Val

Definition at line1069 of fileAPInt.h.

◆ operator[]()

bool llvm::APInt::operator[](unsigned bitPosition) const
inline

Array-indexing support.

Returns
the bit value at bitPosition

Definition at line1043 of fileAPInt.h.

Referencesassert(), andgetBitWidth().

◆ operator^=()[1/2]

APInt & llvm::APInt::operator^=(constAPIntRHS)
inline

Bitwise XOR assignment operator.

Performs a bitwise XOR operation on thisAPInt and RHS. The result is assigned to *this.

Returns
*this after XORing with RHS.

Definition at line733 of fileAPInt.h.

Referencesassert(),BitWidth, andRHS.

◆ operator^=()[2/2]

APInt & llvm::APInt::operator^=(uint64_t RHS)
inline

Bitwise XOR assignment operator.

Performs a bitwise XOR operation on thisAPInt and RHS. RHS is logically zero-extended or truncated to match the bit-width of the LHS.

Definition at line747 of fileAPInt.h.

ReferencesclearUnusedBits(), andRHS.

◆ operator|=()[1/2]

APInt & llvm::APInt::operator|=(constAPIntRHS)
inline

Bitwise OR assignment operator.

Performs a bitwise OR operation on thisAPInt and RHS. The result is assigned *this;

Returns
*this after ORing with RHS.

Definition at line704 of fileAPInt.h.

Referencesassert(),BitWidth, andRHS.

◆ operator|=()[2/2]

APInt & llvm::APInt::operator|=(uint64_t RHS)
inline

Bitwise OR assignment operator.

Performs a bitwise OR operation on thisAPInt and RHS. RHS is logically zero-extended or truncated to match the bit-width of the LHS.

Definition at line718 of fileAPInt.h.

ReferencesclearUnusedBits(), andRHS.

◆ popcount()

unsigned llvm::APInt::popcount() const
inline

Count the number of bits set.

This function is anAPInt version of std::popcount. It counts the number of 1 bits in theAPInt value.

Returns
0 if the value is zero, otherwise returns the number of set bits.

Definition at line1649 of fileAPInt.h.

Referencesllvm::popcount().

Referenced byllvm::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(),LowerCTPOP(),ParseBFI(),llvm::ARMTargetLowering::PerformCMOVToBFICombine(),simplifyAMDGCNMemoryIntrinsicDemanded(),llvm::InstCombinerImpl::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(),tryBitfieldInsertOpFromOr(), andtryBitfieldInsertOpFromOrAndImm().

◆ print()

void APInt::print(raw_ostreamOS,
bool isSigned 
) const

Definition at line2281 of fileAPInt.cpp.

ReferencesisSigned(),OS, andtoString().

◆ Profile()

void APInt::Profile(FoldingSetNodeIDid) const

Used to insertAPInt objects, or objects that containAPInt objects, into FoldingSets.

This method 'profiles' anAPInt for use withFoldingSet.

Definition at line156 of fileAPInt.cpp.

ReferencesgetNumWords(), andisSingleWord().

Referenced byllvm::Attribute::get(),llvm::APSInt::Profile(), andllvm::AttributeImpl::Profile().

◆ relativeAShl()

APInt llvm::APInt::relativeAShl(int RelativeShift) const
inline

relative arithmetic shift left

Definition at line895 of fileAPInt.h.

Referenced byllvm::APFixedPoint::mul().

◆ relativeAShr()

APInt llvm::APInt::relativeAShr(int RelativeShift) const
inline

relative arithmetic shift right

Definition at line890 of fileAPInt.h.

◆ relativeLShl()

APInt llvm::APInt::relativeLShl(int RelativeShift) const
inline

relative logical shift left

Definition at line885 of fileAPInt.h.

Referenced byllvm::APFixedPoint::mul().

◆ relativeLShr()

APInt llvm::APInt::relativeLShr(int RelativeShift) const
inline

relative logical shift right

Definition at line880 of fileAPInt.h.

◆ reverseBits()

APInt APInt::reverseBits() const
Returns
the value with the bit representation reversed of thisAPIntValue.

Definition at line741 of fileAPInt.cpp.

ReferencesAPInt(), andlshrInPlace().

Referenced bycomputeKnownBitsFromOperator(),computeKnownFPClass(),determineLiveOperandBitsAddCarry(),foldBitwiseLogicWithIntrinsics(),llvm::SelectionDAG::FoldConstantArithmetic(),isKnownNonZeroFromOperator(),llvm::KnownBits::reverseBits(), andllvm::TargetLowering::SimplifyDemandedBits().

◆ rotl()[1/2]

APInt APInt::rotl(constAPIntrotateAmt) const

Rotate left by rotateAmt.

Definition at line1111 of fileAPInt.cpp.

ReferencesrotateModulo(), androtl().

◆ rotl()[2/2]

APInt APInt::rotl(unsigned rotateAmt) const

Rotate left by rotateAmt.

Definition at line1115 of fileAPInt.cpp.

ReferencesLLVM_UNLIKELY,lshr(), andshl().

Referenced byllvm::PPCInstrInfo::combineRLWINM(),FoldValue(),isSplat(), androtl().

◆ rotr()[1/2]

APInt APInt::rotr(constAPIntrotateAmt) const

Rotate right by rotateAmt.

Definition at line1124 of fileAPInt.cpp.

ReferencesrotateModulo(), androtr().

◆ rotr()[2/2]

APInt APInt::rotr(unsigned rotateAmt) const

Rotate right by rotateAmt.

Definition at line1128 of fileAPInt.cpp.

Referenceslshr(), andshl().

Referenced byFoldValue(),llvm::RISCVLegalizerInfo::legalizeCustom(),rotr(),selectI64ImmDirect(), andselectI64ImmDirectPrefix().

◆ roundToDouble()[1/2]

double llvm::APInt::roundToDouble() const
inline

Converts this unsignedAPInt to a double value.

Definition at line1690 of fileAPInt.h.

ReferencesroundToDouble().

Referenced byroundToDouble().

◆ roundToDouble()[2/2]

double APInt::roundToDouble(bool isSigned) const

Converts thisAPInt to a double value.

This function converts thisAPInt to a double.

The layout for double is as following (IEEE Standard 754):

Sign Exponent Fraction Bias
1[63] 11[62-52] 52[51-00] 1023

Definition at line853 of fileAPInt.cpp.

ReferencesAPINT_BITS_PER_WORD,assert(),getActiveBits(),I,isNeg(),isSigned(),isSingleWord(),pVal,sext(), andllvm::SignExtend64().

Referenced byllvm::ExecutionEngine::getConstantValue(), andllvm::APIntOps::RoundAPIntToDouble().

◆ sadd_ov()

APInt APInt::sadd_ov(constAPIntRHS,
boolOverflow 
) const

Definition at line1902 of fileAPInt.cpp.

ReferencesisNonNegative(), andRHS.

Referenced byllvm::APFixedPoint::add(),addWithOverflow(),llvm::checkedAdd(),llvm::exprAdd(),maintainNoSignedWrap(),llvm::detail::SlowDynamicAPInt::operator+(),optimizeIncrementingWhile(),sadd_sat(),llvm::simplifyLoopAfterUnroll(),llvm::InstCombinerImpl::visitCallInst(), andllvm::InstCombinerImpl::visitOr().

◆ sadd_sat()

APInt APInt::sadd_sat(constAPIntRHS) const

Definition at line2000 of fileAPInt.cpp.

ReferencesgetSignedMaxValue(),getSignedMinValue(),isNegative(),RHS, andsadd_ov().

Referenced byllvm::APFixedPoint::add(),FoldValue(), andllvm::ConstantRange::sadd_sat().

◆ sdiv()[1/2]

APInt APInt::sdiv(constAPIntRHS) const

Signed division function forAPInt.

Signed divide thisAPInt byAPInt RHS.

The result is rounded towards zero.

Definition at line1618 of fileAPInt.cpp.

ReferencesisNegative(),RHS, andudiv().

Referenced byllvm::ProfileSummaryBuilder::computeDetailedSummary(),llvm::ConstantFoldBinaryInstruction(),llvm::ConstantFoldBinOp(),findGCD(),llvm::InstCombinerImpl::foldICmpDivConstant(),FoldValue(),getExactSDiv(),isSimpleVIDSequence(),llvm::ConstantRange::sdiv(),llvm::KnownBits::sdiv(),sdiv_ov(),setLimitsForBinOp(),smul_ov(), andllvm::Interpreter::visitBinaryOperator().

◆ sdiv()[2/2]

APInt APInt::sdiv(int64_t RHS) const

Definition at line1629 of fileAPInt.cpp.

ReferencesisNegative(),RHS, andudiv().

◆ sdiv_ov()

APInt APInt::sdiv_ov(constAPIntRHS,
boolOverflow 
) const

Definition at line1928 of fileAPInt.cpp.

ReferencesisMinSignedValue(),RHS, andsdiv().

Referenced byllvm::exprDiv(),llvm::detail::SlowDynamicAPInt::operator/(), andsfloordiv_ov().

◆ sdivrem()[1/2]

void APInt::sdivrem(constAPIntLHS,
constAPIntRHS,
APIntQuotient,
APIntRemainder 
)
static

Definition at line1864 of fileAPInt.cpp.

ReferencesLHS,negate(),RHS, andudivrem().

Referenced byceilingOfQuotient(),llvm::APFixedPoint::div(),findGCD(),floorOfQuotient(),isMultiple(),performMulCombine(),llvm::APIntOps::RoundingSDiv(),llvm::APIntOps::SolveQuadraticEquationWrap(),llvm::SCEVDivision::visitConstant(),llvm::InstCombinerImpl::visitGetElementPtrInst(), andllvm::InstCombinerImpl::visitMul().

◆ sdivrem()[2/2]

void APInt::sdivrem(constAPIntLHS,
int64_t RHS,
APIntQuotient,
int64_t & Remainder 
)
static

Definition at line1882 of fileAPInt.cpp.

ReferencesLHS,negate(),RHS, andudivrem().

◆ setAllBits()

void llvm::APInt::setAllBits()
inline

Set every bit to 1.

Definition at line1319 of fileAPInt.h.

ReferencesclearUnusedBits().

Referenced byllvm::KnownBits::ashr(),llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(),computeKnownBits(),llvm::SelectionDAG::computeKnownBits(),llvm::X86TargetLowering::computeKnownBitsForTargetNode(),computeKnownBitsFromOperator(),llvm::computeKnownBitsFromRangeMetadata(),llvm::GISelKnownBits::computeKnownBitsImpl(),getExtractedDemandedElts(),llvm::KnownBits::lshr(),llvm::KnownBits::setAllOnes(),llvm::KnownBits::setAllZero(),llvm::KnownBits::shl(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::TargetLowering::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), andllvm::ConstantRange::truncate().

◆ setBit()

void llvm::APInt::setBit(unsigned BitPosition)
inline

Set the given bit to 1 whose position is given as "bitPosition".

Definition at line1330 of fileAPInt.h.

Referencesassert(), andBitWidth.

Referenced byllvm::KnownBits::abs(),llvm::KnownBits::blsi(),combineAnd(),combineAndnp(),combineOr(),combineShuffleOfSplatVal(),combineVectorPack(),combineX86ShuffleChain(),combineX86ShufflesConstants(),combineX86ShufflesRecursively(),llvm::SelectionDAG::computeKnownBits(),llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(),computeKnownBitsFromOperator(),llvm::SelectionDAG::computeVectorKnownZeroElements(),computeZeroableShuffleElements(),divComputeLowBit(),EltsFromConsecutiveLoads(),llvm::TargetLowering::expandIS_FPCLASS(),llvm::extractConstantMask(),findDemandedEltsBySingleUser(),getDemandedSrcElements(),llvm::APFixedPoint::getEpsilon(),getExtractedDemandedElts(),llvm::getHorizDemandedEltsForFirstOperand(),llvm::TargetTransformInfoImplCRTPBase< T >::getInstructionCost(),llvm::BasicTTIImplBase< T >::getInterleavedMemoryOpCost(),llvm::X86TTIImpl::getInterleavedMemoryOpCostAVX512(),getKnownBitsFromAndXorOr(),getKnownUndefForVectorBinop(),getOneBitSet(),getPackDemandedElts(),llvm::getShuffleDemandedElts(),getSignedMinValue(),getTargetConstantBitsFromNode(),getTargetShuffleAndZeroables(),llvm::mca::initializeUsedResources(),isCompletePermute(),llvm::ShuffleVectorInst::isInsertSubvectorMask(),llvm::SelectionDAG::isSplatValue(),isTargetShuffleEquivalent(),lowerShuffleAsLanePermuteAndPermute(),matchBinaryShuffle(),llvm::KnownBits::mul(),PerformReduceShuffleCombine(),resolveZeroablesFromTargetShuffle(),llvm::APIntOps::ScaleBitMask(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::TargetLowering::SimplifyDemandedVectorElts(),llvm::InstCombinerImpl::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(),llvm::TargetLowering::SimplifyMultipleUseDemandedBits(),llvm::InstCombinerImpl::visitExtractElementInst(), andllvm::InstCombinerImpl::visitICmpInst().

◆ setBits()

void llvm::APInt::setBits(unsigned loBit,
unsigned hiBit 
)
inline

Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.

This function handles case whenloBit <=hiBit.

Definition at line1367 of fileAPInt.h.

Referencesassert(), andBitWidth.

Referenced byllvm::KnownBits::abs(),llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(),llvm::KnownBits::computeForAddSub(),llvm::LanaiTargetLowering::computeKnownBitsForTargetNode(),llvm::extractConstantMask(),getBitsSet(),getTargetConstantBitsFromNode(),llvm::BuildVectorSDNode::isConstantSplat(),matchBinaryShuffle(),llvm::APIntOps::ScaleBitMask(), andllvm::TargetLowering::SimplifyDemandedVectorElts().

◆ setBitsFrom()

void llvm::APInt::setBitsFrom(unsigned loBit)
inline

Set the top bits starting from loBit.

Definition at line1386 of fileAPInt.h.

ReferencesBitWidth.

Referenced byllvm::KnownBits::blsi(),llvm::KnownBits::blsmsk(),llvm::SelectionDAG::computeKnownBits(),llvm::SITargetLowering::computeKnownBitsForTargetInstr(),llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(),llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(),llvm::SITargetLowering::computeKnownBitsForTargetNode(),llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(),llvm::X86TargetLowering::computeKnownBitsForTargetNode(),computeKnownBitsFromOperator(),llvm::GISelKnownBits::computeKnownBitsImpl(),getBitsSetFrom(),isTruncateOf(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::X86TTIImpl::simplifyDemandedUseBitsIntrinsic(),llvm::RISCVTargetLowering::targetShrinkDemandedConstant(), andllvm::KnownBits::zext().

◆ setBitsWithWrap()

void llvm::APInt::setBitsWithWrap(unsigned loBit,
unsigned hiBit 
)
inline

Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.

This function handles "wrap" case whenloBit >=hiBit, and calls setBits whenloBit <hiBit. ForloBit ==hiBit wrap case, set every bit to 1.

Definition at line1354 of fileAPInt.h.

Referencesassert(), andBitWidth.

Referenced bygetBitsSetWithWrap().

◆ setBitVal()

void llvm::APInt::setBitVal(unsigned BitPosition,
bool BitValue 
)
inline

Set a given bit to a given value.

Definition at line1343 of fileAPInt.h.

Referenced byllvm::mca::RegisterFile::addRegisterWrite(),flipBit(),insertBits(),llvm::TargetLowering::SimplifyDemandedVectorElts(), andllvm::KnownBits::smin().

◆ setHighBits()

void llvm::APInt::setHighBits(unsigned hiBits)
inline

Set the top hiBits bits.

Definition at line1392 of fileAPInt.h.

ReferencesBitWidth.

Referenced byllvm::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(), andllvm::KnownBits::urem().

◆ setLowBits()

void llvm::APInt::setLowBits(unsigned loBits)
inline

Set the bottom loBits bits.

Definition at line1389 of fileAPInt.h.

Referenced byllvm::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(), andllvm::InstCombinerImpl::simplifyShrShlDemandedBits().

◆ setSignBit()

void llvm::APInt::setSignBit()
inline

Set the sign bit to 1.

Definition at line1340 of fileAPInt.h.

ReferencesBitWidth.

Referenced byllvm::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(), andsimplifyShift().

◆ sext()

APInt APInt::sext(unsigned width) const

Sign extend to a new width.

This operation sign extends theAPInt 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 line959 of fileAPInt.cpp.

ReferencesAPInt(),APINT_BITS_PER_WORD,APINT_WORD_SIZE,assert(),getMemory(),getNumWords(),getRawData(),isNegative(), andllvm::SignExtend64().

Referenced bycombineTruncToVnclip(),combineVPMADD(),llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(),detectSSatPattern(),detectSSatSPattern(),llvm::APFixedPoint::div(),llvm::BinaryOperation::eval(),llvm::TargetLowering::expandFP_TO_INT_SAT(),llvm::InstCombinerImpl::foldAddWithConstant(),foldNoWrapAdd(),llvm::ExecutionEngine::getConstantValue(),llvm::SelectionDAG::getNode(),isSaturatingMinMax(),lowerFCOPYSIGN(),llvm::APFixedPoint::mul(),llvm::APIntOps::mulhs(),llvm::ConstantRange::multiply(),narrowSDivOrSRem(),llvm::detail::SlowDynamicAPInt::operator!=(),llvm::detail::SlowDynamicAPInt::operator%(),llvm::detail::SlowDynamicAPInt::operator-(),llvm::detail::SlowDynamicAPInt::operator<(),llvm::detail::SlowDynamicAPInt::operator<=(),llvm::detail::SlowDynamicAPInt::operator==(),llvm::detail::SlowDynamicAPInt::operator>(),llvm::detail::SlowDynamicAPInt::operator>=(),llvm::RISCVTargetLowering::PerformDAGCombine(),performSETCCCombine(),printExtend(),roundToDouble(),selectI64ImmDirectPrefix(),llvm::KnownBits::sext(),sextOrTrunc(),llvm::APFixedPoint::shl(),llvm::ConstantRange::signExtend(),simplifyX86pack(),SolveQuadraticAddRecRange(),llvm::SCEVDivision::visitConstant(), andllvm::LegalizerHelper::widenScalar().

◆ sextOrTrunc()

APInt APInt::sextOrTrunc(unsigned width) const

Sign extend or truncate to width.

Make thisAPInt have the bit width given bywidth. The value is sign extended, truncated, or left alone to make it that width.

Definition at line1015 of fileAPInt.cpp.

Referencessext(), andtrunc().

Referenced byllvm::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(), andsimplifyRelativeLoad().

◆ sfloordiv_ov()

APInt APInt::sfloordiv_ov(constAPIntRHS,
boolOverflow 
) const

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 line1993 of fileAPInt.cpp.

ReferencesisNegative(),RHS, andsdiv_ov().

◆ sge()[1/2]

bool llvm::APInt::sge(constAPIntRHS) const
inline

Signed greater or equal comparison.

Regards both *this and RHS as signed quantities and compares them for validity of the greater-or-equal relationship.

Returns
true if *this >= RHS when both are considered signed.

Definition at line1237 of fileAPInt.h.

ReferencesRHS.

Referenced bycomputeKnownFPClass(),llvm::InstCombinerImpl::foldICmpOrConstant(),foldNoWrapAdd(),FoldValue(),llvm::ConstantRange::icmp(),isNonEqualPointersWithRecursiveGEP(),llvm::ConstantRangeList::isOrderedRanges(),llvm::detail::SlowDynamicAPInt::operator>=(),performMulCombine(),llvm::ConstantRangeList::subtract(), andTryMULWIDECombine().

◆ sge()[2/2]

bool llvm::APInt::sge(int64_t RHS) const
inline

Signed greater or equal comparison.

Regards both *this as a signed quantity and compares it with RHS for the validity of the greater-or-equal relationship.

Returns
true if *this >= RHS when considered signed.

Definition at line1245 of fileAPInt.h.

ReferencesRHS.

◆ sgt()[1/2]

bool llvm::APInt::sgt(constAPIntRHS) const
inline

Signed greater than comparison.

Regards both *this and RHS as signed quantities and compares them for the validity of the greater-than relationship.

Returns
true if *this > RHS when both are considered signed.

Definition at line1201 of fileAPInt.h.

ReferencesRHS.

Referenced bycanUseSExt(),llvm::APFixedPoint::compare(),llvm::InstCombinerImpl::foldICmpBinOpEqualityWithConstant(),llvm::InstCombinerImpl::foldICmpOrConstant(),llvm::InstCombinerImpl::foldICmpShrConstConst(),llvm::BasicTTIImplBase< T >::getEstimatedNumberOfCaseClusters(),llvm::ConstantRange::icmp(),llvm::ConstantRange::isSignWrappedSet(),llvm::ConstantRange::isUpperSignWrapped(),matchClamp(),llvm::detail::SlowDynamicAPInt::operator>(),llvm::ConstantRange::signedAddMayOverflow(),llvm::ConstantRange::signedSubMayOverflow(),llvm::APIntOps::SolveQuadraticEquationWrap(), andswitchToLookupTable().

◆ sgt()[2/2]

bool llvm::APInt::sgt(int64_t RHS) const
inline

Signed greater than comparison.

Regards both *this as a signed quantity and compares it with RHS for the validity of the greater-than relationship.

Returns
true if *this > RHS when considered signed.

Definition at line1209 of fileAPInt.h.

ReferencesRHS.

◆ shl()[1/2]

APInt llvm::APInt::shl(constAPIntShiftAmt) const
inline

Left-shift function.

Left-shift thisAPInt by shiftAmt.

Definition at line932 of fileAPInt.h.

◆ shl()[2/2]

APInt llvm::APInt::shl(unsigned shiftAmt) const
inline

Left-shift function.

Left-shift thisAPInt by shiftAmt.

Definition at line873 of fileAPInt.h.

Referenced byllvm::APFixedPoint::compare(),llvm::SelectionDAG::computeKnownBits(),computeKnownBitsFromOperator(),llvm::GISelKnownBits::computeKnownBitsImpl(),llvm::SelectionDAG::ComputeNumSignBits(),computeShlNSWWithNegLHS(),llvm::ConstantFoldBinaryInstruction(),convertShiftLeftToScale(),llvm::TargetLowering::CTTZTableLookup(),llvm::APFixedPoint::div(),llvm::TargetLowering::expandIS_FPCLASS(),llvm::InstCombinerImpl::foldICmpAndShift(),llvm::InstCombinerImpl::foldICmpShlConstConst(),foldICmpWithTruncSignExtendedVal(),foldSignedTruncationCheck(),llvm::SelectionDAG::isKnownNeverZero(),isNonZeroShift(),llvm::SelectionDAG::isSplatValue(),llvm::LegalizerHelper::lowerISFPCLASS(),LowerShift(),llvm::CombinerHelper::matchShlOfVScale(),rotl(),rotr(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::TargetLowering::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),simplifyX86insertq(),sqrt(),llvm::InstCombinerImpl::visitLShr(),llvm::Interpreter::visitShl(),llvm::InstCombinerImpl::visitShl(), andllvm::InstCombinerImpl::visitXor().

◆ signedRoundToDouble()

double llvm::APInt::signedRoundToDouble() const
inline

Converts this signedAPInt to a double value.

Definition at line1693 of fileAPInt.h.

Referenced byllvm::ExecutionEngine::getConstantValue(),llvm::APIntOps::RoundSignedAPIntToDouble(), andllvm::APIntOps::RoundSignedAPIntToFloat().

◆ sle()[1/2]

bool llvm::APInt::sle(constAPIntRHS) const
inline

Signed less or equal comparison.

Regards both *this and RHS as signed quantities and compares them for validity of the less-or-equal relationship.

Returns
true if *this <= RHS when both are considered signed.

Definition at line1166 of fileAPInt.h.

ReferencesRHS.

Referenced byllvm::SelectionDAG::computeKnownBits(),llvm::SelectionDAG::ComputeNumSignBits(),FoldValue(),llvm::ConstantRange::icmp(),llvm::ConstantRangeList::insert(),isNonEqualPointersWithRecursiveGEP(),isSignedMinMaxClamp(),isSignedMinMaxIntrinsicClamp(),isTruePredicate(),llvm::detail::SlowDynamicAPInt::operator<=(),performMulCombine(), andllvm::ConstantRangeList::subtract().

◆ sle()[2/2]

bool llvm::APInt::sle(uint64_t RHS) const
inline

Signed less or equal comparison.

Regards both *this as a signed quantity and compares it with RHS for the validity of the less-or-equal relationship.

Returns
true if *this <= RHS when considered signed.

Definition at line1174 of fileAPInt.h.

ReferencesRHS.

◆ slt()[1/2]

bool llvm::APInt::slt(constAPIntRHS) const
inline

Signed less than comparison.

Regards both *this and RHS as signed quantities and compares them for validity of the less-than relationship.

Returns
true if *this < RHS when both are considered signed.

Definition at line1130 of fileAPInt.h.

ReferencesRHS.

Referenced byllvm::SwitchCG::SwitchLowering::buildJumpTable(),canUseSExt(),llvm::APFixedPoint::compare(),llvm::exprMax(),findGCD(),foldLoadsRecursive(),getBoundsCheckCond(),llvm::BasicTTIImplBase< T >::getEstimatedNumberOfCaseClusters(),llvm::MDNode::getMostGenericRange(),llvm::ConstantRange::icmp(),llvm::ConstantRangeList::insert(),llvm::ConstantRangeList::intersectWith(),matchClamp(),MinOptional(),llvm::detail::SlowDynamicAPInt::operator<(),llvm::ConstantRange::signedAddMayOverflow(),llvm::ConstantRange::signedSubMayOverflow(),llvm::ConstantRangeList::subtract(),switchToLookupTable(),TryMULWIDECombine(),trySimplifyICmpWithAdds(), andllvm::ConstantRangeList::unionWith().

◆ slt()[2/2]

bool llvm::APInt::slt(int64_t RHS) const
inline

Signed less than comparison.

Regards both *this as a signed quantity and compares it with RHS for the validity of the less-than relationship.

Returns
true if *this < RHS when considered signed.

Definition at line1138 of fileAPInt.h.

ReferencesRHS.

◆ smul_ov()

APInt APInt::smul_ov(constAPIntRHS,
boolOverflow 
) const

Definition at line1934 of fileAPInt.cpp.

ReferencesisMinSignedValue(),RHS, andsdiv().

Referenced byllvm::checkedMul(),llvm::exprMul(),maintainNoSignedWrap(),llvm::APFixedPoint::mul(),multiplyOverflows(),MulWillOverflow(),llvm::detail::SlowDynamicAPInt::operator*(),llvm::ConstantRange::smul_fast(), andsmul_sat().

◆ smul_sat()

APInt APInt::smul_sat(constAPIntRHS) const

Definition at line2038 of fileAPInt.cpp.

ReferencesgetSignedMaxValue(),getSignedMinValue(),isNegative(),RHS, andsmul_ov().

Referenced byllvm::ConstantRange::smul_sat().

◆ sqrt()

APInt APInt::sqrt() const

Compute the square root.

Definition at line1173 of fileAPInt.cpp.

ReferencesAPInt(),assert(),getActiveBits(),isSingleWord(),round(),shl(),sqrt(),udiv(),ule(), andult().

Referenced bysqrt().

◆ srem()[1/2]

APInt APInt::srem(constAPIntRHS) const

Function for signed remainder operation.

Signed remainder operation onAPInt.

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 line1710 of fileAPInt.cpp.

ReferencesisNegative(),RHS, andurem().

Referenced byllvm::ConstantFoldBinaryInstruction(),llvm::ConstantFoldBinOp(),findGCD(),FoldValue(),getExactSDiv(),getStrideAndModOffsetOfGEP(),isRemainderZero(),isSimpleVIDSequence(),llvm::detail::SlowDynamicAPInt::operator%(),simplifyRelativeLoad(), andllvm::Interpreter::visitBinaryOperator().

◆ srem()[2/2]

int64_t APInt::srem(int64_t RHS) const

Definition at line1721 of fileAPInt.cpp.

ReferencesisNegative(),RHS, andurem().

◆ sshl_ov()[1/2]

APInt APInt::sshl_ov(constAPIntAmt,
boolOverflow 
) const

Definition at line1962 of fileAPInt.cpp.

ReferencesgetBitWidth(),getLimitedValue(), andsshl_ov().

Referenced bycomputeShlNSWWithNegLHS(),computeShlNSWWithNNegLHS(),sshl_ov(), andsshl_sat().

◆ sshl_ov()[2/2]

APInt APInt::sshl_ov(unsigned Amt,
boolOverflow 
) const

Definition at line1966 of fileAPInt.cpp.

ReferencesAPInt(),countl_one(),countl_zero(),getBitWidth(), andisNonNegative().

◆ sshl_sat()[1/2]

APInt APInt::sshl_sat(constAPIntRHS) const

Definition at line2060 of fileAPInt.cpp.

ReferencesgetBitWidth(),RHS, andsshl_sat().

Referenced byFoldValue(),sshl_sat(), andllvm::ConstantRange::sshl_sat().

◆ sshl_sat()[2/2]

APInt APInt::sshl_sat(unsigned RHS) const

Definition at line2064 of fileAPInt.cpp.

ReferencesgetSignedMaxValue(),getSignedMinValue(),isNegative(),RHS, andsshl_ov().

◆ ssub_ov()

APInt APInt::ssub_ov(constAPIntRHS,
boolOverflow 
) const

Definition at line1915 of fileAPInt.cpp.

ReferencesisNonNegative(), andRHS.

Referenced byllvm::checkedSub(),llvm::exprSub(),maintainNoSignedWrap(),moveAddAfterMinMax(),llvm::detail::SlowDynamicAPInt::operator-(),ssub_sat(),llvm::APFixedPoint::sub(),subWithOverflow(),switchToLookupTable(), andllvm::InstCombinerImpl::visitOr().

◆ ssub_sat()

APInt APInt::ssub_sat(constAPIntRHS) const

Definition at line2019 of fileAPInt.cpp.

ReferencesgetSignedMaxValue(),getSignedMinValue(),isNegative(),RHS, andssub_ov().

Referenced byFoldValue(),llvm::ConstantRange::ssub_sat(), andllvm::APFixedPoint::sub().

◆ tcAdd()

APInt::WordType APInt::tcAdd(WordTypedst,
constWordTyperhs,
WordType carry,
unsigned parts 
)
static

DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag.

Definition at line2416 of fileAPInt.cpp.

Referencesassert().

Referenced byoperator+=().

◆ tcAddPart()

APInt::WordType APInt::tcAddPart(WordTypedst,
WordType src,
unsigned parts 
)
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.

Returns
the carry of the addition.

Definition at line2438 of fileAPInt.cpp.

Referenced byoperator+=().

◆ tcAssign()

void APInt::tcAssign(WordTypedst,
constWordTypesrc,
unsigned parts 
)
static

Assign one bignum to another.

Definition at line2322 of fileAPInt.cpp.

Referenced byllvm::detail::IEEEFloat::convert(),llvm::detail::IEEEFloat::convertFromSignExtendedInteger(),llvm::detail::IEEEFloat::makeNaN(),llvm::powerOf5(),tcDivide(), andtcExtract().

◆ tcClearBit()

void APInt::tcClearBit(WordTypeparts,
unsigned bit 
)
static

Clear the given bit of a bignum. Zero-based.

Clears the given bit of a bignum.

Definition at line2347 of fileAPInt.cpp.

Referenced byllvm::detail::IEEEFloat::makeNaN().

◆ tcCompare()

int APInt::tcCompare(constWordTypelhs,
constWordTyperhs,
unsigned parts 
)
static

Comparison (unsigned) of two bignums.

Definition at line2725 of fileAPInt.cpp.

Referenced byllvm::detail::IEEEFloat::compareAbsoluteValue(), andtcDivide().

◆ tcDecrement()

staticWordType llvm::APInt::tcDecrement(WordTypedst,
unsigned parts 
)
inlinestatic

Decrement a bignum in-place. Return the borrow flag.

Definition at line1892 of fileAPInt.h.

Referenced byllvm::detail::IEEEFloat::next(), andoperator--().

◆ tcDivide()

int APInt::tcDivide(WordTypelhs,
constWordTyperhs,
WordTyperemainder,
WordTypescratch,
unsigned parts 
)
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 line2630 of fileAPInt.cpp.

ReferencesAPINT_BITS_PER_WORD,assert(),tcAssign(),tcCompare(),tcMSB(),tcSet(),tcShiftLeft(),tcShiftRight(), andtcSubtract().

◆ tcExtract()

void APInt::tcExtract(WordTypedst,
unsigned dstCount,
constWordTypesrc,
unsigned srcBits,
unsigned srcLSB 
)
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 line2386 of fileAPInt.cpp.

ReferencesAPINT_BITS_PER_WORD,assert(),lowBitMask(),tcAssign(), andtcShiftRight().

◆ tcExtractBit()

int APInt::tcExtractBit(constWordTypeparts,
unsigned bit 
)
static

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 line2337 of fileAPInt.cpp.

Referenced byllvm::detail::IEEEFloat::convertFromSignExtendedInteger(),llvm::detail::IEEEFloat::convertFromZeroExtendedInteger(),llvm::detail::IEEEFloat::isDenormal(),llvm::detail::IEEEFloat::isSignaling(), andllvm::lostFractionThroughTruncation().

◆ tcFullMultiply()

void APInt::tcFullMultiply(WordTypedst,
constWordTypelhs,
constWordTyperhs,
unsigned lhsParts,
unsigned rhsParts 
)
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 line2605 of fileAPInt.cpp.

Referencesassert(),tcFullMultiply(), andtcMultiplyPart().

Referenced byllvm::powerOf5(), andtcFullMultiply().

◆ tcIncrement()

staticWordType llvm::APInt::tcIncrement(WordTypedst,
unsigned parts 
)
inlinestatic

Increment a bignum in-place. Return the carry flag.

Definition at line1887 of fileAPInt.h.

Referenced byoperator++(), andtcNegate().

◆ tcIsZero()

bool APInt::tcIsZero(constWordTypesrc,
unsigned parts 
)
static

Returns true if a bignum is zero, false otherwise.

Definition at line2328 of fileAPInt.cpp.

Referenced byllvm::detail::IEEEFloat::makeNaN().

◆ tcLSB()

unsigned APInt::tcLSB(constWordTypeparts,
unsigned n 
)
static

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 line2353 of fileAPInt.cpp.

ReferencesAPINT_BITS_PER_WORD, andllvm::countr_zero().

Referenced byllvm::lostFractionThroughTruncation().

◆ tcMSB()

unsigned APInt::tcMSB(constWordTypeparts,
unsigned n 
)
static

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 line2366 of fileAPInt.cpp.

ReferencesAPINT_BITS_PER_WORD, andllvm::Log2_64().

Referenced bytcDivide().

◆ tcMultiply()

int APInt::tcMultiply(WordTypedst,
constWordTypelhs,
constWordTyperhs,
unsigned parts 
)
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 line2587 of fileAPInt.cpp.

Referencesassert(), andtcMultiplyPart().

Referenced byoperator*().

◆ tcMultiplyPart()

int APInt::tcMultiplyPart(WordTypedst,
constWordTypesrc,
WordType multiplier,
WordType carry,
unsigned srcParts,
unsigned dstParts,
bool add 
)
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 line2504 of fileAPInt.cpp.

ReferencesAPINT_BITS_PER_WORD,assert(),highHalf(), andlowHalf().

Referenced byoperator*=(),tcFullMultiply(), andtcMultiply().

◆ tcNegate()

void APInt::tcNegate(WordTypedst,
unsigned parts 
)
static

Negate a bignum in-place.

Definition at line2490 of fileAPInt.cpp.

ReferencestcComplement(), andtcIncrement().

Referenced byllvm::detail::IEEEFloat::convertFromSignExtendedInteger().

◆ tcSet()

void APInt::tcSet(WordTypedst,
WordType part,
unsigned parts 
)
static

Sets the least significant part of a bignum to the input value, and zeroes out higher parts.

Definition at line2314 of fileAPInt.cpp.

Referencesassert().

Referenced byllvm::detail::IEEEFloat::convert(),llvm::detail::IEEEFloat::makeInf(),llvm::detail::IEEEFloat::makeNaN(),llvm::detail::IEEEFloat::makeSmallest(),llvm::detail::IEEEFloat::makeZero(),llvm::detail::IEEEFloat::next(), andtcDivide().

◆ tcSetBit()

void APInt::tcSetBit(WordTypeparts,
unsigned bit 
)
static

Set the given bit of a bignum. Zero-based.

Set the given bit of a bignum.

Definition at line2342 of fileAPInt.cpp.

Referenced byllvm::detail::IEEEFloat::convert(),llvm::detail::IEEEFloat::makeNaN(),llvm::detail::IEEEFloat::makeQuiet(),llvm::detail::IEEEFloat::makeSmallestNormalized(), andllvm::detail::IEEEFloat::next().

◆ tcShiftLeft()

void APInt::tcShiftLeft(WordTypeDst,
unsigned Words,
unsigned Count 
)
static

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 line2672 of fileAPInt.cpp.

ReferencesAPINT_BITS_PER_WORD, andAPINT_WORD_SIZE.

Referenced byllvm::detail::IEEEFloat::convert(),llvm::detail::IEEEFloat::convertToInteger(), andtcDivide().

◆ tcShiftRight()

void APInt::tcShiftRight(WordTypeDst,
unsigned Words,
unsigned Count 
)
static

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 line2699 of fileAPInt.cpp.

ReferencesAPINT_BITS_PER_WORD, andAPINT_WORD_SIZE.

Referenced byllvm::shiftRight(),tcDivide(), andtcExtract().

◆ tcSubtract()

APInt::WordType APInt::tcSubtract(WordTypedst,
constWordTyperhs,
WordType carry,
unsigned parts 
)
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 line2451 of fileAPInt.cpp.

Referencesassert().

Referenced byoperator-=(), andtcDivide().

◆ tcSubtractPart()

APInt::WordType APInt::tcSubtractPart(WordTypedst,
WordType src,
unsigned parts 
)
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.

Returns
the borrow out of the subtraction

Definition at line2476 of fileAPInt.cpp.

Referenced byoperator-=().

◆ toString()

void APInt::toString(SmallVectorImpl<char > & Str,
unsigned Radix,
bool Signed,
bool formatAsCLiteral =false,
bool UpperCase =true,
bool InsertSeparators =false 
) const

Converts anAPInt to a string and append it to Str.

Str is commonly aSmallString. If Radix > 10, UpperCase determine the case of letter digits.

Definition at line2138 of fileAPInt.cpp.

Referencesassert(),getBoolValue(),getRawData(),getSExtValue(),getZExtValue(),I,isNegative(),isSingleWord(),isZero(),llvm_unreachable,lshrInPlace(),N,negate(),Signed, andudivrem().

Referenced byllvm::ExpressionFormat::getMatchingString(), andprint().

◆ toStringSigned()

void llvm::APInt::toStringSigned(SmallVectorImpl<char > & Str,
unsigned Radix =10 
) const
inline

Considers theAPInt 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 line1675 of fileAPInt.h.

ReferencestoString().

Referenced bydump().

◆ toStringUnsigned()

void llvm::APInt::toStringUnsigned(SmallVectorImpl<char > & Str,
unsigned Radix =10 
) const
inline

Considers theAPInt 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 line1669 of fileAPInt.h.

ReferencestoString().

Referenced bydump().

◆ trunc()

APInt APInt::trunc(unsigned width) const

Truncate to new width.

Truncate theAPInt to a specified width. It is an error to specify a width that is greater than the current width.

Definition at line910 of fileAPInt.cpp.

ReferencesAPInt(),APINT_BITS_PER_WORD,assert(),getMemory(),getNumWords(), andgetRawData().

Referenced byllvm::APSInt::APSInt(),areUsedBitsDense(),combineVectorPack(),combineX86ShufflesRecursively(),llvm::KnownBits::computeForAddSub(),llvm::TargetLowering::expandDIVREMByConstant(),extractConstantWithoutWrapping(),llvm::SelectionDAG::FoldConstantArithmetic(),llvm::InstCombinerImpl::foldICmpShlConstant(),foldNoWrapAdd(),llvm::ExecutionEngine::getConstantValue(),getDemandedSrcElements(),llvm::SelectionDAG::getNode(),llvm::GCNTTIImpl::instCombineIntrinsic(),llvm::BuildVectorSDNode::isConstantSequence(),llvm::ISD::isConstantSplatVector(),llvm::TargetLowering::isConstTrueVal(),isSaturatingMinMax(),llvm::SelectionDAG::isSplatValue(),llvm::SystemZVectorConstantInfo::isVectorConstantLegal(),lowerMSABinaryBitImmIntr(),llvm::CombinerHelper::matchCastOfInteger(),llvm::CombinerHelper::matchCombineUnmergeConstant(),llvm::LegalizerHelper::narrowScalar(),llvm::RISCVTargetLowering::PerformDAGCombine(),performSETCCCombine(),processUMulZExtIdiom(),rebuildExtCst(),sextOrTrunc(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::TargetLowering::SimplifySetCC(),llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(),llvm::X86TargetLowering::targetShrinkDemandedConstant(),llvm::KnownBits::trunc(),llvm::ConstantRange::truncate(),truncSSat(),truncUSat(),llvm::InstCombinerImpl::visitAnd(),llvm::InstCombinerImpl::visitICmpInst(),llvm::InstCombinerImpl::visitSwitchInst(), andzextOrTrunc().

◆ truncSSat()

APInt APInt::truncSSat(unsigned width) const

Truncate to new width with signed saturation.

If thisAPInt, treated as signed integer, can be losslessly truncated to the new bitwidth, then return truncatedAPInt. Else, return either signed min value if theAPInt was negative, or signed max value.

Definition at line947 of fileAPInt.cpp.

Referencesassert(),getSignedMaxValue(),getSignedMinValue(),isNegative(),isSignedIntN(), andtrunc().

Referenced bycombineVectorPack().

◆ truncUSat()

APInt APInt::truncUSat(unsigned width) const

Truncate to new width with unsigned saturation.

If theAPInt, treated as unsigned integer, can be losslessly truncated to the new bitwidth, then return truncatedAPInt. Else, return max value.

Definition at line936 of fileAPInt.cpp.

Referencesassert(),getMaxValue(),isIntN(), andtrunc().

◆ trySExtValue()

std::optional< int64_t > llvm::APInt::trySExtValue() const
inline

Get sign extended value if possible.

This method attempts to return the value of thisAPInt 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 line1554 of fileAPInt.h.

Referenced byllvm::getExpressionForConstant(), andsimplifySwitchOfCmpIntrinsic().

◆ tryZExtValue()

std::optional<uint64_t > llvm::APInt::tryZExtValue() const
inline

Get zero extended value if possible.

This method attempts to return the value of thisAPInt 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 line1532 of fileAPInt.h.

Referenced bymayLoopAccessLocation().

◆ uadd_ov()

APInt APInt::uadd_ov(constAPIntRHS,
boolOverflow 
) const

Definition at line1909 of fileAPInt.cpp.

ReferencesRHS, andult().

Referenced byllvm::APFixedPoint::add(),addWithOverflow(),llvm::checkedAddUnsigned(),combineShiftOfShiftedLogic(),optimizeIncrementingWhile(),uadd_sat(),llvm::InstCombinerImpl::visitCallInst(), andllvm::InstCombinerImpl::visitOr().

◆ uadd_sat()

APInt APInt::uadd_sat(constAPIntRHS) const

Definition at line2010 of fileAPInt.cpp.

ReferencesgetMaxValue(),RHS, anduadd_ov().

Referenced byllvm::APFixedPoint::add(),FoldValue(),llvm::ConstantRange::uadd_sat(), andllvm::InstCombinerImpl::visitCallInst().

◆ udiv()[1/2]

APInt APInt::udiv(constAPIntRHS) const

Unsigned division operation.

Perform an unsigned divide operation on thisAPInt by RHS. Both this and RHS are treated as unsigned quantities for purposes of this division.

Returns
a newAPInt value containing the division result, rounded towards zero.

Definition at line1547 of fileAPInt.cpp.

ReferencesAPInt(),assert(),getActiveBits(),getNumWords(),isSingleWord(),pVal,RHS, andult().

Referenced bycalculateGEPOffset(),llvm::InstCombinerImpl::commonIDivTransforms(),llvm::ConstantFoldBinaryInstruction(),llvm::ConstantFoldBinOp(),llvm::APFixedPoint::div(),llvm::InstCombinerImpl::foldICmpDivConstant(),llvm::InstCombinerImpl::foldICmpUDivConstant(),FoldValue(),foldVecExtTruncToExtElt(),getRangeForAffineARHelper(),optimizeSection(),llvm::scaleProfData(),sdiv(),setLimitsForBinOp(),llvm::APIntOps::SolveQuadraticEquationWrap(),sqrt(),llvm::ConstantRange::udiv(),llvm::KnownBits::udiv(), andllvm::Interpreter::visitBinaryOperator().

◆ udiv()[2/2]

APInt APInt::udiv(uint64_t RHS) const

Definition at line1585 of fileAPInt.cpp.

ReferencesAPInt(),assert(),getActiveBits(),getNumWords(),isSingleWord(),pVal,RHS, andult().

◆ udivrem()[1/2]

void APInt::udivrem(constAPIntLHS,
constAPIntRHS,
APIntQuotient,
APIntRemainder 
)
static

Dual division/remainder interface.

Sometimes it is convenient to divide twoAPInt 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 line1732 of fileAPInt.cpp.

ReferencesAPInt(),APINT_WORD_SIZE,assert(),llvm::BitWidth,getNumWords(),LHS,pVal, andRHS.

Referenced byextractShiftForRotate(),foldICmpShlLHSC(),GEPToVectorIndex(),llvm::SignedDivisionByConstantInfo::get(),llvm::UnsignedDivisionByConstantInfo::get(),isMultiple(),llvm::APIntOps::RoundingUDiv(),sdivrem(),toString(), andllvm::InstCombinerImpl::visitGetElementPtrInst().

◆ udivrem()[2/2]

void APInt::udivrem(constAPIntLHS,
uint64_t RHS,
APIntQuotient,
uint64_tRemainder 
)
static

Definition at line1803 of fileAPInt.cpp.

ReferencesAPInt(),APINT_WORD_SIZE,assert(),llvm::BitWidth,getNumWords(),LHS,pVal, andRHS.

◆ uge()[1/2]

bool llvm::APInt::uge(constAPIntRHS) const
inline

Unsigned greater or equal comparison.

Regards both *this and RHS as unsigned quantities and compares them for validity of the greater-or-equal relationship.

Returns
true if *this >= RHS when both are considered unsigned.

Definition at line1221 of fileAPInt.h.

ReferencesRHS.

Referenced byllvm::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::foldICmpSRemConstant(),llvm::InstCombinerImpl::FoldShiftByConstant(),FoldValue(),foldVecExtTruncToExtElt(),llvm::SignedDivisionByConstantInfo::get(),llvm::UnsignedDivisionByConstantInfo::get(),llvm::SelectionDAG::getValidShiftAmountRange(),getVariantMatchScore(),llvm::ConstantRange::icmp(),isDereferenceableAndAlignedPointer(),isNonZeroShift(),isPoisonShift(),LowerShiftByScalarImmediate(),matchAndOrChain(),llvm::CombinerHelper::matchCombineTruncOfShift(),PerformSHLSimplify(),llvm::X86TargetLowering::preferedOpcodeForCmpEqPiecesOfOperand(),simplifyAndCommutative(),simplifyLShrInst(),simplifyShift(),llvm::InstCombinerImpl::simplifyShrShlDemandedBits(),simplifyX86immShift(),simplifyX86varShift(),splitGlobal(),llvm::ConstantInt::uge(),llvm::ConstantRange::unionWith(),llvm::InstCombinerImpl::visitICmpInst(), andllvm::InstCombinerImpl::visitLShr().

◆ uge()[2/2]

bool llvm::APInt::uge(uint64_t RHS) const
inline

Unsigned greater or equal comparison.

Regards both *this as an unsigned quantity and compares it with RHS for the validity of the greater-or-equal relationship.

Returns
true if *this >= RHS when considered unsigned.

Definition at line1229 of fileAPInt.h.

ReferencesRHS.

◆ ugt()[1/2]

bool llvm::APInt::ugt(constAPIntRHS) const
inline

Unsigned greater than comparison.

Regards both *this and RHS as unsigned quantities and compares them for the validity of the greater-than relationship.

Returns
true if *this > RHS when both are considered unsigned.

Definition at line1182 of fileAPInt.h.

ReferencesRHS.

Referenced byllvm::SelectionDAG::canCreateUndefOrPoison(),canEvaluateShiftedShift(),llvm::APFixedPoint::compare(),llvm::InstCombinerImpl::convertOrOfShiftsToFunnelShift(),extractShiftForRotate(),foldICmpShlLHSC(),foldICmpWithTruncSignExtendedVal(),llvm::SelectionDAG::getValidShiftAmountRange(),llvm::ConstantRange::icmp(),llvm::isDereferenceableAndAlignedInLoop(),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(), andllvm::InstCombinerImpl::visitLShr().

◆ ugt()[2/2]

bool llvm::APInt::ugt(uint64_t RHS) const
inline

Unsigned greater than comparison.

Regards both *this as an unsigned quantity and compares it with RHS for the validity of the greater-than relationship.

Returns
true if *this > RHS when considered unsigned.

Definition at line1190 of fileAPInt.h.

ReferencesRHS.

◆ ule()[1/2]

bool llvm::APInt::ule(constAPIntRHS) const
inline

Unsigned less or equal comparison.

Regards both *this and RHS as unsigned quantities and compares them for validity of the less-or-equal relationship.

Returns
true if *this <= RHS when both are considered unsigned.

Definition at line1150 of fileAPInt.h.

ReferencesRHS.

Referenced byllvm::SCEVAAResult::alias(),combineArithReduction(),llvm::InstCombinerImpl::commonIDivTransforms(),llvm::ConstantRange::contains(),llvm::InstCombinerImpl::convertOrOfShiftsToFunnelShift(),llvm::TargetLowering::expandDIVREMByConstant(),llvm::InstCombinerImpl::foldICmpAndConstConst(),llvm::InstCombinerImpl::foldICmpBinOp(),foldShiftIntoShiftInAnotherHandOfAndInICmp(),FoldValue(),llvm::ScalarEvolution::getAddExpr(),llvm::ConstantRange::icmp(),llvm::ConstantRange::intersectWith(),isTruePredicate(),matchIntPart(),llvm::AMDGPUTargetLowering::performTruncateCombine(),processAnd(),llvm::ConstantRange::shl(),simplifyICmpWithBinOpOnLHS(),sqrt(),llvm::ConstantRange::unionWith(), andllvm::InstCombinerImpl::visitGetElementPtrInst().

◆ ule()[2/2]

bool llvm::APInt::ule(uint64_t RHS) const
inline

Unsigned less or equal comparison.

Regards both *this as an unsigned quantity and compares it with RHS for the validity of the less-or-equal relationship.

Returns
true if *this <= RHS when considered unsigned.

Definition at line1158 of fileAPInt.h.

ReferencesRHS.

◆ ult()[1/2]

bool llvm::APInt::ult(constAPIntRHS) const
inline

Unsigned less than comparison.

Regards both *this and RHS as unsigned quantities and compares them for the validity of the less-than relationship.

Returns
true if *this < RHS when both are considered unsigned.

Definition at line1111 of fileAPInt.h.

ReferencesRHS.

Referenced bycanEvaluateShiftedShift(),canEvaluateTruncated(),cheapToScalarize(),combineCMov(),combineCMP(),combineExtractWithShuffle(),combineShiftRightArithmetic(),llvm::InstCombinerImpl::commonIDivTransforms(),llvm::APFixedPoint::compare(),CompareSCEVComplexity(),llvm::ARMTargetLowering::computeKnownBitsForTargetNode(),computeKnownBitsFromShiftOperator(),llvm::SelectionDAG::computeOverflowForUnsignedAdd(),computePointerICmp(),llvm::InstCombinerImpl::convertOrOfShiftsToFunnelShift(),findDemandedEltsBySingleUser(),foldICmpWithTruncSignExtendedVal(),foldShiftIntoShiftInAnotherHandOfAndInICmp(),llvm::SignedDivisionByConstantInfo::get(),llvm::UnsignedDivisionByConstantInfo::get(),llvm::omp::getBestVariantMatchForContext(),getRangeForAffineARHelper(),llvm::SelectionDAG::getShiftAmountConstant(),llvm::SelectionDAG::getValidShiftAmountRange(),llvm::ConstantRange::icmp(),llvm::ConstantRange::intersectWith(),llvm::SelectionDAG::isKnownNeverZero(),matchClamp(),llvm::X86TargetLowering::preferedOpcodeForCmpEqPiecesOfOperand(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),simplifyIRemMulShl(),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(), andllvm::InstCombinerImpl::visitShl().

◆ ult()[2/2]

bool llvm::APInt::ult(uint64_t RHS) const
inline

Unsigned less than comparison.

Regards both *this as an unsigned quantity and compares it with RHS for the validity of the less-than relationship.

Returns
true if *this < RHS when considered unsigned.

Definition at line1119 of fileAPInt.h.

ReferencesRHS.

◆ umul_ov()

APInt APInt::umul_ov(constAPIntRHS,
boolOverflow 
) const

Definition at line1945 of fileAPInt.cpp.

Referencescountl_zero(),isNegative(),lshr(),RHS, andult().

Referenced byllvm::checkedMulUnsigned(),llvm::SelectionDAG::computeKnownBits(),llvm::ScalarEvolution::getUDivExpr(),llvm::APFixedPoint::mul(),llvm::KnownBits::mul(),multiplyOverflows(),MulWillOverflow(),umul_sat(), andllvm::ConstantRange::unsignedMulMayOverflow().

◆ umul_sat()

APInt APInt::umul_sat(constAPIntRHS) const

Definition at line2051 of fileAPInt.cpp.

ReferencesgetMaxValue(),RHS, andumul_ov().

Referenced byllvm::ConstantRange::umul_sat().

◆ urem()[1/2]

APInt APInt::urem(constAPIntRHS) const

Unsigned remainder operation.

Perform an unsigned remainder operation on thisAPInt with RHS being the divisor. Both this and RHS are treated as unsigned quantities for purposes of this operation.

Returns
a newAPInt value containing the remainder result

Definition at line1640 of fileAPInt.cpp.

ReferencesAPInt(),assert(),getActiveBits(),getNumWords(),isSingleWord(),RHS, andult().

Referenced byllvm::CombinerHelper::applyFunnelShiftConstantModulo(),combineExtractWithShuffle(),computeKnownBitsFromOperator(),llvm::ConstantFoldBinaryInstruction(),llvm::ConstantFoldBinOp(),llvm::TargetLowering::expandDIVREMByConstant(),FoldValue(),foldVecExtTruncToExtElt(),llvm::ScalarEvolution::getUDivExpr(),llvm::isDereferenceableAndAlignedInLoop(),isLoadCombineCandidateImpl(),isNonZeroModBitWidthOrUndef(),LowerFunnelShift(),LowerRotate(),rotateModulo(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),simplifyIntrinsic(),srem(),llvm::ScalarEvolution::verify(), andllvm::Interpreter::visitBinaryOperator().

◆ urem()[2/2]

uint64_t APInt::urem(uint64_t RHS) const

Definition at line1678 of fileAPInt.cpp.

Referencesassert(),getActiveBits(),getNumWords(),getZExtValue(),isSingleWord(),RHS, andult().

◆ ushl_ov()[1/2]

APInt APInt::ushl_ov(constAPIntAmt,
boolOverflow 
) const

Definition at line1979 of fileAPInt.cpp.

ReferencesgetBitWidth(),getLimitedValue(), andushl_ov().

Referenced bycomputeShlNUW(),ushl_ov(),ushl_sat(), andllvm::InstCombinerImpl::visitUDiv().

◆ ushl_ov()[2/2]

APInt APInt::ushl_ov(unsigned Amt,
boolOverflow 
) const

Definition at line1983 of fileAPInt.cpp.

ReferencesAPInt(),countl_zero(), andgetBitWidth().

◆ ushl_sat()[1/2]

APInt APInt::ushl_sat(constAPIntRHS) const

Definition at line2074 of fileAPInt.cpp.

ReferencesgetBitWidth(),RHS, andushl_sat().

Referenced byFoldValue(),ushl_sat(), andllvm::ConstantRange::ushl_sat().

◆ ushl_sat()[2/2]

APInt APInt::ushl_sat(unsigned RHS) const

Definition at line2078 of fileAPInt.cpp.

ReferencesgetMaxValue(),RHS, andushl_ov().

◆ usub_ov()

APInt APInt::usub_ov(constAPIntRHS,
boolOverflow 
) const

Definition at line1922 of fileAPInt.cpp.

ReferencesRHS, andugt().

Referenced bymoveAddAfterMinMax(),llvm::APFixedPoint::sub(),subWithOverflow(),usub_sat(), andllvm::InstCombinerImpl::visitOr().

◆ usub_sat()

APInt APInt::usub_sat(constAPIntRHS) const

Definition at line2029 of fileAPInt.cpp.

ReferencesAPInt(),RHS, andusub_ov().

Referenced byFoldValue(),llvm::APFixedPoint::sub(), andllvm::ConstantRange::usub_sat().

◆ zext()

APInt APInt::zext(unsigned width) const

Zero extend to a new width.

This operation zero extends theAPInt 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 line986 of fileAPInt.cpp.

ReferencesAPInt(),APINT_BITS_PER_WORD,APINT_WORD_SIZE,assert(),getMemory(),getNumWords(), andgetRawData().

Referenced byllvm::KnownBits::anyext(),llvm::ConstantRange::castOp(),combineVPMADD(),combineX86ShufflesRecursively(),llvm::SelectionDAG::computeKnownBits(),llvm::GISelKnownBits::computeKnownBitsImpl(),llvm::SelectionDAG::ComputeNumSignBits(),llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(),ConstantBuildVector(),detectSSatPattern(),detectSSatUPattern(),detectUSatUPattern(),llvm::APFixedPoint::div(),llvm::TargetLowering::expandFP_TO_INT_SAT(),extractConstantWithoutWrapping(),llvm::InstCombinerImpl::foldICmpAndConstConst(),llvm::InstCombinerImpl::foldICmpEquality(),foldSignedTruncationCheck(),llvm::SCEVExpander::generateOverflowCheck(),llvm::getAllocSize(),llvm::ExecutionEngine::getConstantValue(),llvm::SelectionDAG::getNode(),llvm::X86TTIImpl::getReplicationShuffleCost(),llvm::X86TTIImpl::getScalarizationOverhead(),isObjectSizeLessThanOrEq(),isSameValue(),llvm::SelectionDAG::isSplatValue(),llvm::RISCVLegalizerInfo::legalizeCustom(),llvm::APFixedPoint::mul(),llvm::APIntOps::mulhu(),llvm::ConstantRange::multiply(),performANDCombine(),llvm::PPCTargetLowering::PerformDAGCombine(),PerformUMinFpToSatCombine(),printExtend(),processUMulZExtIdiom(),rotateModulo(),llvm::APFixedPoint::shl(),llvm::ConstantRange::signExtend(),llvm::TargetLowering::SimplifyDemandedBits(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::TargetLowering::SimplifyDemandedVectorElts(),llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(),SolveLinEquationWithOverflow(),toSigned(),llvm::APFixedPoint::toString(),llvm::LegalizationArtifactCombiner::tryCombineZExt(),tryToMergePartialOverlappingStores(),llvm::InstCombinerImpl::visitAnd(),llvm::LegalizerHelper::widenScalar(),llvm::ConstantRange::zeroExtend(),llvm::KnownBits::zext(), andzextOrTrunc().

◆ zextOrTrunc()

APInt APInt::zextOrTrunc(unsigned width) const

Zero extend or truncate to width.

Make thisAPInt have the bit width given bywidth. The value is zero extended, truncated, or left alone to make it that width.

Definition at line1007 of fileAPInt.cpp.

Referencestrunc(), andzext().

Referenced byllvm::computeKnownBitsFromRangeMetadata(),llvm::X86TargetLowering::ComputeNumSignBitsForTargetNode(),llvm::DIExpression::constantFold(),llvm::Interpreter::exitCalled(),extractShiftForRotate(),llvm::SelectionDAG::FoldConstantArithmetic(),llvm::SelectionDAG::getConstant(),llvm::ExecutionEngine::getConstantValue(),getFauxShuffleMask(),getPreferredVectorIndex(),llvm::ScalarEvolution::getSmallConstantTripMultiple(),llvm::X86TTIImpl::instCombineIntrinsic(),isBitfieldDstMask(),llvm::isKnownToBeAPowerOfTwo(),llvm::CombinerHelper::matchCombineConstPtrAddToI2P(),resolveBuildVector(),llvm::simplifyBinaryIntrinsic(),llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(),llvm::InstCombinerImpl::SimplifyDemandedUseBits(),llvm::X86TTIImpl::simplifyDemandedUseBitsIntrinsic(),llvm::TargetLowering::SimplifyDemandedVectorElts(),llvm::InstCombinerImpl::SimplifyDemandedVectorElts(),llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(),simplifyX86extrq(),simplifyX86immShift(),simplifyX86insertq(),SkipExtensionForVMULL(),llvm::APFixedPoint::toString(), andtryLowerToSLI().

Friends And Related Function Documentation

◆ APSInt

friend classAPSInt
friend

Definition at line1917 of fileAPInt.h.

◆ DenseMapInfo< APInt, void >

friend structDenseMapInfo<APInt, void >
friend

Definition at line1914 of fileAPInt.h.

◆ hash_value

hash_code hash_value(constAPIntArg)
friend

Overload to compute ahash_code for anAPInt value.

Member Data Documentation

◆ APINT_BITS_PER_WORD

constexprunsigned llvm::APInt::APINT_BITS_PER_WORD =APINT_WORD_SIZE * CHAR_BIT
staticconstexpr

Bits in a word.

Definition at line86 of fileAPInt.h.

Referenced bybyteSwap(),extractBits(),extractBitsAsZExtValue(),llvm::detail::IEEEFloat::getExactLog2Abs(),highHalf(),insertBits(),lowBitMask(),lowHalf(),nextAPIntBitWidth(),roundToDouble(),sext(),tcDivide(),tcExtract(),tcLSB(),tcMSB(),tcMultiplyPart(),llvm::detail::tcSetLeastSignificantBits(),tcShiftLeft(),tcShiftRight(),trunc(), andzext().

◆ APINT_WORD_SIZE

constexprunsigned llvm::APInt::APINT_WORD_SIZE = sizeof(WordType)
staticconstexpr

Byte size of a word.

Definition at line83 of fileAPInt.h.

Referenced byinsertBits(),sext(),tcShiftLeft(),tcShiftRight(),udivrem(), andzext().

◆ pVal

uint64_t* llvm::APInt::pVal

Used to store the >64 bits integer value.

Definition at line1911 of fileAPInt.h.

Referenced byllvm::hash_value(),roundToDouble(),udiv(), andudivrem().

◆ VAL

uint64_t llvm::APInt::VAL

Used to store the <= 64 bits integer value.

Definition at line1910 of fileAPInt.h.

Referenced byAPInt(),concat(),llvm::hash_value(), andinsertBits().

◆ WORDTYPE_MAX

constexprWordType llvm::APInt::WORDTYPE_MAX = ~WordType(0)
staticconstexpr

Definition at line94 of fileAPInt.h.

Referenced byinsertBits().


The documentation for this class was generated from the following files:

Generated on Sun Jul 20 2025 15:08:26 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp