LLVM 22.0.0git
|
An arbitrary precision integer that knows its signedness. More...
#include "llvm/ADT/APSInt.h"
Public Member Functions | |
APSInt ()=default | |
Default constructor that creates an uninitialized APInt. | |
APSInt (uint32_t BitWidth, bool isUnsigned=true) | |
Create an APSInt with the specified width, default to unsigned. | |
APSInt (APInt I, bool isUnsigned=true) | |
LLVM_ABI | APSInt (StringRef Str) |
Construct an APSInt from a string representation. | |
bool | isNegative () const |
Determine sign of this APSInt. | |
bool | isNonNegative () const |
Determine if this APSInt Value is non-negative (>= 0) | |
bool | isStrictlyPositive () const |
Determine if this APSInt Value is positive. | |
APSInt & | operator= (APInt RHS) |
APSInt & | operator= (uint64_t RHS) |
bool | isSigned () const |
bool | isUnsigned () const |
void | setIsUnsigned (bool Val) |
void | setIsSigned (bool Val) |
void | toString (SmallVectorImpl< char > &Str, unsigned Radix=10) const |
Append this APSInt to the specified SmallString. | |
bool | isRepresentableByInt64 () const |
If this int is representable using an int64_t. | |
int64_t | getExtValue () const |
Get the correctly-extended int64_t value. | |
std::optional< int64_t > | tryExtValue () const |
APSInt | trunc (uint32_t width) const |
APSInt | extend (uint32_t width) const |
APSInt | extOrTrunc (uint32_t width) const |
const APSInt & | operator%= (const APSInt &RHS) |
const APSInt & | operator/= (const APSInt &RHS) |
APSInt | operator% (const APSInt &RHS) const |
APSInt | operator/ (const APSInt &RHS) const |
APSInt | operator>> (unsigned Amt) const |
APSInt & | operator>>= (unsigned Amt) |
APSInt | relativeShr (unsigned Amt) const |
bool | operator< (const APSInt &RHS) const |
bool | operator> (const APSInt &RHS) const |
bool | operator<= (const APSInt &RHS) const |
bool | operator>= (const APSInt &RHS) const |
bool | operator== (const APSInt &RHS) const |
bool | operator!= (const APSInt &RHS) const |
bool | operator== (int64_t RHS) const |
bool | operator!= (int64_t RHS) const |
bool | operator<= (int64_t RHS) const |
bool | operator>= (int64_t RHS) const |
bool | operator< (int64_t RHS) const |
bool | operator> (int64_t RHS) const |
APSInt | operator<< (unsigned Bits) const |
APSInt & | operator<<= (unsigned Amt) |
APSInt | relativeShl (unsigned Amt) const |
APSInt & | operator++ () |
APSInt & | operator-- () |
APSInt | operator++ (int) |
APSInt | operator-- (int) |
APSInt | operator- () const |
APSInt & | operator+= (const APSInt &RHS) |
APSInt & | operator-= (const APSInt &RHS) |
APSInt & | operator*= (const APSInt &RHS) |
APSInt & | operator&= (const APSInt &RHS) |
APSInt & | operator|= (const APSInt &RHS) |
APSInt & | operator^= (const APSInt &RHS) |
APSInt | operator& (const APSInt &RHS) const |
APSInt | operator| (const APSInt &RHS) const |
APSInt | operator^ (const APSInt &RHS) const |
APSInt | operator* (const APSInt &RHS) const |
APSInt | operator+ (const APSInt &RHS) const |
APSInt | operator- (const APSInt &RHS) const |
APSInt | operator~ () const |
LLVM_ABI void | Profile (FoldingSetNodeID &ID) const |
Used to insert APSInt objects, or objects that contain APSInt objects, into FoldingSets. | |
LLVM_ABI 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. | |
![]() | |
APInt (unsigned numBits, uint64_t val, bool isSigned=false, bool implicitTrunc=false) | |
Create a new APInt of numBits width, initialized as val. | |
LLVM_ABI | APInt (unsigned numBits, ArrayRef< uint64_t > bigVal) |
Construct an APInt of numBits width, initialized as bigVal[]. | |
LLVM_ABI | 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. | |
LLVM_ABI | 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. | |
APInt | operator++ (int) |
Postfix increment operator. | |
LLVM_ABI APInt & | operator++ () |
Prefix increment operator. | |
APInt | operator-- (int) |
Postfix decrement operator. | |
LLVM_ABI APInt & | operator-- () |
Prefix decrement operator. | |
bool | operator! () const |
Logical negation operation on this APInt returns true if zero, like normal integers. | |
APInt & | operator= (const APInt &RHS) |
Copy assignment operator. | |
APInt & | operator= (APInt &&that) |
Move assignment operator. | |
APInt & | operator= (uint64_t RHS) |
Assignment operator. | |
APInt & | operator&= (const APInt &RHS) |
Bitwise AND assignment operator. | |
APInt & | operator&= (uint64_t RHS) |
Bitwise AND assignment operator. | |
APInt & | operator|= (const APInt &RHS) |
Bitwise OR assignment operator. | |
APInt & | operator|= (uint64_t RHS) |
Bitwise OR assignment operator. | |
APInt & | operator^= (const APInt &RHS) |
Bitwise XOR assignment operator. | |
APInt & | operator^= (uint64_t RHS) |
Bitwise XOR assignment operator. | |
LLVM_ABI APInt & | operator*= (const APInt &RHS) |
Multiplication assignment operator. | |
LLVM_ABI APInt & | operator*= (uint64_t RHS) |
LLVM_ABI APInt & | operator+= (const APInt &RHS) |
Addition assignment operator. | |
LLVM_ABI APInt & | operator+= (uint64_t RHS) |
LLVM_ABI APInt & | operator-= (const APInt &RHS) |
Subtraction assignment operator. | |
LLVM_ABI APInt & | operator-= (uint64_t RHS) |
APInt & | operator<<= (unsigned ShiftAmt) |
Left-shift assignment function. | |
LLVM_ABI APInt & | operator<<= (const APInt &ShiftAmt) |
Left-shift assignment function. | |
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. | |
LLVM_ABI APInt | trunc (unsigned width) const |
Truncate to new width. | |
LLVM_ABI APInt | truncUSat (unsigned width) const |
Truncate to new width with unsigned saturation. | |
LLVM_ABI APInt | truncSSat (unsigned width) const |
Truncate to new width with signed saturation. | |
LLVM_ABI APInt | sext (unsigned width) const |
Sign extend to a new width. | |
LLVM_ABI APInt | zext (unsigned width) const |
Zero extend to a new width. | |
LLVM_ABI APInt | sextOrTrunc (unsigned width) const |
Sign extend or truncate to width. | |
LLVM_ABI APInt | zextOrTrunc (unsigned width) const |
Zero extend or truncate to width. | |
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 | clearBits (unsigned LoBit, unsigned HiBit) |
Clear the bits from LoBit (inclusive) to HiBit (exclusive) to 0. | |
void | clearLowBits (unsigned loBits) |
Set bottom loBits bits to 0. | |
void | clearHighBits (unsigned hiBits) |
Set top hiBits bits to 0. | |
void | clearSignBit () |
Set the sign bit to 0. | |
void | flipAllBits () |
Toggle every bit to its opposite value. | |
LLVM_ABI void | flipBit (unsigned bitPosition) |
Toggles a given bit to its opposite value. | |
void | negate () |
Negate this APInt in place. | |
LLVM_ABI void | insertBits (const APInt &SubBits, unsigned bitPosition) |
Insert the bits from a smaller APInt starting at bitPosition. | |
LLVM_ABI void | insertBits (uint64_t SubBits, unsigned bitPosition, unsigned numBits) |
LLVM_ABI APInt | extractBits (unsigned numBits, unsigned bitPosition) const |
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits). | |
LLVM_ABI uint64_t | extractBitsAsZExtValue (unsigned numBits, unsigned bitPosition) const |
unsigned | logBase2 () const |
unsigned | ceilLogBase2 () const |
LLVM_ABI unsigned | nearestLogBase2 () const |
int32_t | exactLogBase2 () const |
LLVM_ABI APInt | sqrt () const |
Compute the square root. | |
APInt | abs () const |
Get the absolute value. | |
LLVM_ABI APInt | multiplicativeInverse () const |
LLVM_ABI void | Profile (FoldingSetNodeID &id) const |
Used to insert APInt objects, or objects that contain APInt objects, into FoldingSets. | |
LLVM_DUMP_METHOD void | dump () const |
debug method | |
bool | needsCleanup () const |
Returns whether this instance allocated memory. | |
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. | |
LLVM_ABI 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. | |
LLVM_ABI 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. | |
LLVM_ABI APInt | getHiBits (unsigned numBits) const |
Compute an APInt containing numBits highbits from this APInt. | |
LLVM_ABI APInt | getLoBits (unsigned numBits) const |
Compute an APInt containing numBits lowbits from this APInt. | |
const uint64_t * | getRawData () const |
This function returns a pointer to the internal storage of the APInt. | |
LLVM_ABI 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 | |
LLVM_ABI APInt | rotl (unsigned rotateAmt) const |
Rotate left by rotateAmt. | |
LLVM_ABI APInt | rotr (unsigned rotateAmt) const |
Rotate right by rotateAmt. | |
APInt | ashr (const APInt &ShiftAmt) const |
Arithmetic right-shift function. | |
LLVM_ABI void | ashrInPlace (const APInt &shiftAmt) |
Arithmetic right-shift this APInt by shiftAmt in place. | |
APInt | lshr (const APInt &ShiftAmt) const |
Logical right-shift function. | |
LLVM_ABI void | lshrInPlace (const APInt &ShiftAmt) |
Logical right-shift this APInt by ShiftAmt in place. | |
APInt | shl (const APInt &ShiftAmt) const |
Left-shift function. | |
LLVM_ABI APInt | rotl (const APInt &rotateAmt) const |
Rotate left by rotateAmt. | |
LLVM_ABI 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. | |
LLVM_ABI APInt | udiv (const APInt &RHS) const |
Unsigned division operation. | |
LLVM_ABI APInt | udiv (uint64_t RHS) const |
LLVM_ABI APInt | sdiv (const APInt &RHS) const |
Signed division function for APInt. | |
LLVM_ABI APInt | sdiv (int64_t RHS) const |
LLVM_ABI APInt | urem (const APInt &RHS) const |
Unsigned remainder operation. | |
LLVM_ABI uint64_t | urem (uint64_t RHS) const |
LLVM_ABI APInt | srem (const APInt &RHS) const |
Function for signed remainder operation. | |
LLVM_ABI int64_t | srem (int64_t RHS) const |
LLVM_ABI APInt | sadd_ov (const APInt &RHS, bool &Overflow) const |
LLVM_ABI APInt | uadd_ov (const APInt &RHS, bool &Overflow) const |
LLVM_ABI APInt | ssub_ov (const APInt &RHS, bool &Overflow) const |
LLVM_ABI APInt | usub_ov (const APInt &RHS, bool &Overflow) const |
LLVM_ABI APInt | sdiv_ov (const APInt &RHS, bool &Overflow) const |
LLVM_ABI APInt | smul_ov (const APInt &RHS, bool &Overflow) const |
LLVM_ABI APInt | umul_ov (const APInt &RHS, bool &Overflow) const |
LLVM_ABI APInt | sshl_ov (const APInt &Amt, bool &Overflow) const |
LLVM_ABI APInt | sshl_ov (unsigned Amt, bool &Overflow) const |
LLVM_ABI APInt | ushl_ov (const APInt &Amt, bool &Overflow) const |
LLVM_ABI APInt | ushl_ov (unsigned Amt, bool &Overflow) const |
LLVM_ABI APInt | sfloordiv_ov (const APInt &RHS, bool &Overflow) const |
Signed integer floor division operation. | |
LLVM_ABI APInt | sadd_sat (const APInt &RHS) const |
LLVM_ABI APInt | uadd_sat (const APInt &RHS) const |
LLVM_ABI APInt | ssub_sat (const APInt &RHS) const |
LLVM_ABI APInt | usub_sat (const APInt &RHS) const |
LLVM_ABI APInt | smul_sat (const APInt &RHS) const |
LLVM_ABI APInt | umul_sat (const APInt &RHS) const |
LLVM_ABI APInt | sshl_sat (const APInt &RHS) const |
LLVM_ABI APInt | sshl_sat (unsigned RHS) const |
LLVM_ABI APInt | ushl_sat (const APInt &RHS) const |
LLVM_ABI APInt | ushl_sat (unsigned RHS) const |
bool | operator[] (unsigned bitPosition) const |
Array-indexing support. | |
unsigned | getBitWidth () const |
Return the number of bits in the APInt. | |
unsigned | getNumWords () const |
Get the number of words. | |
unsigned | getActiveBits () const |
Compute the number of active bits in the value. | |
unsigned | getActiveWords () const |
Compute the number of active words in the value of this APInt. | |
unsigned | getSignificantBits () const |
Get the minimum bit size for this signed APInt. | |
uint64_t | getZExtValue () const |
Get zero extended value. | |
std::optional< uint64_t > | tryZExtValue () const |
Get zero extended value if possible. | |
int64_t | getSExtValue () const |
Get sign extended value. | |
std::optional< int64_t > | trySExtValue () const |
Get sign extended value if possible. | |
unsigned | countl_zero () const |
The APInt version of std::countl_zero. | |
unsigned | countLeadingZeros () const |
unsigned | countl_one () const |
Count the number of leading one bits. | |
unsigned | countLeadingOnes () const |
unsigned | getNumSignBits () const |
Computes the number of leading bits of this APInt that are equal to its sign bit. | |
unsigned | countr_zero () const |
Count the number of trailing zero bits. | |
unsigned | countTrailingZeros () const |
unsigned | countr_one () const |
Count the number of trailing one bits. | |
unsigned | countTrailingOnes () const |
unsigned | popcount () const |
Count the number of bits set. | |
LLVM_ABI void | print (raw_ostream &OS, bool isSigned) const |
LLVM_ABI 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. | |
LLVM_ABI APInt | byteSwap () const |
LLVM_ABI APInt | reverseBits () const |
LLVM_ABI 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 Public Member Functions | |
static APSInt | getMaxValue (uint32_t numBits, bool Unsigned) |
Return the APSInt representing the maximum integer value with the given bit width and signedness. | |
static APSInt | getMinValue (uint32_t numBits, bool Unsigned) |
Return the APSInt representing the minimum integer value with the given bit width and signedness. | |
static bool | isSameValue (const APSInt &I1, const APSInt &I2) |
Determine if two APSInts have the same value, zero- or sign-extending as needed. | |
static int | compareValues (const APSInt &I1, const APSInt &I2) |
Compare underlying values of two numbers. | |
static APSInt | get (int64_t X) |
static APSInt | getUnsigned (uint64_t X) |
![]() | |
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 LLVM_ABI APInt | getSplat (unsigned NewLen, const APInt &V) |
Return a value containing V broadcasted over NewLen bits. | |
static LLVM_ABI void | tcSet (WordType *, WordType, unsigned) |
Sets the least significant part of a bignum to the input value, and zeroes out higher parts. | |
static LLVM_ABI void | tcAssign (WordType *, const WordType *, unsigned) |
Assign one bignum to another. | |
static LLVM_ABI bool | tcIsZero (const WordType *, unsigned) |
Returns true if a bignum is zero, false otherwise. | |
static LLVM_ABI int | tcExtractBit (const WordType *, unsigned bit) |
Extract the given bit of a bignum; returns 0 or 1. Zero-based. | |
static LLVM_ABI 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 LLVM_ABI void | tcSetBit (WordType *, unsigned bit) |
Set the given bit of a bignum. Zero-based. | |
static LLVM_ABI void | tcClearBit (WordType *, unsigned bit) |
Clear the given bit of a bignum. Zero-based. | |
static LLVM_ABI unsigned | tcLSB (const WordType *, unsigned n) |
Returns the bit number of the least or most significant set bit of a number. | |
static LLVM_ABI unsigned | tcMSB (const WordType *parts, unsigned n) |
Returns the bit number of the most significant set bit of a number. | |
static LLVM_ABI void | tcNegate (WordType *, unsigned) |
Negate a bignum in-place. | |
static LLVM_ABI WordType | tcAdd (WordType *, const WordType *, WordType carry, unsigned) |
DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag. | |
static LLVM_ABI WordType | tcAddPart (WordType *, WordType, unsigned) |
DST += RHS. Returns the carry flag. | |
static LLVM_ABI WordType | tcSubtract (WordType *, const WordType *, WordType carry, unsigned) |
DST -= RHS + CARRY where CARRY is zero or one. Returns the carry flag. | |
static LLVM_ABI WordType | tcSubtractPart (WordType *, WordType, unsigned) |
DST -= RHS. Returns the carry flag. | |
static LLVM_ABI 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 LLVM_ABI 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 LLVM_ABI 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 LLVM_ABI 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 LLVM_ABI void | tcShiftLeft (WordType *, unsigned Words, unsigned Count) |
Shift a bignum left Count bits. | |
static LLVM_ABI void | tcShiftRight (WordType *, unsigned Words, unsigned Count) |
Shift a bignum right Count bits. | |
static LLVM_ABI 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. | |
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. | |
static LLVM_ABI void | udivrem (const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder) |
Dual division/remainder interface. | |
static LLVM_ABI void | udivrem (const APInt &LHS, uint64_t RHS, APInt &Quotient, uint64_t &Remainder) |
static LLVM_ABI void | sdivrem (const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder) |
static LLVM_ABI void | sdivrem (const APInt &LHS, int64_t RHS, APInt &Quotient, int64_t &Remainder) |
static unsigned | getNumWords (unsigned BitWidth) |
Get the number of words. | |
static LLVM_ABI unsigned | getBitsNeeded (StringRef str, uint8_t radix) |
Get bits required for string value. | |
static LLVM_ABI unsigned | getSufficientBitsNeeded (StringRef Str, uint8_t Radix) |
Get the bits that are sufficient to represent the string value. | |
static APInt | doubleToBits (double V) |
Converts a double to APInt bits. | |
static APInt | floatToBits (float V) |
Converts a float to APInt bits. | |
Additional Inherited Members | |
![]() | |
enum class | Rounding { DOWN , TOWARD_ZERO , UP } |
typedef uint64_t | WordType |
![]() | |
static constexpr unsigned | APINT_WORD_SIZE = sizeof(WordType) |
Byte size of a word. | |
static constexpr unsigned | APINT_BITS_PER_WORD = APINT_WORD_SIZE * CHAR_BIT |
Bits in a word. | |
static constexpr WordType | WORDTYPE_MAX = ~WordType(0) |
|
explicitdefault |
Definition at line 35 of file APSInt.h.
References llvm::move().
|
explicit |
Construct an APSInt from a string representation.
This constructor interprets the string Str
using the radix of 10. The interpretation stops at the end of the string. The bit width of the constructed APSInt is determined automatically.
Str | the string to be interpreted. |
Definition at line 21 of file APSInt.cpp.
References APSInt(), assert(), llvm::APInt::getActiveBits(), llvm::APInt::getSignificantBits(), and llvm::APInt::trunc().
Compare underlying values of two numbers.
Definition at line 325 of file APSInt.h.
References assert(), extend(), llvm::APInt::getBitWidth(), isNegative(), and isSigned().
Definition at line 113 of file APSInt.h.
Referenced by compareValues(), llvm::APFixedPoint::convert(), llvm::APFixedPoint::convertToInt(), and llvm::APFixedPoint::getIntPart().
Definition at line 120 of file APSInt.h.
Referenced by llvm::APFixedPoint::compare(), llvm::APFixedPoint::convert(), llvm::APFixedPoint::div(), llvm::APFixedPoint::mul(), and llvm::APFixedPoint::shl().
|
inlinestatic |
Definition at line 350 of file APSInt.h.
References X.
Referenced by llvm::APFixedPoint::toString().
|
inline |
Get the correctly-extended int64_t
value.
Definition at line 99 of file APSInt.h.
References assert(), and isSigned().
Return the APSInt representing the maximum integer value with the given bit width and signedness.
Definition at line 304 of file APSInt.h.
References Unsigned.
Referenced by llvm::APFixedPoint::convertToInt(), llvm::APFixedPoint::getMax(), and llvm::InstCombinerImpl::visitCallInst().
Return the APSInt representing the minimum integer value with the given bit width and signedness.
Definition at line 312 of file APSInt.h.
References Unsigned.
Referenced by llvm::APFixedPoint::convertToInt(), llvm::APFixedPoint::getMin(), and llvm::InstCombinerImpl::visitCallInst().
|
inline |
Determine sign of this APSInt.
Definition at line 50 of file APSInt.h.
References isSigned().
Referenced by compareValues(), llvm::APFixedPoint::convert(), llvm::APFixedPoint::div(), and llvm::APFixedPoint::toString().
|
inline |
|
inline |
If this int is representable using an int64_t.
Definition at line 90 of file APSInt.h.
References llvm::isIntN(), and isSigned().
Determine if two APSInts have the same value, zero- or sign-extending as needed.
Definition at line 320 of file APSInt.h.
Referenced by llvm::ConstantFoldExtractElementInstruction().
|
inline |
Definition at line 78 of file APSInt.h.
Referenced by llvm::APFixedPoint::add(), llvm::APFixedPoint::compare(), compareValues(), llvm::APFixedPoint::convert(), llvm::APFloat::convertToInteger(), llvm::FixedPointSemantics::fitsInFloatSemantics(), llvm::LLParser::parseMDField(), llvm::APFixedPoint::sub(), and llvm::APFixedPoint::toString().
|
inline |
|
inline |
Definition at line 79 of file APSInt.h.
Referenced by llvm::APFixedPoint::getIntPart().
|
inline |
|
inline |
Definition at line 192 of file APSInt.h.
References llvm::get(), and RHS.
|
inline |
Definition at line 201 of file APSInt.h.
References llvm::get(), and RHS.
|
inline |
Definition at line 195 of file APSInt.h.
References llvm::get(), and RHS.
|
inline |
Definition at line 189 of file APSInt.h.
References llvm::get(), and RHS.
|
inline |
Definition at line 204 of file APSInt.h.
References llvm::get(), and RHS.
|
inline |
Definition at line 198 of file APSInt.h.
References llvm::get(), and RHS.
void APSInt::Profile | ( | FoldingSetNodeID & | ID | ) | const |
Used to insert APSInt objects, or objects that contain APSInt objects, into FoldingSets.
Definition at line 40 of file APSInt.cpp.
References llvm::APInt::Profile().
Definition at line 218 of file APSInt.h.
Referenced by llvm::APFixedPoint::convert(), and llvm::APFixedPoint::getIntPart().
|
inline |
Definition at line 81 of file APSInt.h.
Referenced by llvm::APFixedPoint::convert().
|
inline |
Definition at line 80 of file APSInt.h.
Referenced by llvm::APFixedPoint::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 1684 of file APInt.cpp.
References RHS.
|
inline |
Append this APSInt to the specified SmallString.
Definition at line 84 of file APSInt.h.
References isSigned().
|
inline |