LLVM 19.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  : unsigned { APINT_WORD_SIZE = sizeof(WordType) , APINT_BITS_PER_WORD = APINT_WORD_SIZE * CHAR_BIT }
 This enum is used to hold the constants we needed for APInt. More...
 
enum class  Rounding { DOWN , TOWARD_ZERO , UP }
 
typedef uint64_t WordType
 

Public Member Functions

Constructors
 APInt (unsigned numBits, uint64_t val, bool isSigned=false)
 Create a new APInt of numBits width, initialized as val.
 
 APInt (unsigned numBits, ArrayRef< uint64_t > bigVal)
 Construct an APInt of numBits width, initialized as bigVal[].
 
 APInt (unsigned numBits, unsigned numWords, const uint64_t bigVal[])
 Equivalent to APInt(numBits, ArrayRef<uint64_t>(bigVal, numWords)), but deprecated because this constructor is prone to ambiguity with the APInt(unsigned, uint64_t, bool) constructor.
 
 APInt (unsigned numBits, StringRef str, uint8_t radix)
 Construct an APInt from a string representation.
 
 APInt ()
 Default constructor that creates an APInt with a 1-bit zero value.
 
 APInt (const APInt &that)
 Copy Constructor.
 
 APInt (APInt &&that)
 Move Constructor.
 
 ~APInt ()
 Destructor.
 
Unary Operators
APInt operator++ (int)
 Postfix increment operator.
 
APIntoperator++ ()
 Prefix increment operator.
 
APInt operator-- (int)
 Postfix decrement operator.
 
APIntoperator-- ()
 Prefix decrement operator.
 
bool operator! () const
 Logical negation operation on this APInt returns true if zero, like normal integers.
 
Assignment Operators
APIntoperator= (const APInt &RHS)
 Copy assignment operator.
 
APIntoperator= (APInt &&that)
 Move assignment operator.
 
APIntoperator= (uint64_t RHS)
 Assignment operator.
 
APIntoperator&= (const APInt &RHS)
 Bitwise AND assignment operator.
 
APIntoperator&= (uint64_t RHS)
 Bitwise AND assignment operator.
 
APIntoperator|= (const APInt &RHS)
 Bitwise OR assignment operator.
 
APIntoperator|= (uint64_t RHS)
 Bitwise OR assignment operator.
 
APIntoperator^= (const APInt &RHS)
 Bitwise XOR assignment operator.
 
APIntoperator^= (uint64_t RHS)
 Bitwise XOR assignment operator.
 
APIntoperator*= (const APInt &RHS)
 Multiplication assignment operator.
 
APIntoperator*= (uint64_t RHS)
 
APIntoperator+= (const APInt &RHS)
 Addition assignment operator.
 
APIntoperator+= (uint64_t RHS)
 
APIntoperator-= (const APInt &RHS)
 Subtraction assignment operator.
 
APIntoperator-= (uint64_t RHS)
 
APIntoperator<<= (unsigned ShiftAmt)
 Left-shift assignment function.
 
APIntoperator<<= (const APInt &ShiftAmt)
 Left-shift assignment function.
 
Comparison Operators
bool operator== (const APInt &RHS) const
 Equality operator.
 
bool operator== (uint64_t Val) const
 Equality operator.
 
bool eq (const APInt &RHS) const
 Equality comparison.
 
bool operator!= (const APInt &RHS) const
 Inequality operator.
 
bool operator!= (uint64_t Val) const
 Inequality operator.
 
bool ne (const APInt &RHS) const
 Inequality comparison.
 
bool ult (const APInt &RHS) const
 Unsigned less than comparison.
 
bool ult (uint64_t RHS) const
 Unsigned less than comparison.
 
bool slt (const APInt &RHS) const
 Signed less than comparison.
 
bool slt (int64_t RHS) const
 Signed less than comparison.
 
bool ule (const APInt &RHS) const
 Unsigned less or equal comparison.
 
bool ule (uint64_t RHS) const
 Unsigned less or equal comparison.
 
bool sle (const APInt &RHS) const
 Signed less or equal comparison.
 
bool sle (uint64_t RHS) const
 Signed less or equal comparison.
 
bool ugt (const APInt &RHS) const
 Unsigned greater than comparison.
 
bool ugt (uint64_t RHS) const
 Unsigned greater than comparison.
 
bool sgt (const APInt &RHS) const
 Signed greater than comparison.
 
bool sgt (int64_t RHS) const
 Signed greater than comparison.
 
bool uge (const APInt &RHS) const
 Unsigned greater or equal comparison.
 
bool uge (uint64_t RHS) const
 Unsigned greater or equal comparison.
 
bool sge (const APInt &RHS) const
 Signed greater or equal comparison.
 
bool sge (int64_t RHS) const
 Signed greater or equal comparison.
 
bool intersects (const APInt &RHS) const
 This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are both set.
 
bool isSubsetOf (const APInt &RHS) const
 This operation checks that all bits set in this APInt are also set in RHS.
 
Resizing Operators
APInt trunc (unsigned width) const
 Truncate to new width.
 
APInt truncUSat (unsigned width) const
 Truncate to new width with unsigned saturation.
 
APInt truncSSat (unsigned width) const
 Truncate to new width with signed saturation.
 
APInt sext (unsigned width) const
 Sign extend to a new width.
 
APInt zext (unsigned width) const
 Zero extend to a new width.
 
APInt sextOrTrunc (unsigned width) const
 Sign extend or truncate to width.
 
APInt zextOrTrunc (unsigned width) const
 Zero extend or truncate to width.
 
Bit Manipulation Operators
void setAllBits ()
 Set every bit to 1.
 
void setBit (unsigned BitPosition)
 Set the given bit to 1 whose position is given as "bitPosition".
 
void setSignBit ()
 Set the sign bit to 1.
 
void setBitVal (unsigned BitPosition, bool BitValue)
 Set a given bit to a given value.
 
void setBitsWithWrap (unsigned loBit, unsigned hiBit)
 Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
 
void setBits (unsigned loBit, unsigned hiBit)
 Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
 
void setBitsFrom (unsigned loBit)
 Set the top bits starting from loBit.
 
void setLowBits (unsigned loBits)
 Set the bottom loBits bits.
 
void setHighBits (unsigned hiBits)
 Set the top hiBits bits.
 
void clearAllBits ()
 Set every bit to 0.
 
void clearBit (unsigned BitPosition)
 Set a given bit to 0.
 
void clearLowBits (unsigned loBits)
 Set bottom loBits bits to 0.
 
void clearSignBit ()
 Set the sign bit to 0.
 
void flipAllBits ()
 Toggle every bit to its opposite value.
 
void flipBit (unsigned bitPosition)
 Toggles a given bit to its opposite value.
 
void negate ()
 Negate this APInt in place.
 
void insertBits (const APInt &SubBits, unsigned bitPosition)
 Insert the bits from a smaller APInt starting at bitPosition.
 
void insertBits (uint64_t SubBits, unsigned bitPosition, unsigned numBits)
 
APInt extractBits (unsigned numBits, unsigned bitPosition) const
 Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
 
uint64_t extractBitsAsZExtValue (unsigned numBits, unsigned bitPosition) const
 
Mathematics Operations
unsigned logBase2 () const
 
unsigned ceilLogBase2 () const
 
unsigned nearestLogBase2 () const
 
int32_t exactLogBase2 () const
 
APInt sqrt () const
 Compute the square root.
 
APInt abs () const
 Get the absolute value.
 
APInt multiplicativeInverse (const APInt &modulo) const
 Computes the multiplicative inverse of this APInt for a given modulo.
 

Static Public Member Functions

Value Generators
static APInt getZero (unsigned numBits)
 Get the '0' value for the specified bit-width.
 
static APInt getZeroWidth ()
 Return an APInt zero bits wide.
 
static APInt getMaxValue (unsigned numBits)
 Gets maximum unsigned value of APInt for specific bit width.
 
static APInt getSignedMaxValue (unsigned numBits)
 Gets maximum signed value of APInt for a specific bit width.
 
static APInt getMinValue (unsigned numBits)
 Gets minimum unsigned value of APInt for a specific bit width.
 
static APInt getSignedMinValue (unsigned numBits)
 Gets minimum signed value of APInt for a specific bit width.
 
static APInt getSignMask (unsigned BitWidth)
 Get the SignMask for a specific bit width.
 
static APInt getAllOnes (unsigned numBits)
 Return an APInt of a specified width with all bits set.
 
static APInt getOneBitSet (unsigned numBits, unsigned BitNo)
 Return an APInt with exactly one bit set in the result.
 
static APInt getBitsSet (unsigned numBits, unsigned loBit, unsigned hiBit)
 Get a value with a block of bits set.
 
static APInt getBitsSetWithWrap (unsigned numBits, unsigned loBit, unsigned hiBit)
 Wrap version of getBitsSet.
 
static APInt getBitsSetFrom (unsigned numBits, unsigned loBit)
 Constructs an APInt value that has a contiguous range of bits set.
 
static APInt getHighBitsSet (unsigned numBits, unsigned hiBitsSet)
 Constructs an APInt value that has the top hiBitsSet bits set.
 
static APInt getLowBitsSet (unsigned numBits, unsigned loBitsSet)
 Constructs an APInt value that has the bottom loBitsSet bits set.
 
static APInt getSplat (unsigned NewLen, const APInt &V)
 Return a value containing V broadcasted over NewLen bits.
 

Static Public Attributes

static constexpr WordType WORDTYPE_MAX = ~WordType(0)
 

Building-block Operations for APInt and APFloat

struct DenseMapInfo< APInt, void >
 
class APSInt
 
void Profile (FoldingSetNodeID &id) const
 Used to insert APInt objects, or objects that contain APInt objects, into FoldingSets.
 
void dump () const
 debug method
 
bool needsCleanup () const
 Returns whether this instance allocated memory.
 
static void tcSet (WordType *, WordType, unsigned)
 Sets the least significant part of a bignum to the input value, and zeroes out higher parts.
 
static void tcAssign (WordType *, const WordType *, unsigned)
 Assign one bignum to another.
 
static bool tcIsZero (const WordType *, unsigned)
 Returns true if a bignum is zero, false otherwise.
 
static int tcExtractBit (const WordType *, unsigned bit)
 Extract the given bit of a bignum; returns 0 or 1. Zero-based.
 
static void tcExtract (WordType *, unsigned dstCount, const WordType *, unsigned srcBits, unsigned srcLSB)
 Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to DST, of dstCOUNT parts, such that the bit srcLSB becomes the least significant bit of DST.
 
static void tcSetBit (WordType *, unsigned bit)
 Set the given bit of a bignum. Zero-based.
 
static void tcClearBit (WordType *, unsigned bit)
 Clear the given bit of a bignum. Zero-based.
 
static unsigned tcLSB (const WordType *, unsigned n)
 Returns the bit number of the least or most significant set bit of a number.
 
static unsigned tcMSB (const WordType *parts, unsigned n)
 Returns the bit number of the most significant set bit of a number.
 
static void tcNegate (WordType *, unsigned)
 Negate a bignum in-place.
 
static WordType tcAdd (WordType *, const WordType *, WordType carry, unsigned)
 DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag.
 
static WordType tcAddPart (WordType *, WordType, unsigned)
 DST += RHS. Returns the carry flag.
 
static WordType tcSubtract (WordType *, const WordType *, WordType carry, unsigned)
 DST -= RHS + CARRY where CARRY is zero or one. Returns the carry flag.
 
static WordType tcSubtractPart (WordType *, WordType, unsigned)
 DST -= RHS. Returns the carry flag.
 
static int tcMultiplyPart (WordType *dst, const WordType *src, WordType multiplier, WordType carry, unsigned srcParts, unsigned dstParts, bool add)
 DST += SRC * MULTIPLIER + PART if add is true DST = SRC * MULTIPLIER + PART if add is false.
 
static int tcMultiply (WordType *, const WordType *, const WordType *, unsigned)
 DST = LHS * RHS, where DST has the same width as the operands and is filled with the least significant parts of the result.
 
static void tcFullMultiply (WordType *, const WordType *, const WordType *, unsigned, unsigned)
 DST = LHS * RHS, where DST has width the sum of the widths of the operands.
 
