|
LLVM
10.0.0
|
Class for arbitrary precision integers. More...
#include "llvm/ADT/APInt.h"
Classes | |
| struct | ms |
| Magic data for optimising signed division by a constant. More... | |
| struct | mu |
| Magic data for optimising unsigned division by a constant. More... | |
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 | Rounding { Rounding::DOWN, Rounding::TOWARD_ZERO, Rounding::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. More... | |
| APInt (unsigned numBits, ArrayRef< uint64_t > bigVal) | |
| Construct an APInt of numBits width, initialized as bigVal[]. More... | |
| 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. More... | |
| APInt (unsigned numBits, StringRef str, uint8_t radix) | |
| Construct an APInt from a string representation. More... | |
| APInt (const APInt &that) | |
| Simply makes *this a copy of that. More... | |
| APInt (APInt &&that) | |
| Move Constructor. More... | |
| ~APInt () | |
| Destructor. More... | |
| APInt () | |
| Default constructor that creates an uninteresting APInt representing a 1-bit zero value. More... | |
| bool | needsCleanup () const |
| Returns whether this instance allocated memory. More... | |
| void | Profile (FoldingSetNodeID &id) const |
| Used to insert APInt objects, or objects that contain APInt objects, into FoldingSets. More... | |
Value Tests | |
| bool | isNegative () const |
| Determine sign of this APInt. More... | |
| bool | isNonNegative () const |
| Determine if this APInt Value is non-negative (>= 0) More... | |
| bool | isSignBitSet () const |
| Determine if sign bit of this APInt is set. More... | |
| bool | isSignBitClear () const |
| Determine if sign bit of this APInt is clear. More... | |
| bool | isStrictlyPositive () const |
| Determine if this APInt Value is positive. More... | |
| bool | isNonPositive () const |
| Determine if this APInt Value is non-positive (<= 0). More... | |
| bool | isAllOnesValue () const |
| Determine if all bits are set. More... | |
| bool | isNullValue () const |
| Determine if all bits are clear. More... | |
| bool | isOneValue () const |
| Determine if this is a value of 1. More... | |
| bool | isMaxValue () const |
| Determine if this is the largest unsigned value. More... | |
| bool | isMaxSignedValue () const |
| Determine if this is the largest signed value. More... | |
| bool | isMinValue () const |
| Determine if this is the smallest unsigned value. More... | |
| bool | isMinSignedValue () const |
| Determine if this is the smallest signed value. More... | |
| bool | isIntN (unsigned N) const |
| Check if this APInt has an N-bits unsigned integer value. More... | |
| bool | isSignedIntN (unsigned N) const |
| Check if this APInt has an N-bits signed integer value. More... | |
| bool | isPowerOf2 () const |
| Check if this APInt's value is a power of two greater than zero. More... | |
| bool | isSignMask () const |
| Check if the APInt's value is returned by getSignMask. More... | |
| bool | getBoolValue () const |
| Convert APInt to a boolean value. More... | |
| 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. More... | |
| bool | isSplat (unsigned SplatSizeInBits) const |
| Check if the APInt consists of a repeated bit pattern. More... | |
| bool | isMask (unsigned numBits) const |
| bool | isMask () const |
| bool | isShiftedMask () const |
| Return true if this APInt value contains a sequence of ones with the remainder zero. More... | |
Unary Operators | |
| const APInt | operator++ (int) |
| Postfix increment operator. More... | |
| APInt & | operator++ () |
| Prefix increment operator. More... | |
| const APInt | operator-- (int) |
| Postfix decrement operator. More... | |
| APInt & | operator-- () |
| Prefix decrement operator. More... | |
| bool | operator! () const |
| Logical negation operator. More... | |
Assignment Operators | |
| APInt & | operator= (const APInt &RHS) |
| Copy assignment operator. More... | |
| APInt & | operator= (APInt &&that) |
| Move assignment operator. More... | |
| APInt & | operator= (uint64_t RHS) |
| Assignment operator. More... | |
| APInt & | operator &= (const APInt &RHS) |
| Bitwise AND assignment operator. More... | |
| APInt & | operator &= (uint64_t RHS) |
| Bitwise AND assignment operator. More... | |
| APInt & | operator|= (const APInt &RHS) |
| Bitwise OR assignment operator. More... | |
| APInt & | operator|= (uint64_t RHS) |
| Bitwise OR assignment operator. More... | |
| APInt & | operator^= (const APInt &RHS) |
| Bitwise XOR assignment operator. More... | |
| APInt & | operator^= (uint64_t RHS) |
| Bitwise XOR assignment operator. More... | |
| APInt & | operator*= (const APInt &RHS) |
| Multiplication assignment operator. More... | |
| APInt & | operator*= (uint64_t RHS) |
| APInt & | operator+= (const APInt &RHS) |
| Addition assignment operator. More... | |
| APInt & | operator+= (uint64_t RHS) |
| APInt & | operator-= (const APInt &RHS) |
| Subtraction assignment operator. More... | |
| APInt & | operator-= (uint64_t RHS) |
| APInt & | operator<<= (unsigned ShiftAmt) |
| Left-shift assignment function. More... | |
| APInt & | operator<<= (const APInt &ShiftAmt) |
| Left-shift assignment function. More... | |
Comparison Operators | |
| bool | operator== (const APInt &RHS) const |
| Equality operator. More... | |
| bool | operator== (uint64_t Val) const |
| Equality operator. More... | |
| bool | eq (const APInt &RHS) const |
| Equality comparison. More... | |
| bool | operator!= (const APInt &RHS) const |
| Inequality operator. More... | |
| bool | operator!= (uint64_t Val) const |
| Inequality operator. More... | |
| bool | ne (const APInt &RHS) const |
| Inequality comparison. More... | |
| bool | ult (const APInt &RHS) const |
| Unsigned less than comparison. More... | |
| bool | ult (uint64_t RHS) const |
| Unsigned less than comparison. More... | |
| bool | slt (const APInt &RHS) const |
| Signed less than comparison. More... | |
| bool | slt (int64_t RHS) const |
| Signed less than comparison. More... | |
| bool | ule (const APInt &RHS) const |
| Unsigned less or equal comparison. More... | |
| bool | ule (uint64_t RHS) const |
| Unsigned less or equal comparison. More... | |
| bool | sle (const APInt &RHS) const |
| Signed less or equal comparison. More... | |
| bool | sle (uint64_t RHS) const |
| Signed less or equal comparison. More... | |
| bool | ugt (const APInt &RHS) const |
| Unsigned greater than comparison. More... | |
| bool | ugt (uint64_t RHS) const |
| Unsigned greater than comparison. More... | |
| bool | sgt (const APInt &RHS) const |
| Signed greater than comparison. More... | |
| bool | sgt (int64_t RHS) const |
| Signed greater than comparison. More... | |
| bool | uge (const APInt &RHS) const |
| Unsigned greater or equal comparison. More... | |
| bool | uge (uint64_t RHS) const |
| Unsigned greater or equal comparison. More... | |
| bool | sge (const APInt &RHS) const |
| Signed greater or equal comparison. More... | |
| bool | sge (int64_t RHS) const |
| Signed greater or equal comparison. More... | |
| 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. More... | |
| bool | isSubsetOf (const APInt &RHS) const |
| This operation checks that all bits set in this APInt are also set in RHS. More... | |
Resizing Operators | |
| APInt | trunc (unsigned width) const |
| Truncate to new width. More... | |
| APInt | truncUSat (unsigned width) const |
| Truncate to new width with unsigned saturation. More... | |
| APInt | truncSSat (unsigned width) const |
| Truncate to new width with signed saturation. More... | |
| APInt | sext (unsigned width) const |
| Sign extend to a new width. More... | |
| APInt | zext (unsigned width) const |
| Zero extend to a new width. More... | |
| APInt | sextOrTrunc (unsigned width) const |
| Sign extend or truncate to width. More... | |
| APInt | zextOrTrunc (unsigned width) const |
| Zero extend or truncate to width. More... | |
| APInt | sextOrSelf (unsigned width) const |
| Sign extend or truncate to width. More... | |
| APInt | zextOrSelf (unsigned width) const |
| Zero extend or truncate to width. More... | |
Bit Manipulation Operators | |
| void | setAllBits () |
| Set every bit to 1. More... | |
| void | setBit (unsigned BitPosition) |
| Set a given bit to 1. More... | |
| void | setSignBit () |
| Set the sign bit to 1. More... | |
| void | setBitsWithWrap (unsigned loBit, unsigned hiBit) |
| Set the bits from loBit (inclusive) to hiBit (exclusive) to 1. More... | |
| void | setBits (unsigned loBit, unsigned hiBit) |
| Set the bits from loBit (inclusive) to hiBit (exclusive) to 1. More... | |
| void | setBitsFrom (unsigned loBit) |
| Set the top bits starting from loBit. More... | |
| void | setLowBits (unsigned loBits) |
| Set the bottom loBits bits. More... | |
| void | setHighBits (unsigned hiBits) |
| Set the top hiBits bits. More... | |
| void | clearAllBits () |
| Set every bit to 0. More... | |
| void | clearBit (unsigned BitPosition) |
| Set a given bit to 0. More... | |
| void | clearLowBits (unsigned loBits) |
| Set bottom loBits bits to 0. More... | |
| void | clearSignBit () |
| Set the sign bit to 0. More... | |
| void | flipAllBits () |
| Toggle every bit to its opposite value. More... | |
| void | flipBit (unsigned bitPosition) |
| Toggles a given bit to its opposite value. More... | |
| void | negate () |
| Negate this APInt in place. More... | |
| void | insertBits (const APInt &SubBits, unsigned bitPosition) |
| Insert the bits from a smaller APInt starting at bitPosition. More... | |
| 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). More... | |
| 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. More... | |
| APInt | abs () const |
| Get the absolute value;. More... | |
| APInt | multiplicativeInverse (const APInt &modulo) const |
| Computes the multiplicative inverse of this APInt for a given modulo. More... | |
Support for division by constant | |
| ms | magic () const |
| Calculate the magic numbers required to implement a signed integer division by a constant as a sequence of multiplies, adds and shifts. More... | |
| mu | magicu (unsigned LeadingZeros=0) const |
| Calculate the magic numbers required to implement an unsigned integer division by a constant as a sequence of multiplies, adds and shifts. More... | |
Static Public Attributes | |
| static const WordType | WORDTYPE_MAX = ~WordType(0) |
Friends | |
| struct | DenseMapAPIntKeyInfo |
| class | APSInt |
Value Generators | |
| hash_code | hash_value (const APInt &Arg) |
| Overload to compute a hash_code for an APInt value. More... | |
| APInt | getHiBits (unsigned numBits) const |
| Compute an APInt containing numBits highbits from this APInt. More... | |
| APInt | getLoBits (unsigned numBits) const |
| Compute an APInt containing numBits lowbits from this APInt. More... | |
| const uint64_t * | getRawData () const |
| This function returns a pointer to the internal storage of the APInt. More... | |
| static APInt | getMaxValue (unsigned numBits) |
| Gets maximum unsigned value of APInt for specific bit width. More... | |
| static APInt | getSignedMaxValue (unsigned numBits) |
| Gets maximum signed value of APInt for a specific bit width. More... | |
| static APInt | getMinValue (unsigned numBits) |
| Gets minimum unsigned value of APInt for a specific bit width. More... | |
| static APInt | getSignedMinValue (unsigned numBits) |
| Gets minimum signed value of APInt for a specific bit width. More... | |
| static APInt | getSignMask (unsigned BitWidth) |
| Get the SignMask for a specific bit width. More... | |
| static APInt | getAllOnesValue (unsigned numBits) |
| Get the all-ones value. More... | |
| static APInt | getNullValue (unsigned numBits) |
| Get the '0' value. More... | |
| static APInt | getOneBitSet (unsigned numBits, unsigned BitNo) |
| Return an APInt with exactly one bit set in the result. More... | |
| static APInt | getBitsSet (unsigned numBits, unsigned loBit, unsigned hiBit) |
| Get a value with a block of bits set. More... | |
| static APInt | getBitsSetWithWrap (unsigned numBits, unsigned loBit, unsigned hiBit) |
| Wrap version of getBitsSet. More... | |
| static APInt | getBitsSetFrom (unsigned numBits, unsigned loBit) |
| Get a value with upper bits starting at loBit set. More... | |
| static APInt | getHighBitsSet (unsigned numBits, unsigned hiBitsSet) |
| Get a value with high bits set. More... | |
| static APInt | getLowBitsSet (unsigned numBits, unsigned loBitsSet) |
| Get a value with low bits set. More... | |
| static APInt | getSplat (unsigned NewLen, const APInt &V) |
| Return a value containing V broadcasted over NewLen bits. More... | |
| 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. More... | |
Binary Operators | |
| APInt | operator* (const APInt &RHS) const |
| Multiplication operator. More... | |
| APInt | operator<< (unsigned Bits) const |
| Left logical shift operator. More... | |
| APInt | operator<< (const APInt &Bits) const |
| Left logical shift operator. More... | |
| APInt | ashr (unsigned ShiftAmt) const |
| Arithmetic right-shift function. More... | |
| void | ashrInPlace (unsigned ShiftAmt) |
| Arithmetic right-shift this APInt by ShiftAmt in place. More... | |
| APInt | lshr (unsigned shiftAmt) const |
| Logical right-shift function. More... | |
| void | lshrInPlace (unsigned ShiftAmt) |
| Logical right-shift this APInt by ShiftAmt in place. More... | |
| APInt | shl (unsigned shiftAmt) const |
| Left-shift function. More... | |
| APInt | rotl (unsigned rotateAmt) const |
| Rotate left by rotateAmt. More... | |
| APInt | rotr (unsigned rotateAmt) const |
| Rotate right by rotateAmt. More... | |
| APInt | ashr (const APInt &ShiftAmt) const |
| Arithmetic right-shift function. More... | |
| void | ashrInPlace (const APInt &shiftAmt) |
| Arithmetic right-shift this APInt by shiftAmt in place. More... | |
| APInt | lshr (const APInt &ShiftAmt) const |
| Logical right-shift function. More... | |
| void | lshrInPlace (const APInt &ShiftAmt) |
| Logical right-shift this APInt by ShiftAmt in place. More... | |
| APInt | shl (const APInt &ShiftAmt) const |
| Left-shift function. More... | |
| APInt | rotl (const APInt &rotateAmt) const |
| Rotate left by rotateAmt. More... | |
| APInt | rotr (const APInt &rotateAmt) const |
| Rotate right by rotateAmt. More... | |
| APInt | udiv (const APInt &RHS) const |
| Unsigned division operation. More... | |
| APInt | udiv (uint64_t RHS) const |
| APInt | sdiv (const APInt &RHS) const |
| Signed division function for APInt. More... | |
| APInt | sdiv (int64_t RHS) const |
| APInt | urem (const APInt &RHS) const |
| Unsigned remainder operation. More... | |
| uint64_t | urem (uint64_t RHS) const |
| APInt | srem (const APInt &RHS) const |
| Function for signed remainder operation. More... | |
| 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 | ushl_ov (const APInt &Amt, bool &Overflow) const |
| 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 | ushl_sat (const APInt &RHS) const |
| bool | operator[] (unsigned bitPosition) const |
| Array-indexing support. More... | |
| static void | udivrem (const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder) |
| Dual division/remainder interface. More... | |
| 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. More... | |
| unsigned | getNumWords () const |
| Get the number of words. More... | |
| unsigned | getActiveBits () const |
| Compute the number of active bits in the value. More... | |
| unsigned | getActiveWords () const |
| Compute the number of active words in the value of this APInt. More... | |
| unsigned | getMinSignedBits () const |
| Get the minimum bit size for this signed APInt. More... | |
| uint64_t | getZExtValue () const |
| Get zero extended value. More... | |
| int64_t | getSExtValue () const |
| Get sign extended value. More... | |
| unsigned | countLeadingZeros () const |
| The APInt version of the countLeadingZeros functions in MathExtras.h. More... | |
| unsigned | countLeadingOnes () const |
| Count the number of leading one bits. More... | |
| unsigned | getNumSignBits () const |
| Computes the number of leading bits of this APInt that are equal to its sign bit. More... | |
| unsigned | countTrailingZeros () const |
| Count the number of trailing zero bits. More... | |
| unsigned | countTrailingOnes () const |
| Count the number of trailing one bits. More... | |
| unsigned | countPopulation () const |
| Count the number of bits set. More... | |
| static unsigned | getNumWords (unsigned BitWidth) |
| Get the number of words. More... | |
| static unsigned | getBitsNeeded (StringRef str, uint8_t radix) |
| Get bits required for string value. More... | |
Conversion Functions | |
| void | print (raw_ostream &OS, bool isSigned) const |
| void | toString (SmallVectorImpl< char > &Str, unsigned Radix, bool Signed, bool formatAsCLiteral=false) const |
| Converts an APInt to a string and append it to Str. More... | |
| 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. More... | |
| 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. More... | |
| std::string | toString (unsigned Radix, bool Signed) const |
| Return the APInt as a std::string. More... | |
| APInt | byteSwap () const |
| APInt | reverseBits () const |
| double | roundToDouble (bool isSigned) const |
| Converts this APInt to a double value. More... | |
| double | roundToDouble () const |
| Converts this unsigned APInt to a double value. More... | |
| double | signedRoundToDouble () const |
| Converts this signed APInt to a double value. More... | |
| double | bitsToDouble () const |
| Converts APInt bits to a double. More... | |
| float | bitsToFloat () const |
| Converts APInt bits to a float. More... | |
| static APInt | doubleToBits (double V) |
| Converts a double to APInt bits. More... | |
| static APInt | floatToBits (float V) |
| Converts a float to APInt bits. More... | |
Building-block Operations for APInt and APFloat | |
| void | dump () const |
| debug method More... | |
| static void | tcSet (WordType *, WordType, unsigned) |
| Sets the least significant part of a bignum to the input value, and zeroes out higher parts. More... | |
| static void | tcAssign (WordType *, const WordType *, unsigned) |
| Assign one bignum to another. More... | |
| static bool | tcIsZero (const WordType *, unsigned) |
| Returns true if a bignum is zero, false otherwise. More... | |
| static int | tcExtractBit (const WordType *, unsigned bit) |
| Extract the given bit of a bignum; returns 0 or 1. Zero-based. More... | |
| 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. More... | |
| static void | tcSetBit (WordType *, unsigned bit) |
| Set the given bit of a bignum. Zero-based. More... | |
| static void | tcClearBit (WordType *, unsigned bit) |
| Clear the given bit of a bignum. Zero-based. More... | |
| static unsigned | tcLSB (const WordType *, unsigned n) |
| Returns the bit number of the least or most significant set bit of a number. More... | |
| static unsigned | tcMSB (const WordType *parts, unsigned n) |
| static void | tcNegate (WordType *, unsigned) |
| Negate a bignum in-place. More... | |
| static WordType | tcAdd (WordType *, const WordType *, WordType carry, unsigned) |
| DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag. More... | |
| static WordType | tcAddPart (WordType *, WordType, unsigned) |
| DST += RHS. Returns the carry flag. More... | |
| static WordType | tcSubtract (WordType *, const WordType *, WordType carry, unsigned) |
| DST -= RHS + CARRY where CARRY is zero or one. Returns the carry flag. More... | |
| static WordType | tcSubtractPart (WordType *, WordType, unsigned) |
| DST -= RHS. Returns the carry flag. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| static void | tcShiftLeft (WordType *, unsigned Words, unsigned Count) |
| Shift a bignum left Count bits. More... | |
| static void | tcShiftRight (WordType *, unsigned Words, unsigned Count) |
| Shift a bignum right Count bits. More... | |
| static void | tcAnd (WordType *, const WordType *, unsigned) |
| The obvious AND, OR and XOR and complement operations. More... | |
| static void | tcOr (WordType *, const WordType *, unsigned) |
| static void | tcXor (WordType *, const WordType *, unsigned) |
| static void | tcComplement (WordType *, unsigned) |
| static int | tcCompare (const WordType *, const WordType *, unsigned) |
| Comparison (unsigned) of two bignums. More... | |
| static WordType | tcIncrement (WordType *dst, unsigned parts) |
| Increment a bignum in-place. Return the carry flag. More... | |
| static WordType | tcDecrement (WordType *dst, unsigned parts) |
| Decrement a bignum in-place. Return the borrow flag. More... | |
| static void | tcSetLeastSignificantBits (WordType *, unsigned, unsigned bits) |
| Set the least significant BITS and clear the rest. More... | |
Class for arbitrary precision integers.
APInt is a functional replacement for common case unsigned integer type like "unsigned", "unsigned long" or "uint64_t", but also allows non-byte-width integer sizes and large integer value types such as 3-bits, 15-bits, or more than 64-bits of precision. APInt provides a variety of arithmetic operators and methods to manipulate integer values of any bit-width. It supports both the typical integer arithmetic and comparison operations as well as bitwise manipulation.
The class has several invariants worth noting:
| typedef uint64_t llvm::APInt::WordType |
| anonymous enum : unsigned |
|
strong |
Create a new APInt of numBits width, initialized as val.
If isSigned is true then val is treated as if it were a signed value (i.e. as an int64_t) and the appropriate sign extension to the bit width will be done. Otherwise, no sign extension occurs (high order bits beyond the range of val are zero filled).
| numBits | the bit width of the constructed APInt |
| val | the initial value of the APInt |
| isSigned | how to treat signedness of val |
Definition at line 277 of file APInt.h.
References assert().
Construct an APInt of numBits width, initialized as bigVal[].
Note that bigVal.size() can be smaller or larger than the corresponding bit width but any extraneous bits will be dropped.
Equivalent to APInt(numBits, ArrayRef<uint64_t>(bigVal, numWords)), but deprecated because this constructor is prone to ambiguity with the APInt(unsigned, uint64_t, bool) constructor.
If this overload is ever deleted, care should be taken to prevent calls from being incorrectly captured by the APInt(unsigned, uint64_t, bool) constructor.
Definition at line 113 of file APInt.cpp.
References llvm::makeArrayRef().
Construct an APInt from a string representation.
This constructor interprets the string str in the given radix. The interpretation stops when the first character that is not suitable for the radix is encountered, or the end of the string. Acceptable radix values are 2, 8, 10, 16, and 36. It is an error for the value implied by the string to require more bits than numBits.
| numBits | the bit width of the constructed APInt |
| str | the string to be interpreted |
| radix | the radix to use for the conversion |
Definition at line 118 of file APInt.cpp.
References APINT_WORD_SIZE, assert(), getBitWidth(), getMemory(), getNumWords(), pVal, and VAL.
|
inline |
|
inlineexplicit |
Default constructor that creates an uninteresting APInt representing a 1-bit zero value.
This is useful for object deserialization (pair this with the static method Read).
Definition at line 345 of file APInt.h.
Referenced by byteSwap(), extractBits(), multiplicativeInverse(), operator*(), reverseBits(), rotateModulo(), llvm::APIntOps::RoundDoubleToAPInt(), sext(), llvm::APIntOps::SolveQuadraticEquationWrap(), sqrt(), sshl_ov(), trunc(), udiv(), udivrem(), urem(), ushl_ov(), usub_sat(), and zext().
|
inline |
Get the absolute value;.
If *this is < 0 then return -(*this), otherwise *this;
Definition at line 1857 of file APInt.h.
References add(), and remainder.
Referenced by areStridedAccessesIndependent(), combineADDToADDZE(), findGCD(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), gcd(), GenerateSignBits(), getConstantPart(), llvm::SelectionDAG::getNode(), getRangeForAffineARHelper(), isDivZero(), magic(), MergeAliasResults(), setLimitsForBinOp(), llvm::APIntOps::SolveQuadraticEquationWrap(), tryFoldToZero(), and llvm::InstCombiner::visitMul().
Arithmetic right-shift function.
Arithmetic right-shift this APInt by shiftAmt.
Definition at line 963 of file APInt.h.
References ashrInPlace(), and llvm::RISCVFenceField::R.
Referenced by llvm::ConstantRange::ashr(), computeKnownBitsFromOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), foldICmpShlOne(), FoldValue(), llvm::AArch64TTIImpl::getIntImmCost(), llvm::X86TTIImpl::getIntImmCost(), llvm::RISCVMatInt::getIntMatCost(), performMulCombine(), setLimitsForBinOp(), ShrinkDemandedConstant(), llvm::Interpreter::visitAShr(), and llvm::Interpreter::visitInsertValueInst().
Arithmetic right-shift function.
Arithmetic right-shift this APInt by shiftAmt.
Definition at line 1024 of file APInt.h.
References ashrInPlace(), and llvm::RISCVFenceField::R.
|
inline |
Arithmetic right-shift this APInt by ShiftAmt in place.
Definition at line 970 of file APInt.h.
References assert(), and llvm::SignExtend64().
Referenced by ashr(), ashrInPlace(), BuildExactSDIV(), llvm::SelectionDAG::computeKnownBits(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), llvm::SIInstrInfo::expandMovDPP64(), and llvm::SelectionDAG::getNode().
Arithmetic right-shift this APInt by shiftAmt in place.
Arithmetic right-shift this APInt by shiftAmt.
Arithmetic right-shift function.
Definition at line 985 of file APInt.cpp.
References APINT_BITS_PER_WORD, APINT_WORD_SIZE, ashrInPlace(), getLimitedValue(), getNumWords(), isNegative(), and llvm::SignExtend64().
|
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 1771 of file APInt.h.
References llvm::BitsToDouble().
Referenced by llvm::detail::IEEEFloat::convertToDouble(), llvm::ExecutionEngine::getConstantValue(), and llvm::Interpreter::visitAShr().
|
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 1780 of file APInt.h.
References llvm::BitsToFloat().
Referenced by llvm::detail::IEEEFloat::convertToFloat(), llvm::ExecutionEngine::getConstantValue(), and llvm::Interpreter::visitAShr().
| APInt APInt::byteSwap | ( | ) | const |
Definition at line 672 of file APInt.cpp.
References APInt(), APINT_BITS_PER_WORD, assert(), llvm::ByteSwap_16(), llvm::ByteSwap_32(), llvm::ByteSwap_64(), getNumWords(), I, lshrInPlace(), N, and pVal.
Referenced by llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), foldICmpBitCast(), llvm::SelectionDAG::getNode(), isAlwaysLive(), SimplifyBSwap(), and llvm::TargetLowering::SimplifyDemandedBits().
|
inline |
Definition at line 1808 of file APInt.h.
References getActiveBits().
Referenced by ComputeNumSignBitsImpl(), genConstMult(), and llvm::InstCombiner::replacedSelectWithOperand().
|
inline |
Set every bit to 0.
Definition at line 1500 of file APInt.h.
Referenced by llvm::MCInstrAnalysis::clearsSuperRegisters(), llvm::X86_MC::X86MCInstrAnalysis::clearsSuperRegisters(), llvm::SelectionDAG::computeKnownBits(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), getUsefulBitsFromOrWithShiftedReg(), llvm::KnownBits::resetAll(), llvm::KnownBits::setAllOnes(), llvm::KnownBits::setAllZero(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), and llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode().
|
inline |
Set a given bit to 0.
Set the given bit to 0 whose position is given as "bitPosition".
Definition at line 1510 of file APInt.h.
References assert(), and llvm::BitmaskEnumDetail::Mask().
Referenced by llvm::mca::RegisterFile::addRegisterWrite(), llvm::SelectionDAG::ComputeNumSignBits(), flipBit(), generateEquivalentSub(), GetFPLibCall(), getHopForBuildVector(), getSignedMaxValue(), insertBits(), llvm::possiblyDemandedEltsInMask(), propagateMetadata(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifyDemandedVectorElts(), and llvm::ConstantRange::truncate().
|
inline |
|
inline |
Set the sign bit to 0.
Definition at line 1527 of file APInt.h.
Referenced by llvm::SelectionDAG::computeKnownBits(), computeSignedMinMaxValuesFromKnownBits(), and llvm::ConstantRange::fromKnownBits().
|
inline |
Count the number of leading one bits.
This function is an APInt version of the countLeadingOnes functions in MathExtras.h. It counts the number of ones from the most significant bit to the first zero bit.
Definition at line 1669 of file APInt.h.
References llvm::countLeadingOnes().
Referenced by llvm::KnownBits::countMinLeadingOnes(), llvm::KnownBits::countMinLeadingZeros(), lower1BitShuffle(), lowerShuffleAsByteShiftMask(), lowerShuffleAsVTRUNCAndUnpack(), setLimitsForBinOp(), ShrinkDemandedConstant(), and sshl_ov().
|
inline |
The APInt version of the countLeadingZeros functions in MathExtras.h.
It counts the number of zeros from the most significant bit to the first one bit.
Definition at line 1653 of file APInt.h.
References llvm::countLeadingZeros().
Referenced by areUsedBitsDense(), BitsProperlyConcatenate(), llvm::canConstantFoldCallTo(), computeKnownBitsFromOperator(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::KnownBits::countMaxLeadingOnes(), llvm::KnownBits::countMaxLeadingZeros(), getContiguousRangeOfSetBits(), llvm::APIntOps::GetMostSignificantDifferentBit(), llvm::SelectionDAG::getNode(), getRangeForAffineARHelper(), KnuthDiv(), processUMulZExtIdiom(), setLimitsForBinOp(), llvm::ConstantRange::shl(), ShrinkDemandedConstant(), ShrinkLoadReplaceStoreWithStore(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), sshl_ov(), tryBitfieldInsertOpFromOr(), umul_ov(), ushl_ov(), and llvm::InstCombiner::visitZExt().
|
inline |
Count the number of bits set.
This function is an APInt version of the countPopulation functions in MathExtras.h. It counts the number of 1 bits in the APInt value.
Definition at line 1715 of file APInt.h.
References llvm::countPopulation(), print(), Signed, and llvm::toString().
Referenced by llvm::KnownBits::countMaxPopulation(), llvm::KnownBits::countMinPopulation(), EltsFromConsecutiveLoads(), getContiguousRangeOfSetBits(), llvm::SelectionDAG::getNode(), llvm::KnownBits::isConstant(), isStackPtrRelative(), ParseBFI(), llvm::ARMTargetLowering::PerformCMOVToBFICombine(), ShrinkDemandedConstant(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), llvm::AArch64TargetLowering::targetShrinkDemandedConstant(), tryBitfieldInsertOpFromOr(), tryBitfieldInsertOpFromOrAndImm(), and llvm::InstCombiner::visitTrunc().
|
inline |
Count the number of trailing one bits.
This function is an APInt version of the countTrailingOnes functions in MathExtras.h. It counts the number of ones from the least significant bit to the first zero bit.
Definition at line 1703 of file APInt.h.
References llvm::countTrailingOnes().
Referenced by combineAndMaskToShift(), combineShiftRightLogical(), llvm::KnownBits::countMinTrailingOnes(), llvm::KnownBits::countMinTrailingZeros(), llvm::AlignmentFromAssumptionsPass::extractAlignmentInfo(), getDemandedBitsLHSMask(), llvm::isBitwiseNot(), lowerShuffleAsByteShiftMask(), simplifyDivRem(), llvm::ConstantRange::truncate(), and widenCtPop().
|
inline |
Count the number of trailing zero bits.
This function is an APInt version of the countTrailingZeros functions in MathExtras.h. It counts the number of zeros from the least significant bit to the first set bit.
Definition at line 1689 of file APInt.h.
References llvm::countTrailingZeros().
Referenced by areUsedBitsDense(), BinomialCoefficient(), BitsProperlyConcatenate(), BuildExactSDIV(), llvm::TargetLowering::BuildUDIV(), llvm::canConstantFoldCallTo(), checkForNegativeOperand(), combineShiftOfShiftedLogic(), computeKnownBitsFromOperator(), llvm::KnownBits::countMaxTrailingOnes(), llvm::KnownBits::countMaxTrailingZeros(), EltsFromConsecutiveLoads(), EmitCmp(), foldICmpShlOne(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), getContiguousRangeOfSetBits(), getDemandedBitsLHSMask(), llvm::SelectionDAG::getNode(), getPermuteMask(), getPowerOf2Factor(), getRangeForAffineARHelper(), llvm::BuildVectorSDNode::getSplatValue(), llvm::APIntOps::GreatestCommonDivisor(), PerformBFICombine(), performXorCombine(), processUGT_ADDCST_ADD(), llvm::InstCombiner::replacedSelectWithOperand(), setLimitsForBinOp(), ShrinkDemandedConstant(), ShrinkLoadReplaceStoreWithStore(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), SolveLinEquationWithOverflow(), llvm::detail::IEEEFloat::toString(), tryBitfieldInsertOpFromOr(), llvm::InstCombiner::visitTrunc(), llvm::InstCombiner::visitZExt(), and widenCtPop().
|
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 1788 of file APInt.h.
References llvm::DoubleToBits().
Referenced by llvm::ExecutionEngine::getConstantValue(), llvm::detail::IEEEFloat::IEEEFloat(), and llvm::Interpreter::visitAShr().
| LLVM_DUMP_METHOD void APInt::dump | ( | ) | const |
debug method
Definition at line 2290 of file APInt.cpp.
References llvm::dbgs(), toStringSigned(), and toStringUnsigned().
Referenced by llvm::mca::RegisterFile::dump().
Equality comparison.
Compares this APInt with RHS for the validity of the equality relationship.
Definition at line 1173 of file APInt.h.
Referenced by llvm::PatternMatch::icmp_pred_with_threshold::isValue(), and processUMulZExtIdiom().
|
inline |
Definition at line 1845 of file APInt.h.
Referenced by llvm::BuildVectorSDNode::getConstantFPSplatPow2ToLog2Int(), processUGT_ADDCST_ADD(), shouldMergeGEPs(), and llvm::TargetLowering::SimplifyDemandedBits().
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
Definition at line 431 of file APInt.cpp.
References APInt(), APINT_BITS_PER_WORD, assert(), getNumWords(), llvm::makeArrayRef(), pVal, and VAL.
Referenced by combineShiftAnd1ToBitTest(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), computeZeroableShuffleElements(), EltsFromConsecutiveLoads(), llvm::extractConstantMask(), getConstantVector(), getFauxShuffleMask(), getTargetConstantBitsFromNode(), llvm::SelectionDAG::isSplatValue(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), and simplifyShuffleOfShuffle().
|
inline |
Toggle every bit to its opposite value.
Definition at line 1532 of file APInt.h.
Referenced by annotateNonNullAndDereferenceable(), getUsefulBits(), getUsefulBitsFromBFM(), getUsefulBitsFromOrWithShiftedReg(), insert1BitVector(), and llvm::operator~().
| 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 339 of file APInt.cpp.
References assert(), clearBit(), and setBit().
|
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 1796 of file APInt.h.
References llvm::FloatToBits().
Referenced by llvm::ExecutionEngine::getConstantValue(), llvm::detail::IEEEFloat::IEEEFloat(), and llvm::Interpreter::visitAShr().
|
inline |
Compute the number of active bits in the value.
This function returns the number of active bits which is defined as the bit width minus the number of leading zeros. This is used in several computations to see how "wide" the value is.
Definition at line 1590 of file APInt.h.
References llvm::countLeadingZeros().
Referenced by aliasSameBasePointerGEPs(), llvm::APSInt::APSInt(), areUsedBitsDense(), ceilLogBase2(), llvm::ObjectSizeOffsetVisitor::compute(), getConstantTripCount(), llvm::SelectionDAG::GetDemandedBits(), llvm::ARMTTIImpl::getIntImmCost(), getOtherIncomingValue(), llvm::ScalarEvolution::getSmallConstantTripMultiple(), hasSameExtUse(), llvm::detail::IEEEFloat::IEEEFloat(), isAlwaysLive(), isSubBorrowChain(), llvm::SelectionDAGBuilder::lowerRangeToAssertZExt(), llvm::ARMTargetLowering::PerformCMOVToBFICombine(), processUDivOrURem(), llvm::InstCombiner::replacedSelectWithOperand(), roundToDouble(), ShrinkDemandedConstant(), llvm::TargetLowering::ShrinkDemandedOp(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), sqrt(), llvm::X86TargetLowering::targetShrinkDemandedConstant(), llvm::ConstantRange::truncate(), udiv(), udivrem(), UpdatePDTWorklist(), and urem().
|
inline |
Get the all-ones value.
Definition at line 566 of file APInt.h.
Referenced by canonicalizeSaturatedAdd(), combineAnd(), combineExtractVectorElt(), combineHorizontalMinMaxResult(), combineKSHIFT(), combineMOVMSK(), combinePMULDQ(), combineShiftAnd1ToBitTest(), combineShiftOfShiftedLogic(), combineShuffle(), combineVectorInsert(), combineVectorPack(), combineVectorShiftImm(), combineVectorShiftVar(), combineX86INT_TO_FP(), combineX86ShuffleChain(), combineX86ShufflesRecursively(), llvm::SelectionDAG::computeKnownBits(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), llvm::GISelKnownBits::computeNumSignBits(), llvm::SelectionDAG::ComputeNumSignBits(), createBSWAPShuffleMask(), detectSSatPattern(), findDemandedEltsByAllUsers(), findDemandedEltsBySingleUser(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), GenerateSignBits(), llvm::SelectionDAG::getAllOnesConstant(), llvm::Constant::getAllOnesValue(), llvm::APFloat::getAllOnesValue(), llvm::DemandedBits::getDemandedBits(), llvm::SelectionDAG::GetDemandedBits(), getDemandedBitsLHSMask(), GetFPLibCall(), getHopForBuildVector(), llvm::GISelKnownBits::getKnownBits(), llvm::IntegerType::getMask(), llvm::SelectionDAG::getNOT(), getOnesVector(), getSelectFoldableConstant(), getShiftAmountTyForConstant(), llvm::SelectionDAG::getSplatSourceVector(), llvm::BuildVectorSDNode::getSplatValue(), getTargetConstantBitsFromNode(), getTargetShuffleInputs(), isConditionalZeroOrAllOnes(), llvm::SelectionDAG::isSplatValue(), isStackPtrRelative(), LowerADDSUBCARRY(), magicu(), llvm::SelectionDAG::MaskedValueIsZero(), llvm::PPCTargetLowering::PerformDAGCombine(), llvm::possiblyDemandedEltsInMask(), llvm::InstCombiner::reassociateShiftAmtsOfTwoSameDirectionShifts(), llvm::DemandedBitsWrapperPass::releaseMemory(), llvm::InstCombiner::replacedSelectWithOperand(), setLimitsForBinOp(), ShrinkDemandedConstant(), ShrinkLoadReplaceStoreWithStore(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), stripTruncAndExt(), llvm::LegalizationArtifactCombiner::tryCombineZExt(), llvm::InstCombiner::visitCallInst(), llvm::InstCombiner::visitGetElementPtrInst(), llvm::InstCombiner::visitInsertElementInst(), llvm::InstCombiner::visitShuffleVectorInst(), and llvm::LegalizerHelper::widenScalar().
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 493 of file APInt.cpp.
References assert(), llvm::StringRef::begin(), llvm::StringRef::empty(), isNegative(), isPowerOf2(), logBase2(), and llvm::StringRef::size().
|
inlinestatic |
Get a value with a block of bits set.
Constructs an APInt value that has a contiguous range of bits set. The bits from loBit (inclusive) to hiBit (exclusive) will be set. All other bits will be zero. For example, with parameters(32, 0, 16) you would get 0x0000FFFF. Please call getBitsSetWithWrap if loBit may be greater than hiBit.
| numBits | the intended bit width of the result |
| loBit | the index of the lowest bit set. |
| hiBit | the index of the highest bit set. |
Definition at line 611 of file APInt.h.
References assert(), and setBits().
Referenced by combineToExtendBoolVectorInReg(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), eliminateDeadStores(), insert1BitVector(), llvm::AMDGPUTargetLowering::PerformDAGCombine(), ShrinkLoadReplaceStoreWithStore(), tryBitfieldInsertOpFromOr(), llvm::RegisterBankInfo::ValueMapping::verify(), and widenCtPop().
Get a value with upper bits starting at loBit set.
Constructs an APInt value that has a contiguous range of bits set. The bits from loBit (inclusive) to numBits (exclusive) will be set. All other bits will be zero. For example, with parameters(32, 12) you would get 0xFFFFF000.
| numBits | the intended bit width of the result |
| loBit | the index of the lowest bit to set. |
Definition at line 640 of file APInt.h.
References setBitsFrom().
Referenced by canEvaluateTruncated(), getDemandedBitsLHSMask(), and llvm::ConstantRange::truncate().
|
inlinestatic |
Wrap version of getBitsSet.
If hiBit is no less than loBit, this is same with getBitsSet. If hiBit is less than loBit, the set bits "wrap". For example, with parameters (32, 28, 4), you would get 0xF000000F.
Definition at line 622 of file APInt.h.
References setBitsWithWrap().
|
inline |
Return the number of bits in the APInt.
Definition at line 1566 of file APInt.h.
Referenced by llvm::GEPOperator::accumulateConstantOffset(), llvm::DwarfUnit::addConstantFPValue(), llvm::DwarfUnit::addConstantValue(), llvm::DwarfExpression::addUnsignedConstant(), llvm::detail::PtrUseVisitorBase::adjustOffsetForGEP(), adjustToPointerSize(), APInt(), APIntToHexString(), BitsProperlyConcatenate(), llvm::SwitchCG::SwitchLowering::buildBitTests(), BuildExactSDIV(), llvm::TargetLowering::BuildUDIV(), calculateOffsetDiff(), llvm::canConstantFoldCallTo(), llvm::X86_MC::X86MCInstrAnalysis::clearsSuperRegisters(), llvm::FunctionComparator::cmpAPInts(), combineShiftOfShiftedLogic(), CombineVMOVDRRCandidateWithVecOp(), llvm::InstCombiner::commonIDivTransforms(), CompareSCEVComplexity(), llvm::APSInt::compareValues(), llvm::ObjectSizeOffsetVisitor::compute(), llvm::SelectionDAG::computeKnownBits(), llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::computeMinimumValueSizes(), llvm::ComputeMultiple(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), computeSignedMinMaxValuesFromKnownBits(), computeUnsignedMinMaxValuesFromKnownBits(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantRange::ConstantRange(), llvm::detail::IEEEFloat::convertToDouble(), llvm::APFloat::convertToInteger(), llvm::MDBuilder::createRange(), llvm::decomposeBitTestICmp(), llvm::BitTracker::MachineEvaluator::eIMM(), eliminateDeadStores(), emitGlobalConstantFP(), extractConstantWithoutWrapping(), extractShiftForRotate(), foldICmpBitCast(), foldICmpShlOne(), foldNoWrapAdd(), foldSelectICmpAnd(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), gcd(), genConstMult(), GenerateSignBits(), llvm::ConstantInt::get(), getAdjustedPtr(), llvm::StringRef::getAsInteger(), llvm::KnownBits::getBitWidth(), llvm::ConstantInt::getBitWidth(), llvm::ConstantRange::getBitWidth(), llvm::ExecutionEngine::getConstantValue(), llvm::getConstantVRegValWithLookThrough(), getConstVector(), getContiguousRangeOfSetBits(), llvm::SelectionDAG::GetDemandedBits(), getFauxShuffleMask(), getHorizDemandedElts(), llvm::SystemZTTIImpl::getIntImmCost(), llvm::PPCTTIImpl::getIntImmCost(), llvm::SystemZTTIImpl::getIntImmCostInst(), llvm::PPCTTIImpl::getIntImmCostInst(), llvm::X86TTIImpl::getIntImmCostInst(), llvm::SystemZTTIImpl::getIntImmCostIntrin(), llvm::PPCTTIImpl::getIntImmCostIntrin(), llvm::AArch64TTIImpl::getIntImmCostIntrin(), llvm::X86TTIImpl::getIntImmCostIntrin(), llvm::SwitchCG::getJumpTableRange(), getKnownUndefForVectorBinop(), llvm::APIntOps::GetMostSignificantDifferentBit(), getNaturalGEPRecursively(), getNaturalGEPWithOffset(), llvm::SelectionDAG::getNode(), llvm::ConstantRange::getNonEmpty(), getPackDemandedElts(), llvm::getPtrStride(), getRangeForAffineARHelper(), getShiftAmount(), getSplat(), llvm::BuildVectorSDNode::getSplatValue(), llvm::getStrideFromPointer(), getTargetConstantBitsFromNode(), getUnsigned(), getUsefulBits(), getUsefulBitsForUse(), getUsefulBitsFromAndWithImmediate(), getUsefulBitsFromBFM(), getUsefulBitsFromBitfieldMoveOpd(), hasHugeExpression(), llvm::detail::IEEEFloat::IEEEFloat(), IncorporateWeight(), INITIALIZE_PASS(), insertBits(), isAligned(), isAlwaysLive(), isAnyConstantBuildVector(), isConstantOrConstantVector(), llvm::TargetTransformInfoImplBase::isConstantStridedAccessLessThan(), llvm::TargetLowering::isConstTrueVal(), isDereferenceableAndAlignedPointer(), llvm::DenseMapAPIntKeyInfo::isEqual(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), llvm::SIInstrInfo::isInlineConstant(), isMemOPCandidate(), isMultiple(), isObjectSize(), isRemainderZero(), llvm::isSafeToLoadUnconditionally(), isSameValue(), isSplat(), llvm::SelectionDAG::isSplatValue(), isSupportedGuardInstruction(), llvm::LoadIntFromMemory(), magic(), magicu(), makeExactMulNSWRegion(), makeExactMulNUWRegion(), MaskedValueIsZero(), matchAndOrChain(), MatchDiv(), MatchMul(), minAPInt(), MinOptional(), operator*(), ParseBFI(), parseHexOcta(), parseIRValue(), parseOptionalLinkageAux(), PerformORCombine(), PerformSHLSimplify(), PickMostRelevantLoop(), printConstant(), processUGT_ADDCST_ADD(), processUMulZExtIdiom(), propagateMetadata(), llvm::Constant::replaceUndefsWith(), resolveTargetShuffleFromZeroables(), rotateModulo(), setLimitsForBinOp(), setLimitsForIntrinsic(), shouldMergeGEPs(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), simplifyIntrinsic(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), simplifyX86vpermv(), AllocaSlices::SliceBuilder::SliceBuilder(), SolveLinEquationWithOverflow(), SolveQuadraticAddRecRange(), llvm::APIntOps::SolveQuadraticEquationWrap(), sshl_ov(), llvm::StoreIntToMemory(), llvm::Value::stripAndAccumulateConstantOffsets(), llvm::ConstantRange::subtract(), toString(), llvm::detail::IEEEFloat::toString(), TruncIfPossible(), tryFoldToZero(), unifyBitWidth(), ushl_ov(), llvm::Interpreter::visitAShr(), llvm::InstCombiner::visitMul(), llvm::TBAAVerifier::visitTBAAMetadata(), llvm::InstCombiner::visitZExt(), and zeroExtendToMatch().
|
inline |
Convert APInt to a boolean value.
This converts the APInt to a boolean value as a test against zero.
Definition at line 482 of file APInt.h.
Referenced by llvm::X86_MC::X86MCInstrAnalysis::clearsSuperRegisters(), combineShiftOfShiftedLogic(), llvm::KnownBits::computeForAddCarry(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::computeOverflowKind(), createAndInstr(), getPowerOf2Factor(), getTargetConstantBitsFromNode(), isKnownToBeAPowerOfTwo(), processDbgDeclares(), llvm::PPCTargetLowering::SelectAddressRegReg(), and toString().
Compute an APInt containing numBits highbits from this APInt.
This function returns the high "numBits" bits of this APInt.
Get an APInt with the same BitWidth as this APInt, just zero mask the low bits and right shift to the least significant bit.
Definition at line 565 of file APInt.cpp.
References lshr().
Referenced by llvm::SelectionDAG::computeKnownBits(), parseHexOcta(), llvm::TargetLowering::SimplifyDemandedBits(), tryAdvSIMDModImm16(), tryAdvSIMDModImm32(), tryAdvSIMDModImm321s(), tryAdvSIMDModImm64(), tryAdvSIMDModImm8(), tryAdvSIMDModImmFP(), and WriteConstantInternal().
Get a value with high bits set.
Constructs an APInt value that has the top hiBitsSet bits set.
| numBits | the bitwidth of the result |
| hiBitsSet | the number of high-order bits set in the result. |
Definition at line 652 of file APInt.h.
References setHighBits().
Referenced by canEvaluateShifted(), canEvaluateZExtd(), combineAnd(), combineCMP(), combineMulToPMADDWD(), combineMulToPMULDQ(), combineShiftAnd1ToBitTest(), combineShiftOfShiftedLogic(), combineVectorPack(), combineZext(), llvm::SelectionDAG::computeKnownBits(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::AArch64TargetLowering::computeKnownBitsForTargetNode(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::computeKnownBitsFromRangeMetadata(), EmitCmp(), llvm::XCoreTargetLowering::EmitInstrWithCustomInserter(), llvm::TargetLowering::expandMUL_LOHI(), foldICmpBitCast(), foldICmpShlOne(), foldMaskAndShiftToScale(), foldMaskedShiftToBEXTR(), llvm::InstCombiner::FoldShiftByConstant(), foldShiftedShift(), foldVecTruncToExtElt(), generateEquivalentSub(), getFauxShuffleMask(), getSPDenormModeValue(), getVectorCompareInfo(), isADDADDMUL(), isAlwaysLive(), isTruncWithZeroHighBitsInput(), lowerMSABitClearImm(), LowerMUL(), LowerScalarImmediateShift(), llvm::AMDGPUTargetLowering::LowerUDIVREM64(), matchShuffleWithPACK(), mayUseP9Setb(), llvm::ARMTargetLowering::PerformDAGCombine(), PerformShiftCombine(), PerformSHLSimplify(), performSRLCombine(), processUGT_ADDCST_ADD(), ShrinkDemandedConstant(), llvm::ConstantRange::signExtend(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), simplifyDivRem(), llvm::InstCombiner::visitAdd(), llvm::InstCombiner::visitShl(), and llvm::InstCombiner::visitZExt().
|
inline |
If this value is smaller than the specified limit, return it, otherwise return the limit value.
This causes the value to saturate to the limit.
Definition at line 486 of file APInt.h.
References isSplat().
Referenced by ashrInPlace(), calculateOffsetDiff(), canEvaluateTruncated(), llvm::InstCombiner::commonIDivTransforms(), llvm::ComputeMultiple(), llvm::codeview::consume_numeric(), createGlobalFwdRef(), despeculateCountZeros(), llvm::Evaluator::EvaluateBlock(), foldICmpBitCast(), llvm::InstCombiner::FoldShiftByConstant(), llvm::ARMTTIImpl::getIntImmCodeSizeCost(), llvm::ConstantInt::getLimitedValue(), getUnsigned(), isAlwaysLive(), isObjectSize(), LowerBUILD_VECTOR_i1(), lshrInPlace(), operator<<=(), ParseBFI(), parseHexOcta(), llvm::DemandedBitsWrapperPass::releaseMemory(), rotateModulo(), ShrinkDemandedConstant(), SimplifyAndInst(), SimplifyShift(), AllocaSlices::SliceBuilder::SliceBuilder(), and SwitchToLookupTable().
Compute an APInt containing numBits lowbits from this APInt.
This function returns the low "numBits" bits of this APInt.
Get an APInt with the same BitWidth as this APInt, just zero mask the high bits.
Definition at line 570 of file APInt.cpp.
References getLowBitsSet().
Referenced by computeKnownBitsMul(), ConvertDoubleToBytes(), matchRotateSub(), parseHexOcta(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), simplifyX86vpermilvar(), tryAdvSIMDModImm16(), tryAdvSIMDModImm32(), tryAdvSIMDModImm321s(), tryAdvSIMDModImm64(), tryAdvSIMDModImm8(), tryAdvSIMDModImmFP(), tryToFoldACImm(), and WriteConstantInternal().
Get a value with low bits set.
Constructs an APInt value that has the bottom loBitsSet bits set.
| numBits | the bitwidth of the result |
| loBitsSet | the number of low-order bits set in the result. |
Definition at line 664 of file APInt.h.
References setLowBits().
Referenced by canEvaluateShiftedShift(), clampDynamicVectorIndex(), combineBEXTR(), combineBT(), combineCMP(), combineHorizontalPredicateResult(), combineMOVMSK(), combineShiftOfShiftedLogic(), combineSubToSubus(), combineVectorTruncationWithPACKUS(), llvm::SelectionDAG::computeKnownBits(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldCastOperand(), EmitCmp(), llvm::XCoreTargetLowering::EmitInstrWithCustomInserter(), foldICmpBitCast(), foldICmpShlOne(), foldICmpWithMinMax(), llvm::InstCombiner::FoldShiftByConstant(), foldShiftedShift(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), foldUnsignedUnderflowCheck(), generateEquivalentSub(), getLoBits(), getRangeForAffineARHelper(), llvm::SelectionDAG::getZeroExtendInReg(), isAlwaysLive(), llvm::LegalizerHelper::lowerFCopySign(), lowerMSABitClearImm(), LowerMUL(), numVectorEltsOrZero(), ParseBFI(), llvm::RISCVTargetLowering::PerformDAGCombine(), llvm::ARMTargetLowering::PerformDAGCombine(), performTBISimplification(), processUGT_ADDCST_ADD(), ShrinkDemandedConstant(), ShrinkLoadReplaceStoreWithStore(), llvm::ConstantRange::signExtend(), SimplifyAndInst(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), simplifyI24(), simplifyX86pack(), llvm::X86TargetLowering::targetShrinkDemandedConstant(), llvm::InstCombiner::visitAShr(), llvm::InstCombiner::visitCallInst(), llvm::InstCombiner::visitLShr(), and llvm::InstCombiner::visitZExt().
Gets maximum unsigned value of APInt for specific bit width.
Definition at line 534 of file APInt.h.
Referenced by llvm::cannotBeMaxInLoop(), llvm::ConstantRange::castOp(), llvm::TargetLowering::expandMUL_LOHI(), getIdentityValueForAtomicOp(), llvm::APSInt::getMaxValue(), getRangeForAffineARHelper(), GetRangeFromMetadata(), llvm::ConstantRange::getUnsignedMax(), llvm::ScalarEvolution::getZeroExtendExpr(), isKnownPredicateExtendIdiom(), isPromotedResultSafe(), llvm::ConstantRange::isSizeLargerThan(), llvm::fuzzerop::makeConstantsWithType(), makeExactMulNUWRegion(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), processUMulZExtIdiom(), setLimitsForBinOp(), setLimitsForIntrinsic(), llvm::ConstantRange::truncate(), truncUSat(), uadd_sat(), umul_sat(), and ushl_sat().
|
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 1609 of file APInt.h.
References llvm::countLeadingOnes().
Referenced by llvm::APSInt::APSInt(), canFoldIVIncExpr(), combineShiftRightLogical(), llvm::RISCVTTIImpl::getIntImmCostInst(), getMaxPointerSize(), getSetupCost(), llvm::RISCVTargetLowering::isDesirableToCommuteWithShift(), isIndexInRangeOfArrayType(), isPromotedInstructionLegal(), mapBinOpcode(), propagateMetadata(), simplifyDivRem(), and llvm::Value::stripAndAccumulateConstantOffsets().
Gets minimum unsigned value of APInt for a specific bit width.
Definition at line 546 of file APInt.h.
Referenced by llvm::cannotBeMinInLoop(), llvm::ConstantRange::castOp(), getIdentityValueForAtomicOp(), llvm::APSInt::getMinValue(), GetRangeFromMetadata(), llvm::ConstantRange::getUnsignedMin(), getUnsignedOverflowLimitForStep(), llvm::ScalarEvolution::getZeroExtendExpr(), isKnownPredicateExtendIdiom(), llvm::ConstantRange::makeAllowedICmpRegion(), llvm::fuzzerop::makeConstantsWithType(), makeExactMulNUWRegion(), and llvm::ConstantRange::makeGuaranteedNoWrapRegion().
Get the '0' value.
Definition at line 573 of file APInt.h.
Referenced by llvm::ConstantRange::abs(), llvm::ConstantRange::binaryAnd(), llvm::ConstantRange::binaryOr(), llvm::SwitchCG::SwitchLowering::buildBitTests(), llvm::TargetLowering::BuildUDIV(), combineOr(), combineShiftAnd1ToBitTest(), combineVectorPack(), combineX86ShuffleChain(), combineX86ShufflesConstants(), combineX86ShufflesRecursively(), llvm::ObjectSizeOffsetVisitor::compute(), computeZeroableShuffleElements(), llvm::ConstantFoldCastInstruction(), EltsFromConsecutiveLoads(), getConstantPart(), getFauxShuffleMask(), getHorizDemandedElts(), getKnownUndefForVectorBinop(), llvm::SelectionDAG::getNode(), llvm::Constant::getNullValue(), getPackDemandedElts(), getSelectFoldableConstant(), getTargetConstantBitsFromNode(), getTargetShuffleAndZeroables(), isKnownNonZeroFromAssume(), llvm::SelectionDAG::isSplatValue(), llvm::LegalizerHelper::lowerFPTOUI(), llvm::ConstantRange::makeAllowedICmpRegion(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), mapBinOpcode(), matchScalarReduction(), resolveZeroablesFromTargetShuffle(), scalarConstantToHexString(), scalarizeExtractedBinop(), llvm::ConstantRange::sdiv(), setLimitsForSelectPattern(), 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().
|
inline |
Computes the number of leading bits of this APInt that are equal to its sign bit.
Definition at line 1677 of file APInt.h.
References llvm::countLeadingOnes(), and llvm::countLeadingZeros().
Referenced by llvm::SelectionDAG::computeKnownBits(), llvm::GISelKnownBits::computeNumSignBits(), llvm::SelectionDAG::ComputeNumSignBits(), ComputeNumSignBitsImpl(), and llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo().
|
inline |
Get the number of words.
Here one word's bitwidth equals to that of uint64_t.
Definition at line 1573 of file APInt.h.
References getNumWords().
Referenced by APInt(), ashrInPlace(), byteSwap(), llvm::detail::IEEEFloat::convertFromAPInt(), llvm::APFloat::convertToInteger(), emitGlobalConstantFP(), extractBits(), getDigit(), getNumWords(), getSplat(), llvm::hash_value(), lshrInPlace(), llvm::detail::IEEEFloat::makeNaN(), operator*(), operator*=(), operator++(), operator+=(), operator--(), operator-=(), operator<<=(), printConstant(), Profile(), sext(), trunc(), udiv(), udivrem(), urem(), ushl_sat(), and zext().
Return an APInt with exactly one bit set in the result.
Definition at line 592 of file APInt.h.
References setBit().
Referenced by BinomialCoefficient(), llvm::TargetLowering::BuildUDIV(), combineExtractVectorElt(), combineShiftAnd1ToBitTest(), llvm::InstCombiner::commonIDivTransforms(), llvm::SelectionDAG::computeKnownBits(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), llvm::SelectionDAG::ComputeNumSignBits(), extractShiftForRotate(), findDemandedEltsBySingleUser(), foldICmpBitCast(), foldICmpShlOne(), foldICmpWithMinMax(), foldSelectICmpAndOr(), getPromotedVectorElementType(), getRangeForAffineARHelper(), getShiftAmountTyForConstant(), IncorporateWeight(), llvm::fuzzerop::makeConstantsWithType(), MatchBinaryOp(), processUMulZExtIdiom(), scalarizeMaskedCompressStore(), scalarizeMaskedExpandLoad(), scalarizeMaskedGather(), scalarizeMaskedLoad(), scalarizeMaskedScatter(), scalarizeMaskedStore(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), SolveLinEquationWithOverflow(), llvm::APIntOps::SolveQuadraticEquationWrap(), widenCtPop(), llvm::LegalizerHelper::widenScalar(), and llvm::ConstantRange::zeroExtend().
|
inline |
This function returns a pointer to the internal storage of the APInt.
This is useful for writing out the APInt in binary form without any conversions.
Definition at line 691 of file APInt.h.
Referenced by llvm::DwarfUnit::addConstantFPValue(), llvm::DwarfUnit::addConstantValue(), llvm::DwarfExpression::addUnsignedConstant(), llvm::detail::IEEEFloat::convertFromAPInt(), llvm::detail::IEEEFloat::convertFromZeroExtendedInteger(), llvm::detail::IEEEFloat::convertToDouble(), llvm::detail::DoubleAPFloat::DoubleAPFloat(), emitGlobalConstantFP(), emitSignedInt64(), GetFPLibCall(), llvm::detail::hash_value(), llvm::HexagonLowerToMC(), insertBits(), llvm::LoadIntFromMemory(), llvm::detail::IEEEFloat::makeNaN(), printConstant(), sext(), llvm::StoreIntToMemory(), llvm::ExecutionEngine::StoreValueToMemory(), toString(), trunc(), and zext().
|
inline |
Get sign extended value.
This method attempts to return the value of this APInt as a sign extended int64_t. The bit width must be <= 64 or the value must fit within an int64_t. Otherwise an assertion will result.
Definition at line 1632 of file APInt.h.
References assert(), and llvm::SignExtend64().
Referenced by llvm::DwarfUnit::addConstantValue(), llvm::InterleavedAccessInfo::analyzeInterleaving(), areStridedAccessesIndependent(), llvm::TargetLowering::BuildSDIV(), calculateOffsetDiff(), checkParametrizedPassName(), llvm::ConstantFoldLoadThroughBitcast(), ConvertDoubleToBytes(), llvm::PPCInstrInfo::convertToImmediateForm(), llvm::IRPosition::getAttrs(), getComparePred(), llvm::getConstantVRegValWithLookThrough(), llvm::AArch64_AM::getFP16Imm(), llvm::ARM_AM::getFP16Imm(), llvm::AArch64_AM::getFP32Imm(), llvm::ARM_AM::getFP32Imm(), llvm::AArch64_AM::getFP64Imm(), llvm::ARM_AM::getFP64Imm(), llvm::TargetTransformInfoImplCRTPBase< AMDGPUTTIImpl >::getGEPCost(), llvm::SystemZTTIImpl::getIntImmCost(), llvm::PPCTTIImpl::getIntImmCost(), llvm::LanaiTTIImpl::getIntImmCost(), llvm::AArch64TTIImpl::getIntImmCost(), llvm::ARMTTIImpl::getIntImmCost(), llvm::X86TTIImpl::getIntImmCost(), llvm::SystemZTTIImpl::getIntImmCostInst(), llvm::RISCVTTIImpl::getIntImmCostInst(), llvm::PPCTTIImpl::getIntImmCostInst(), llvm::ARMTTIImpl::getIntImmCostInst(), llvm::SystemZTTIImpl::getIntImmCostIntrin(), llvm::PPCTTIImpl::getIntImmCostIntrin(), llvm::AArch64TTIImpl::getIntImmCostIntrin(), llvm::X86TTIImpl::getIntImmCostIntrin(), llvm::RISCVMatInt::getIntMatCost(), llvm::GetPointerBaseWithConstantOffset(), llvm::getPtrStride(), llvm::ConstantInt::getSExtValue(), getSPDenormModeValue(), llvm::getStrideFromPointer(), getVShiftImm(), INITIALIZE_PASS(), isAnyConstantBuildVector(), llvm::TargetTransformInfoImplBase::isConstantStridedAccessLessThan(), llvm::RISCVTargetLowering::isDesirableToCommuteWithShift(), llvm::SIInstrInfo::isInlineConstant(), isLoopIncrement(), isPromotedInstructionLegal(), LLVMGenericValueToInt(), llvm::HexagonTargetLowering::LowerBITCAST(), llvm::AsmPrinter::lowerConstant(), llvm::codeview::CodeViewRecordIO::mapEncodedInteger(), mayUsePostIncMode(), false::next_type(), llvm::salvageDebugInfoImpl(), llvm::AArch64TargetLowering::shouldConvertConstantLoadToIntImm(), simplifyDivRem(), toString(), tryCombineShiftImm(), and llvm::InstCombiner::visitGetElementPtrInst().
Gets maximum signed value of APInt for a specific bit width.
Definition at line 539 of file APInt.h.
References clearBit().
Referenced by llvm::canConstantFoldCallTo(), llvm::cannotBeMaxInLoop(), canonicalizeSaturatedAdd(), llvm::ConstantRange::castOp(), combineHorizontalMinMaxResult(), combineVectorPack(), detectSSatPattern(), getIdentityValueForAtomicOp(), llvm::APSInt::getMaxValue(), GetRangeFromMetadata(), getShiftAmountTyForConstant(), llvm::ConstantRange::getSignedMax(), getSignedOverflowLimitForStep(), isKnownNonZero(), isKnownPredicateExtendIdiom(), isRemainderZero(), LowerFABSorFNEG(), LowerFCOPYSIGN(), magicu(), llvm::fuzzerop::makeConstantsWithType(), makeExactMulNSWRegion(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), minAPInt(), sadd_sat(), setLimitsForBinOp(), setLimitsForIntrinsic(), setLimitsForSelectPattern(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), simplifyX86pack(), smul_sat(), sshl_sat(), ssub_sat(), and truncSSat().
Gets minimum signed value of APInt for a specific bit width.
Definition at line 549 of file APInt.h.
References setBit().
Referenced by llvm::ConstantRange::abs(), BinomialCoefficient(), llvm::canConstantFoldCallTo(), llvm::cannotBeMinInLoop(), canonicalizeSaturatedAdd(), llvm::ConstantRange::castOp(), combineHorizontalMinMaxResult(), combineVectorPack(), detectSSatPattern(), getIdentityValueForAtomicOp(), llvm::APSInt::getMinValue(), GetRangeFromMetadata(), getShiftAmountTyForConstant(), llvm::ConstantRange::getSignedMin(), getSignedOverflowLimitForStep(), isKnownPredicateExtendIdiom(), llvm::ScalarEvolution::isLoopEntryGuardedByCond(), isRemainderZero(), isSupportedGuardInstruction(), LowerMINMAX(), magic(), magicu(), llvm::ConstantRange::makeAllowedICmpRegion(), llvm::fuzzerop::makeConstantsWithType(), makeExactMulNSWRegion(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), minAPInt(), sadd_sat(), llvm::ConstantRange::sdiv(), setLimitsForBinOp(), setLimitsForIntrinsic(), setLimitsForSelectPattern(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), simplifyX86pack(), smul_sat(), sshl_sat(), ssub_sat(), and truncSSat().
Get the SignMask for a specific bit width.
This is just a wrapper function of getSignedMinValue(), and it helps code readability when we want to get a SignMask.
Definition at line 559 of file APInt.h.
Referenced by combineGatherScatter(), combineMaskedStore(), combineX86GatherScatter(), llvm::SelectionDAG::computeKnownBits(), llvm::decomposeBitTestICmp(), foldBitcastedFPLogic(), foldICmpShlOne(), FoldIntToFPToInt(), getDemandedBitsLHSMask(), GetFPLibCall(), LowerFABSorFNEG(), llvm::LegalizerHelper::lowerFCopySign(), LowerFCOPYSIGN(), llvm::LegalizerHelper::lowerFPTOUI(), LowerShift(), lowerUINT_TO_FP_vec(), llvm::RISCVTargetLowering::PerformDAGCombine(), ShrinkDemandedConstant(), llvm::GISelKnownBits::signBitIsZero(), llvm::SelectionDAG::SignBitIsZero(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), tryFoldToZero(), llvm::InstCombiner::visitAShr(), llvm::InstCombiner::visitSDiv(), llvm::InstCombiner::visitShl(), and llvm::InstCombiner::visitSRem().
Return a value containing V broadcasted over NewLen bits.
Definition at line 577 of file APInt.cpp.
References APINT_BITS_PER_WORD, assert(), llvm::countLeadingOnes(), llvm::countLeadingZeros(), llvm::countPopulation(), llvm::countTrailingOnes(), llvm::countTrailingZeros(), llvm::numbers::e, getBitWidth(), getNumWords(), I, llvm::Mod, pVal, WORDTYPE_MAX, and zextOrSelf().
Referenced by FoldIntToFPToInt(), getMemsetValue(), getTargetConstantBitsFromNode(), llvm::LegalizerHelper::lowerBitreverse(), tryToRecognizePopCount(), and visitFMinMax().
|
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 1620 of file APInt.h.
References assert().
Referenced by llvm::DwarfUnit::addConstantValue(), annotateAnyAllocSite(), annotateNonNullAndDereferenceable(), areStridedAccessesIndependent(), calcArraySize(), llvm::canConstantFoldCallTo(), canEvaluateZExtd(), CC_MipsO32_FP64(), checkMDProf(), combineCMP(), combineShiftAnd1ToBitTest(), combineShiftOfShiftedLogic(), llvm::computeExpressionSize(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromShiftOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::computeMinimumValueSizes(), llvm::X86TargetLowering::ComputeNumSignBitsForTargetNode(), ComputeNumSignBitsImpl(), llvm::ConstantFoldLoadFromConstPtr(), ConvertDoubleToBytes(), convertIntToDoubleImm(), llvm::R600TargetLowering::EmitInstrWithCustomInserter(), llvm::Interpreter::exitCalled(), ExtractConstantBytes(), llvm::extractConstantMask(), extractShiftForRotate(), llvm::InstCombiner::FoldShiftByConstant(), foldShiftedShift(), GetBranchWeights(), getComparePred(), llvm::ExecutionEngine::getConstantValue(), llvm::Function::getEntryCount(), getFauxShuffleMask(), llvm::AArch64_AM::getFP16Imm(), llvm::ARM_AM::getFP16Imm(), llvm::AArch64_AM::getFP32Imm(), llvm::ARM_AM::getFP32Imm(), llvm::AArch64_AM::getFP64Imm(), llvm::ARM_AM::getFP64Imm(), getImplicitScaleFactor(), llvm::SystemZTTIImpl::getIntImmCost(), llvm::PPCTTIImpl::getIntImmCost(), llvm::LanaiTTIImpl::getIntImmCost(), llvm::ARMTTIImpl::getIntImmCost(), llvm::SystemZTTIImpl::getIntImmCostInst(), llvm::PPCTTIImpl::getIntImmCostInst(), llvm::X86TTIImpl::getIntImmCostInst(), llvm::SystemZTTIImpl::getIntImmCostIntrin(), llvm::AsmToken::getIntVal(), llvm::ARMTTIImpl::getMemcpyCost(), getNaturalGEPRecursively(), llvm::SelectionDAG::getNode(), getNormalLoadInput(), llvm::getObjectSize(), getOpenCLAlignment(), getOtherIncomingValue(), getRegNum(), getUnsigned(), getVectorSHLImm(), llvm::ConstantInt::getZExtValue(), hasUndefContents(), IncorporateWeight(), llvm::SwitchInstProfUpdateWrapper::init(), INITIALIZE_PASS(), llvm::mca::initializeUsedResources(), insertDAGNode(), isEXTMask(), llvm::AArch64TargetLowering::isFPImmLegal(), isOpcWithIntImmediate(), isRepeatedByteSequence(), llvm::isSafeToLoadUnconditionally(), isStackPtrRelative(), LLVMGenericValueToInt(), lookupFunction(), llvm::HexagonTargetLowering::LowerBITCAST(), LowerBUILD_VECTOR_i1(), llvm::lowerObjectSizeCall(), LowerScalarImmediateShift(), llvm::codeview::CodeViewRecordIO::mapEncodedInteger(), maskMatters(), mayUseP9Setb(), mayUsePostIncMode(), optimizeLogicalImm(), parseHexOcta(), parseIRValue(), parseOptionalLinkageAux(), PerformANDCombine(), llvm::R600TargetLowering::PerformDAGCombine(), llvm::AMDGPUTargetLowering::PerformDAGCombine(), performDSPShiftCombine(), PerformORCombine(), printConstant(), llvm::NVPTXFloatMCExpr::printImpl(), processDbgDeclares(), llvm::ExecutionEngine::runFunctionAsMain(), llvm::PPCTargetLowering::SelectAddressRegImm(), llvm::AVRDAGToDAGISel::SelectInlineAsmMemoryOperand(), shouldUseAndMask(), ShrinkDemandedConstant(), ShrinkLoadReplaceStoreWithStore(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), simplifyDivRem(), simplifyX86extrq(), simplifyX86insertq(), simplifyX86varShift(), AllocaSlices::SliceBuilder::SliceBuilder(), llvm::ARMTargetLowering::targetShrinkDemandedConstant(), toString(), llvm::detail::IEEEFloat::toString(), toString(), tryAdvSIMDModImm16(), tryAdvSIMDModImm32(), tryAdvSIMDModImm321s(), tryAdvSIMDModImm64(), tryAdvSIMDModImm8(), tryAdvSIMDModImmFP(), tryBitfieldInsertOpFromOrAndImm(), tryBuildVectorShuffle(), udivrem(), urem(), llvm::sroa::AllocaSliceRewriter::visit(), llvm::Interpreter::visitAllocaInst(), llvm::Interpreter::visitAShr(), llvm::InstCombiner::visitAShr(), llvm::Interpreter::visitLShr(), llvm::InstCombiner::visitLShr(), llvm::Interpreter::visitShl(), llvm::InstCombiner::visitShl(), llvm::LegalizerHelper::widenScalar(), and WriteConstantInternal().
Insert the bits from a smaller APInt starting at bitPosition.
Definition at line 345 of file APInt.cpp.
References APINT_BITS_PER_WORD, APINT_WORD_SIZE, assert(), clearBit(), getBitWidth(), getRawData(), setBit(), VAL, and WORDTYPE_MAX.
Referenced by llvm::extractConstantMask(), getDemandedSrcElements(), getTargetConstantBitsFromNode(), llvm::BuildVectorSDNode::isConstantSplat(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), and llvm::TargetLowering::SimplifyMultipleUseDemandedBits().
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are both set.
Definition at line 1341 of file APInt.h.
Referenced by aliasSameBasePointerGEPs(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), foldSignedTruncationCheck(), llvm::KnownBits::hasConflict(), isKnownNonEqual(), isKnownNonZero(), ShrinkDemandedConstant(), SimplifyAndInst(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), and visitORCommutative().
|
inline |
Determine if all bits are set.
This checks to see if the value has all bits of the APInt are set or not.
Definition at line 400 of file APInt.h.
Referenced by areUsedBitsDense(), llvm::TargetLowering::BuildSDIV(), clearAssumptionsOfUsers(), combineAnd(), combineX86ShufflesRecursively(), llvm::ConstantFoldBinaryInstruction(), createAndInstr(), llvm::decomposeBitTestICmp(), EltsFromConsecutiveLoads(), llvm::extractConstantMask(), findDemandedEltsByAllUsers(), foldICmpShlOne(), getExactSDiv(), llvm::ARMTTIImpl::getIntImmCostInst(), getTargetConstantBitsFromNode(), llvm::KnownBits::isAllOnes(), llvm::TargetLowering::isConstTrueVal(), llvm::ConstantInt::isMinusOne(), isMultiple(), isPromotedInstructionLegal(), isSelect01(), llvm::isSignBitCheck(), isSignTest(), llvm::PatternMatch::is_all_ones::isValue(), isVectorAllOnes(), llvm::KnownBits::isZero(), LowerBUILD_VECTOR_i1(), lowerVECTOR_SHUFFLE(), makeExactMulNSWRegion(), matchMinMax(), matchShuffleAsEXTRQ(), llvm::ConstantRange::sdiv(), sdiv_ov(), setLimitsForBinOp(), ShrinkDemandedConstant(), ShrinkLoadReplaceStoreWithStore(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), simplifyDivRem(), simplifyShuffleOfShuffle(), tryFoldToZero(), unifyBitWidth(), llvm::RegisterBankInfo::ValueMapping::verify(), llvm::InstCombiner::visitExtractElementInst(), llvm::InstCombiner::visitOr(), and llvm::InstCombiner::visitTrunc().
Check if this APInt has an N-bits unsigned integer value.
Definition at line 454 of file APInt.h.
Referenced by AreMulWideOperandsDemotable(), combineShiftLeft(), combineVectorPack(), llvm::codeview::consume_numeric(), llvm::ScalarEvolution::getUDivExactExpr(), INITIALIZE_PASS(), intToken(), mustBeFiniteCountedLoop(), parseHexOcta(), truncUSat(), and llvm::InstCombiner::visitAnd().
| numBits | ones starting at the least significant bit with the remainder zero. |
Definition at line 499 of file APInt.h.
References assert().
Referenced by combineAndMaskToShift(), combineScalarAndWithMaskSetcc(), combineShiftRightLogical(), detectUSatPattern(), hasSameExtUse(), llvm::PatternMatch::is_lowbit_mask::isValue(), processAnd(), ShrinkDemandedConstant(), simplifyDivRem(), SimplifyOrInst(), llvm::InstCombiner::visitSub(), and widenCtPop().
|
inline |
Definition at line 512 of file APInt.h.
References llvm::isMask_64().
|
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 431 of file APInt.h.
Referenced by foldICmpShlOne(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), llvm::ConstantInt::isMaxValue(), llvm::isSignBitCheck(), llvm::PatternMatch::is_maxsignedvalue::isValue(), matchMinMax(), processUGT_ADDCST_ADD(), and llvm::ScalarEvolution::SimplifyICmpOperands().
|
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 425 of file APInt.h.
Referenced by foldICmpShlOne(), incDecVectorConstant(), llvm::ConstantInt::isMaxValue(), and llvm::ScalarEvolution::SimplifyICmpOperands().
|
inline |
Determine if this is the smallest signed value.
This checks to see if the value of this APInt is the minimum signed value for the APInt's bit width.
Definition at line 447 of file APInt.h.
Referenced by llvm::InstCombiner::commonIRemTransforms(), llvm::ConstantFoldBinaryInstruction(), foldICmpShlOne(), foldNoWrapAdd(), getBinOpsForFactorization(), llvm::ConstantRange::getEquivalentICmp(), isDivZero(), llvm::ConstantInt::isMinValue(), isMultiple(), llvm::isSafeToSpeculativelyExecute(), llvm::isSignBitCheck(), llvm::ConstantRange::isSignWrappedSet(), matchMinMax(), llvm::ConstantRange::multiply(), propagateMetadata(), llvm::ConstantRange::sdiv(), sdiv_ov(), setLimitsForBinOp(), llvm::ConstantRange::signExtend(), SimplifyBSwap(), simplifyDivRem(), llvm::ScalarEvolution::SimplifyICmpOperands(), and llvm::InstCombiner::visitSRem().
|
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 441 of file APInt.h.
Referenced by llvm::InstCombiner::commonIRemTransforms(), foldICmpShlOne(), IncorporateWeight(), isDereferenceableAndAlignedPointer(), llvm::ScalarEvolution::isLoopEntryGuardedByCond(), llvm::ConstantInt::isMinValue(), isSupportedGuardInstruction(), LinearizeExprTree(), llvm::SelectionDAGBuilder::lowerRangeToAssertZExt(), shouldMergeGEPs(), SimplifyBSwap(), and llvm::ScalarEvolution::SimplifyICmpOperands().
|
inline |
Determine sign of this APInt.
This tests the high bit of this APInt to determine if it is set.
Definition at line 363 of file APInt.h.
Referenced by areStridedAccessesIndependent(), llvm::ConstantRange::ashr(), ashrInPlace(), llvm::TargetLowering::BuildSDIV(), combineADDToADDZE(), combineMOVMSK(), combineShiftRightArithmetic(), combineVectorPack(), llvm::SelectionDAG::computeKnownBits(), computePointerICmp(), llvm::ConstantFoldLoadFromConstPtr(), llvm::detail::IEEEFloat::convertFromAPInt(), foldNoWrapAdd(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), genConstMult(), getBitsNeeded(), llvm::ARMTTIImpl::getIntImmCostInst(), getRangeForAffineARHelper(), isDereferenceableAndAlignedPointer(), llvm::ScalarEvolution::isLoopInvariantPredicate(), llvm::APSInt::isNegative(), llvm::ConstantInt::isNegative(), llvm::SCEV::isNonConstantNegative(), isTruePredicate(), llvm::PatternMatch::is_negative::isValue(), llvm::HexagonTargetLowering::LowerSETCC(), magic(), makeExactMulNSWRegion(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), mayUsePostIncMode(), multiplicativeInverse(), operator*=(), processUGT_ADDCST_ADD(), propagateMetadata(), llvm::InstCombiner::replacedSelectWithOperand(), llvm::APIntOps::RoundingSDiv(), sadd_sat(), sdiv(), sdivrem(), setLimitsForBinOp(), setLimitsForIntrinsic(), sext(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), smul_sat(), SolveQuadraticAddRecRange(), llvm::APIntOps::SolveQuadraticEquationWrap(), srem(), sshl_sat(), ssub_sat(), toString(), toString(), truncSSat(), tryFoldToZero(), umul_ov(), and llvm::InstCombiner::visitMul().
|
inline |
Determine if this APInt Value is non-negative (>= 0)
This tests the high bit of the APInt to determine if it is unset.
Definition at line 368 of file APInt.h.
Referenced by llvm::ConstantRange::abs(), annotateNonNullAndDereferenceable(), llvm::ConstantRange::ashr(), llvm::SelectionDAG::computeKnownBits(), detectUSatPattern(), EmitCmp(), llvm::ARMTTIImpl::getIntImmCodeSizeCost(), llvm::ScalarEvolution::isLoopInvariantPredicate(), llvm::PatternMatch::is_nonnegative::isValue(), llvm::ConstantRange::multiply(), performXorCombine(), sadd_ov(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), llvm::APIntOps::SolveQuadraticEquationWrap(), llvm::ConstantRange::srem(), sshl_ov(), llvm::ConstantRange::sshl_sat(), ssub_ov(), truncateIVUse(), llvm::InstCombiner::visitCallInst(), and llvm::InstCombiner::visitGetElementPtrInst().
|
inline |
|
inline |
Determine if all bits are clear.
This checks to see if the value has all bits of the APInt are clear or not.
Definition at line 410 of file APInt.h.
Referenced by bitTrackingDCE(), llvm::canConstantFoldCallTo(), canonicalizeSaturatedAdd(), canWidenShuffleElements(), combineAnd(), combineSetCCAtomicArith(), combineX86ShufflesRecursively(), llvm::InstCombiner::commonIDivTransforms(), llvm::ConstantFoldLoadFromConstPtr(), createAndInstr(), llvm::decomposeBitTestICmp(), EltsFromConsecutiveLoads(), foldAndOrOfEqualityCmpsWithConstants(), foldCttzCtlz(), foldICmpBitCast(), foldICmpShlOne(), foldSelectICmpAnd(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), foldSignedTruncationCheck(), getFauxShuffleMask(), getMulHu(), GetQuadraticEquation(), GetRangeFromMetadata(), incDecVectorConstant(), isMultiple(), isSelect01(), llvm::isSignBitCheck(), isSignTest(), llvm::KnownBits::isStrictlyPositive(), llvm::KnownBits::isUnknown(), llvm::PatternMatch::is_zero_int::isValue(), llvm::ConstantRange::isWrappedSet(), llvm::ConstantInt::isZero(), matchMinMax(), llvm::LegalizerHelper::narrowScalarShiftByConstant(), processUGT_ADDCST_ADD(), llvm::ConstantRange::sdiv(), setLimitsForBinOp(), llvm::ConstantRange::shl(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), simplifyIntrinsic(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), simplifyX86immShift(), llvm::APIntOps::SolveQuadraticEquationWrap(), llvm::ConstantRange::srem(), tryFoldToZero(), llvm::ConstantRange::udiv(), llvm::ConstantRange::unionWith(), llvm::ConstantRange::urem(), llvm::InstCombiner::visitSub(), and llvm::InstCombiner::visitTrunc().
|
inline |
Determine if this is a value of 1.
This checks to see if the value of this APInt is one.
Definition at line 415 of file APInt.h.
Referenced by llvm::TargetLowering::BuildSDIV(), llvm::TargetLowering::BuildUDIV(), llvm::canConstantFoldCallTo(), canonicalizeSaturatedAdd(), foldICmpShlOne(), foldNoWrapAdd(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), llvm::TargetLowering::isConstTrueVal(), llvm::ConstantInt::isOne(), isSelect01(), isSignTest(), llvm::PatternMatch::is_one::isValue(), makeExactMulNSWRegion(), processUGT_ADDCST_ADD(), llvm::InstCombiner::replacedSelectWithOperand(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), simplifyICmpWithBinOp(), tryFoldToZero(), and llvm::InstCombiner::visitAnd().
|
inline |
Check if this APInt's value is a power of two greater than zero.
Definition at line 468 of file APInt.h.
References llvm::isPowerOf2_64().
Referenced by llvm::PPCTargetLowering::BuildSDIVPow2(), combineShiftOfShiftedLogic(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), llvm::createSeparateConstOffsetFromGEPPass(), llvm::decomposeBitTestICmp(), EmitCmp(), foldAndOrOfEqualityCmpsWithConstants(), foldICmpBitCast(), foldICmpShlOne(), foldICmpWithMinMax(), foldSelectICmpAnd(), foldSignedTruncationCheck(), foldUnsignedUnderflowCheck(), genConstMult(), llvm::SystemZTTIImpl::getArithmeticInstrCost(), getBitsNeeded(), getIntToFPVal(), getLogBase2(), getMaskedICmpType(), getParentPad(), llvm::AArch64TargetLowering::isMaskAndCmp0FoldingBeneficial(), isPowerOf2Constant(), isTargetConstant(), llvm::PatternMatch::is_power2::isValue(), llvm::PatternMatch::is_power2_or_zero::isValue(), performMulCombine(), performXorCombine(), PickMostRelevantLoop(), processUGT_ADDCST_ADD(), processUMulZExtIdiom(), llvm::InstCombiner::replacedSelectWithOperand(), ShrinkDemandedConstant(), SimplifyBSwap(), simplifyICmpWithBinOp(), simplifySelectBitTest(), tryBitfieldInsertOpFromOr(), unifyBitWidth(), llvm::InstCombiner::visitAdd(), visitFMinMax(), llvm::InstCombiner::visitMul(), llvm::InstCombiner::visitTrunc(), and llvm::InstCombiner::visitZExt().
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 675 of file APInt.h.
References Arg, getBitWidth(), llvm::hash_value(), and zext().
Referenced by llvm::PatternMatch::specific_intval::match().
|
inline |
Return true if this APInt value contains a sequence of ones with the remainder zero.
Definition at line 521 of file APInt.h.
References llvm::countTrailingZeros(), and llvm::isShiftedMask_64().
Referenced by widenCtPop().
|
inline |
|
inline |
Determine if sign bit of this APInt is set.
This tests the high bit of this APInt to determine if it is set.
Definition at line 375 of file APInt.h.
Referenced by computeKnownBitsFromOperator(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::KnownBits::isStrictlyPositive(), and ShrinkDemandedConstant().
Check if this APInt has an N-bits signed integer value.
Definition at line 460 of file APInt.h.
Referenced by AreMulWideOperandsDemotable(), combineCMP(), combineVectorPack(), EmitCmp(), GetPointerOperand(), INITIALIZE_PASS(), swapMIOperands(), and truncSSat().
|
inline |
Check if the APInt's value is returned by getSignMask.
Definition at line 477 of file APInt.h.
Referenced by foldICmpShlOne(), foldNoWrapAdd(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), getRangeForAffineARHelper(), llvm::PatternMatch::is_sign_mask::isValue(), processUGT_ADDCST_ADD(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), simplifyICmpWithBinOp(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), llvm::InstCombiner::visitAdd(), and llvm::InstCombiner::visitXor().
Check if the APInt consists of a repeated bit pattern.
e.g. 0x01010101 satisfies isSplat(8).
| SplatSizeInBits | The size of the pattern in bits. Must divide bit width without remainder. |
Definition at line 556 of file APInt.cpp.
References assert(), getBitWidth(), and rotl().
Referenced by foldICmpBitCast(), and isRepeatedByteSequence().
|
inline |
Determine if this APInt Value is positive.
This tests if the value of this APInt is positive (> 0). Note that 0 is not a positive value.
Definition at line 390 of file APInt.h.
Referenced by llvm::ConstantRange::abs(), areStridedAccessesIndependent(), llvm::SwitchCG::SwitchLowering::buildBitTests(), llvm::TargetLowering::BuildSDIV(), ComputeNumSignBitsImpl(), EvaluateConstantChrecAtConstant(), foldICmpShlOne(), llvm::ConstantRange::isAllNegative(), llvm::ScalarEvolution::isLoopInvariantPredicate(), llvm::PatternMatch::is_strictlypositive::isValue(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), and llvm::APIntOps::SolveQuadraticEquationWrap().
This operation checks that all bits set in this APInt are also set in RHS.
Definition at line 1349 of file APInt.h.
Referenced by llvm::SelectionDAGISel::CheckAndMask(), llvm::SelectionDAGISel::CheckOrMask(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), foldSignedTruncationCheck(), llvm::SelectionDAG::GetDemandedBits(), llvm::SelectionDAG::getSplatSourceVector(), LowerMUL(), llvm::SelectionDAG::MaskedValueIsAllOnes(), llvm::GISelKnownBits::maskedValueIsZero(), MaskedValueIsZero(), llvm::SelectionDAG::MaskedValueIsZero(), ShrinkDemandedConstant(), llvm::TargetLowering::ShrinkDemandedConstant(), SimplifyAndInst(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), llvm::X86TargetLowering::SimplifyMultipleUseDemandedBitsForTargetNode(), llvm::X86TargetLowering::targetShrinkDemandedConstant(), and widenCtPop().
|
inline |
Definition at line 1805 of file APInt.h.
Referenced by ComputeNumSignBitsImpl(), llvm::createSeparateConstOffsetFromGEPPass(), foldICmpShlOne(), foldICmpWithMinMax(), foldSelectICmpAnd(), foldSelectICmpAndOr(), genConstMult(), getBitsNeeded(), getIntToFPVal(), getLogBase2(), isEXTMask(), isTargetConstant(), llvm::ARMTargetLowering::PerformCMOVCombine(), llvm::ARMTargetLowering::PerformCMOVToBFICombine(), performMulCombine(), PickMostRelevantLoop(), processUMulZExtIdiom(), tryBitfieldInsertOpFromOr(), unifyBitWidth(), llvm::InstCombiner::visitAdd(), and visitFMinMax().
Logical right-shift function.
Logical right-shift this APInt by shiftAmt.
Definition at line 987 of file APInt.h.
References lshrInPlace(), and llvm::RISCVFenceField::R.
Referenced by areUsedBitsDense(), llvm::SparcTargetLowering::bitcastConstantFPToInt(), llvm::TargetLowering::BuildUDIV(), llvm::canConstantFoldCallTo(), combineShiftRightLogical(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), foldICmpShlOne(), foldICmpWithTruncSignExtendedVal(), FoldValue(), llvm::SelectionDAG::getConstant(), getConstVector(), getDemandedSrcElements(), llvm::AArch64_AM::getFP16Imm(), llvm::ARM_AM::getFP16Imm(), llvm::AArch64_AM::getFP32Imm(), llvm::ARM_AM::getFP32Imm(), llvm::AArch64_AM::getFP64Imm(), llvm::ARM_AM::getFP64Imm(), getHiBits(), getHopForBuildVector(), llvm::SelectionDAG::getNode(), llvm::BlockFrequencyInfoImplBase::getProfileCountFromFreq(), isAlwaysLive(), llvm::BuildVectorSDNode::isConstantSplat(), isVMOVModifiedImm(), lowerMSABinaryBitImmIntr(), llvm::ConstantRange::lshr(), magic(), magicu(), llvm::LegalizerHelper::narrowScalar(), llvm::RISCVTargetLowering::PerformDAGCombine(), processUGT_ADDCST_ADD(), rotl(), rotr(), setLimitsForBinOp(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), SolveLinEquationWithOverflow(), stripTruncAndExt(), llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(), umul_ov(), llvm::Interpreter::visitInsertValueInst(), llvm::Interpreter::visitLShr(), llvm::InstCombiner::visitXor(), and widenCtPop().
Logical right-shift function.
Logical right-shift this APInt by shiftAmt.
Definition at line 1036 of file APInt.h.
References lshrInPlace(), and llvm::RISCVFenceField::R.
|
inline |
Logical right-shift this APInt by ShiftAmt in place.
Definition at line 994 of file APInt.h.
References assert().
Referenced by BinomialCoefficient(), byteSwap(), combineShiftOfShiftedLogic(), llvm::SelectionDAG::computeKnownBits(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromAssume(), ConvertDoubleToBytes(), ExtractConstantBytes(), foldBitcastedFPLogic(), llvm::InstCombiner::FoldShiftByConstant(), getDemandedSrcElements(), getUsefulBitsFromBitfieldMoveOpd(), getUsefulBitsFromOrWithShiftedReg(), llvm::APIntOps::GreatestCommonDivisor(), lshr(), lshrInPlace(), PerformSHLSimplify(), reverseBits(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), simplifyX86vpermilvar(), llvm::detail::IEEEFloat::toString(), toString(), and llvm::Interpreter::visitAShr().
Logical right-shift this APInt by ShiftAmt in place.
Logical right-shift this APInt by shiftAmt.
Logical right-shift function.
Definition at line 1034 of file APInt.cpp.
References getLimitedValue(), getNumWords(), lshrInPlace(), and tcShiftRight().
| APInt::ms APInt::magic | ( | ) | const |
Calculate the magic numbers required to implement a signed integer division by a constant as a sequence of multiplies, adds and shifts.
Requires that the divisor not be 0, 1, or -1. Taken from "Hacker's Delight", Henry S. Warren, Jr., chapter 10.
Definition at line 1226 of file APInt.cpp.
References abs(), getBitWidth(), getSignedMinValue(), isNegative(), lshr(), llvm::APInt::ms::m, r1(), r2(), llvm::APInt::ms::s, udiv(), uge(), ult(), and urem().
Referenced by llvm::TargetLowering::BuildSDIV().
Calculate the magic numbers required to implement an unsigned integer division by a constant as a sequence of multiplies, adds and shifts.
Requires that the divisor not be 0. Taken from "Hacker's Delight", Henry S. Warren, Jr., chapter 10. LeadingZeros can be used to simplify the calculation if the upper bits of the divided value are known zero.
Definition at line 1270 of file APInt.cpp.
References llvm::APInt::mu::a, allOnes(), getAllOnesValue(), getBitWidth(), getSignedMaxValue(), getSignedMinValue(), lshr(), llvm::APInt::mu::m, r1(), r2(), llvm::APInt::mu::s, udiv(), uge(), ult(), and urem().
Referenced by llvm::TargetLowering::BuildUDIV().
Computes the multiplicative inverse of this APInt 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 1180 of file APInt.cpp.
References APInt(), assert(), isNegative(), udivrem(), and ult().
Referenced by BinomialCoefficient(), and SolveLinEquationWithOverflow().
Inequality comparison.
Compares this APInt with RHS for the validity of the inequality relationship.
Definition at line 1197 of file APInt.h.
Referenced by llvm::PatternMatch::icmp_pred_with_threshold::isValue().
|
inline |
|
inline |
|
inline |
Negate this APInt in place.
Definition at line 1548 of file APInt.h.
Referenced by foldICmpShlOne(), llvm::operator-(), propagateMetadata(), sdivrem(), llvm::APIntOps::SolveQuadraticEquationWrap(), toString(), and ushl_sat().
|
inline |
|
inline |
|
inline |
|
inline |
Multiplication operator.
Multiplies this APInt by RHS and returns the result.
Definition at line 230 of file APInt.cpp.
References APInt(), assert(), getBitWidth(), getMemory(), getNumWords(), pVal, tcAnd(), tcMultiply(), tcOr(), tcXor(), and VAL.
| APInt & APInt::operator*= | ( | uint64_t | RHS | ) |
Definition at line 261 of file APInt.cpp.
References APINT_BITS_PER_WORD, assert(), llvm::lltok::equal, getNumWords(), isNegative(), pVal, llvm::SignExtend64(), tcCompare(), tcComplement(), tcMultiplyPart(), VAL, and WORDTYPE_MAX.
| APInt & APInt::operator++ | ( | ) |
Prefix increment operator.
Prefix increment operator. Increments the APInt by one.
Definition at line 173 of file APInt.cpp.
References getNumWords(), and tcIncrement().
| APInt & APInt::operator+= | ( | uint64_t | RHS | ) |
Definition at line 202 of file APInt.cpp.
References getNumWords(), and tcAddPart().
| APInt & APInt::operator-- | ( | ) |
Prefix decrement operator.
Prefix decrement operator. Decrements the APInt by one.
Definition at line 182 of file APInt.cpp.
References getNumWords(), and tcDecrement().
Subtraction assignment operator.
Subtracts the RHS APInt from this APInt.
Subtracts RHS from *this and assigns the result to *this.
Definition at line 213 of file APInt.cpp.
References assert(), getNumWords(), pVal, tcSubtract(), and VAL.
| APInt & APInt::operator-= | ( | uint64_t | RHS | ) |
Definition at line 222 of file APInt.cpp.
References getNumWords(), and tcSubtractPart().
Left-shift assignment function.
Shifts *this left by shiftAmt and assigns the result to *this.
Definition at line 921 of file APInt.h.
References assert(), and llvm::operator*().
Left-shift assignment function.
Left-shift this APInt by shiftAmt.
Shifts *this left by shiftAmt and assigns the result to *this.
Left-shift function.
Definition at line 1046 of file APInt.cpp.
References getLimitedValue(), getNumWords(), and tcShiftLeft().
Copy assignment operator.
Definition at line 751 of file APInt.h.
References VAL.
Referenced by llvm::APSInt::operator=().
|
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.
Definition at line 791 of file APInt.h.
References VAL.
|
inline |
Array-indexing support.
Definition at line 1137 of file APInt.h.
References assert(), and getBitWidth().
|
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 882 of file APInt.h.
References llvm::operator+=(), and VAL.
|
inline |
| void APInt::print | ( | raw_ostream & | OS, |
| bool | isSigned | ||
| ) | const |
Definition at line 2299 of file APInt.cpp.
References APINT_BITS_PER_WORD, and toString().
Referenced by emitDebugValueComment(), and llvm::operator<<().
| 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 159 of file APInt.cpp.
References llvm::FoldingSetNodeID::AddInteger(), and getNumWords().
Referenced by llvm::APSInt::Profile().
| APInt APInt::reverseBits | ( | ) | const |
Definition at line 698 of file APInt.cpp.
References APInt(), and lshrInPlace().
Referenced by llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), llvm::SelectionDAG::getNode(), isAlwaysLive(), and llvm::TargetLowering::SimplifyDemandedBits().
Rotate left by rotateAmt.
Definition at line 1074 of file APInt.cpp.
Referenced by llvm::PPCInstrInfo::convertToImmediateForm(), FoldValue(), isSplat(), and rotl().
Rotate left by rotateAmt.
Definition at line 1070 of file APInt.cpp.
References rotateModulo(), and rotl().
Rotate right by rotateAmt.
Definition at line 1081 of file APInt.cpp.
References rotateModulo(), and rotr().
| double APInt::roundToDouble | ( | bool | isSigned | ) | const |
Converts this APInt to a double value.
This function converts this APInt to a double.
| Sign Exponent Fraction Bias |
|---|
| 1[63] 11[62-52] 52[51-00] 1023 |
Definition at line 808 of file APInt.cpp.
References APINT_BITS_PER_WORD, assert(), llvm::bit_cast(), getActiveBits(), I, pVal, sext(), and llvm::SignExtend64().
Referenced by llvm::ExecutionEngine::getConstantValue(), and llvm::APIntOps::RoundAPIntToDouble().
|
inline |
Converts this unsigned APInt to a double value.
Definition at line 1761 of file APInt.h.
References roundToDouble().
Referenced by roundToDouble().
Definition at line 1956 of file APInt.cpp.
References isNonNegative().
Referenced by addWithOverflow(), llvm::canConstantFoldCallTo(), llvm::checkedAdd(), maintainNoSignedWrap(), sadd_sat(), and llvm::InstCombiner::visitCallInst().
Definition at line 2038 of file APInt.cpp.
References getSignedMaxValue(), getSignedMinValue(), isNegative(), and sadd_ov().
Referenced by llvm::canConstantFoldCallTo(), FoldValue(), and llvm::ConstantRange::sadd_sat().
Signed division function for APInt.
Signed divide this APInt by APInt RHS.
The result is rounded towards zero.
Definition at line 1672 of file APInt.cpp.
References isNegative(), and udiv().
Referenced by llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), findGCD(), foldICmpShlOne(), FoldValue(), getConstantPart(), llvm::ExecutionEngine::getConstantValue(), getExactSDiv(), getNaturalGEPRecursively(), getNaturalGEPWithOffset(), isRemainderZero(), minAPInt(), llvm::APIntOps::RoundingSDiv(), llvm::ConstantRange::sdiv(), sdiv_ov(), setLimitsForBinOp(), smul_ov(), llvm::Interpreter::visitBinaryOperator(), and llvm::Interpreter::visitInsertValueInst().
| APInt APInt::sdiv | ( | int64_t | RHS | ) | const |
Definition at line 1683 of file APInt.cpp.
References isNegative(), and udiv().
Definition at line 1982 of file APInt.cpp.
References isAllOnesValue(), isMinSignedValue(), and sdiv().
Referenced by llvm::ConstantFoldLoadFromConstPtr().
|
static |
Definition at line 1918 of file APInt.cpp.
References isNegative(), negate(), and udivrem().
Referenced by ceilingOfQuotient(), findGCD(), floorOfQuotient(), hasHugeExpression(), isMultiple(), llvm::FullDependence::isSplitable(), llvm::APIntOps::RoundingSDiv(), shouldMergeGEPs(), llvm::APIntOps::SolveQuadraticEquationWrap(), and unifyBitWidth().
|
static |
Definition at line 1936 of file APInt.cpp.
References isNegative(), negate(), llvm::RISCVFenceField::R, and udivrem().
|
inline |
Set every bit to 1.
Definition at line 1423 of file APInt.h.
Referenced by computeKnownBits(), llvm::SelectionDAG::computeKnownBits(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), llvm::computeKnownBitsFromRangeMetadata(), computeKnownBitsFromShiftOperator(), numVectorEltsOrZero(), llvm::KnownBits::setAllOnes(), llvm::KnownBits::setAllZero(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), and llvm::ConstantRange::truncate().
|
inline |
Set a given bit to 1.
Set the given bit to 1 whose position is given as "bitPosition".
Definition at line 1436 of file APInt.h.
References assert(), and llvm::BitmaskEnumDetail::Mask().
Referenced by llvm::mca::RegisterFile::addRegisterWrite(), annotateNonNullAndDereferenceable(), llvm::X86_MC::X86MCInstrAnalysis::clearsSuperRegisters(), combineMOVMSK(), combineVectorPack(), combineX86ShuffleChain(), combineX86ShufflesConstants(), combineX86ShufflesRecursively(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), llvm::ComputeMultiple(), llvm::SelectionDAG::ComputeNumSignBits(), ComputeNumSignBitsImpl(), computeZeroableShuffleElements(), EltsFromConsecutiveLoads(), llvm::extractConstantMask(), findDemandedEltsBySingleUser(), flipBit(), getDemandedSrcElements(), getFauxShuffleMask(), getHorizDemandedElts(), getKnownUndefForVectorBinop(), getOneBitSet(), getPackDemandedElts(), getSignedMinValue(), getTargetConstantBitsFromNode(), getTargetShuffleAndZeroables(), llvm::mca::initializeUsedResources(), insertBits(), matchAndOrChain(), resolveZeroablesFromTargetShuffle(), scalarizeExtractedBinop(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), SolveLinEquationWithOverflow(), and llvm::InstCombiner::visitExtractElementInst().
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
This function handles case when loBit <= hiBit.
Definition at line 1466 of file APInt.h.
References assert().
Referenced by llvm::LanaiTargetLowering::computeKnownBitsForTargetNode(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::extractConstantMask(), getBitsSet(), getTargetConstantBitsFromNode(), llvm::BuildVectorSDNode::isConstantSplat(), and llvm::TargetLowering::SimplifyDemandedVectorElts().
|
inline |
Set the top bits starting from loBit.
Definition at line 1485 of file APInt.h.
Referenced by llvm::SelectionDAG::computeKnownBits(), llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), getBitsSetFrom(), ShrinkDemandedConstant(), and llvm::KnownBits::zext().
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
This function handles "wrap" case when loBit > hiBit, and calls setBits when loBit <= hiBit.
Definition at line 1453 of file APInt.h.
References assert().
Referenced by getBitsSetWithWrap().
|
inline |
Set the top hiBits bits.
Definition at line 1495 of file APInt.h.
Referenced by llvm::SelectionDAG::computeKnownBits(), llvm::SITargetLowering::computeKnownBitsForFrameIndex(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), computeKnownBitsMul(), getHighBitsSet(), ShrinkDemandedConstant(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), and llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode().
|
inline |
Set the bottom loBits bits.
Definition at line 1490 of file APInt.h.
Referenced by computeKnownBits(), llvm::SelectionDAG::computeKnownBits(), llvm::GISelKnownBits::computeKnownBitsForAlignment(), llvm::TargetLowering::computeKnownBitsForFrameIndex(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), getLowBitsSet(), hasSameExtUse(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), and llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode().
|
inline |
Set the sign bit to 1.
Definition at line 1446 of file APInt.h.
Referenced by computeKnownBitsFromOperator(), computeSignedMinMaxValuesFromKnownBits(), llvm::ConstantRange::fromKnownBits(), isAlwaysLive(), llvm::KnownBits::makeNegative(), llvm::KnownBits::makeNonNegative(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), and llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode().
Sign extend to a new width.
This operation sign extends the APInt to a new width. If the high order bit is set, the fill on the left will be done with 1 bits, otherwise zero. It is an error to specify a width that is less than or equal to the current width.
Definition at line 913 of file APInt.cpp.
References APInt(), APINT_BITS_PER_WORD, APINT_WORD_SIZE, assert(), getMemory(), getNumWords(), getRawData(), isNegative(), pVal, and llvm::SignExtend64().
Referenced by llvm::ConstantFoldExtOp(), createMCStreamer(), decodeSoppBrTarget(), detectSSatPattern(), foldExtendedSignBitTest(), foldNoWrapAdd(), llvm::ExecutionEngine::getConstantValue(), llvm::getConstantVRegValWithLookThrough(), llvm::AArch64TTIImpl::getIntImmCost(), llvm::X86TTIImpl::getIntImmCost(), getMaxPointerSize(), GetQuadraticEquation(), getRangeForAffineARHelper(), getShiftAmountTyForConstant(), handlePhiDef(), hasHugeExpression(), isObjectSize(), llvm::ConstantRange::multiply(), llvm::RISCVTargetLowering::PerformDAGCombine(), roundToDouble(), llvm::KnownBits::sext(), sextOrSelf(), sextOrTrunc(), shouldMergeGEPs(), llvm::ConstantRange::signExtend(), simplifyX86pack(), llvm::ConstantRange::smul_sat(), llvm::APIntOps::SolveQuadraticEquationWrap(), tryToFoldExtendOfConstant(), unifyBitWidth(), llvm::Interpreter::visitAShr(), and llvm::LegalizerHelper::widenScalar().
Sign extend or truncate to width.
Make this APInt have the bit width given by width. The value is sign extended, or left alone to make it that width.
Definition at line 977 of file APInt.cpp.
References sext().
Referenced by aliasSameBasePointerGEPs(), llvm::canConstantFoldCallTo(), llvm::ConstantRange::castOp(), MinOptional(), and SolveQuadraticAddRecRange().
Sign extend or truncate to width.
Make this APInt have the bit width given by width. The value is sign extended, truncated, or left alone to make it that width.
Definition at line 963 of file APInt.cpp.
References sext(), and trunc().
Referenced by llvm::GEPOperator::accumulateConstantOffset(), llvm::detail::PtrUseVisitorBase::adjustOffsetForGEP(), llvm::canConstantFoldCallTo(), llvm::TargetTransformInfoImplCRTPBase< AMDGPUTTIImpl >::getGEPCost(), llvm::AArch64TTIImpl::getIntImmCost(), llvm::X86TTIImpl::getIntImmCost(), llvm::RISCVMatInt::getIntMatCost(), getMaxPointerSize(), llvm::SelectionDAG::getNode(), llvm::isConsecutiveAccess(), isDereferenceableAndAlignedPointer(), propagateMetadata(), AllocaSlices::SliceBuilder::SliceBuilder(), llvm::APIntOps::SolveQuadraticEquationWrap(), llvm::Value::stripAndAccumulateConstantOffsets(), and stripAndComputeConstantOffsets().
Signed greater or equal comparison.
Regards both *this and RHS as signed quantities and compares them for validity of the greater-or-equal relationship.
Definition at line 1329 of file APInt.h.
Referenced by aliasSameBasePointerGEPs(), canonicalizeSaturatedAdd(), llvm::ConstantFoldCompareInstruction(), foldNoWrapAdd(), FoldValue(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), hasSingleUsesFromRoot(), llvm::PatternMatch::icmp_pred_with_threshold::isValue(), minMaxOpcToMin3Max3Opc(), and TryMULWIDECombine().
|
inline |
Signed greater than comparison.
Regards both *this and RHS as signed quantities and compares them for the validity of the greater-than relationship.
Definition at line 1294 of file APInt.h.
Referenced by aliasSameBasePointerGEPs(), canonicalizeSaturatedAdd(), ceilingOfQuotient(), llvm::ConstantFoldCompareInstruction(), floorOfQuotient(), foldICmpBitCast(), foldUnsignedUnderflowCheck(), llvm::BasicTTIImplBase< AMDGPUTTIImpl >::getEstimatedNumberOfCaseClusters(), isContiguous(), isRemainderZero(), llvm::FullDependence::isSplitable(), llvm::PatternMatch::icmp_pred_with_threshold::isValue(), matchClamp(), maxAPInt(), minAPInt(), setLimitsForBinOp(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), llvm::APIntOps::smax(), llvm::APIntOps::SolveQuadraticEquationWrap(), SwitchToLookupTable(), and llvm::ObjectSizeOffsetVisitor::visitSelectInst().
|
inline |
Left-shift function.
Left-shift this APInt by shiftAmt.
Definition at line 1009 of file APInt.h.
References llvm::RISCVFenceField::R.
Referenced by llvm::canConstantFoldCallTo(), combineShiftAnd1ToBitTest(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::ConstantFoldBinaryInstruction(), convertShiftLeftToScale(), foldICmpShlOne(), foldICmpWithTruncSignExtendedVal(), foldSignedTruncationCheck(), getRangeForAffineARHelper(), isAlwaysLive(), llvm::SelectionDAG::isSplatValue(), processUGT_ADDCST_ADD(), rotl(), rotr(), setLimitsForBinOp(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), sqrt(), stripTruncAndExt(), llvm::Interpreter::visitInsertValueInst(), and llvm::Interpreter::visitShl().
Left-shift function.
Left-shift this APInt by shiftAmt.
Definition at line 1048 of file APInt.h.
References llvm::RISCVFenceField::R, and umul_ov().
|
inline |
Converts this signed APInt to a double value.
Definition at line 1764 of file APInt.h.
Referenced by llvm::ExecutionEngine::getConstantValue(), llvm::APIntOps::RoundSignedAPIntToDouble(), and llvm::APIntOps::RoundSignedAPIntToFloat().
Signed less or equal comparison.
Regards both *this and RHS as signed quantities and compares them for validity of the less-or-equal relationship.
Definition at line 1259 of file APInt.h.
Referenced by canonicalizeSaturatedAdd(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::ConstantFoldCompareInstruction(), FoldValue(), isSignedMinMaxClamp(), llvm::PatternMatch::icmp_pred_with_threshold::isValue(), minAPInt(), propagateMetadata(), llvm::InstCombiner::replacedSelectWithOperand(), and llvm::APIntOps::SolveQuadraticEquationWrap().
|
inline |
Signed less than comparison.
Regards both *this and RHS as signed quantities and compares them for validity of the less-than relationship.
Definition at line 1224 of file APInt.h.
Referenced by aliasSameBasePointerGEPs(), llvm::SwitchCG::SwitchLowering::buildBitTests(), llvm::SwitchCG::SwitchLowering::buildJumpTable(), canonicalizeSaturatedAdd(), ceilingOfQuotient(), llvm::ConstantFoldCompareInstruction(), findGCD(), floorOfQuotient(), getBoundsCheckCond(), llvm::BasicTTIImplBase< AMDGPUTTIImpl >::getEstimatedNumberOfCaseClusters(), llvm::MDNode::getMostGenericRange(), hasSingleUsesFromRoot(), llvm::FullDependence::isSplitable(), llvm::PatternMatch::icmp_pred_with_threshold::isValue(), matchClamp(), minAPInt(), MinOptional(), llvm::ConstantRange::multiply(), llvm::InstCombiner::replacedSelectWithOperand(), llvm::ConstantRange::signedAddMayOverflow(), llvm::ConstantRange::signedSubMayOverflow(), SimplifyBSwap(), llvm::APIntOps::smin(), llvm::ConstantRange::smul_sat(), llvm::SwitchCG::sortAndRangeify(), SwitchToLookupTable(), TryMULWIDECombine(), and llvm::ObjectSizeOffsetVisitor::visitSelectInst().
|
inline |
Definition at line 1988 of file APInt.cpp.
References sdiv().
Referenced by llvm::canConstantFoldCallTo(), llvm::checkedMul(), multiplyOverflows(), MulWillOverflow(), and smul_sat().
Definition at line 2076 of file APInt.cpp.
References getSignedMaxValue(), getSignedMinValue(), isNegative(), and smul_ov().
| APInt APInt::sqrt | ( | ) | const |
Function for signed remainder operation.
Signed remainder operation on APInt.
Definition at line 1764 of file APInt.cpp.
References isNegative(), and urem().
Referenced by llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), findGCD(), FoldValue(), getConstantPart(), llvm::ExecutionEngine::getConstantValue(), getExactSDiv(), GetPointerOperand(), isRemainderZero(), llvm::APIntOps::SolveQuadraticEquationWrap(), llvm::Interpreter::visitBinaryOperator(), and llvm::Interpreter::visitInsertValueInst().
| int64_t APInt::srem | ( | int64_t | RHS | ) | const |
Definition at line 1775 of file APInt.cpp.
References isNegative(), and urem().
Definition at line 2015 of file APInt.cpp.
References APInt(), countLeadingOnes(), countLeadingZeros(), getBitWidth(), isNonNegative(), and uge().
Referenced by sshl_sat().
Definition at line 2098 of file APInt.cpp.
References getSignedMaxValue(), getSignedMinValue(), isNegative(), and sshl_ov().
Referenced by llvm::ConstantRange::sshl_sat().
Definition at line 1969 of file APInt.cpp.
References isNonNegative().
Referenced by llvm::canConstantFoldCallTo(), llvm::checkedSub(), foldICmpShlOne(), maintainNoSignedWrap(), ssub_sat(), and subWithOverflow().
Definition at line 2057 of file APInt.cpp.
References getSignedMaxValue(), getSignedMinValue(), isNegative(), and ssub_ov().
Referenced by llvm::canConstantFoldCallTo(), FoldValue(), and llvm::ConstantRange::ssub_sat().
|
static |
DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag.
Definition at line 2450 of file APInt.cpp.
References assert().
Referenced by operator+=(), and llvm::detail::IEEEFloat::~IEEEFloat().
|
static |
DST += RHS. Returns the carry flag.
This function adds a single "word" integer, src, to the multiple "word" integer array, dst[].
dst[] is modified to reflect the addition and 1 is returned if there is a carry out, otherwise 0 is returned.
Definition at line 2472 of file APInt.cpp.
Referenced by operator+=().
The obvious AND, OR and XOR and complement operations.
Definition at line 2765 of file APInt.cpp.
Referenced by operator*().
Assign one bignum to another.
Definition at line 2356 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::convertFromSignExtendedInteger(), llvm::detail::IEEEFloat::makeNaN(), llvm::powerOf5(), tcDivide(), tcExtract(), llvm::writeSignedDecimal(), and llvm::detail::IEEEFloat::~IEEEFloat().
Clear the given bit of a bignum. Zero-based.
Definition at line 2381 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::makeNaN().
Comparison (unsigned) of two bignums.
Definition at line 2789 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::compareAbsoluteValue(), operator*=(), tcDivide(), and llvm::detail::IEEEFloat::~IEEEFloat().
Definition at line 2783 of file APInt.cpp.
Referenced by operator*=(), and tcNegate().
Decrement a bignum in-place. Return the borrow flag.
Definition at line 1998 of file APInt.h.
References bits, and llvm::dump().
Referenced by llvm::detail::IEEEFloat::next(), and operator--().
|
static |
If RHS is zero LHS and REMAINDER are left unchanged, return one.
Otherwise set LHS to LHS / RHS with the fractional part discarded, set REMAINDER to the remainder, return zero. i.e.
OLD_LHS = RHS * LHS + REMAINDER
SCRATCH is a bignum of the same size as the operands and result for use by the routine; its contents need not be initialized and are destroyed. LHS, REMAINDER and SCRATCH must be distinct.
Definition at line 2670 of file APInt.cpp.
References APINT_BITS_PER_WORD, assert(), llvm::ScaledNumbers::compare(), tcAssign(), tcCompare(), tcMSB(), tcSet(), tcShiftLeft(), tcShiftRight(), and tcSubtract().
|
static |
Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to DST, of dstCOUNT parts, such that the bit srcLSB becomes the least significant bit of DST.
All high bits above srcBITS in DST are zero-filled.
Definition at line 2420 of file APInt.cpp.
References APINT_BITS_PER_WORD, assert(), lowBitMask(), tcAssign(), and tcShiftRight().
Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::convertFromZeroExtendedInteger(), and llvm::detail::IEEEFloat::convertToInteger().
Extract the given bit of a bignum; returns 0 or 1. Zero-based.
Definition at line 2371 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::compareAbsoluteValue(), llvm::detail::IEEEFloat::convertFromSignExtendedInteger(), llvm::detail::IEEEFloat::convertFromZeroExtendedInteger(), llvm::detail::IEEEFloat::isDenormal(), llvm::detail::IEEEFloat::isSignaling(), and llvm::lostFractionThroughTruncation().
|
static |
DST = LHS * RHS, where DST has width the sum of the widths of the operands.
No overflow occurs. DST must be disjoint from both operands.
Definition at line 2645 of file APInt.cpp.
References assert(), tcMultiplyPart(), and tcSet().
Referenced by llvm::powerOf5(), and llvm::detail::IEEEFloat::~IEEEFloat().
Increment a bignum in-place. Return the carry flag.
Definition at line 1993 of file APInt.h.
Referenced by llvm::detail::IEEEFloat::convert(), operator++(), tcNegate(), and llvm::detail::IEEEFloat::~IEEEFloat().
Returns true if a bignum is zero, false otherwise.
Definition at line 2362 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::makeNaN(), and llvm::detail::IEEEFloat::~IEEEFloat().
Returns the bit number of the least or most significant set bit of a number.
If the input number has no bits set -1U is returned.
Definition at line 2387 of file APInt.cpp.
References APINT_BITS_PER_WORD, and partLSB().
Referenced by llvm::detail::IEEEFloat::convert(), llvm::lostFractionThroughTruncation(), and llvm::detail::IEEEFloat::~IEEEFloat().
Definition at line 2401 of file APInt.cpp.
References APINT_BITS_PER_WORD, and partMSB().
Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::convertToInteger(), tcDivide(), and llvm::detail::IEEEFloat::~IEEEFloat().
|
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 2629 of file APInt.cpp.
References assert(), tcMultiplyPart(), and tcSet().
Referenced by operator*().
|
static |
DST += SRC * MULTIPLIER + PART if add is true DST = SRC * MULTIPLIER + PART if add is false.
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.
Definition at line 2540 of file APInt.cpp.
References APINT_BITS_PER_WORD, assert(), highHalf(), and lowHalf().
Referenced by operator*=(), tcFullMultiply(), and tcMultiply().
Negate a bignum in-place.
Definition at line 2524 of file APInt.cpp.
References tcComplement(), and tcIncrement().
Referenced by llvm::detail::IEEEFloat::convert(), and llvm::detail::IEEEFloat::convertFromSignExtendedInteger().
Definition at line 2771 of file APInt.cpp.
Referenced by operator*().
Sets the least significant part of a bignum to the input value, and zeroes out higher parts.
Definition at line 2347 of file APInt.cpp.
References assert().
Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::makeInf(), llvm::detail::IEEEFloat::makeNaN(), llvm::detail::IEEEFloat::makeSmallest(), llvm::detail::IEEEFloat::makeZero(), llvm::detail::IEEEFloat::next(), tcDivide(), tcFullMultiply(), tcMultiply(), and llvm::detail::IEEEFloat::~IEEEFloat().
Set the given bit of a bignum. Zero-based.
Definition at line 2376 of file APInt.cpp.
Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::makeNaN(), llvm::detail::IEEEFloat::makeQuiet(), llvm::detail::IEEEFloat::next(), and llvm::detail::IEEEFloat::~IEEEFloat().
Set the least significant BITS and clear the rest.
Definition at line 2802 of file APInt.cpp.
References APINT_BITS_PER_WORD.
Referenced by llvm::detail::IEEEFloat::compareAbsoluteValue(), and llvm::detail::IEEEFloat::convertToInteger().
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 2712 of file APInt.cpp.
References APINT_BITS_PER_WORD, and APINT_WORD_SIZE.
Referenced by llvm::detail::IEEEFloat::convert(), llvm::detail::IEEEFloat::convertToInteger(), operator<<=(), tcDivide(), and llvm::detail::IEEEFloat::~IEEEFloat().
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 2739 of file APInt.cpp.
References APINT_BITS_PER_WORD, and APINT_WORD_SIZE.
Referenced by lshrInPlace(), llvm::shiftRight(), tcDivide(), and tcExtract().
|
static |
DST -= RHS + CARRY where CARRY is zero or one. Returns the carry flag.
Definition at line 2485 of file APInt.cpp.
References assert().
Referenced by operator-=(), tcDivide(), and llvm::detail::IEEEFloat::~IEEEFloat().
|
static |
DST -= RHS. Returns the carry flag.
This function subtracts a single "word" (64-bit word), src, from the multi-word integer array, dst[], propagating the borrowed 1 value until no further borrowing is needed or it runs out of "words" in dst.
The result is 1 if "borrowing" exhausted the digits in dst, or 0 if dst was not exhausted. In other words, if src > dst then this function returns 1, otherwise 0.
Definition at line 2510 of file APInt.cpp.
Referenced by operator-=().
Definition at line 2777 of file APInt.cpp.
Referenced by operator*().
| void APInt::toString | ( | SmallVectorImpl< char > & | Str, |
| unsigned | Radix, | ||
| bool | Signed, | ||
| bool | formatAsCLiteral = false |
||
| ) | const |
Converts an APInt to a string and append it to Str.
Str is commonly a SmallString.
Definition at line 2168 of file APInt.cpp.
References llvm::SmallVectorImpl< T >::append(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::sys::path::end(), llvm::SmallVectorTemplateCommon< T, typename >::end(), getBoolValue(), getRawData(), getSExtValue(), getZExtValue(), I, isNegative(), llvm_unreachable, lshrInPlace(), N, negate(), llvm::cl::Prefix, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::reverse(), llvm::SmallVectorBase::size(), and udivrem().
Referenced by APIntToHexString(), llvm::GISelKnownBits::computeKnownBitsImpl(), print(), llvm::APSInt::toString(), and toString().
Return the APInt as a std::string.
Returns the APInt as a std::string.
Note that this is an inefficient method. It is better to pass in a SmallVector/SmallString to the methods above to avoid thrashing the heap for the string.
Note that this is an inefficient method. It is better to pass in a SmallVector/SmallString to the methods above.
Definition at line 2283 of file APInt.cpp.
References Signed, llvm::SmallString< InternalLen >::str(), and toString().
|
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 1739 of file APInt.h.
References llvm::reverseBits(), and llvm::toString().
Referenced by dump().
|
inline |
Considers the APInt to be unsigned and converts it into a string in the radix given.
The radix can be 2, 8, 10 16, or 36.
Definition at line 1733 of file APInt.h.
References llvm::toString().
Referenced by dump().
Truncate to new width.
Truncate the APInt to a specified width. It is an error to specify a width that is greater than or equal to the current width.
Definition at line 865 of file APInt.cpp.
References APInt(), APINT_BITS_PER_WORD, assert(), bits, getMemory(), getNumWords(), getRawData(), and pVal.
Referenced by llvm::APSInt::APSInt(), areUsedBitsDense(), BinomialCoefficient(), combineShiftAnd1ToBitTest(), combineVectorPack(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::ConstantFoldExtOp(), ExtractConstantBytes(), extractConstantWithoutWrapping(), foldBitcastedFPLogic(), foldICmpBitCast(), foldICmpShlOne(), foldNoWrapAdd(), llvm::ExecutionEngine::getConstantValue(), llvm::getConstantVRegValWithLookThrough(), getConstVector(), llvm::SelectionDAG::GetDemandedBits(), getDemandedSrcElements(), llvm::SelectionDAG::getNode(), getRangeForAffineARHelper(), llvm::detail::IEEEFloat::IEEEFloat(), INITIALIZE_PASS(), isAlwaysLive(), llvm::BuildVectorSDNode::isConstantSplat(), llvm::TargetLowering::isConstTrueVal(), isObjectSize(), isVMOVModifiedImm(), lowerMSABinaryBitImmIntr(), llvm::LegalizerHelper::narrowScalar(), llvm::RISCVTargetLowering::PerformDAGCombine(), processUMulZExtIdiom(), propagateMetadata(), sextOrTrunc(), shouldMergeGEPs(), ShrinkDemandedConstant(), ShrinkLoadReplaceStoreWithStore(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), simplifyDivRem(), SolveLinEquationWithOverflow(), llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(), llvm::APSInt::trunc(), llvm::KnownBits::trunc(), llvm::ConstantRange::truncate(), TruncIfPossible(), truncSSat(), truncUSat(), llvm::Interpreter::visitAShr(), llvm::InstCombiner::visitTrunc(), and zextOrTrunc().
Truncate to new width with signed saturation.
If this APInt, treated as signed integer, can be losslessly truncated to the new bitwidth, then return truncated APInt. Else, return either signed min value if the APInt was negative, or signed max value.
Definition at line 900 of file APInt.cpp.
References assert(), getSignedMaxValue(), getSignedMinValue(), isNegative(), isSignedIntN(), and trunc().
Definition at line 1963 of file APInt.cpp.
References ult().
Referenced by addWithOverflow(), llvm::canConstantFoldCallTo(), llvm::checkedAddUnsigned(), llvm::SelectionDAG::computeOverflowKind(), uadd_sat(), and llvm::InstCombiner::visitCallInst().
Definition at line 2048 of file APInt.cpp.
References getMaxValue(), and uadd_ov().
Referenced by llvm::canConstantFoldCallTo(), llvm::computeExpressionSize(), FoldValue(), llvm::ConstantRange::uadd_sat(), and llvm::InstCombiner::visitCallInst().
Unsigned division operation.
Perform an unsigned divide operation on this APInt by RHS. Both this and RHS are treated as unsigned quantities for purposes of this division.
Definition at line 1601 of file APInt.cpp.
References APInt(), assert(), getActiveBits(), getNumWords(), pVal, ult(), and VAL.
Referenced by llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), foldICmpShlOne(), FoldValue(), llvm::ExecutionEngine::getConstantValue(), llvm::detail::IEEEFloat::IEEEFloat(), magic(), magicu(), propagateMetadata(), llvm::APIntOps::RoundingUDiv(), sdiv(), llvm::BlockFrequencyInfo::setBlockFreqAndScale(), setLimitsForBinOp(), llvm::APIntOps::SolveQuadraticEquationWrap(), sqrt(), llvm::ConstantRange::udiv(), llvm::Interpreter::visitBinaryOperator(), and llvm::Interpreter::visitInsertValueInst().
| APInt APInt::udiv | ( | uint64_t | RHS | ) | const |
Definition at line 1639 of file APInt.cpp.
References APInt(), assert(), getActiveBits(), getNumWords(), pVal, and ult().
|
static |
Dual division/remainder interface.
Sometimes it is convenient to divide two APInt values and obtain both the quotient and remainder. This function does both operations in the same computation making it a little more efficient. The pair of input arguments may overlap with the pair of output arguments. It is safe to call udivrem(X, Y, X, Y), for example.
Definition at line 1786 of file APInt.cpp.
References APInt(), APINT_WORD_SIZE, assert(), getActiveBits(), getNumWords(), pVal, ult(), and VAL.
Referenced by extractShiftForRotate(), isMultiple(), multiplicativeInverse(), llvm::APIntOps::RoundingUDiv(), sdivrem(), llvm::detail::IEEEFloat::toString(), and toString().
|
static |
Definition at line 1857 of file APInt.cpp.
References APInt(), APINT_WORD_SIZE, assert(), getActiveBits(), getNumWords(), getZExtValue(), pVal, ult(), and VAL.
Unsigned greater or equal comparison.
Regards both *this and RHS as unsigned quantities and compares them for validity of the greater-or-equal relationship.
Definition at line 1313 of file APInt.h.
Referenced by aliasSameBasePointerGEPs(), canonicalizeSaturatedAdd(), combineShiftAnd1ToBitTest(), combineShiftOfShiftedLogic(), computeKnownBitsFromShiftOperator(), llvm::X86TargetLowering::ComputeNumSignBitsForTargetNode(), ComputeNumSignBitsImpl(), llvm::ConstantFoldCompareInstruction(), llvm::ConstantFoldLoadFromConstPtr(), detectUSatPattern(), ExtractConstantBytes(), foldICmpBitCast(), llvm::InstCombiner::FoldShiftByConstant(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), FoldValue(), GetLoopInvariantInsertPosition(), getNaturalGEPRecursively(), getRangeForAffineARHelper(), getValidMaximumShiftAmountConstant(), getValidMinimumShiftAmountConstant(), llvm::PatternMatch::icmp_pred_with_threshold::isValue(), LowerScalarImmediateShift(), magic(), magicu(), MergeAliasResults(), minMaxOpcToMin3Max3Opc(), reduceBuildVecToShuffleWithZero(), ShrinkDemandedConstant(), SimplifyLShrInst(), simplifyX86immShift(), simplifyX86varShift(), AllocaSlices::SliceBuilder::SliceBuilder(), sshl_ov(), llvm::ConstantInt::uge(), llvm::ConstantRange::unionWith(), ushl_ov(), and llvm::InstCombiner::visitTrunc().
|
inline |
Unsigned greater than comparison.
Regards both *this and RHS as unsigned quantities and compares them for the validity of the greater-than relationship.
Definition at line 1275 of file APInt.h.
Referenced by canonicalizeSaturatedAdd(), llvm::FunctionComparator::cmpAPInts(), llvm::ConstantFoldCompareInstruction(), detectAVGPattern(), extractShiftForRotate(), foldAndOrOfEqualityCmpsWithConstants(), foldICmpShlOne(), foldICmpWithTruncSignExtendedVal(), foldSelectICmpAnd(), foldSignedTruncationCheck(), foldUnsignedUnderflowCheck(), GenerateSignBits(), getOtherIncomingValue(), llvm::APIntOps::GreatestCommonDivisor(), hasSameExtUse(), llvm::ConstantRange::isSizeLargerThan(), llvm::PatternMatch::icmp_pred_with_threshold::isValue(), matchClamp(), llvm::LegalizerHelper::narrowScalarShiftByConstant(), llvm::ConstantRange::shl(), llvm::TargetLowering::SimplifyDemandedVectorElts(), simplifyDivRem(), AllocaSlices::SliceBuilder::SliceBuilder(), llvm::ConstantRange::srem(), llvm::APIntOps::umax(), llvm::ConstantRange::unionWith(), llvm::ConstantRange::unsignedAddMayOverflow(), ushl_ov(), usub_ov(), llvm::ObjectSizeOffsetVisitor::visitCallSite(), and llvm::InstCombiner::visitLShr().
|
inline |
Unsigned less or equal comparison.
Regards both *this and RHS as unsigned quantities and compares them for validity of the less-or-equal relationship.
Definition at line 1243 of file APInt.h.
References llvm::ScaledNumbers::compare().
Referenced by annotateNonNullAndDereferenceable(), canonicalizeSaturatedAdd(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::ConstantFoldCompareInstruction(), llvm::ConstantRange::contains(), ExtractConstantBytes(), foldICmpBitCast(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), FoldValue(), getValidMinimumShiftAmountConstant(), llvm::ConstantRange::intersectWith(), llvm::SelectionDAG::isSplatValue(), isTruePredicate(), llvm::PatternMatch::icmp_pred_with_threshold::isValue(), llvm::AMDGPUTargetLowering::performTruncateCombine(), processAnd(), llvm::InstCombiner::replacedSelectWithOperand(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::TargetLowering::SimplifyDemandedVectorElts(), sqrt(), llvm::ConstantRange::unionWith(), and llvm::InstCombiner::visitGetElementPtrInst().
|
inline |
Unsigned less than comparison.
Regards both *this and RHS as unsigned quantities and compares them for the validity of the less-than relationship.
Definition at line 1205 of file APInt.h.
References llvm::ScaledNumbers::compare().
Referenced by aliasSameBasePointerGEPs(), calculateOffsetDiff(), canonicalizeSaturatedAdd(), combineCMP(), combineShiftOfShiftedLogic(), llvm::SelectionDAG::computeKnownBits(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::SelectionDAG::ComputeNumSignBits(), computePointerICmp(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldCompareInstruction(), ConstantIntSortPredicate(), llvm::ConstantRange::contains(), detectAVGPattern(), foldICmpBitCast(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), llvm::ScalarEvolution::getAddExpr(), getRangeForAffineARHelper(), getValidShiftAmountConstant(), hasSingleUsesFromRoot(), IncorporateWeight(), llvm::ConstantRange::intersectWith(), isSafePHIToSpeculate(), llvm::PatternMatch::icmp_pred_with_threshold::isValue(), magic(), magicu(), matchClamp(), multiplicativeInverse(), propagateMetadata(), llvm::InstCombiner::reassociateShiftAmtsOfTwoSameDirectionShifts(), llvm::InstCombiner::replacedSelectWithOperand(), setBranchWeights(), setLimitsForBinOp(), ShrinkDemandedConstant(), SimplifyBSwap(), simplifyDivRem(), sqrt(), llvm::ConstantRange::truncate(), uadd_ov(), udiv(), udivrem(), llvm::APIntOps::umin(), umul_ov(), llvm::ConstantRange::unionWith(), llvm::ConstantRange::unsignedSubMayOverflow(), llvm::ConstantRange::urem(), urem(), llvm::InstCombiner::visitAShr(), llvm::InstCombiner::visitLShr(), and llvm::InstCombiner::visitTrunc().
|
inline |
Definition at line 1998 of file APInt.cpp.
References countLeadingZeros(), isNegative(), lshr(), and ult().
Referenced by annotateAnyAllocSite(), llvm::canConstantFoldCallTo(), llvm::checkedMulUnsigned(), llvm::ScalarEvolution::getUDivExpr(), multiplyOverflows(), MulWillOverflow(), simplifyDiv(), umul_sat(), llvm::ConstantRange::unsignedMulMayOverflow(), llvm::ObjectSizeOffsetVisitor::visitAllocaInst(), and llvm::ObjectSizeOffsetVisitor::visitCallSite().
Definition at line 2089 of file APInt.cpp.
References getMaxValue(), and umul_ov().
Referenced by llvm::ConstantRange::umul_sat().
Unsigned remainder operation.
Perform an unsigned remainder operation on this APInt with RHS being the divisor. Both this and RHS are treated as unsigned quantities for purposes of this operation. 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 1694 of file APInt.cpp.
References APInt(), assert(), getActiveBits(), getNumWords(), pVal, ult(), and VAL.
Referenced by llvm::canConstantFoldCallTo(), computeKnownBitsFromOperator(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldBinOp(), FoldValue(), llvm::ExecutionEngine::getConstantValue(), GetPointerOperand(), llvm::ScalarEvolution::getUDivExpr(), isAlwaysLive(), isDereferenceableAndAlignedPointer(), LowerFunnelShift(), magic(), magicu(), propagateMetadata(), rotateModulo(), ShrinkDemandedConstant(), simplifyIntrinsic(), llvm::APIntOps::SolveQuadraticEquationWrap(), srem(), llvm::Interpreter::visitBinaryOperator(), and llvm::Interpreter::visitInsertValueInst().
| uint64_t APInt::urem | ( | uint64_t | RHS | ) | const |
Definition at line 1732 of file APInt.cpp.
References assert(), getActiveBits(), getNumWords(), getZExtValue(), and ult().
Definition at line 2028 of file APInt.cpp.
References APInt(), countLeadingZeros(), getBitWidth(), uge(), and ugt().
Referenced by ushl_sat(), and llvm::InstCombiner::visitUDiv().
Definition at line 2108 of file APInt.cpp.
References assert(), llvm::StringRef::begin(), llvm::numbers::e, llvm::StringRef::empty(), llvm::StringRef::end(), llvm::AMDGPU::HSAMD::fromString(), getClearedMemory(), getDigit(), getMaxValue(), getNumWords(), negate(), llvm::StringRef::size(), and ushl_ov().
Referenced by llvm::ConstantRange::ushl_sat().
Definition at line 1976 of file APInt.cpp.
References ugt().
Referenced by llvm::canConstantFoldCallTo(), foldICmpShlOne(), subWithOverflow(), and usub_sat().
Definition at line 2067 of file APInt.cpp.
References APInt(), and usub_ov().
Referenced by llvm::canConstantFoldCallTo(), FoldValue(), and llvm::ConstantRange::usub_sat().
Zero extend to a new width.
This operation zero extends the APInt to a new width. The high order bits are filled with 0 bits. It is an error to specify a width that is less than or equal to the current width.
Definition at line 937 of file APInt.cpp.
References APInt(), APINT_BITS_PER_WORD, APINT_WORD_SIZE, assert(), getMemory(), getNumWords(), getRawData(), and pVal.
Referenced by BinomialCoefficient(), llvm::SelectionDAG::computeKnownBits(), llvm::decomposeBitTestICmp(), detectSSatPattern(), eliminateDeadStores(), ExtendUsesToFormExtLoad(), extractConstantWithoutWrapping(), foldBitcastedFPLogic(), foldICmpWithMinMax(), foldSignedTruncationCheck(), foldUnsignedUnderflowCheck(), gcd(), GenerateSignBits(), llvm::StringRef::getAsInteger(), llvm::ExecutionEngine::getConstantValue(), llvm::getConstantVRegValWithLookThrough(), getMulHu(), getRangeForAffineARHelper(), getShiftAmountTyForConstant(), handlePhiDef(), isAlwaysLive(), isSameValue(), llvm::ConstantRange::multiply(), llvm::PPCTargetLowering::PerformDAGCombine(), processUGT_ADDCST_ADD(), processUMulZExtIdiom(), propagateMetadata(), rotateModulo(), ShrinkDemandedConstant(), llvm::ConstantRange::signExtend(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), SolveLinEquationWithOverflow(), llvm::detail::IEEEFloat::toString(), llvm::LegalizationArtifactCombiner::tryCombineZExt(), tryToFoldExtendOfConstant(), llvm::Interpreter::visitAShr(), widenCtPop(), llvm::LegalizerHelper::widenScalar(), llvm::ConstantRange::zeroExtend(), llvm::KnownBits::zext(), zextOrSelf(), and zextOrTrunc().
Zero extend or truncate to width.
Make this APInt have the bit width given by width. The value is zero extended, or left alone to make it that width.
Definition at line 971 of file APInt.cpp.
References zext().
Referenced by llvm::ConstantRange::castOp(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), getSplat(), INITIALIZE_PASS(), isObjectSize(), isObjectSizeLessThanOrEq(), llvm::SelectionDAG::isSplatValue(), propagateMetadata(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::SystemZVectorConstantInfo::SystemZVectorConstantInfo(), llvm::ObjectSizeOffsetVisitor::visitCallSite(), and zeroExtendToMatch().
Zero extend or truncate to width.
Make this APInt have the bit width given by width. The value is zero extended, truncated, or left alone to make it that width.
Definition at line 955 of file APInt.cpp.
References trunc(), and zext().
Referenced by llvm::SparcTargetLowering::bitcastConstantFPToInt(), combineShiftAnd1ToBitTest(), llvm::ObjectSizeOffsetVisitor::compute(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromShiftOperator(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), llvm::ConstantFoldLoadFromConstPtr(), llvm::Interpreter::exitCalled(), extractShiftForRotate(), foldBitcastedFPLogic(), llvm::SelectionDAG::getConstant(), llvm::ExecutionEngine::getConstantValue(), llvm::SelectionDAG::getNode(), isBitfieldDstMask(), isRepeatedByteSequence(), MergeAliasResults(), resolveBuildVector(), ShrinkDemandedConstant(), ShrinkLoadReplaceStoreWithStore(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::TargetLowering::SimplifyDemandedVectorElts(), llvm::X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(), simplifyX86extrq(), simplifyX86immShift(), simplifyX86insertq(), simplifyX86vpermilvar(), tryAdvSIMDModImm16(), tryAdvSIMDModImm32(), tryAdvSIMDModImm321s(), tryAdvSIMDModImm64(), tryAdvSIMDModImm8(), tryAdvSIMDModImmFP(), unrollVectorShift(), llvm::sroa::AllocaSliceRewriter::visit(), llvm::Interpreter::visitAShr(), and llvm::KnownBits::zextOrTrunc().
|
friend |
| uint64_t* llvm::APInt::pVal |
Used to store the >64 bits integer value.
Definition at line 94 of file APInt.h.
Referenced by APInt(), byteSwap(), extractBits(), getDigit(), getSplat(), llvm::hash_value(), operator*(), operator*=(), operator+=(), operator-=(), roundToDouble(), sext(), trunc(), udiv(), udivrem(), urem(), and zext().
| uint64_t llvm::APInt::VAL |
Used to store the <= 64 bits integer value.
Definition at line 93 of file APInt.h.
Referenced by APInt(), extractBits(), llvm::DenseMapAPIntKeyInfo::getEmptyKey(), llvm::DenseMapAPIntKeyInfo::getTombstoneKey(), llvm::hash_value(), insertBits(), intersects(), isSubsetOf(), operator &=(), operator*(), operator*=(), operator+=(), operator-=(), operator=(), operator==(), operator^=(), operator|=(), udiv(), udivrem(), and urem().
Definition at line 87 of file APInt.h.
Referenced by getDigit(), getSplat(), insertBits(), and operator*=().
1.8.13