class APSInt
Declaration
class APSInt : public APInt { /* full declaration omitted */ };
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: * All bit, byte, and word positions are zero-based. * Once the bit width is set, it doesn't change except by the Truncate, SignExtend, or ZeroExtend operations. * All binary operators must be on APInt instances of the same bit width. Attempting to use these operators on instances with different bit widths will yield an assertion. * The value is stored canonically as an unsigned value. For operations where it makes a difference, there are both signed and unsigned variants of the operation. For example, sdiv and udiv. However, because the bit widths must be the same, operations such as Mul and Add produce the same results regardless of whether the values are interpreted as signed or not. * In general, the class tries to follow the style of computation that LLVM uses in its IR. This simplifies its use for LLVM.
Declared at: llvm/include/llvm/ADT/APSInt.h:21
Inherits from: APInt
Member Variables
Inherited from APInt:
- public static WORDTYPE_MAX = ~unsigned long(0)
Method Overview
- public APSInt(uint32_t BitWidth, bool isUnsigned = true)
- public APSInt(llvm::APInt I, bool isUnsigned = true)
- public APSInt(llvm::StringRef Str)
- public APSInt()
- public void Profile(llvm::FoldingSetNodeID & ID) const
- public static int compareValues(const llvm::APSInt & I1, const llvm::APSInt & I2)
- public llvm::APSInt extOrTrunc(uint32_t width) const
- public llvm::APSInt extend(uint32_t width) const
- public static llvm::APSInt get(int64_t X)
- public int64_t getExtValue() const
- public static llvm::APSInt getMaxValue(uint32_t numBits, bool Unsigned)
- public static llvm::APSInt getMinValue(uint32_t numBits, bool Unsigned)
- public static llvm::APSInt getUnsigned(uint64_t X)
- public bool isNegative() const
- public bool isNonNegative() const
- public static bool isSameValue(const llvm::APSInt & I1, const llvm::APSInt & I2)
- public bool isSigned() const
- public bool isStrictlyPositive() const
- public bool isUnsigned() const
- public void setIsSigned(bool Val)
- public void setIsUnsigned(bool Val)
- public std::string toString(unsigned int Radix) const
- public void toString(SmallVectorImpl<char> & Str, unsigned int Radix = 10) const
- public llvm::APSInt trunc(uint32_t width) const
Inherited from APInt:
- public Profile
- public abs
- public ashr
- public ashr
- public ashrInPlace
- public ashrInPlace
- public bitsToDouble
- public bitsToFloat
- public byteSwap
- public ceilLogBase2
- public clearAllBits
- public clearBit
- public clearLowBits
- public clearSignBit
- public countLeadingOnes
- public countLeadingZeros
- public countPopulation
- public countTrailingOnes
- public countTrailingZeros
- public doubleToBits
- public dump
- public eq
- public exactLogBase2
- public extractBits
- public extractBitsAsZExtValue
- public flipAllBits
- public flipBit
- public floatToBits
- public getActiveBits
- public getActiveWords
- public getAllOnesValue
- public getBitWidth
- public getBitsNeeded
- public getBitsSet
- public getBitsSetFrom
- public getBitsSetWithWrap
- public getBoolValue
- public getHiBits
- public getHighBitsSet
- public getLimitedValue
- public getLoBits
- public getLowBitsSet
- public getMaxValue
- public getMinSignedBits
- public getMinValue
- public getNullValue
- public getNumSignBits
- public getNumWords
- public getNumWords
- public getOneBitSet
- public getRawData
- public getSExtValue
- public getSignMask
- public getSignedMaxValue
- public getSignedMinValue
- public getSplat
- public getZExtValue
- public insertBits
- public insertBits
- public intersects
- public isAllOnesValue
- public isIntN
- public isMask
- public isMask
- public isMaxSignedValue
- public isMaxValue
- public isMinSignedValue
- public isMinValue
- public isNegative
- public isNonNegative
- public isNonPositive
- public isNullValue
- public isOneValue
- public isPowerOf2
- public isSameValue
- public isShiftedMask
- public isSignBitClear
- public isSignBitSet
- public isSignMask
- public isSignedIntN
- public isSplat
- public isStrictlyPositive
- public isSubsetOf
- public logBase2
- public lshr
- public lshr
- public lshrInPlace
- public lshrInPlace
- public magic
- public magicu
- public multiplicativeInverse
- public ne
- public nearestLogBase2
- public needsCleanup
- public negate
- public print
- public reverseBits
- public rotl
- public rotl
- public rotr
- public rotr
- public roundToDouble
- public roundToDouble
- public sadd_ov
- public sadd_sat
- public sdiv
- public sdiv
- public sdiv_ov
- public sdivrem
- public sdivrem
- public setAllBits
- public setBit
- public setBits
- public setBitsFrom
- public setBitsWithWrap
- public setHighBits
- public setLowBits
- public setSignBit
- public sext
- public sextOrSelf
- public sextOrTrunc
- public sge
- public sge
- public sgt
- public sgt
- public shl
- public shl
- public signedRoundToDouble
- public sle
- public sle
- public slt
- public slt
- public smul_ov
- public smul_sat
- public sqrt
- public srem
- public srem
- public sshl_ov
- public sshl_sat
- public ssub_ov
- public ssub_sat
- public tcAdd
- public tcAddPart
- public tcAnd
- public tcAssign
- public tcClearBit
- public tcCompare
- public tcComplement
- public tcDecrement
- public tcDivide
- public tcExtract
- public tcExtractBit
- public tcFullMultiply
- public tcIncrement
- public tcIsZero
- public tcLSB
- public tcMSB
- public tcMultiply
- public tcMultiplyPart
- public tcNegate
- public tcOr
- public tcSet
- public tcSetBit
- public tcSetLeastSignificantBits
- public tcShiftLeft
- public tcShiftRight
- public tcSubtract
- public tcSubtractPart
- public tcXor
- public toString
- public toString
- public toStringSigned
- public toStringUnsigned
- public trunc
- public truncSSat
- public truncUSat
- public uadd_ov
- public uadd_sat
- public udiv
- public udiv
- public udivrem
- public udivrem
- public uge
- public uge
- public ugt
- public ugt
- public ule
- public ule
- public ult
- public ult
- public umul_ov
- public umul_sat
- public urem
- public urem
- public ushl_ov
- public ushl_sat
- public usub_ov
- public usub_sat
- public zext
- public zextOrSelf
- public zextOrTrunc
Methods
¶APSInt(uint32_t BitWidth, bool isUnsigned = true)
APSInt(uint32_t BitWidth, bool isUnsigned = true)
Description
APSInt ctor - Create an APSInt with the specified width, default to unsigned.
Declared at: llvm/include/llvm/ADT/APSInt.h:30
Parameters
- uint32_t BitWidth
- bool isUnsigned = true
¶APSInt(llvm::APInt I, bool isUnsigned = true)
APSInt(llvm::APInt I, bool isUnsigned = true)
Declared at: llvm/include/llvm/ADT/APSInt.h:33
Parameters
- llvm::APInt I
- bool isUnsigned = true
¶APSInt(llvm::StringRef Str)
APSInt(llvm::StringRef Str)
Description
Construct an APSInt from a string representation. This constructor interprets the string \p 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.
Declared at: llvm/include/llvm/ADT/APSInt.h:43
Parameters
- llvm::StringRef Str
- the string to be interpreted.
¶APSInt()
APSInt()
Description
Default constructor that creates an uninitialized APInt.
Declared at: llvm/include/llvm/ADT/APSInt.h:26
¶void Profile(llvm::FoldingSetNodeID& ID) const
void Profile(llvm::FoldingSetNodeID& ID) const
Description
Profile - Used to insert APSInt objects, or objects that contain APSInt objects, into FoldingSets.
Declared at: llvm/include/llvm/ADT/APSInt.h:336
Parameters
¶static int compareValues(const llvm::APSInt& I1,
const llvm::APSInt& I2)
static int compareValues(const llvm::APSInt& I1,
const llvm::APSInt& I2)
Description
Compare underlying values of two numbers.
Declared at: llvm/include/llvm/ADT/APSInt.h:306
Parameters
- const llvm::APSInt& I1
- const llvm::APSInt& I2
¶llvm::APSInt extOrTrunc(uint32_t width) const
llvm::APSInt extOrTrunc(uint32_t width) const
Declared at: llvm/include/llvm/ADT/APSInt.h:109
Parameters
- uint32_t width
¶llvm::APSInt extend(uint32_t width) const
llvm::APSInt extend(uint32_t width) const
Declared at: llvm/include/llvm/ADT/APSInt.h:102
Parameters
- uint32_t width
¶static llvm::APSInt get(int64_t X)
static llvm::APSInt get(int64_t X)
Declared at: llvm/include/llvm/ADT/APSInt.h:331
Parameters
- int64_t X
¶int64_t getExtValue() const
int64_t getExtValue() const
Description
Get the correctly-extended \c int64_t value.
Declared at: llvm/include/llvm/ADT/APSInt.h:93
¶static llvm::APSInt getMaxValue(uint32_t numBits,
bool Unsigned)
static llvm::APSInt getMaxValue(uint32_t numBits,
bool Unsigned)
Description
getMaxValue - Return the APSInt representing the maximum integer value with the given bit width and signedness.
Declared at: llvm/include/llvm/ADT/APSInt.h:287
Parameters
- uint32_t numBits
- bool Unsigned
¶static llvm::APSInt getMinValue(uint32_t numBits,
bool Unsigned)
static llvm::APSInt getMinValue(uint32_t numBits,
bool Unsigned)
Description
getMinValue - Return the APSInt representing the minimum integer value with the given bit width and signedness.
Declared at: llvm/include/llvm/ADT/APSInt.h:294
Parameters
- uint32_t numBits
- bool Unsigned
¶static llvm::APSInt getUnsigned(uint64_t X)
static llvm::APSInt getUnsigned(uint64_t X)
Declared at: llvm/include/llvm/ADT/APSInt.h:332
Parameters
- uint64_t X
¶bool isNegative() const
bool isNegative() const
Description
Determine sign of this APSInt.
Declared at: llvm/include/llvm/ADT/APSInt.h:48
Returns
true if this APSInt is negative, false otherwise
¶bool isNonNegative() const
bool isNonNegative() const
Description
Determine if this APSInt Value is non-negative (>= 0)
Declared at: llvm/include/llvm/ADT/APSInt.h:53
Returns
true if this APSInt is non-negative, false otherwise
¶static bool isSameValue(const llvm::APSInt& I1,
const llvm::APSInt& I2)
static bool isSameValue(const llvm::APSInt& I1,
const llvm::APSInt& I2)
Description
Determine if two APSInts have the same value, zero- or sign-extending as needed.
Declared at: llvm/include/llvm/ADT/APSInt.h:301
Parameters
- const llvm::APSInt& I1
- const llvm::APSInt& I2
¶bool isSigned() const
bool isSigned() const
Declared at: llvm/include/llvm/ADT/APSInt.h:76
¶bool isStrictlyPositive() const
bool isStrictlyPositive() const
Description
Determine if this APSInt Value is positive. This tests if the value of this APSInt is positive (> 0). Note that 0 is not a positive value.
Declared at: llvm/include/llvm/ADT/APSInt.h:61
Returns
true if this APSInt is positive.
¶bool isUnsigned() const
bool isUnsigned() const
Declared at: llvm/include/llvm/ADT/APSInt.h:77
¶void setIsSigned(bool Val)
void setIsSigned(bool Val)
Declared at: llvm/include/llvm/ADT/APSInt.h:79
Parameters
- bool Val
¶void setIsUnsigned(bool Val)
void setIsUnsigned(bool Val)
Declared at: llvm/include/llvm/ADT/APSInt.h:78
Parameters
- bool Val
¶std::string toString(unsigned int Radix) const
std::string toString(unsigned int Radix) const
Description
toString - Converts an APInt to a std::string. This is an inefficient method; you should prefer passing in a SmallString instead.
Declared at: llvm/include/llvm/ADT/APSInt.h:87
Parameters
- unsigned int Radix
¶void toString(SmallVectorImpl<char>& Str,
unsigned int Radix = 10) const
void toString(SmallVectorImpl<char>& Str,
unsigned int Radix = 10) const
Description
toString - Append this APSInt to the specified SmallString.
Declared at: llvm/include/llvm/ADT/APSInt.h:82
Parameters
- SmallVectorImpl<char>& Str
- unsigned int Radix = 10
¶llvm::APSInt trunc(uint32_t width) const
llvm::APSInt trunc(uint32_t width) const
Declared at: llvm/include/llvm/ADT/APSInt.h:98
Parameters
- uint32_t width