static int tcDivide (WordType *lhs, const WordType *rhs, WordType *remainder, WordType *scratch, unsigned parts)
 If RHS is zero LHS and REMAINDER are left unchanged, return one.
 
static void tcShiftLeft (WordType *, unsigned Words, unsigned Count)
 Shift a bignum left Count bits.
 
static void tcShiftRight (WordType *, unsigned Words, unsigned Count)
 Shift a bignum right Count bits.
 
static int tcCompare (const WordType *, const WordType *, unsigned)
 Comparison (unsigned) of two bignums.
 
static WordType tcIncrement (WordType *dst, unsigned parts)
 Increment a bignum in-place. Return the carry flag.
 
static WordType tcDecrement (WordType *dst, unsigned parts)
 Decrement a bignum in-place. Return the borrow flag.
 

Value Tests

hash_code hash_value (const APInt &Arg)
 Overload to compute a hash_code for an APInt value.
 
bool isSingleWord () const
 Determine if this APInt just has one word to store value.
 
bool isNegative () const
 Determine sign of this APInt.
 
bool isNonNegative () const
 Determine if this APInt Value is non-negative (>= 0)
 
bool isSignBitSet () const
 Determine if sign bit of this APInt is set.
 
bool isSignBitClear () const
 Determine if sign bit of this APInt is clear.
 
bool isStrictlyPositive () const
 Determine if this APInt Value is positive.
 
bool isNonPositive () const
 Determine if this APInt Value is non-positive (<= 0).
 
bool isOneBitSet (unsigned BitNo) const
 Determine if this APInt Value only has the specified bit set.
 
bool isAllOnes () const
 Determine if all bits are set. This is true for zero-width values.
 
bool isZero () const
 Determine if this value is zero, i.e. all bits are clear.
 
bool isOne () const
 Determine if this is a value of 1.
 
bool isMaxValue () const
 Determine if this is the largest unsigned value.
 
bool isMaxSignedValue () const
 Determine if this is the largest signed value.
 
bool isMinValue () const
 Determine if this is the smallest unsigned value.
 
bool isMinSignedValue () const
 Determine if this is the smallest signed value.
 
bool isIntN (unsigned N) const
 Check if this APInt has an N-bits unsigned integer value.
 
bool isSignedIntN (unsigned N) const
 Check if this APInt has an N-bits signed integer value.
 
bool isPowerOf2 () const
 Check if this APInt's value is a power of two greater than zero.
 
bool isNegatedPowerOf2 () const
 Check if this APInt's negated value is a power of two greater than zero.
 
bool isAligned (Align A) const
 Checks if this APInt -interpreted as an address- is aligned to the provided value.
 
bool isSignMask () const
 Check if the APInt's value is returned by getSignMask.
 
bool getBoolValue () const
 Convert APInt to a boolean value.
 
uint64_t getLimitedValue (uint64_t Limit=UINT64_MAX) const
 If this value is smaller than the specified limit, return it, otherwise return the limit value.
 
bool isSplat (unsigned SplatSizeInBits) const
 Check if the APInt consists of a repeated bit pattern.
 
bool isMask (unsigned numBits) const
 
bool isMask () const
 
bool isShiftedMask () const
 Return true if this APInt value contains a non-empty sequence of ones with the remainder zero.
 
bool isShiftedMask (unsigned &MaskIdx, unsigned &MaskLen) const
 Return true if this APInt value contains a non-empty sequence of ones with the remainder zero.
 
APInt getHiBits (unsigned numBits) const
 Compute an APInt containing numBits highbits from this APInt.
 
APInt getLoBits (unsigned numBits) const
 Compute an APInt containing numBits lowbits from this APInt.
 
const uint64_tgetRawData () const
 This function returns a pointer to the internal storage of the APInt.
 
static bool isSameValue (const APInt &I1, const APInt &I2)
 Determine if two APInts have the same value, after zero-extending one of them (if needed!) to ensure that the bit-widths match.
 

Binary Operators

APInt operator* (const APInt &RHS) const
 Multiplication operator.
 
APInt operator<< (unsigned Bits) const
 Left logical shift operator.
 
APInt operator<< (const APInt &Bits) const
 Left logical shift operator.
 
APInt ashr (unsigned ShiftAmt) const
 Arithmetic right-shift function.
 
void ashrInPlace (unsigned ShiftAmt)
 Arithmetic right-shift this APInt by ShiftAmt in place.
 
APInt lshr (unsigned shiftAmt) const
 Logical right-shift function.
 
void lshrInPlace (unsigned ShiftAmt)
 Logical right-shift this APInt by ShiftAmt in place.
 
APInt shl (unsigned shiftAmt) const
 Left-shift function.
 
APInt relativeLShr (int RelativeShift) const
 relative logical shift right
 
APInt relativeLShl (int RelativeShift) const
 relative logical shift left
 
APInt relativeAShr (int RelativeShift) const
 relative arithmetic shift right
 
APInt relativeAShl (int RelativeShift) const
 relative arithmetic shift left
 
APInt rotl (unsigned rotateAmt) const
 Rotate left by rotateAmt.
 
APInt rotr (unsigned rotateAmt) const
 Rotate right by rotateAmt.
 
APInt ashr (const APInt &ShiftAmt) const
 Arithmetic right-shift function.
 
void ashrInPlace (const APInt &shiftAmt)
 Arithmetic right-shift this APInt by shiftAmt in place.
 
APInt lshr (const APInt &ShiftAmt) const
 Logical right-shift function.
 
void lshrInPlace (const APInt &ShiftAmt)
 Logical right-shift this APInt by ShiftAmt in place.
 
APInt shl (const APInt &ShiftAmt) const
 Left-shift function.
 
APInt rotl (const APInt &rotateAmt) const
 Rotate left by rotateAmt.
 
APInt rotr (const APInt &rotateAmt) const
 Rotate right by rotateAmt.
 
APInt concat (const APInt &NewLSB) const
 Concatenate the bits from "NewLSB" onto the bottom of *this.
 
APInt udiv (const APInt &RHS) const
 Unsigned division operation.
 
APInt udiv (uint64_t RHS) const
 
APInt sdiv (const APInt &RHS) const
 Signed division function for APInt.
 
APInt sdiv (int64_t RHS) const
 
APInt urem (const APInt &RHS) const
 Unsigned remainder operation.
 
uint64_t urem (uint64_t RHS) const
 
APInt srem (const APInt &RHS) const
 Function for signed remainder operation.
 
int64_t srem (int64_t RHS) const
 
APInt sadd_ov (const APInt &RHS, bool &Overflow) const
 
APInt uadd_ov (const APInt &RHS, bool &Overflow) const
 
APInt ssub_ov (const APInt &RHS, bool &Overflow) const
 
APInt usub_ov (const APInt &RHS, bool &Overflow) const
 
APInt sdiv_ov (const APInt &RHS, bool &Overflow) const
 
APInt smul_ov (const APInt &RHS, bool &Overflow) const
 
APInt umul_ov (const APInt &RHS, bool &Overflow) const
 
APInt sshl_ov (const APInt &Amt, bool &Overflow) const
 
APInt sshl_ov (unsigned Amt, bool &Overflow) const
 
APInt ushl_ov (const APInt &Amt, bool &Overflow) const
 
APInt ushl_ov (unsigned Amt, bool &Overflow) const
 
APInt sfloordiv_ov (const APInt &RHS, bool &Overflow) const
 Signed integer floor division operation.
 
APInt sadd_sat (const APInt &RHS) const
 
APInt uadd_sat (const APInt &RHS) const
 
APInt ssub_sat (const APInt &RHS) const
 
APInt usub_sat (const APInt &RHS) const
 
APInt smul_sat (const APInt &RHS) const
 
APInt umul_sat (const APInt &RHS) const
 
APInt sshl_sat (const APInt &RHS) const
 
APInt sshl_sat (unsigned RHS) const
 
APInt ushl_sat (const APInt &RHS) const
 
APInt ushl_sat (unsigned RHS) const
 
bool operator[] (unsigned bitPosition) const
 Array-indexing support.
 
static void udivrem (const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
 Dual division/remainder interface.
 
static void udivrem (const APInt &LHS, uint64_t RHS, APInt &Quotient, uint64_t &Remainder)
 
static void sdivrem (const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
 
static void sdivrem (const APInt &LHS, int64_t RHS, APInt &Quotient, int64_t &Remainder)
 

Value Characterization Functions

unsigned getBitWidth () const
 Return the number of bits in the APInt.
 
unsigned getNumWords () const
 Get the number of words.
 
unsigned getActiveBits () const
 Compute the number of active bits in the value.
 
unsigned getActiveWords () const
 Compute the number of active words in the value of this APInt.
 
unsigned getSignificantBits () const
 Get the minimum bit size for this signed APInt.
 
uint64_t getZExtValue () const
 Get zero extended value.
 
std::optional< uint64_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
 The APInt version of std::countl_zero.
 
unsigned countLeadingZeros () const
 
unsigned countl_one () const
 Count the number of leading one bits.
 
unsigned countLeadingOnes () const
 
unsigned getNumSignBits () const
 Computes the number of leading bits of this APInt that are equal to its sign bit.
 
unsigned countr_zero () const
 Count the number of trailing zero bits.
 
unsigned countTrailingZeros () const
 
unsigned countr_one () const
 Count the number of trailing one bits.
 
unsigned countTrailingOnes () const
 
unsigned popcount () const
 Count the number of bits set.
 
static unsigned getNumWords (unsigned BitWidth)
 Get the number of words.
 
static unsigned getBitsNeeded (StringRef str, uint8_t radix)
 Get bits required for string value.
 
static unsigned getSufficientBitsNeeded (StringRef Str, uint8_t Radix)
 Get the bits that are sufficient to represent the string value.
 

Conversion Functions

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

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 line 76 of file APInt.h.

Member Typedef Documentation

◆ WordType

Definition at line 78 of file APInt.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : unsigned

This enum is used to hold the constants we needed for APInt.

Enumerator
APINT_WORD_SIZE 

Byte size of a word.

APINT_BITS_PER_WORD 

Bits in a word.

Definition at line 81 of file APInt.h.

◆ Rounding

enum class llvm::APInt::Rounding
strong
Enumerator
DOWN 
TOWARD_ZERO 
UP 

Definition at line 88 of file APInt.h.

Constructor & Destructor Documentation

◆ APInt() [1/7]

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

Create a new APInt of numBits width, initialized as val.

If isSigned is true then val is treated as if it were a signed value (i.e. as an int64_t) and the appropriate sign extension to the bit width will be done. Otherwise, no sign extension occurs (high order bits beyond the range of val are zero filled).

Parameters
numBitsthe bit width of the constructed APInt
valthe initial value of the APInt
isSignedhow to treat signedness of val

Definition at line 109 of file APInt.h.

References llvm::BitWidth, clearUnusedBits(), and isSigned().

◆ APInt() [2/7]

APInt::APInt ( unsigned  numBits,
ArrayRef< uint64_t bigVal 
)

Construct an APInt of numBits width, initialized as bigVal[].

Note that bigVal.size() can be smaller or larger than the corresponding bit width but any extraneous bits will be dropped.

Parameters
numBitsthe bit width of the constructed APInt
bigVala sequence of words to form the initial value of the APInt

Definition at line 106 of file APInt.cpp.

◆ APInt() [3/7]

APInt::APInt ( unsigned  numBits,
unsigned  numWords,
const uint64_t  bigVal[] 
)

Equivalent to APInt(numBits, ArrayRef<uint64_t>(bigVal, numWords)), but deprecated because this constructor is prone to ambiguity with the APInt(unsigned, uint64_t, bool) constructor.

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 line 110 of file APInt.cpp.

◆ APInt() [4/7]

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

Construct an APInt from a string representation.

This constructor interprets the string str in the given radix. The interpretation stops when the first character that is not suitable for the radix is encountered, or the end of the string. Acceptable radix values are 2, 8, 10, 16, and 36. It is an error for the value implied by the string to require more bits than numBits.

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

Definition at line 115 of file APInt.cpp.

◆ APInt() [5/7]

llvm::APInt::APInt ( )
inlineexplicit

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

Definition at line 151 of file APInt.h.

Referenced by byteSwap(), extractBits(), multiplicativeInverse(), operator*(), reverseBits(), sext(), sqrt(), sshl_ov(), trunc(), udiv(), udivrem(), urem(), ushl_ov(), usub_sat(), and zext().

◆ APInt() [6/7]

llvm::APInt::APInt ( const APInt that)
inline

Copy Constructor.

Definition at line 154 of file APInt.h.

References llvm::BitWidth, and VAL.

◆ APInt() [7/7]

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

Move Constructor.

Definition at line 162 of file APInt.h.

References llvm::BitWidth.

◆ ~APInt()

llvm::APInt::~APInt ( )
inline

Destructor.

Definition at line 168 of file APInt.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 wide APInt) is unchanged due to how negation works.

Definition at line 1737 of file APInt.h.

Referenced by combineSelectOfTwoConstants(), findGCD(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::InstCombinerImpl::foldICmpBinOp(), gcd(), llvm::ScalarEvolution::getAddExpr(), llvm::ExpressionFormat::getMatchingString(), getRangeForAffineARHelper(), and llvm::InstCombinerImpl::SimplifyDemandedUseBits().

◆ ashr() [1/2]

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

Arithmetic right-shift function.

Arithmetic right-shift this APInt by shiftAmt.

Definition at line 886 of file APInt.h.

◆ ashr() [2/2]

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

◆ ashrInPlace() [1/2]

void APInt::ashrInPlace ( const APInt shiftAmt)

Arithmetic right-shift this APInt by shiftAmt in place.

Arithmetic right-shift this APInt by shiftAmt.

Arithmetic right-shift function.

Definition at line 1020 of file APInt.cpp.

References ashrInPlace(), and getLimitedValue().

◆ ashrInPlace() [2/2]

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

◆ bitsToDouble()

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

Converts APInt bits to a double.

The conversion does not do a translation from integer to double, it just re-interprets the bits as a double. Note that it is valid to do this on any bit width. Exactly 64 bits will be translated.

Definition at line 1671 of file APInt.h.

Referenced by llvm::detail::IEEEFloat::convertToDouble(), llvm::convertToNonDenormSingle(), and llvm::ExecutionEngine::getConstantValue().

◆ bitsToFloat()

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

Converts APInt bits to a float.

The conversion does not do a translation from integer to float, it just re-interprets the bits as a float. Note that it is valid to do this on any bit width. Exactly 32 bits will be translated.

Definition at line 1678 of file APInt.h.

Referenced by llvm::detail::IEEEFloat::convertToFloat(), and llvm::ExecutionEngine::getConstantValue().

◆ byteSwap()

APInt APInt::byteSwap ( ) const

◆ ceilLogBase2()

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

Definition at line 1706 of file APInt.h.

References getActiveBits().

Referenced by ComputeNumSignBitsImpl(), and llvm::InstCombinerImpl::foldICmpUsingKnownBits().

◆ clearAllBits()

void llvm::APInt::clearAllBits ( )
inline

◆ clearBit()

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

◆ clearLowBits()

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

◆ clearSignBit()

void llvm::APInt::clearSignBit ( )
inline

Set the sign bit to 0.

Definition at line 1402 of file APInt.h.

References llvm::BitWidth.

Referenced by llvm::KnownBits::abs(), computeForSatAddSub(), and llvm::ConstantRange::fromKnownBits().

◆ concat()

APInt llvm::APInt::concat ( const APInt NewLSB) 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 line 925 of file APInt.h.

References getBitWidth(), getBitWidth(), and VAL.

Referenced by llvm::KnownBits::concat().

◆ countl_one()

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

Count the number of leading one bits.

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

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 line 1565 of file APInt.h.

References llvm::BitWidth, llvm::countl_one(), and LLVM_UNLIKELY.

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

◆ countl_zero()

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

◆ countLeadingOnes()

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

Definition at line 1574 of file APInt.h.

References llvm::countl_one().

Referenced by foldNegativePower2AndShiftedMask().

◆ countLeadingZeros()

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

◆ countr_one()

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

Count the number of trailing one bits.

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

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 line 1606 of file APInt.h.

References llvm::countr_one().

Referenced by combineAndMaskToShift(), combineShiftRightLogical(), llvm::KnownBits::countMinTrailingOnes(), llvm::KnownBits::countMinTrailingZeros(), llvm::InstCombinerImpl::foldICmpEquality(), lowerShuffleAsByteShiftMask(), lowerShuffleAsVALIGN(), llvm::CombinerHelper::matchCombineLoadWithAndMask(), PerformMinMaxToSatCombine(), llvm::TargetLowering::SimplifySetCC(), and llvm::ConstantRange::truncate().

◆ countr_zero()

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

Count the number of trailing zero bits.

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

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 line 1589 of file APInt.h.

References llvm::BitWidth, and llvm::countr_zero().

Referenced by areUsedBitsDense(), BuildExactSDIV(), llvm::TargetLowering::buildSDIVPow2WithCMov(), llvm::CombinerHelper::buildSDivUsingMul(), canEvaluateShifted(), canonicalizeLogicFirst(), checkForNegativeOperand(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), llvm::KnownBits::countMaxTrailingOnes(), llvm::KnownBits::countMaxTrailingZeros(), EltsFromConsecutiveLoads(), llvm::TargetLowering::expandDIVREMByConstant(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::InstCombinerImpl::foldICmpShlConstConst(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), getPowerOf2Factor(), llvm::BuildVectorSDNode::getSplatValue(), isAligned(), llvm::ShuffleVectorInst::isInsertSubvectorMask(), PerformBFICombine(), performMulCombine(), performSRACombine(), processUGT_ADDCST_ADD(), simplifyAMDGCNMemoryIntrinsicDemanded(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), simplifyDiv(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifySetCC(), llvm::detail::IEEEFloat::toString(), tryBitfieldInsertOpFromOr(), llvm::InstCombinerImpl::visitAdd(), llvm::InstCombinerImpl::visitAnd(), llvm::InstCombinerImpl::visitMul(), llvm::InstCombinerImpl::visitSDiv(), and llvm::InstCombinerImpl::visitSub().

◆ countTrailingOnes()

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

Definition at line 1612 of file APInt.h.

References llvm::countr_one().

◆ countTrailingZeros()

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

Definition at line 1597 of file APInt.h.

References llvm::countr_zero().

Referenced by llvm::ScalarEvolution::getSmallConstantTripMultiple().

◆ doubleToBits()

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

Converts a double to APInt bits.

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

Definition at line 1686 of file APInt.h.

Referenced by llvm::ExecutionEngine::getConstantValue(), and llvm::detail::IEEEFloat::IEEEFloat().

◆ dump()

LLVM_DUMP_METHOD void APInt::dump ( ) const

debug method

Definition at line 2304 of file APInt.cpp.

References llvm::dbgs(), toStringSigned(), and toStringUnsigned().

◆ eq()

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

Equality comparison.

Compares this APInt with RHS for the validity of the equality relationship.

Returns
true if *this == Val

Definition at line 1057 of file APInt.h.

References RHS.

Referenced by llvm::omp::getBestVariantMatchForContext(), processUMulZExtIdiom(), and llvm::InstCombinerImpl::visitLShr().

◆ exactLogBase2()

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

Definition at line 1725 of file APInt.h.

Referenced by combineAnd(), foldAddToAshr(), isSaturatingMinMax(), llvm::LoongArchDAGToDAGISel::selectVSplatUimmPow2(), and llvm::InstCombinerImpl::visitAnd().

◆ extractBits()

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

◆ extractBitsAsZExtValue()

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

Definition at line 489 of file APInt.cpp.

References assert(), and isSingleWord().

Referenced by getExactInteger(), and getMaxShiftAmount().

◆ flipAllBits()

void llvm::APInt::flipAllBits ( )
inline

Toggle every bit to its opposite value.

Definition at line 1405 of file APInt.h.

References clearUnusedBits().

Referenced by getUsefulBits(), getUsefulBitsFromBFM(), and insert1BitVector().

◆ 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 line 363 of file APInt.cpp.

References assert(), and setBitVal().

◆ floatToBits()

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

Converts a float to APInt bits.

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

Definition at line 1694 of file APInt.h.

Referenced by llvm::ExecutionEngine::getConstantValue(), and llvm::detail::IEEEFloat::IEEEFloat().

◆ getActiveBits()

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

◆ getActiveWords()

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

Compute the number of active words in the value of this APInt.

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

Definition at line 1469 of file APInt.h.

Referenced by emitConstantRange().

◆ getAllOnes()

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

Return an APInt of a specified width with all bits set.

Definition at line 212 of file APInt.h.

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

◆ 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 the APInt equivalent of the string given by str.

Definition at line 545 of file APInt.cpp.

References assert(), llvm::StringRef::begin(), getSufficientBitsNeeded(), isNegative(), isPowerOf2(), logBase2(), and llvm::StringRef::size().

◆ getBitsSet()

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

Get a value with a block of bits set.

Constructs an APInt value that has a contiguous range of bits set. The bits from loBit (inclusive) to hiBit (exclusive) will be set. All other bits will be zero. For example, with parameters(32, 0, 16) you would get 0x0000FFFF. Please call getBitsSetWithWrap if loBit may be greater than hiBit.

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

Definition at line 236 of file APInt.h.

References setBits().

Referenced by combineToExtendBoolVectorInReg(), llvm::X86TTIImpl::getMemoryOpCost(), insert1BitVector(), llvm::AMDGPUTargetLowering::PerformDAGCombine(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), simplifyX86immShift(), tryBitfieldInsertOpFromOr(), tryToMergePartialOverlappingStores(), and llvm::RegisterBankInfo::ValueMapping::verify().

◆ getBitsSetFrom()

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

Constructs an APInt value that has a contiguous range of bits set.

The bits from loBit (inclusive) to numBits (exclusive) will be set. All other bits will be zero. For example, with parameters(32, 12) you would get 0xFFFFF000.

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

Definition at line 264 of file APInt.h.

References setBitsFrom().

Referenced by canEvaluateTruncated(), combine_CC(), combineAddOfBooleanXor(), combineCMP(), combineDeMorganOfBoolean(), combineSetCC(), llvm::SelectionDAG::computeKnownBits(), 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(), and tryDemorganOfBooleanCondition().

◆ getBitsSetWithWrap()

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

Wrap version of getBitsSet.

If hiBit is bigger than loBit, this is same with getBitsSet. If hiBit is not bigger than loBit, the set bits "wrap". For example, with parameters (32, 28, 4), you would get 0xF000000F. If hiBit is equal to loBit, you would get a result with all bits set.

Definition at line 248 of file APInt.h.

References setBitsWithWrap().

Referenced by llvm::PPCInstrInfo::combineRLWINM(), and llvm::LegalizerHelper::lowerInsert().

◆ getBitWidth()

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

Return the number of bits in the APInt.

Definition at line 1439 of file APInt.h.

References llvm::BitWidth.

Referenced by llvm::DwarfExpression::addConstantFP(), llvm::DwarfUnit::addConstantValue(), llvm::APFixedPoint::APFixedPoint(), APIntToHexString(), BuildExactSDIV(), llvm::CombinerHelper::buildSDivUsingMul(), llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), calculateOffsetDiff(), combineCMov(), combineConcatVectorOps(), combineLoad(), combineSetCCMOVMSK(), combineShiftOfShiftedLogic(), CombineVMOVDRRCandidateWithVecOp(), llvm::InstCombinerImpl::commonIDivTransforms(), CompareSCEVComplexity(), llvm::APSInt::compareValues(), computeKnownBits(), llvm::SelectionDAG::computeKnownBits(), llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), computeKnownFPClass(), llvm::SelectionDAG::ComputeNumSignBits(), ComputeNumSignBitsImpl(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), llvm::SelectionDAG::computeVectorKnownZeroElements(), concat(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), llvm::ConstantRange::ConstantRange(), llvm::APFixedPoint::convert(), llvm::APFloat::convertToInteger(), emitGlobalConstantFP(), llvm::BinaryOperation::eval(), llvm::TargetLowering::expandDIVREMByConstant(), extractConstantWithoutWrapping(), extractShiftForRotate(), llvm::SelectionDAG::FoldConstantArithmetic(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::InstCombinerImpl::foldICmpEquality(), llvm::InstCombinerImpl::foldICmpShlConstConst(), foldNoWrapAdd(), foldSelectICmpAnd(), FoldValue(), FoldValueWithUndef(), getAVX512Node(), llvm::ConstantInt::getBitWidth(), llvm::KnownBits::getBitWidth(), llvm::ExecutionEngine::getConstantValue(), getConstVector(), getFauxShuffleMask(), getHorizDemandedElts(), llvm::SwitchCG::getJumpTableRange(), getKnownUndefForVectorBinop(), llvm::SelectionDAG::getNode(), llvm::ScalarEvolution::getNonZeroConstantMultiple(), getPackDemandedElts(), llvm::getPtrStride(), GetQuadraticEquation(), getRangeForAffineARHelper(), llvm::BuildVectorSDNode::getRepeatedSequence(), llvm::BasicTTIImplBase< T >::getReplicationShuffleCost(), llvm::BasicTTIImplBase< T >::getScalarizationOverhead(), llvm::X86TTIImpl::getScalarizationOverhead(), getShiftAmount(), llvm::BuildVectorSDNode::getSplatValue(), llvm::SelectionDAG::getStepVector(), getStrideFromPointer(), getTargetConstantBitsFromNode(), getUsefulBits(), getUsefulBitsForUse(), getUsefulBitsFromAndWithImmediate(), getUsefulBitsFromBFM(), getUsefulBitsFromBitfieldMoveOpd(), llvm::SelectionDAG::getVScale(), insertBits(), llvm::ConstantRange::intrinsic(), llvm::TargetTransformInfoImplBase::isConstantStridedAccessLessThan(), llvm::TargetLowering::isConstTrueVal(), llvm::X86TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), isKnownNonZero(), isMultiple(), isPoisonShift(), isSameValue(), isSaturatingMinMax(), isSplat(), llvm::SelectionDAG::isSplatValue(), llvm::X86TargetLowering::isSplatValueForTargetNode(), LowerVectorAllEqual(), matchAndOrChain(), MatchDiv(), MatchMul(), operator*(), optimizeWhile(), ParseBFI(), parseHexOcta(), performANDCombine(), 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(), llvm::detail::IEEEFloat::toString(), tryToMergePartialOverlappingStores(), ushl_ov(), ushl_sat(), llvm::InstCombinerImpl::visitAdd(), and llvm::SCEVDivision::visitConstant().

◆ getBoolValue()

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

◆ getHiBits()

APInt APInt::getHiBits ( unsigned  numBits) const

Compute an APInt containing numBits highbits from this APInt.

This function returns the high "numBits" bits of this APInt.

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

Returns
the high "numBits" bits of this APInt.

Definition at line 608 of file APInt.cpp.

References lshr().

Referenced by llvm::SelectionDAG::computeKnownBits(), parseHexOcta(), and WriteAPFloatInternal().

◆ getHighBitsSet()

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

Constructs an APInt 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 line 274 of file APInt.h.

References setHighBits().

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

◆ getLimitedValue()

uint64_t llvm::APInt::getLimitedValue ( uint64_t  Limit = UINT64_MAX) const
inline

◆ getLoBits()

APInt APInt::getLoBits ( unsigned  numBits) const

Compute an APInt containing numBits lowbits from this APInt.

This function returns the low "numBits" bits of this APInt.

Get an APInt with the same BitWidth as this APInt, just zero mask the high bits.

Returns
the low "numBits" bits of this APInt.

Definition at line 613 of file APInt.cpp.

References getLowBitsSet().

Referenced by matchRotateSub(), llvm::KnownBits::mul(), parseHexOcta(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), simplifyX86vpermilvar(), and WriteAPFloatInternal().

◆ getLowBitsSet()

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

Constructs an APInt 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 line 284 of file APInt.h.

References setLowBits().

Referenced by buildBitFieldInsert(), llvm::TargetLowering::buildSDIVPow2WithCMov(), llvm::MachineIRBuilder::buildZExtInReg(), canEvaluateShiftedShift(), clampDynamicVectorIndex(), clampVectorIndex(), combineBT(), combineCMP(), combineCVTPH2PS(), combineMOVMSK(), combinePredicateReduction(), combineSetCCMOVMSK(), combineVEXTRACT_STORE(), llvm::SelectionDAG::computeKnownBits(), llvm::ConstantFoldBinaryInstruction(), llvm::TargetLowering::expandDIVREMByConstant(), llvm::TargetLowering::expandFixedPointMul(), llvm::TargetLowering::expandUnalignedStore(), extractBits(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpEqIntrinsicWithConstant(), llvm::InstCombinerImpl::foldICmpEquality(), llvm::InstCombinerImpl::foldICmpIntrinsicWithConstant(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpTruncConstant(), foldShiftedShift(), llvm::TargetLowering::forceExpandWideMUL(), getLoBits(), getShiftedValue(), getTruncatedUSUBSAT(), llvm::SelectionDAG::getZeroExtendInReg(), llvm::ARMTTIImpl::instCombineIntrinsic(), llvm::X86TTIImpl::instCombineIntrinsic(), LowerEXTEND_VECTOR_INREG(), llvm::LegalizerHelper::lowerFCopySign(), LowerMUL(), LowerShiftByScalarImmediate(), matchRotateSub(), MatchVectorAllEqualTest(), ParseBFI(), llvm::ARMTargetLowering::PerformDAGCombine(), llvm::RISCVTargetLowering::PerformDAGCombine(), llvm::ARMTargetLowering::PerformIntrinsicCombine(), PerformPREDICATE_CASTCombine(), performTBISimplification(), performTruncateCombine(), performVectorShiftCombine(), PerformVMOVhrCombine(), PerformVMOVNCombine(), PerformVQMOVNCombine(), processUGT_ADDCST_ADD(), SaturateWidenedDIVFIX(), llvm::TargetLowering::scalarizeVectorLoad(), llvm::ConstantRange::signExtend(), simplifyAndInst(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::ARMTTIImpl::simplifyDemandedVectorEltsIntrinsic(), simplifyMul24(), llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(), llvm::TargetLowering::SimplifySetCC(), simplifyX86insertq(), simplifyX86pack(), llvm::X86TargetLowering::targetShrinkDemandedConstant(), tryLowerToSLI(), llvm::InstCombinerImpl::visitAnd(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitLShr(), llvm::InstCombinerImpl::visitSwitchInst(), and llvm::InstCombinerImpl::visitZExt().

◆ getMaxValue()

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

◆ getMinValue()

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

◆ getNumSignBits()

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

◆ 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 this APInt.

Definition at line 1446 of file APInt.h.

References llvm::BitWidth, and getNumWords().

Referenced by byteSwap(), llvm::detail::IEEEFloat::convertFromAPInt(), llvm::APFloat::convertToInteger(), emitGlobalConstantFP(), extractBits(), getNumWords(), llvm::hash_value(), llvm::detail::IEEEFloat::makeNaN(), operator*(), operator*=(), operator++(), operator+=(), operator--(), operator-=(), printConstant(), Profile(), sext(), trunc(), udiv(), udivrem(), urem(), and zext().

◆ getNumWords() [2/2]

static unsigned 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 line 1454 of file APInt.h.

References llvm::BitWidth.

◆ getOneBitSet()

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

Return an APInt with exactly one bit set in the result.

Definition at line 217 of file APInt.h.

References setBit().

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

◆ getRawData()

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

◆ getSExtValue()

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

Get sign extended value.

This method attempts to return the value of this APInt as a sign extended int64_t. The bit width must be <= 64 or the value must fit within an int64_t. Otherwise an assertion will result.

Definition at line 1513 of file APInt.h.

References assert(), llvm::BitWidth, and llvm::SignExtend64().

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

◆ getSignedMaxValue()

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

Gets maximum signed value of APInt for a specific bit width.

Definition at line 187 of file APInt.h.

References clearBit().

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

◆ getSignedMinValue()

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

Gets minimum signed value of APInt for a specific bit width.

Definition at line 197 of file APInt.h.

References setBit().

Referenced by llvm::ConstantRange::abs(), BinomialCoefficient(), llvm::CombinerHelper::buildSDivUsingMul(), llvm::cannotBeMinInLoop(), canonicalizeForInvariantConditionInjection(), llvm::ConstantRange::castOp(), combineMinMaxReduction(), computeForSatAddSub(), detectSSatPattern(), llvm::TargetLowering::expandAddSubSat(), llvm::TargetLowering::expandDIVREMByConstant(), 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(), llvm::SignedDivisionByConstantInfo::get(), llvm::UnsignedDivisionByConstantInfo::get(), getIdentityValueForAtomicOp(), llvm::ConstantExpr::getIntrinsicIdentity(), llvm::getMinMaxLimit(), llvm::ScalarEvolution::getMulExpr(), llvm::SelectionDAG::getNeutralElement(), getRangeForIntrinsic(), getRangeForSelectPattern(), llvm::RecurrenceDescriptor::getRecurrenceIdentity(), llvm::MinMaxIntrinsic::getSaturationPoint(), llvm::ConstantRange::getSignedMin(), getSignedOverflowLimitForStep(), isSafeDecreasingBound(), LowerADDSAT_SUBSAT(), llvm::LegalizerHelper::lowerAddSubSatToAddoSubo(), llvm::LegalizerHelper::lowerAddSubSatToMinMax(), lowerSADDSAT_SSUBSAT(), llvm::LegalizerHelper::lowerShlSat(), llvm::ConstantRange::makeAllowedICmpRegion(), llvm::fuzzerop::makeConstantsWithType(), makeExactMulNSWRegion(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), narrowSDivOrSRem(), llvm::X86InstrInfo::optimizeCompareInstr(), processAbsIntrinsic(), sadd_sat(), llvm::ConstantRange::sdiv(), setLimitsForBinOp(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), llvm::TargetLowering::SimplifySetCC(), simplifyX86pack(), smul_sat(), sshl_sat(), ssub_sat(), truncSSat(), llvm::InstCombinerImpl::visitCallInst(), llvm::InstCombinerImpl::visitSDiv(), and llvm::ScalarEvolution::willNotOverflow().

◆ getSignificantBits()

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

Get the minimum bit size for this signed APInt.

Computes the minimum bit width for this APInt while considering it to be a signed (and probably negative) value. If the value is not negative, this function returns the same value as getActiveBits()+1. Otherwise, it returns the smallest bit width that will retain the negative value. For example, -1 can be written as 0b1 or 0xFFFFFFFFFF. 0b1 is shorter and so for -1, this function will always return 1.

Definition at line 1482 of file APInt.h.

References llvm::BitWidth.

Referenced by llvm::APSInt::APSInt(), canFoldIVIncExpr(), combineShiftRightLogical(), eliminateDeadSwitchCases(), llvm::RISCVTargetLowering::isDesirableToCommuteWithShift(), isIndexInRangeOfArrayType(), rebuildExtCst(), llvm::TargetLowering::SimplifySetCC(), llvm::RISCVTargetLowering::targetShrinkDemandedConstant(), and llvm::InstCombinerImpl::visitSDiv().

◆ getSignMask()

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

◆ getSplat()

APInt APInt::getSplat ( unsigned  NewLen,
const APInt V 
)
static

◆ 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 line 513 of file APInt.cpp.

References assert().

Referenced by getBitsNeeded().

◆ getZero()

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

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

Definition at line 178 of file APInt.h.

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

◆ getZeroWidth()

static APInt llvm::APInt::getZeroWidth ( )
inlinestatic

Return an APInt zero bits wide.

Definition at line 181 of file APInt.h.

◆ getZExtValue()

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

Get zero extended value.

This method attempts to return the value of this APInt as a zero extended uint64_t. The bitwidth must be <= 64 or the value must fit within a uint64_t. Otherwise an assertion will result.

Definition at line 1491 of file APInt.h.

References assert().

Referenced by llvm::DwarfExpression::addConstantFP(), llvm::DwarfUnit::addConstantValue(), llvm::CombinerHelper::applyFunnelShiftConstantModulo(), llvm::buildSelectInst(), canEvaluateShiftedShift(), canEvaluateZExtd(), collectBitParts(), combineCMov(), combineCMP(), combineExtractWithShuffle(), llvm::PPCInstrInfo::combineRLWINM(), CombineVMOVDRRCandidateWithVecOp(), llvm::InstCombinerImpl::commonIDivTransforms(), llvm::ProfileSummaryBuilder::computeDetailedSummary(), computeFlagsForAddressComputation(), llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::ComputeNumSignBitsForTargetNode(), ComputeNumSignBitsImpl(), convertIntToDoubleImm(), llvm::TargetLowering::CTTZTableLookup(), llvm::Interpreter::exitCalled(), ExtractConstantBytes(), llvm::extractConstantMask(), extractShiftForRotate(), foldConsecutiveLoads(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpTruncConstant(), foldLoadsRecursive(), foldSelectICmpAndZeroShl(), llvm::InstCombinerImpl::FoldShiftByConstant(), foldShiftedShift(), GenerateFixedLengthSVETBL(), llvm::generateSpecConstantInst(), GetBranchWeights(), getConstant(), llvm::ExecutionEngine::getConstantValue(), llvm::getConstFromIntrinsic(), llvm::Function::getEntryCount(), llvm::getExpressionForConstant(), llvm::ScalarEvolution::getGEPExpr(), llvm::getObjectSize(), llvm::SelectionDAG::getShiftAmountConstant(), llvm::ScalarEvolution::getSmallConstantTripMultiple(), llvm::AArch64TargetMachine::getSubtargetImpl(), getVariantMatchScore(), llvm::ConstantInt::getZExtValue(), llvm::mca::initializeUsedResources(), isEXTMask(), llvm::AArch64TargetLowering::isFPImmLegal(), isKnownTypeIdMember(), llvm::AArch64TargetLowering::isMulAddWithConstProfitable(), llvm::ARMTargetLowering::isMulAddWithConstProfitable(), llvm::SystemZVectorConstantInfo::isVectorConstantLegal(), LLVMGenericValueToInt(), LowerShiftByScalarImmediate(), matchAndOrChain(), matchIntPart(), narrowIndex(), NormalizeBuildVector(), optimizeLogicalImm(), optimizeWhile(), parseHexOcta(), parseJumpTable(), PerformANDCombine(), llvm::AMDGPUTargetLowering::PerformDAGCombine(), performDSPShiftCombine(), PerformORCombine(), PerformSHLSimplify(), llvm::X86TargetLowering::preferedOpcodeForCmpEqPiecesOfOperand(), printConstant(), llvm::NVPTXFloatMCExpr::printImpl(), llvm::ExecutionEngine::runFunctionAsMain(), llvm::PPCTargetLowering::SelectAddressRegImm(), llvm::PPCTargetLowering::SelectAddressRegImm34(), selectI64ImmDirect(), selectI64ImmDirectPrefix(), llvm::LoongArchDAGToDAGISel::selectVSplatImm(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(), llvm::InstCombinerImpl::simplifyShrShlDemandedBits(), simplifyX86extrq(), simplifyX86insertq(), simplifyX86varShift(), llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(), toString(), llvm::detail::IEEEFloat::toString(), toString(), tryBitfieldInsertOpFromOrAndImm(), llvm::tryPromoteCall(), urem(), llvm::Interpreter::visitAllocaInst(), llvm::InstCombinerImpl::visitAnd(), llvm::Interpreter::visitAShr(), llvm::InstCombinerImpl::visitAShr(), llvm::Interpreter::visitExtractElementInst(), llvm::Interpreter::visitInsertElementInst(), llvm::Interpreter::visitLShr(), llvm::InstCombinerImpl::visitLShr(), llvm::Interpreter::visitShl(), llvm::InstCombinerImpl::visitShl(), walkToAllocaAndPrependOffsetDeref(), and WriteAPFloatInternal().

◆ insertBits() [1/2]

void APInt::insertBits ( const APInt SubBits,
unsigned  bitPosition 
)

◆ insertBits() [2/2]

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

Definition at line 426 of file APInt.cpp.

References isSingleWord().

◆ intersects()

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

◆ isAligned()

bool APInt::isAligned ( Align  A) const

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

Definition at line 168 of file APInt.cpp.

References A, countr_zero(), isZero(), and llvm::Log2().

◆ isAllOnes()

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

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

Definition at line 349 of file APInt.h.

References llvm::BitWidth.

Referenced by areUsedBitsDense(), bitTrackingDCE(), llvm::TargetLowering::BuildSDIV(), combineSetCCMOVMSK(), 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::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(), and llvm::InstCombinerImpl::visitOr().

◆ isIntN()

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

◆ isMask() [1/2]

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

Definition at line 479 of file APInt.h.

References llvm::BitWidth, and llvm::isMask_64().

◆ isMask() [2/2]

bool llvm::APInt::isMask ( unsigned  numBits) const
inline

◆ isMaxSignedValue()

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

Determine if this is the largest signed value.

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

Definition at line 383 of file APInt.h.

References assert(), and llvm::BitWidth.

Referenced by combineSetCCAtomicArith(), llvm::InstCombinerImpl::foldICmpXorConstant(), incDecVectorConstant(), llvm::ConstantInt::isMaxValue(), LowerVSETCC(), matchMinMax(), llvm::TargetLowering::SimplifySetCC(), and simplifySubInst().

◆ isMaxValue()

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

Determine if this is the largest unsigned value.

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

Definition at line 377 of file APInt.h.

Referenced by combineSetCCAtomicArith(), llvm::ConstantRange::ConstantRange(), incDecVectorConstant(), llvm::ConstantRange::isFullSet(), and llvm::ConstantInt::isMaxValue().

◆ isMinSignedValue()

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

◆ isMinValue()

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

Determine if this is the smallest unsigned value.

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

Definition at line 395 of file APInt.h.

References isZero().

Referenced by combineSetCCAtomicArith(), llvm::InstCombinerImpl::commonIRemTransforms(), llvm::ConstantRange::ConstantRange(), llvm::ConstantRange::isEmptySet(), llvm::ConstantInt::isMinValue(), isMultiple(), and LinearizeExprTree().

◆ isNegatedPowerOf2()

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

◆ isNegative()

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

Determine sign of this APInt.

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

Returns
true if this APInt is negative, false otherwise

Definition at line 307 of file APInt.h.

References llvm::BitWidth.

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

◆ isNonNegative()

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

◆ isNonPositive()

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

Determine if this APInt Value is non-positive (<= 0).

Returns
true if this APInt is non-positive.

Definition at line 339 of file APInt.h.

Referenced by trySimplifyICmpWithAdds().

◆ isOne()

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

◆ isOneBitSet()

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

Determine if this APInt Value only has the specified bit set.

Returns
true if this APInt only has the specified bit set.

Definition at line 344 of file APInt.h.

References llvm::popcount().

◆ isPowerOf2()

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

◆ isSameValue()

static bool llvm::APInt::isSameValue ( const APInt I1,
const APInt I2 
)
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 line 531 of file APInt.h.

References getBitWidth(), and zext().

Referenced by llvm::SDPatternMatch::SpecificInt_match::match(), and llvm::PatternMatch::specific_intval< AllowUndefs >::match().

◆ isShiftedMask() [1/2]

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

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

Definition at line 488 of file APInt.h.

References llvm::BitWidth, llvm::countr_zero(), and llvm::isShiftedMask_64().

◆ isShiftedMask() [2/2]

bool llvm::APInt::isShiftedMask ( unsigned MaskIdx,
unsigned MaskLen 
) const
inline

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

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

Definition at line 500 of file APInt.h.

References llvm::BitWidth, and llvm::isShiftedMask_64().

◆ isSignBitClear()

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

Determine if sign bit of this APInt is clear.

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

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

Definition at line 326 of file APInt.h.

Referenced by llvm::KnownBits::getSignedMaxValue(), and llvm::KnownBits::getSignedMinValue().

◆ isSignBitSet()

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

Determine if sign bit of this APInt is set.

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

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

Definition at line 319 of file APInt.h.

References llvm::BitWidth.

Referenced by combineSetCC(), llvm::APFixedPoint::compare(), llvm::ScalarEvolution::getAddExpr(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::KnownBits::isSignUnknown(), llvm::KnownBits::isStrictlyPositive(), simplifyShift(), and toSigned().

◆ isSignedIntN()

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

◆ isSignMask()

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

◆ isSingleWord()

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

Determine if this APInt just has one word to store value.

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

Definition at line 300 of file APInt.h.

References llvm::BitWidth.

Referenced by extractBits(), extractBitsAsZExtValue(), llvm::hash_value(), insertBits(), operator*(), operator*=(), operator++(), operator+=(), operator--(), operator-=(), Profile(), roundToDouble(), sqrt(), llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(), toString(), udiv(), and urem().

◆ isSplat()

bool APInt::isSplat ( unsigned  SplatSizeInBits) const

Check if the APInt 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 line 599 of file APInt.cpp.

References assert(), getBitWidth(), and rotl().

◆ isStrictlyPositive()

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

◆ isSubsetOf()

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

◆ isZero()

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

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

Definition at line 358 of file APInt.h.

References llvm::BitWidth.

Referenced by llvm::KnownBits::abs(), llvm::ScalarEvolution::applyLoopGuards(), canWidenShuffleElements(), llvm::GEPOperator::collectOffset(), llvm::PPCInstrInfo::combineRLWINM(), combineSetCCAtomicArith(), combineSetCCMOVMSK(), combineX86ShufflesRecursively(), llvm::InstCombinerImpl::commonIDivTransforms(), computeKnownBitsFromOperator(), computeKnownFPClass(), createAndInstr(), llvm::ConstantRange::cttz(), llvm::APFixedPoint::div(), EltsFromConsecutiveLoads(), llvm::exprDiv(), foldAndOrOfICmpEqConstantAndICmp(), foldAndOrOfSETCC(), foldBinOpIntoSelectIfProfitable(), foldCttzCtlz(), llvm::InstCombinerImpl::foldICmpAndConstant(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpAndShift(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpDivConstant(), llvm::InstCombinerImpl::foldICmpMulConstant(), llvm::InstCombinerImpl::foldICmpShlConstConst(), llvm::InstCombinerImpl::foldICmpShrConstConst(), llvm::InstCombinerImpl::foldICmpWithZero(), foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed(), foldSelectICmpAnd(), llvm::InstCombinerImpl::FoldShiftByConstant(), foldSignedTruncationCheck(), GEPToVectorIndex(), llvm::SignedDivisionByConstantInfo::get(), llvm::UnsignedDivisionByConstantInfo::get(), getFauxShuffleMask(), getKnownBitsFromAndXorOr(), llvm::X86TTIImpl::getScalarizationOverhead(), llvm::getShuffleDemandedElts(), incDecVectorConstant(), isAligned(), llvm::BuildVectorSDNode::isConstantSequence(), llvm::ISD::isConstantSplatVectorAllZeros(), llvm::ShuffleVectorInst::isInsertSubvectorMask(), llvm::SelectionDAG::isKnownNeverZero(), 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::TargetLowering::SimplifyDemandedBits(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), 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(), and llvm::KnownBits::udiv().

◆ logBase2()

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

◆ lshr() [1/2]

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

Logical right-shift function.

Logical right-shift this APInt by shiftAmt.

Definition at line 898 of file APInt.h.

◆ lshr() [2/2]

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

Logical right-shift function.

Logical right-shift this APInt by shiftAmt.

Definition at line 829 of file APInt.h.

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

◆ lshrInPlace() [1/2]

void APInt::lshrInPlace ( const APInt shiftAmt)

Logical right-shift this APInt by ShiftAmt in place.

Logical right-shift this APInt by shiftAmt.

Logical right-shift function.

Definition at line 1069 of file APInt.cpp.

References getLimitedValue(), and lshrInPlace().

◆ lshrInPlace() [2/2]

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

◆ multiplicativeInverse()

APInt APInt::multiplicativeInverse ( const APInt modulo) const

Computes the multiplicative inverse of this APInt for a given modulo.

Returns
the multiplicative inverse for a given modulo.

The iterative extended Euclidean algorithm is used to solve for this value, however we simplify it to speed up calculating only the inverse, and take advantage of div+rem calculations. We also use some tricks to avoid copying (potentially large) APInts around. WARNING: a value of '0' may be returned, signifying that no multiplicative inverse exists!

Definition at line 1250 of file APInt.cpp.

References APInt(), assert(), isNegative(), udivrem(), and ult().

Referenced by BinomialCoefficient(), llvm::CombinerHelper::buildSDivUsingMul(), llvm::TargetLowering::expandDIVREMByConstant(), and SolveLinEquationWithOverflow().

◆ ne()

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

Inequality comparison.

Compares this APInt with RHS for the validity of the inequality relationship.

Returns
true if *this != Val

Definition at line 1081 of file APInt.h.

References RHS.

◆ nearestLogBase2()

unsigned APInt::nearestLogBase2 ( ) const
Returns
the nearest log base 2 of this APInt. 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 line 1142 of file APInt.cpp.

References isZero(), and logBase2().

◆ needsCleanup()

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

Returns whether this instance allocated memory.

Definition at line 1868 of file APInt.h.

◆ negate()

void llvm::APInt::negate ( )
inline

◆ operator!()

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

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

Definition at line 587 of file APInt.h.

References isZero().

◆ operator!=() [1/2]

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

Inequality operator.

Compares this APInt with RHS for the validity of the inequality relationship.

Returns
true if *this != Val

Definition at line 1065 of file APInt.h.

References RHS.

◆ operator!=() [2/2]

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

Inequality operator.

Compares this APInt with a uint64_t for the validity of the inequality relationship.

Returns
true if *this != Val

Definition at line 1073 of file APInt.h.

◆ operator&=() [1/2]

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

Bitwise AND assignment operator.

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

Returns
*this after ANDing with RHS.

Definition at line 652 of file APInt.h.

References assert(), llvm::BitWidth, and RHS.

◆ operator&=() [2/2]

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

Bitwise AND assignment operator.

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

Definition at line 666 of file APInt.h.

References RHS.

◆ operator*()

APInt APInt::operator* ( const APInt RHS) const

Multiplication operator.

Multiplies this APInt by RHS and returns the result.

Definition at line 234 of file APInt.cpp.

References APInt(), assert(), getBitWidth(), getMemory(), getNumWords(), isSingleWord(), RHS, and tcMultiply().

◆ operator*=() [1/2]

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

Multiplication assignment operator.

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

Returns
*this

Definition at line 263 of file APInt.cpp.

References RHS.

◆ operator*=() [2/2]

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

Definition at line 268 of file APInt.cpp.

References getNumWords(), isSingleWord(), RHS, and tcMultiplyPart().

◆ operator++() [1/2]

APInt & APInt::operator++ ( )

Prefix increment operator.

Prefix increment operator. Increments the APInt by one.

Returns
*this incremented by one

Definition at line 177 of file APInt.cpp.

References getNumWords(), isSingleWord(), and tcIncrement().

◆ operator++() [2/2]

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

Postfix increment operator.

Increment *this by 1.

Returns
a new APInt value representing the original value of *this.

Definition at line 560 of file APInt.h.

◆ operator+=() [1/2]

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

Addition assignment operator.

Adds the RHS APInt to this APInt.

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

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

Definition at line 197 of file APInt.cpp.

References assert(), getNumWords(), isSingleWord(), RHS, and tcAdd().

◆ operator+=() [2/2]

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

Definition at line 206 of file APInt.cpp.

References getNumWords(), isSingleWord(), RHS, and tcAddPart().

◆ operator--() [1/2]

APInt & APInt::operator-- ( )

Prefix decrement operator.

Prefix decrement operator. Decrements the APInt by one.

Returns
*this decremented by one.

Definition at line 186 of file APInt.cpp.

References getNumWords(), isSingleWord(), and tcDecrement().

◆ operator--() [2/2]

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

Postfix decrement operator.

Decrement *this by 1.

Returns
a new APInt value representing the original value of *this.

Definition at line 574 of file APInt.h.

◆ operator-=() [1/2]

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

Subtraction assignment operator.

Subtracts the RHS APInt from this APInt.

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

Returns
*this
this, after subtraction Subtraction assignment operator.

Definition at line 217 of file APInt.cpp.

References assert(), getNumWords(), isSingleWord(), RHS, and tcSubtract().

◆ operator-=() [2/2]

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

Definition at line 226 of file APInt.cpp.

References getNumWords(), isSingleWord(), RHS, and tcSubtractPart().

◆ operator<<() [1/2]

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

Left logical shift operator.

Shifts this APInt left by Bits and returns the result.

Definition at line 800 of file APInt.h.

◆ operator<<() [2/2]

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

Left logical shift operator.

Shifts this APInt left by Bits and returns the result.

Definition at line 795 of file APInt.h.

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

APInt & APInt::operator<<= ( const APInt shiftAmt)

Left-shift assignment function.

Left-shift this APInt 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 line 1081 of file APInt.cpp.

References getLimitedValue().

◆ 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 line 763 of file APInt.h.

References assert(), llvm::BitWidth, and clearUnusedBits().

◆ operator=() [1/3]

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

Move assignment operator.

Definition at line 610 of file APInt.h.

References assert(), and llvm::BitWidth.

◆ operator=() [2/3]

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

Copy assignment operator.

Returns
*this after assignment of RHS.

Definition at line 596 of file APInt.h.

References llvm::BitWidth, and RHS.

◆ 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 line 636 of file APInt.h.

References clearUnusedBits(), and RHS.

◆ operator==() [1/2]

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

Equality operator.

Compares this APInt with RHS for the validity of the equality relationship.

Definition at line 1034 of file APInt.h.

References assert(), llvm::BitWidth, and RHS.

◆ operator==() [2/2]

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

Equality operator.

Compares this APInt with a uint64_t for the validity of the equality relationship.

Returns
true if *this == Val

Definition at line 1047 of file APInt.h.

◆ operator[]()

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

Array-indexing support.

Returns
the bit value at bitPosition

Definition at line 1021 of file APInt.h.

References assert(), and getBitWidth().

◆ operator^=() [1/2]

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

Bitwise XOR assignment operator.

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

Returns
*this after XORing with RHS.

Definition at line 711 of file APInt.h.

References assert(), llvm::BitWidth, and RHS.

◆ operator^=() [2/2]

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

Bitwise XOR assignment operator.

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

Definition at line 725 of file APInt.h.

References clearUnusedBits(), and RHS.

◆ operator|=() [1/2]

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

Bitwise OR assignment operator.

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

Returns
*this after ORing with RHS.

Definition at line 682 of file APInt.h.

References assert(), llvm::BitWidth, and RHS.

◆ operator|=() [2/2]

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

Bitwise OR assignment operator.

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

Definition at line 696 of file APInt.h.

References clearUnusedBits(), and RHS.

◆ popcount()

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

◆ print()

void APInt::print ( raw_ostream OS,
bool  isSigned 
) const

Definition at line 2313 of file APInt.cpp.

References isSigned(), OS, and toString().

◆ Profile()

void APInt::Profile ( FoldingSetNodeID id) const

Used to insert APInt objects, or objects that contain APInt objects, into FoldingSets.

This method 'profiles' an APInt for use with FoldingSet.

Definition at line 155 of file APInt.cpp.

References getNumWords(), and isSingleWord().

Referenced by llvm::APSInt::Profile().

◆ relativeAShl()

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

relative arithmetic shift left

Definition at line 873 of file APInt.h.

Referenced by llvm::APFixedPoint::mul().

◆ relativeAShr()

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

relative arithmetic shift right

Definition at line 868 of file APInt.h.

◆ relativeLShl()

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

relative logical shift left

Definition at line 863 of file APInt.h.

Referenced by llvm::APFixedPoint::mul().

◆ relativeLShr()

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

relative logical shift right

Definition at line 858 of file APInt.h.

◆ reverseBits()

APInt APInt::reverseBits ( ) const

◆ rotl() [1/2]

APInt APInt::rotl ( const APInt rotateAmt) const

Rotate left by rotateAmt.

Definition at line 1107 of file APInt.cpp.

References rotateModulo(), and rotl().

◆ rotl() [2/2]

APInt APInt::rotl ( unsigned  rotateAmt) const

Rotate left by rotateAmt.

Definition at line 1111 of file APInt.cpp.

References LLVM_UNLIKELY, lshr(), and shl().

Referenced by llvm::PPCInstrInfo::combineRLWINM(), FoldValue(), isSplat(), and rotl().

◆ rotr() [1/2]

APInt APInt::rotr ( const APInt rotateAmt) const

Rotate right by rotateAmt.

Definition at line 1120 of file APInt.cpp.

References rotateModulo(), and rotr().

◆ rotr() [2/2]

APInt APInt::rotr ( unsigned  rotateAmt) const

Rotate right by rotateAmt.

Definition at line 1124 of file APInt.cpp.

References lshr(), and shl().

Referenced by FoldValue(), llvm::RISCVLegalizerInfo::legalizeCustom(), rotr(), selectI64ImmDirect(), and selectI64ImmDirectPrefix().

◆ roundToDouble() [1/2]

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

Converts this unsigned APInt to a double value.

Definition at line 1661 of file APInt.h.

References roundToDouble().

Referenced by roundToDouble().

◆ roundToDouble() [2/2]

double APInt::roundToDouble ( bool  isSigned) const

Converts this APInt to a double value.

This function converts this APInt 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 line 849 of file APInt.cpp.

References APINT_BITS_PER_WORD, assert(), getActiveBits(), I, isNeg(), isSigned(), isSingleWord(), pVal, sext(), and llvm::SignExtend64().

Referenced by llvm::ExecutionEngine::getConstantValue(), and llvm::APIntOps::RoundAPIntToDouble().

◆ sadd_ov()

APInt APInt::sadd_ov ( const APInt RHS,
bool Overflow 
) const

◆ sadd_sat()

APInt APInt::sadd_sat ( const APInt RHS) const

◆ sdiv() [1/2]

APInt APInt::sdiv ( const APInt RHS) const

◆ sdiv() [2/2]

APInt APInt::sdiv ( int64_t  RHS) const

Definition at line 1661 of file APInt.cpp.

References isNegative(), RHS, and udiv().

◆ sdiv_ov()

APInt APInt::sdiv_ov ( const APInt RHS,
bool Overflow 
) const

Definition at line 1960 of file APInt.cpp.

References isMinSignedValue(), RHS, and sdiv().

Referenced by llvm::exprDiv(), and sfloordiv_ov().

◆ sdivrem() [1/2]

void APInt::sdivrem ( const APInt LHS,
const APInt RHS,
APInt Quotient,
APInt Remainder 
)
static

◆ sdivrem() [2/2]

void APInt::sdivrem ( const APInt LHS,
int64_t  RHS,
APInt Quotient,
int64_t &  Remainder 
)
static

Definition at line 1914 of file APInt.cpp.

References LHS, negate(), RHS, and udivrem().

◆ setAllBits()

void llvm::APInt::setAllBits ( )
inline

◆ setBit()

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

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

Definition at line 1308 of file APInt.h.

References assert(), and llvm::BitWidth.

Referenced by llvm::KnownBits::abs(), llvm::KnownBits::blsi(), combineAnd(), combineAndnp(), combineOr(), combineSetCCMOVMSK(), 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(), getHorizDemandedElts(), llvm::TargetTransformInfoImplCRTPBase< T >::getInstructionCost(), llvm::BasicTTIImplBase< T >::getInterleavedMemoryOpCost(), llvm::X86TTIImpl::getInterleavedMemoryOpCostAVX512(), getKnownBitsFromAndXorOr(), getKnownUndefForVectorBinop(), getOneBitSet(), getPackDemandedElts(), llvm::getShuffleDemandedElts(), getSignedMinValue(), getTargetConstantBitsFromNode(), getTargetShuffleAndZeroables(), llvm::mca::initializeUsedResources(), llvm::ShuffleVectorInst::isInsertSubvectorMask(), llvm::SelectionDAG::isSplatValue(), isTargetShuffleEquivalent(), matchAndOrChain(), matchBinaryShuffle(), llvm::KnownBits::mul(), PerformReduceShuffleCombine(), resolveZeroablesFromTargetShuffle(), llvm::APIntOps::ScaleBitMask(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::InstCombinerImpl::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::X86TTIImpl::simplifyDemandedVectorEltsIntrinsic(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), and llvm::InstCombinerImpl::visitExtractElementInst().

◆ setBits()

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

◆ setBitsFrom()

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

◆ 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 when loBit >= hiBit, and calls setBits when loBit < hiBit. For loBit == hiBit wrap case, set every bit to 1.

Definition at line 1332 of file APInt.h.

References assert(), and llvm::BitWidth.

Referenced by getBitsSetWithWrap().

◆ setBitVal()

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

◆ setHighBits()

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

◆ setLowBits()

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

◆ setSignBit()

void llvm::APInt::setSignBit ( )
inline

◆ sext()

APInt APInt::sext ( unsigned  width) const

◆ sextOrTrunc()

APInt APInt::sextOrTrunc ( unsigned  width) const

◆ sfloordiv_ov()

APInt APInt::sfloordiv_ov ( const APInt RHS,
bool Overflow 
) 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 line 2025 of file APInt.cpp.

References isNegative(), RHS, and sdiv_ov().

◆ sge() [1/2]

bool llvm::APInt::sge ( const APInt RHS) 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 line 1215 of file APInt.h.

References RHS.

Referenced by computeKnownFPClass(), llvm::InstCombinerImpl::foldICmpOrConstant(), foldNoWrapAdd(), FoldValue(), isNonEqualPointersWithRecursiveGEP(), performMulCombine(), and TryMULWIDECombine().

◆ 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 line 1223 of file APInt.h.

References RHS.

◆ sgt() [1/2]

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

◆ 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 line 1187 of file APInt.h.

References RHS.

◆ shl() [1/2]

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

Left-shift function.

Left-shift this APInt by shiftAmt.

Definition at line 910 of file APInt.h.

◆ shl() [2/2]

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

◆ signedRoundToDouble()

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

Converts this signed APInt to a double value.

Definition at line 1664 of file APInt.h.

Referenced by llvm::ExecutionEngine::getConstantValue(), llvm::APIntOps::RoundSignedAPIntToDouble(), and llvm::APIntOps::RoundSignedAPIntToFloat().

◆ sle() [1/2]

bool llvm::APInt::sle ( const APInt RHS) 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 line 1144 of file APInt.h.

References RHS.

Referenced by llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), FoldValue(), isNonEqualPointersWithRecursiveGEP(), isSignedMinMaxClamp(), isSignedMinMaxIntrinsicClamp(), and performMulCombine().

◆ 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 line 1152 of file APInt.h.

References RHS.

◆ slt() [1/2]

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

◆ 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 line 1116 of file APInt.h.

References RHS.

◆ smul_ov()

APInt APInt::smul_ov ( const APInt RHS,
bool Overflow 
) const

◆ smul_sat()

APInt APInt::smul_sat ( const APInt RHS) const

Definition at line 2070 of file APInt.cpp.

References getSignedMaxValue(), getSignedMinValue(), isNegative(), RHS, and smul_ov().

Referenced by llvm::ConstantRange::smul_sat().

◆ sqrt()

APInt APInt::sqrt ( ) const

Compute the square root.

Definition at line 1169 of file APInt.cpp.

References APInt(), assert(), getActiveBits(), isSingleWord(), round(), shl(), sqrt(), udiv(), ule(), and ult().

Referenced by sqrt().

◆ srem() [1/2]

APInt APInt::srem ( const APInt RHS) const

Function for signed remainder operation.

Signed remainder operation on APInt.

Note that this is a true remainder operation and not a modulo operation because the sign follows the sign of the dividend which is *this.

Definition at line 1742 of file APInt.cpp.

References isNegative(), RHS, and urem().

Referenced by llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), findGCD(), FoldValue(), getExactSDiv(), getStrideAndModOffsetOfGEP(), isRemainderZero(), simplifyRelativeLoad(), and llvm::Interpreter::visitBinaryOperator().

◆ srem() [2/2]

int64_t APInt::srem ( int64_t  RHS) const

Definition at line 1753 of file APInt.cpp.

References isNegative(), RHS, and urem().

◆ sshl_ov() [1/2]

APInt APInt::sshl_ov ( const APInt Amt,
bool Overflow 
) const

Definition at line 1994 of file APInt.cpp.

References getBitWidth(), getLimitedValue(), and sshl_ov().

Referenced by sshl_ov(), and sshl_sat().

◆ sshl_ov() [2/2]

APInt APInt::sshl_ov ( unsigned  Amt,
bool Overflow 
) const

Definition at line 1998 of file APInt.cpp.

References APInt(), countl_one(), countl_zero(), getBitWidth(), and isNonNegative().

◆ sshl_sat() [1/2]

APInt APInt::sshl_sat ( const APInt RHS) const

Definition at line 2092 of file APInt.cpp.

References getBitWidth(), RHS, and sshl_sat().

Referenced by FoldValue(), sshl_sat(), and llvm::ConstantRange::sshl_sat().

◆ sshl_sat() [2/2]

APInt APInt::sshl_sat ( unsigned  RHS) const

Definition at line 2096 of file APInt.cpp.

References getSignedMaxValue(), getSignedMinValue(), isNegative(), RHS, and sshl_ov().

◆ ssub_ov()

APInt APInt::ssub_ov ( const APInt RHS,
bool Overflow 
) const

◆ ssub_sat()

APInt APInt::ssub_sat ( const APInt RHS) const

◆ tcAdd()

APInt::WordType APInt::tcAdd ( WordType dst,
const WordType rhs,
WordType  carry,
unsigned  parts 
)
static

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

Definition at line 2448 of file APInt.cpp.

References assert().

Referenced by operator+=().

◆ tcAddPart()

APInt::WordType APInt::tcAddPart ( WordType dst,
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 line 2470 of file APInt.cpp.

Referenced by operator+=().

◆ tcAssign()

void APInt::tcAssign ( WordType dst,
const WordType src,
unsigned  parts 
)
static

◆ tcClearBit()

void APInt::tcClearBit ( WordType parts,
unsigned  bit 
)
static

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

Clears the given bit of a bignum.

Definition at line 2379 of file APInt.cpp.

Referenced by llvm::detail::IEEEFloat::makeNaN().

◆ tcCompare()

int APInt::tcCompare ( const WordType lhs,
const WordType rhs,
unsigned  parts 
)
static

Comparison (unsigned) of two bignums.

Definition at line 2754 of file APInt.cpp.

Referenced by llvm::detail::IEEEFloat::compareAbsoluteValue(), and tcDivide().

◆ tcDecrement()

static WordType llvm::APInt::tcDecrement ( WordType dst,
unsigned  parts 
)
inlinestatic

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

Definition at line 1856 of file APInt.h.

Referenced by llvm::detail::IEEEFloat::next(), and operator--().

◆ tcDivide()

int APInt::tcDivide ( WordType lhs,
const WordType rhs,
WordType remainder,
WordType scratch,
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 line 2659 of file APInt.cpp.

References APINT_BITS_PER_WORD, assert(), tcAssign(), tcCompare(), tcMSB(), tcSet(), tcShiftLeft(), tcShiftRight(), and tcSubtract().

◆ tcExtract()

void APInt::tcExtract ( WordType dst,
unsigned  dstCount,
const WordType src,
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 line 2418 of file APInt.cpp.

References APINT_BITS_PER_WORD, assert(), lowBitMask(), tcAssign(), and tcShiftRight().

◆ tcExtractBit()

int APInt::tcExtractBit ( const WordType parts,
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 line 2369 of file APInt.cpp.

Referenced by llvm::detail::IEEEFloat::convertFromSignExtendedInteger(), llvm::detail::IEEEFloat::convertFromZeroExtendedInteger(), llvm::detail::IEEEFloat::isDenormal(), llvm::detail::IEEEFloat::isSignaling(), and llvm::lostFractionThroughTruncation().

◆ tcFullMultiply()

void APInt::tcFullMultiply ( WordType dst,
const WordType lhs,
const WordType rhs,
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 line 2635 of file APInt.cpp.

References assert(), tcFullMultiply(), tcMultiplyPart(), and tcSet().

Referenced by llvm::powerOf5(), and tcFullMultiply().

◆ tcIncrement()

static WordType llvm::APInt::tcIncrement ( WordType dst,
unsigned  parts 
)
inlinestatic

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

Definition at line 1851 of file APInt.h.

Referenced by operator++(), and tcNegate().

◆ tcIsZero()

bool APInt::tcIsZero ( const WordType src,
unsigned  parts 
)
static

Returns true if a bignum is zero, false otherwise.

Definition at line 2360 of file APInt.cpp.

Referenced by llvm::detail::IEEEFloat::makeNaN().

◆ tcLSB()

unsigned APInt::tcLSB ( const WordType parts,
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 line 2385 of file APInt.cpp.

References APINT_BITS_PER_WORD, and llvm::countr_zero().

Referenced by llvm::lostFractionThroughTruncation().

◆ tcMSB()

unsigned APInt::tcMSB ( const WordType parts,
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 line 2398 of file APInt.cpp.

References APINT_BITS_PER_WORD, and llvm::Log2_64().

Referenced by tcDivide().

◆ tcMultiply()

int APInt::tcMultiply ( WordType dst,
const WordType lhs,
const WordType rhs,
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 line 2619 of file APInt.cpp.

References assert(), tcMultiplyPart(), and tcSet().

Referenced by operator*().

◆ tcMultiplyPart()

int APInt::tcMultiplyPart ( WordType dst,
const WordType src,
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 line 2536 of file APInt.cpp.

References APINT_BITS_PER_WORD, assert(), highHalf(), and lowHalf().

Referenced by operator*=(), tcFullMultiply(), and tcMultiply().

◆ tcNegate()

void APInt::tcNegate ( WordType dst,
unsigned  parts 
)
static

Negate a bignum in-place.

Definition at line 2522 of file APInt.cpp.

References tcComplement(), and tcIncrement().

Referenced by llvm::detail::IEEEFloat::convertFromSignExtendedInteger().

◆ tcSet()

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

◆ tcSetBit()

void APInt::tcSetBit ( WordType parts,
unsigned  bit 
)
static

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

Set the given bit of a bignum.

Definition at line 2374 of file APInt.cpp.

Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::makeNaN(), llvm::detail::IEEEFloat::makeQuiet(), llvm::detail::IEEEFloat::makeSmallestNormalized(), and llvm::detail::IEEEFloat::next().

◆ tcShiftLeft()

void APInt::tcShiftLeft ( WordType Dst,
unsigned  Words,
unsigned  Count 
)
static

Shift a bignum left Count bits.

Shift a bignum left Cound bits in-place.

Shifted in bits are zero. There are no restrictions on Count.

Definition at line 2701 of file APInt.cpp.

References APINT_BITS_PER_WORD, and APINT_WORD_SIZE.

Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::convertToInteger(), and tcDivide().

◆ tcShiftRight()

void APInt::tcShiftRight ( WordType Dst,
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 line 2728 of file APInt.cpp.

References APINT_BITS_PER_WORD, and APINT_WORD_SIZE.

Referenced by llvm::shiftRight(), tcDivide(), and tcExtract().

◆ tcSubtract()

APInt::WordType APInt::tcSubtract ( WordType dst,
const WordType rhs,
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 line 2483 of file APInt.cpp.

References assert().

Referenced by operator-=(), and tcDivide().

◆ tcSubtractPart()

APInt::WordType APInt::tcSubtractPart ( WordType dst,
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 line 2508 of file APInt.cpp.

Referenced by operator-=().

◆ toString()

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

Converts an APInt to a string and append it to Str.

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

Definition at line 2170 of file APInt.cpp.

References assert(), getBoolValue(), getRawData(), getSExtValue(), getZExtValue(), I, isNegative(), isSingleWord(), isZero(), llvm_unreachable, lshrInPlace(), N, negate(), Signed, and udivrem().

Referenced by llvm::ExpressionFormat::getMatchingString(), and print().

◆ toStringSigned()

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

Considers the APInt to be signed and converts it into a string in the radix given.

The radix can be 2, 8, 10, 16, or 36.

Definition at line 1646 of file APInt.h.

References toString().

Referenced by dump().

◆ toStringUnsigned()

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

Considers the APInt to be unsigned and converts it into a string in the radix given.

The radix can be 2, 8, 10 16, or 36.

Definition at line 1640 of file APInt.h.

References toString().

Referenced by dump().

◆ trunc()

APInt APInt::trunc ( unsigned  width) const

Truncate to new width.

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

Definition at line 906 of file APInt.cpp.

References APInt(), APINT_BITS_PER_WORD, assert(), getMemory(), getNumWords(), and getRawData().

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

◆ truncSSat()

APInt APInt::truncSSat ( unsigned  width) const

Truncate to new width with signed saturation.

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

Definition at line 942 of file APInt.cpp.

References assert(), getSignedMaxValue(), getSignedMinValue(), isNegative(), isSignedIntN(), and trunc().

Referenced by combineVectorPack().

◆ truncUSat()

APInt APInt::truncUSat ( unsigned  width) const

Truncate to new width with unsigned saturation.

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

Definition at line 931 of file APInt.cpp.

References assert(), getMaxValue(), isIntN(), and trunc().

◆ trySExtValue()

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

Get sign extended value if possible.

This method attempts to return the value of this APInt as a sign extended int64_t. The bitwidth must be <= 64 or the value must fit within an int64_t. Otherwise no value is returned.

Definition at line 1525 of file APInt.h.

Referenced by llvm::getExpressionForConstant().

◆ tryZExtValue()

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

Get zero extended value if possible.

This method attempts to return the value of this APInt as a zero extended uint64_t. The bitwidth must be <= 64 or the value must fit within a uint64_t. Otherwise no value is returned.

Definition at line 1503 of file APInt.h.

Referenced by mayLoopAccessLocation().

◆ uadd_ov()

APInt APInt::uadd_ov ( const APInt RHS,
bool Overflow 
) const

◆ uadd_sat()

APInt APInt::uadd_sat ( const APInt RHS) const

◆ udiv() [1/2]

APInt APInt::udiv ( const APInt RHS) const

◆ udiv() [2/2]

APInt APInt::udiv ( uint64_t  RHS) const

Definition at line 1617 of file APInt.cpp.

References APInt(), assert(), getActiveBits(), getNumWords(), isSingleWord(), and RHS.

◆ udivrem() [1/2]

void APInt::udivrem ( const APInt LHS,
const APInt RHS,
APInt Quotient,
APInt Remainder 
)
static

Dual division/remainder interface.

Sometimes it is convenient to divide two APInt values and obtain both the quotient and remainder. This function does both operations in the same computation making it a little more efficient. The pair of input arguments may overlap with the pair of output arguments. It is safe to call udivrem(X, Y, X, Y), for example.

Definition at line 1764 of file APInt.cpp.

References APInt(), APINT_WORD_SIZE, assert(), llvm::BitWidth, getNumWords(), LHS, pVal, and RHS.

Referenced by extractShiftForRotate(), GEPToVectorIndex(), llvm::SignedDivisionByConstantInfo::get(), llvm::UnsignedDivisionByConstantInfo::get(), isMultiple(), multiplicativeInverse(), llvm::APIntOps::RoundingUDiv(), sdivrem(), llvm::detail::IEEEFloat::toString(), and toString().

◆ udivrem() [2/2]

void APInt::udivrem ( const APInt LHS,
uint64_t  RHS,
APInt Quotient,
uint64_t Remainder 
)
static

Definition at line 1835 of file APInt.cpp.

References APInt(), APINT_WORD_SIZE, assert(), llvm::BitWidth, getNumWords(), LHS, pVal, and RHS.

◆ uge() [1/2]

bool llvm::APInt::uge ( const APInt RHS) 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 line 1199 of file APInt.h.

References RHS.

Referenced by llvm::SelectionDAG::canCreateUndefOrPoison(), canTryToConstantAddTwoShiftAmounts(), collectBitParts(), combineAnd(), combineExtractWithShuffle(), llvm::X86TargetLowering::ComputeNumSignBitsForTargetNode(), ComputeNumSignBitsImpl(), llvm::InstCombinerImpl::convertOrOfShiftsToFunnelShift(), detectUSatPattern(), Expand64BitShift(), llvm::TargetLowering::expandDIVREMByConstant(), ExtractConstantBytes(), llvm::InstCombinerImpl::foldICmpBinOp(), llvm::InstCombinerImpl::foldICmpShlConstant(), llvm::InstCombinerImpl::foldICmpShrConstant(), llvm::InstCombinerImpl::FoldShiftByConstant(), FoldValue(), llvm::SignedDivisionByConstantInfo::get(), llvm::UnsignedDivisionByConstantInfo::get(), llvm::SelectionDAG::getValidMaximumShiftAmountConstant(), llvm::SelectionDAG::getValidMinimumShiftAmountConstant(), getVariantMatchScore(), isDereferenceableAndAlignedPointer(), isNonZeroShift(), isPoisonShift(), LowerShiftByScalarImmediate(), matchAndOrChain(), llvm::CombinerHelper::matchCombineTruncOfShift(), PerformSHLSimplify(), llvm::X86TargetLowering::preferedOpcodeForCmpEqPiecesOfOperand(), simplifyAndCommutative(), llvm::TargetLowering::SimplifyDemandedBits(), simplifyLShrInst(), simplifyShift(), llvm::InstCombinerImpl::simplifyShrShlDemandedBits(), simplifyX86immShift(), simplifyX86varShift(), llvm::ConstantInt::uge(), llvm::ConstantRange::unionWith(), and llvm::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 line 1207 of file APInt.h.

References RHS.

◆ ugt() [1/2]

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

◆ 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 line 1168 of file APInt.h.

References RHS.

◆ ule() [1/2]

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

◆ 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 line 1136 of file APInt.h.

References RHS.

◆ ult() [1/2]

bool llvm::APInt::ult ( const APInt RHS) 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 line 1089 of file APInt.h.

References RHS.

Referenced by canEvaluateShiftedShift(), canEvaluateTruncated(), cheapToScalarize(), combineCMov(), combineCMP(), combineExtractWithShuffle(), llvm::InstCombinerImpl::commonIDivTransforms(), llvm::APFixedPoint::compare(), CompareSCEVComplexity(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromShiftOperator(), llvm::SelectionDAG::computeOverflowForUnsignedAdd(), computePointerICmp(), llvm::InstCombinerImpl::convertOrOfShiftsToFunnelShift(), findDemandedEltsBySingleUser(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), foldICmpWithTruncSignExtendedVal(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), llvm::SignedDivisionByConstantInfo::get(), llvm::UnsignedDivisionByConstantInfo::get(), llvm::omp::getBestVariantMatchForContext(), getRangeForAffineARHelper(), llvm::SelectionDAG::getShiftAmountConstant(), llvm::SelectionDAG::getValidShiftAmountConstant(), llvm::ConstantRange::intersectWith(), llvm::SelectionDAG::isKnownNeverZero(), matchClamp(), multiplicativeInverse(), llvm::X86TargetLowering::preferedOpcodeForCmpEqPiecesOfOperand(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(), simplifyX86immShift(), simplifyX86varShift(), sqrt(), llvm::ConstantRange::truncate(), uadd_ov(), udiv(), umul_ov(), llvm::ConstantRange::unionWith(), llvm::ConstantRange::unsignedSubMayOverflow(), urem(), llvm::InstCombinerImpl::visitAnd(), llvm::InstCombinerImpl::visitAShr(), llvm::InstCombinerImpl::visitLShr(), and llvm::InstCombinerImpl::visitShl().

◆ 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 line 1097 of file APInt.h.

References RHS.

◆ umul_ov()

APInt APInt::umul_ov ( const APInt RHS,
bool Overflow 
) const

◆ umul_sat()

APInt APInt::umul_sat ( const APInt RHS) const

Definition at line 2083 of file APInt.cpp.

References getMaxValue(), RHS, and umul_ov().

Referenced by llvm::ConstantRange::umul_sat().

◆ urem() [1/2]

APInt APInt::urem ( const APInt RHS) const

◆ urem() [2/2]

uint64_t APInt::urem ( uint64_t  RHS) const

Definition at line 1710 of file APInt.cpp.

References assert(), getActiveBits(), getNumWords(), getZExtValue(), isSingleWord(), RHS, and ult().

◆ ushl_ov() [1/2]

APInt APInt::ushl_ov ( const APInt Amt,
bool Overflow 
) const

Definition at line 2011 of file APInt.cpp.

References getBitWidth(), getLimitedValue(), and ushl_ov().

Referenced by ushl_ov(), ushl_sat(), and llvm::InstCombinerImpl::visitUDiv().

◆ ushl_ov() [2/2]

APInt APInt::ushl_ov ( unsigned  Amt,
bool Overflow 
) const

Definition at line 2015 of file APInt.cpp.

References APInt(), countl_zero(), and getBitWidth().

◆ ushl_sat() [1/2]

APInt APInt::ushl_sat ( const APInt RHS) const

Definition at line 2106 of file APInt.cpp.

References getBitWidth(), RHS, and ushl_sat().

Referenced by FoldValue(), ushl_sat(), and llvm::ConstantRange::ushl_sat().

◆ ushl_sat() [2/2]

APInt APInt::ushl_sat ( unsigned  RHS) const

Definition at line 2110 of file APInt.cpp.

References getMaxValue(), RHS, and ushl_ov().

◆ usub_ov()

APInt APInt::usub_ov ( const APInt RHS,
bool Overflow 
) const

◆ usub_sat()

APInt APInt::usub_sat ( const APInt RHS) const

Definition at line 2061 of file APInt.cpp.

References APInt(), RHS, and usub_ov().

Referenced by FoldValue(), llvm::APFixedPoint::sub(), and llvm::ConstantRange::usub_sat().

◆ zext()

APInt APInt::zext ( unsigned  width) const

Zero extend to a new width.

This operation zero extends the APInt to a new width. The high order bits are filled with 0 bits. It is an error to specify a width that is less than the current width.

Definition at line 981 of file APInt.cpp.

References APInt(), APINT_BITS_PER_WORD, APINT_WORD_SIZE, assert(), getMemory(), getNumWords(), and getRawData().

Referenced by llvm::KnownBits::anyext(), BinomialCoefficient(), llvm::CombinerHelper::buildSDivUsingMul(), llvm::ConstantRange::castOp(), combineX86ShufflesRecursively(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), ConstantBuildVector(), detectSSatPattern(), llvm::APFixedPoint::div(), llvm::TargetLowering::expandDIVREMByConstant(), llvm::TargetLowering::expandFP_TO_INT_SAT(), extractConstantWithoutWrapping(), llvm::InstCombinerImpl::foldICmpAndConstConst(), llvm::InstCombinerImpl::foldICmpEquality(), foldSignedTruncationCheck(), FoldValue(), 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::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(), toSigned(), llvm::APFixedPoint::toString(), llvm::detail::IEEEFloat::toString(), llvm::LegalizationArtifactCombiner::tryCombineZExt(), tryToMergePartialOverlappingStores(), llvm::InstCombinerImpl::visitAnd(), llvm::LegalizerHelper::widenScalar(), llvm::ConstantRange::zeroExtend(), llvm::KnownBits::zext(), and zextOrTrunc().

◆ zextOrTrunc()

APInt APInt::zextOrTrunc ( unsigned  width) const

Friends And Related Function Documentation

◆ APSInt

friend class APSInt
friend

Definition at line 1881 of file APInt.h.

◆ DenseMapInfo< APInt, void >

friend struct DenseMapInfo< APInt, void >
friend

Definition at line 1878 of file APInt.h.

◆ hash_value

hash_code hash_value ( const APInt Arg)
friend

Overload to compute a hash_code for an APInt value.

Member Data Documentation

◆ pVal

uint64_t* llvm::APInt::pVal

Used to store the >64 bits integer value.

Definition at line 1875 of file APInt.h.

Referenced by llvm::hash_value(), roundToDouble(), udiv(), udivrem(), and urem().

◆ VAL

uint64_t llvm::APInt::VAL

Used to store the <= 64 bits integer value.

Definition at line 1874 of file APInt.h.

Referenced by APInt(), concat(), llvm::hash_value(), and insertBits().

◆ WORDTYPE_MAX

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

Definition at line 94 of file APInt.h.

Referenced by insertBits().


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