APInt - This class represents arbitrary precision constant integral values. More...
#include <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 Member Functions | ||||||||||
Constructors | ||||||||||
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).
| ||||||||||
APInt (unsigned numBits, uint64_t val, bool isSigned=false) | ||||||||||
APInt (unsigned numBits, ArrayRef< uint64_t > bigVal) | ||||||||||
Note that bigVal.size() can be smaller or larger than the corresponding bit width but any extraneous bits will be dropped. | ||||||||||
APInt (unsigned numBits, unsigned numWords, const uint64_t bigVal[]) | ||||||||||
Equivalent to APInt(numBits, ArrayRef<uint64_t>(bigVal, numWords)), but deprecated because this constructor is prone to ambiguity with the APInt(unsigned, uint64_t, bool) constructor. | ||||||||||
APInt (unsigned numBits, StringRef str, uint8_t radix) | ||||||||||
This constructor interprets the string. | ||||||||||
APInt (const APInt &that) | ||||||||||
Simply makes *this a copy of that. | ||||||||||
~APInt () | ||||||||||
Destructor. | ||||||||||
APInt () | ||||||||||
Default constructor that creates an uninitialized APInt. | ||||||||||
void | Profile (FoldingSetNodeID &id) const | |||||||||
Profile - Used to insert APInt objects, or objects that contain APInt objects, into FoldingSets. | ||||||||||
Value Tests | ||||||||||
bool | isNegative () const | |||||||||
bool | isNonNegative () const | |||||||||
This tests the high bit of the APInt to determine if it is unset. | ||||||||||
bool | isStrictlyPositive () const | |||||||||
This tests if the value of this APInt is positive (> 0). | ||||||||||
bool | isAllOnesValue () const | |||||||||
This checks to see if the value has all bits of the APInt are set or not. | ||||||||||
bool | isMaxValue () const | |||||||||
This checks to see if the value of this APInt is the maximum unsigned value for the APInt's bit width. | ||||||||||
bool | isMaxSignedValue () const | |||||||||
This checks to see if the value of this APInt is the maximum signed value for the APInt's bit width. | ||||||||||
bool | isMinValue () const | |||||||||
This checks to see if the value of this APInt is the minimum unsigned value for the APInt's bit width. | ||||||||||
bool | isMinSignedValue () const | |||||||||
This checks to see if the value of this APInt is the minimum signed value for the APInt's bit width. | ||||||||||
bool | isIntN (unsigned N) const | |||||||||
Check if this APInt has an N-bits unsigned integer value. | ||||||||||
bool | isSignedIntN (unsigned N) const | |||||||||
Check if this APInt has an N-bits signed integer value. | ||||||||||
bool | isPowerOf2 () const | |||||||||
bool | isSignBit () const | |||||||||
isSignBit - Return true if this is the value returned by getSignBit. | ||||||||||
bool | getBoolValue () const | |||||||||
This converts the APInt to a boolean value as a test against zero. | ||||||||||
uint64_t | getLimitedValue (uint64_t Limit=~0ULL) const | |||||||||
getLimitedValue - If this value is smaller than the specified limit, return it, otherwise return the limit value. | ||||||||||
Unary Operators | ||||||||||
const APInt | operator++ (int) | |||||||||
APInt & | operator++ () | |||||||||
Prefix increment operator. | ||||||||||
const APInt | operator-- (int) | |||||||||
Postfix decrement operator. | ||||||||||
APInt & | operator-- () | |||||||||
Prefix decrement operator. | ||||||||||
APInt | operator~ () const | |||||||||
Performs a bitwise complement operation on this APInt. | ||||||||||
APInt | operator- () const | |||||||||
Negates *this using two's complement logic. | ||||||||||
bool | operator! () const | |||||||||
Performs logical negation operation on this APInt. | ||||||||||
Assignment Operators | ||||||||||
APInt & | operator= (const APInt &RHS) | |||||||||
APInt & | operator= (uint64_t RHS) | |||||||||
The RHS value is assigned to *this. | ||||||||||
APInt & | operator&= (const APInt &RHS) | |||||||||
Performs a bitwise AND operation on this APInt and RHS. | ||||||||||
APInt & | operator|= (const APInt &RHS) | |||||||||
Performs a bitwise OR operation on this APInt and RHS. | ||||||||||
APInt & | operator|= (uint64_t RHS) | |||||||||
Performs a bitwise OR operation on this APInt and RHS. | ||||||||||
APInt & | operator^= (const APInt &RHS) | |||||||||
Performs a bitwise XOR operation on this APInt and RHS. | ||||||||||
APInt & | operator*= (const APInt &RHS) | |||||||||
Multiplies this APInt by RHS and assigns the result to *this. | ||||||||||
APInt & | operator+= (const APInt &RHS) | |||||||||
Adds RHS to *this and assigns the result to *this. | ||||||||||
APInt & | operator-= (const APInt &RHS) | |||||||||
Subtracts RHS from *this and assigns the result to *this. | ||||||||||
APInt & | operator<<= (unsigned shiftAmt) | |||||||||
Shifts *this left by shiftAmt and assigns the result to *this. | ||||||||||
Comparison Operators | ||||||||||
bool | operator== (const APInt &RHS) const | |||||||||
bool | operator== (uint64_t Val) const | |||||||||
Compares this APInt with a uint64_t for the validity of the equality relationship. | ||||||||||
bool | eq (const APInt &RHS) const | |||||||||
Compares this APInt with RHS for the validity of the equality relationship. | ||||||||||
bool | operator!= (const APInt &RHS) const | |||||||||
Compares this APInt with RHS for the validity of the inequality relationship. | ||||||||||
bool | operator!= (uint64_t Val) const | |||||||||
Compares this APInt with a uint64_t for the validity of the inequality relationship. | ||||||||||
bool | ne (const APInt &RHS) const | |||||||||
Compares this APInt with RHS for the validity of the inequality relationship. | ||||||||||
bool | ult (const APInt &RHS) const | |||||||||
Regards both *this and RHS as unsigned quantities and compares them for the validity of the less-than relationship. | ||||||||||
bool | ult (uint64_t RHS) const | |||||||||
Regards both *this as an unsigned quantity and compares it with RHS for the validity of the less-than relationship. | ||||||||||
bool | slt (const APInt &RHS) const | |||||||||
Regards both *this and RHS as signed quantities and compares them for validity of the less-than relationship. | ||||||||||
bool | slt (uint64_t RHS) const | |||||||||
Regards both *this as a signed quantity and compares it with RHS for the validity of the less-than relationship. | ||||||||||
bool | ule (const APInt &RHS) const | |||||||||
Regards both *this and RHS as unsigned quantities and compares them for validity of the less-or-equal relationship. | ||||||||||
bool | ule (uint64_t RHS) const | |||||||||
Regards both *this as an unsigned quantity and compares it with RHS for the validity of the less-or-equal relationship. | ||||||||||
bool | sle (const APInt &RHS) const | |||||||||
Regards both *this and RHS as signed quantities and compares them for validity of the less-or-equal relationship. | ||||||||||
bool | sle (uint64_t RHS) const | |||||||||
Regards both *this as a signed quantity and compares it with RHS for the validity of the less-or-equal relationship. | ||||||||||
bool | ugt (const APInt &RHS) const | |||||||||
Regards both *this and RHS as unsigned quantities and compares them for the validity of the greater-than relationship. | ||||||||||
bool | ugt (uint64_t RHS) const | |||||||||
Regards both *this as an unsigned quantity and compares it with RHS for the validity of the greater-than relationship. | ||||||||||
bool | sgt (const APInt &RHS) const | |||||||||
Regards both *this and RHS as signed quantities and compares them for the validity of the greater-than relationship. | ||||||||||
bool | sgt (uint64_t RHS) const | |||||||||
Regards both *this as a signed quantity and compares it with RHS for the validity of the greater-than relationship. | ||||||||||
bool | uge (const APInt &RHS) const | |||||||||
Regards both *this and RHS as unsigned quantities and compares them for validity of the greater-or-equal relationship. | ||||||||||
bool | uge (uint64_t RHS) const | |||||||||
Regards both *this as an unsigned quantity and compares it with RHS for the validity of the greater-or-equal relationship. | ||||||||||
bool | sge (const APInt &RHS) const | |||||||||
Regards both *this and RHS as signed quantities and compares them for validity of the greater-or-equal relationship. | ||||||||||
bool | sge (uint64_t RHS) const | |||||||||
Regards both *this as a signed quantity and compares it with RHS for the validity of the greater-or-equal relationship. | ||||||||||
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. | ||||||||||
Resizing Operators | ||||||||||
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. Truncate to new width. | ||||||||||
APInt | trunc (unsigned width) const | |||||||||
APInt | sext (unsigned width) const | |||||||||
This operation sign extends the APInt to a new width. | ||||||||||
APInt | zext (unsigned width) const | |||||||||
This operation zero extends the APInt to a new width. | ||||||||||
APInt | sextOrTrunc (unsigned width) const | |||||||||
Make this APInt have the bit width given by width . | ||||||||||
APInt | zextOrTrunc (unsigned width) const | |||||||||
Make this APInt have the bit width given by width . | ||||||||||
Bit Manipulation Operators | ||||||||||
void | setAllBits () | |||||||||
void | setBit (unsigned bitPosition) | |||||||||
Set the given bit to 1 whose position is given as "bitPosition". | ||||||||||
void | clearAllBits () | |||||||||
Set every bit to 0. | ||||||||||
void | clearBit (unsigned bitPosition) | |||||||||
Set the given bit to 0 whose position is given as "bitPosition". | ||||||||||
void | flipAllBits () | |||||||||
Toggle every bit to its opposite value. | ||||||||||
void | flipBit (unsigned bitPosition) | |||||||||
Toggle a given bit to its opposite value whose position is given as "bitPosition". | ||||||||||
Mathematics Operations | ||||||||||
unsigned | logBase2 () const | |||||||||
unsigned | ceilLogBase2 () const | |||||||||
int32_t | exactLogBase2 () const | |||||||||
APInt | sqrt () const | |||||||||
Compute the square root. | ||||||||||
APInt | abs () const | |||||||||
If *this is < 0 then return -(*this), otherwise *this;. | ||||||||||
APInt | multiplicativeInverse (const APInt &modulo) const | |||||||||
Computes the multiplicative inverse of this APInt for a given modulo. | ||||||||||
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. | ||||||||||
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. | ||||||||||
Private Types | ||||||||||
enum | { APINT_BITS_PER_WORD, APINT_WORD_SIZE = static_cast<unsigned int>(sizeof(uint64_t)) } | |||||||||
This enum is used to hold the constants we needed for APInt. More... | ||||||||||
Private Member Functions | ||||||||||
APInt (uint64_t *val, unsigned bits) | ||||||||||
This constructor is used only internally for speed of construction of temporaries. | ||||||||||
bool | isSingleWord () const | |||||||||
Determine if this APInt just has one word to store value. | ||||||||||
APInt & | clearUnusedBits () | |||||||||
This method is used internally to clear the to "N" bits in the high order word that are not used by the APInt. | ||||||||||
uint64_t | getWord (unsigned bitPosition) const | |||||||||
Get the word corresponding to a bit position. | ||||||||||
void | fromString (unsigned numBits, StringRef str, uint8_t radix) | |||||||||
Converts a string into a number. | ||||||||||
void | initSlowCase (unsigned numBits, uint64_t val, bool isSigned) | |||||||||
out-of-line slow case for inline constructor | ||||||||||
void | initFromArray (ArrayRef< uint64_t > array) | |||||||||
shared code between two array constructors | ||||||||||
void | initSlowCase (const APInt &that) | |||||||||
out-of-line slow case for inline copy constructor | ||||||||||
APInt | shlSlowCase (unsigned shiftAmt) const | |||||||||
out-of-line slow case for shl | ||||||||||
APInt | AndSlowCase (const APInt &RHS) const | |||||||||
out-of-line slow case for operator& | ||||||||||
APInt | OrSlowCase (const APInt &RHS) const | |||||||||
out-of-line slow case for operator| | ||||||||||
APInt | XorSlowCase (const APInt &RHS) const | |||||||||
out-of-line slow case for operator^ | ||||||||||
APInt & | AssignSlowCase (const APInt &RHS) | |||||||||
out-of-line slow case for operator= | ||||||||||
bool | EqualSlowCase (const APInt &RHS) const | |||||||||
out-of-line slow case for operator== | ||||||||||
bool | EqualSlowCase (uint64_t Val) const | |||||||||
out-of-line slow case for operator== | ||||||||||
unsigned | countLeadingZerosSlowCase () const | |||||||||
out-of-line slow case for countLeadingZeros | ||||||||||
unsigned | countTrailingOnesSlowCase () const | |||||||||
out-of-line slow case for countTrailingOnes | ||||||||||
unsigned | countPopulationSlowCase () const | |||||||||
out-of-line slow case for countPopulation | ||||||||||
Static Private Member Functions | ||||||||||
static unsigned | whichWord (unsigned bitPosition) | |||||||||
Determine which word a bit is in. | ||||||||||
static unsigned | whichBit (unsigned bitPosition) | |||||||||
Determine which bit in a word a bit is in. | ||||||||||
static uint64_t | maskBit (unsigned bitPosition) | |||||||||
This method generates and returns a uint64_t (word) mask for a single bit at a specific bit position. | ||||||||||
static void | divide (const APInt LHS, unsigned lhsWords, const APInt &RHS, unsigned rhsWords, APInt *Quotient, APInt *Remainder) | |||||||||
This is used by the toString method to divide by the radix. | ||||||||||
Private Attributes | ||||||||||
unsigned | BitWidth | |||||||||
The number of bits in this APInt. | ||||||||||
union { | ||||||||||
uint64_t VAL | ||||||||||
Used to store the <= 64 bits integer value. | ||||||||||
uint64_t * pVal | ||||||||||
Used to store the >64 bits integer value. | ||||||||||
}; | ||||||||||
This union is used to store the integer value. | ||||||||||
Value Generators | ||||||||||
Gets maximum unsigned value of APInt for specific bit width. | ||||||||||
APInt | getHiBits (unsigned numBits) const | |||||||||
Get an APInt with the same BitWidth as this APInt, just zero mask the low bits and right shift to the least significant bit. | ||||||||||
APInt | getLoBits (unsigned numBits) const | |||||||||
Get an APInt with the same BitWidth as this APInt, just zero mask the high bits. | ||||||||||
uint64_t | getHashValue () const | |||||||||
The hash value is computed as the sum of the words and the bit width. | ||||||||||
const uint64_t * | getRawData () const | |||||||||
This function returns a pointer to the internal storage of the APInt. | ||||||||||
static APInt | getMaxValue (unsigned numBits) | |||||||||
static APInt | getSignedMaxValue (unsigned numBits) | |||||||||
Gets maximum signed value of APInt for a specific bit width. | ||||||||||
static APInt | getMinValue (unsigned numBits) | |||||||||
Gets minimum unsigned value of APInt for a specific bit width. | ||||||||||
static APInt | getSignedMinValue (unsigned numBits) | |||||||||
Gets minimum signed value of APInt for a specific bit width. | ||||||||||
static APInt | getSignBit (unsigned BitWidth) | |||||||||
getSignBit - This is just a wrapper function of getSignedMinValue(), and it helps code readability when we want to get a SignBit. | ||||||||||
static APInt | getAllOnesValue (unsigned numBits) | |||||||||
Get the all-ones value. | ||||||||||
static APInt | getNullValue (unsigned numBits) | |||||||||
Get the '0' value. | ||||||||||
static APInt | getOneBitSet (unsigned numBits, unsigned BitNo) | |||||||||
getOneBitSet - Return an APInt with exactly one bit set in the result. | ||||||||||
static APInt | getBitsSet (unsigned numBits, unsigned loBit, unsigned hiBit) | |||||||||
Constructs an APInt value that has a contiguous range of bits set. | ||||||||||
static APInt | getHighBitsSet (unsigned numBits, unsigned hiBitsSet) | |||||||||
Constructs an APInt value that has the top hiBitsSet bits set. | ||||||||||
static APInt | getLowBitsSet (unsigned numBits, unsigned loBitsSet) | |||||||||
Constructs an APInt value that has the bottom loBitsSet bits set. | ||||||||||
Binary Operators | ||||||||||
Performs a bitwise AND operation on *this and RHS.
| ||||||||||
APInt | operator& (const APInt &RHS) const | |||||||||
APInt | And (const APInt &RHS) const | |||||||||
APInt | operator| (const APInt &RHS) const | |||||||||
Performs a bitwise OR operation on *this and RHS. | ||||||||||
APInt | Or (const APInt &RHS) const | |||||||||
APInt | operator^ (const APInt &RHS) const | |||||||||
Performs a bitwise XOR operation on *this and RHS. | ||||||||||
APInt | Xor (const APInt &RHS) const | |||||||||
APInt | operator* (const APInt &RHS) const | |||||||||
Multiplies this APInt by RHS and returns the result. | ||||||||||
APInt | operator+ (const APInt &RHS) const | |||||||||
Adds RHS to this APInt and returns the result. | ||||||||||
APInt | operator+ (uint64_t RHS) const | |||||||||
APInt | operator- (const APInt &RHS) const | |||||||||
Subtracts RHS from this APInt and returns the result. | ||||||||||
APInt | operator- (uint64_t RHS) const | |||||||||
APInt | operator<< (unsigned Bits) const | |||||||||
APInt | operator<< (const APInt &Bits) const | |||||||||
APInt | ashr (unsigned shiftAmt) const | |||||||||
Arithmetic right-shift this APInt by shiftAmt. | ||||||||||
APInt | lshr (unsigned shiftAmt) const | |||||||||
Logical right-shift this APInt by shiftAmt. | ||||||||||
APInt | shl (unsigned shiftAmt) const | |||||||||
Left-shift this APInt by shiftAmt. | ||||||||||
APInt | rotl (unsigned rotateAmt) const | |||||||||
Rotate left by rotateAmt. | ||||||||||
APInt | rotr (unsigned rotateAmt) const | |||||||||
Rotate right by rotateAmt. | ||||||||||
APInt | ashr (const APInt &shiftAmt) const | |||||||||
Arithmetic right-shift this APInt by shiftAmt. | ||||||||||
APInt | lshr (const APInt &shiftAmt) const | |||||||||
Logical right-shift this APInt by shiftAmt. | ||||||||||
APInt | shl (const APInt &shiftAmt) const | |||||||||
Left-shift this APInt by shiftAmt. | ||||||||||
APInt | rotl (const APInt &rotateAmt) const | |||||||||
Rotate left by rotateAmt. | ||||||||||
APInt | rotr (const APInt &rotateAmt) const | |||||||||
Rotate right by rotateAmt. | ||||||||||
APInt | udiv (const APInt &RHS) const | |||||||||
Perform an unsigned divide operation on this APInt by RHS. | ||||||||||
APInt | sdiv (const APInt &RHS) const | |||||||||
Signed divide this APInt by APInt RHS. | ||||||||||
APInt | urem (const APInt &RHS) const | |||||||||
Perform an unsigned remainder operation on this APInt with RHS being the divisor. | ||||||||||
APInt | srem (const APInt &RHS) const | |||||||||
Signed remainder operation on APInt. | ||||||||||
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 (unsigned Amt, bool &Overflow) const | |||||||||
bool | operator[] (unsigned bitPosition) const | |||||||||
Array-indexing support. | ||||||||||
static void | udivrem (const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder) | |||||||||
Sometimes it is convenient to divide two APInt values and obtain both the quotient and remainder. | ||||||||||
static void | sdivrem (const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder) | |||||||||
Value Characterization Functions | ||||||||||
| ||||||||||
unsigned | getBitWidth () const | |||||||||
unsigned | getNumWords () const | |||||||||
Here one word's bitwidth equals to that of uint64_t. | ||||||||||
unsigned | getActiveBits () const | |||||||||
This function returns the number of active bits which is defined as the bit width minus the number of leading zeros. | ||||||||||
unsigned | getActiveWords () const | |||||||||
This function returns the number of active words in the value of this APInt. | ||||||||||
unsigned | getMinSignedBits () const | |||||||||
Computes the minimum bit width for this APInt while considering it to be a signed (and probably negative) value. | ||||||||||
uint64_t | getZExtValue () const | |||||||||
This method attempts to return the value of this APInt as a zero extended uint64_t. | ||||||||||
int64_t | getSExtValue () const | |||||||||
This method attempts to return the value of this APInt as a sign extended int64_t. | ||||||||||
unsigned | countLeadingZeros () const | |||||||||
countLeadingZeros - This function is an APInt version of the countLeadingZeros_{32,64} functions in MathExtras.h. | ||||||||||
unsigned | countLeadingOnes () const | |||||||||
countLeadingOnes - This function is an APInt version of the countLeadingOnes_{32,64} functions in MathExtras.h. | ||||||||||
unsigned | getNumSignBits () const | |||||||||
Computes the number of leading bits of this APInt that are equal to its sign bit. | ||||||||||
unsigned | countTrailingZeros () const | |||||||||
countTrailingZeros - This function is an APInt version of the countTrailingZeros_{32,64} functions in MathExtras.h. | ||||||||||
unsigned | countTrailingOnes () const | |||||||||
countTrailingOnes - This function is an APInt version of the countTrailingOnes_{32,64} functions in MathExtras.h. | ||||||||||
unsigned | countPopulation () const | |||||||||
countPopulation - This function is an APInt version of the countPopulation_{32,64} functions in MathExtras.h. | ||||||||||
static unsigned | getNumWords (unsigned BitWidth) | |||||||||
Here one word's bitwidth equals to that of uint64_t. | ||||||||||
static unsigned | getBitsNeeded (StringRef str, uint8_t radix) | |||||||||
This method determines how many bits are required to hold the APInt equivalent of the string given by. | ||||||||||
Conversion Functions | ||||||||||
| ||||||||||
void | print (std::ostream &OS, bool isSigned) const | |||||||||
void | toString (SmallVectorImpl< char > &Str, unsigned Radix, bool Signed, bool formatAsCLiteral=false) const | |||||||||
toString - Converts an APInt to a string and append it to Str. | ||||||||||
void | toStringUnsigned (SmallVectorImpl< char > &Str, unsigned Radix=10) const | |||||||||
Considers the APInt to be unsigned and converts it into a string in the radix given. | ||||||||||
void | toStringSigned (SmallVectorImpl< char > &Str, unsigned Radix=10) const | |||||||||
Considers the APInt to be signed and converts it into a string in the radix given. | ||||||||||
std::string | toString (unsigned Radix, bool Signed) const | |||||||||
toString - This returns the APInt as a std::string. | ||||||||||
APInt | byteSwap () const | |||||||||
double | roundToDouble (bool isSigned) const | |||||||||
Converts this APInt to a double value. | ||||||||||
double | roundToDouble () const | |||||||||
Converts this unsigned APInt to a double value. | ||||||||||
double | signedRoundToDouble () const | |||||||||
Converts this signed APInt to a double value. | ||||||||||
double | bitsToDouble () const | |||||||||
The conversion does not do a translation from integer to double, it just re-interprets the bits as a double. | ||||||||||
float | bitsToFloat () const | |||||||||
The conversion does not do a translation from integer to float, it just re-interprets the bits as a float. | ||||||||||
static APInt | doubleToBits (double V) | |||||||||
The conversion does not do a translation from double to integer, it just re-interprets the bits of the double. | ||||||||||
static APInt | floatToBits (float V) | |||||||||
The conversion does not do a translation from float to integer, it just re-interprets the bits of the float. | ||||||||||
Building-block Operations for APInt and APFloat | ||||||||||
| ||||||||||
void | dump () const | |||||||||
debug method | ||||||||||
*static void | tcSet (integerPart *, integerPart, unsigned int) | |||||||||
Sets the least significant part of a bignum to the input value, and zeroes out higher parts. | ||||||||||
static void | tcAssign (integerPart *, const integerPart *, unsigned int) | |||||||||
Assign one bignum to another. | ||||||||||
static bool | tcIsZero (const integerPart *, unsigned int) | |||||||||
Returns true if a bignum is zero, false otherwise. | ||||||||||
static int | tcExtractBit (const integerPart *, unsigned int bit) | |||||||||
Extract the given bit of a bignum; returns 0 or 1. Zero-based. | ||||||||||
static void | tcExtract (integerPart *, unsigned int dstCount, const integerPart *, unsigned int srcBits, unsigned int srcLSB) | |||||||||
Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to DST, of dstCOUNT parts, such that the bit srcLSB becomes the least significant bit of DST. | ||||||||||
static void | tcSetBit (integerPart *, unsigned int bit) | |||||||||
Set the given bit of a bignum. Zero-based. | ||||||||||
static void | tcClearBit (integerPart *, unsigned int bit) | |||||||||
Clear the given bit of a bignum. Zero-based. | ||||||||||
static unsigned int | tcLSB (const integerPart *, unsigned int) | |||||||||
Returns the bit number of the least or most significant set bit of a number. | ||||||||||
static unsigned int | tcMSB (const integerPart *parts, unsigned int n) | |||||||||
static void | tcNegate (integerPart *, unsigned int) | |||||||||
Negate a bignum in-place. | ||||||||||
static integerPart | tcAdd (integerPart *, const integerPart *, integerPart carry, unsigned) | |||||||||
DST += RHS + CARRY where CARRY is zero or one. | ||||||||||
static integerPart | tcSubtract (integerPart *, const integerPart *, integerPart carry, unsigned) | |||||||||
DST -= RHS + CARRY where CARRY is zero or one. | ||||||||||
static int | tcMultiplyPart (integerPart *dst, const integerPart *src, integerPart multiplier, integerPart carry, unsigned int srcParts, unsigned int dstParts, bool add) | |||||||||
DST += SRC * MULTIPLIER + PART if add is true DST = SRC * MULTIPLIER + PART if add is false. | ||||||||||
static int | tcMultiply (integerPart *, const integerPart *, const integerPart *, unsigned) | |||||||||
DST = LHS * RHS, where DST has the same width as the operands and is filled with the least significant parts of the result. | ||||||||||
static unsigned int | tcFullMultiply (integerPart *, const integerPart *, const integerPart *, unsigned, unsigned) | |||||||||
DST = LHS * RHS, where DST has width the sum of the widths of the operands. | ||||||||||
static int | tcDivide (integerPart *lhs, const integerPart *rhs, integerPart *remainder, integerPart *scratch, unsigned int parts) | |||||||||
If RHS is zero LHS and REMAINDER are left unchanged, return one. | ||||||||||
static void | tcShiftLeft (integerPart *, unsigned int parts, unsigned int count) | |||||||||
Shift a bignum left COUNT bits. | ||||||||||
static void | tcShiftRight (integerPart *, unsigned int parts, unsigned int count) | |||||||||
Shift a bignum right COUNT bits. | ||||||||||
static void | tcAnd (integerPart *, const integerPart *, unsigned int) | |||||||||
The obvious AND, OR and XOR and complement operations. | ||||||||||
static void | tcOr (integerPart *, const integerPart *, unsigned int) | |||||||||
static void | tcXor (integerPart *, const integerPart *, unsigned int) | |||||||||
static void | tcComplement (integerPart *, unsigned int) | |||||||||
static int | tcCompare (const integerPart *, const integerPart *, unsigned int) | |||||||||
Comparison (unsigned) of two bignums. | ||||||||||
static integerPart | tcIncrement (integerPart *, unsigned int) | |||||||||
Increment a bignum in-place. Return the carry flag. | ||||||||||
static void | tcSetLeastSignificantBits (integerPart *, unsigned int, unsigned int bits) | |||||||||
Set the least significant BITS and clear the rest. |
APInt - This class represents arbitrary precision constant integral values.
It is a functional replacement for common case unsigned integer type like "unsigned", "unsigned long" or "uint64_t", but also allows non-byte-width integer sizes and large integer value types such as 3-bits, 15-bits, or more than 64-bits of precision. APInt provides a variety of arithmetic operators and methods to manipulate integer values of any bit-width. It supports both the typical integer arithmetic and comparison operations as well as bitwise manipulation.
The class has several invariants worth noting: All bit, byte, and word positions are zero-based. Once the bit width is set, it doesn't change except by the Truncate, SignExtend, or ZeroExtend operations. All binary operators must be on APInt instances of the same bit width. Attempting to use these operators on instances with different bit widths will yield an assertion. The value is stored canonically as an unsigned value. For operations where it makes a difference, there are both signed and unsigned variants of the operation. For example, sdiv and udiv. However, because the bit widths must be the same, operations such as Mul and Add produce the same results regardless of whether the values are interpreted as signed or not. In general, the class tries to follow the style of computation that LLVM uses in its IR. This simplifies its use for LLVM.
Class for arbitrary precision integers.
anonymous enum [private] |
This enum is used to hold the constants we needed for APInt.
llvm::APInt::APInt | ( | uint64_t * | val, | |
unsigned | bits | |||
) | [inline, private] |
This constructor is used only internally for speed of construction of temporaries.
It is unsafe for general use so it is not public. Fast internal constructor
llvm::APInt::APInt | ( | unsigned | numBits, | |
uint64_t | val, | |||
bool | isSigned = false | |||
) | [inline] |
APInt::APInt | ( | unsigned | numBits, | |
ArrayRef< uint64_t > | bigVal | |||
) |
Note that bigVal.size() can be smaller or larger than the corresponding bit width but any extraneous bits will be dropped.
APInt::APInt | ( | unsigned | numBits, | |
unsigned | numWords, | |||
const uint64_t | bigVal[] | |||
) |
Equivalent to APInt(numBits, ArrayRef<uint64_t>(bigVal, numWords)), but deprecated because this constructor is prone to ambiguity with the APInt(unsigned, uint64_t, bool) constructor.
If this overload is ever deleted, care should be taken to prevent calls from being incorrectly captured by the APInt(unsigned, uint64_t, bool) constructor.
APInt::APInt | ( | unsigned | numBits, | |
StringRef | str, | |||
uint8_t | radix | |||
) |
This constructor interprets the string.
llvm::APInt::APInt | ( | const APInt & | that | ) | [inline] |
Simply makes *this a copy of that.
Copy Constructor.
llvm::APInt::~APInt | ( | ) | [inline] |
Destructor.
llvm::APInt::APInt | ( | ) | [inline, explicit] |
Default constructor that creates an uninitialized APInt.
This is useful for object deserialization (pair this with the static method Read).
APInt llvm::APInt::abs | ( | ) | const [inline] |
If *this is < 0 then return -(*this), otherwise *this;.
Get the absolute value;
Reimplemented in llvm::APSInt.
Arithmetic right-shift this APInt by shiftAmt.
Arithmetic right-shift function.
APInt APInt::ashr | ( | unsigned | shiftAmt | ) | const |
Arithmetic right-shift this APInt by shiftAmt.
Arithmetic right-shift function.
double llvm::APInt::bitsToDouble | ( | ) | const [inline] |
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. Converts APInt bits to a double
float llvm::APInt::bitsToFloat | ( | ) | const [inline] |
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. Converts APInt bits to a double
unsigned llvm::APInt::ceilLogBase2 | ( | ) | const [inline] |
void llvm::APInt::clearAllBits | ( | ) | [inline] |
Set every bit to 0.
void APInt::clearBit | ( | unsigned | bitPosition | ) |
Set the given bit to 0 whose position is given as "bitPosition".
Set a given bit to 0.
APInt& llvm::APInt::clearUnusedBits | ( | ) | [inline, private] |
This method is used internally to clear the to "N" bits in the high order word that are not used by the APInt.
This is needed after the most significant word is assigned a value to ensure that those bits are zero'd out. Clear unused high order bits
unsigned APInt::countLeadingOnes | ( | ) | const |
countLeadingOnes - This function is an APInt version of the countLeadingOnes_{32,64} functions in MathExtras.h.
It counts the number of ones from the most significant bit to the first zero bit.
unsigned llvm::APInt::countLeadingZeros | ( | ) | const [inline] |
countLeadingZeros - This function is an APInt version of the countLeadingZeros_{32,64} functions in MathExtras.h.
It counts the number of zeros from the most significant bit to the first one bit.
unsigned APInt::countLeadingZerosSlowCase | ( | ) | const [private] |
out-of-line slow case for countLeadingZeros
unsigned llvm::APInt::countPopulation | ( | ) | const [inline] |
countPopulation - This function is an APInt version of the countPopulation_{32,64} functions in MathExtras.h.
It counts the number of 1 bits in the APInt value.
unsigned APInt::countPopulationSlowCase | ( | ) | const [private] |
out-of-line slow case for countPopulation
unsigned llvm::APInt::countTrailingOnes | ( | ) | const [inline] |
countTrailingOnes - This function is an APInt version of the countTrailingOnes_{32,64} functions in MathExtras.h.
It counts the number of ones from the least significant bit to the first zero bit.
unsigned APInt::countTrailingOnesSlowCase | ( | ) | const [private] |
out-of-line slow case for countTrailingOnes
unsigned APInt::countTrailingZeros | ( | ) | const |
countTrailingZeros - This function is an APInt version of the countTrailingZeros_{32,64} functions in MathExtras.h.
It counts the number of zeros from the least significant bit to the first set bit.
void APInt::divide | ( | const APInt | LHS, | |
unsigned | lhsWords, | |||
const APInt & | RHS, | |||
unsigned | rhsWords, | |||
APInt * | Quotient, | |||
APInt * | Remainder | |||
) | [static, private] |
This is used by the toString method to divide by the radix.
It simply provides a more convenient form of divide for internal use since KnuthDiv has specific constraints on its inputs. If those constraints are not met then it provides a simpler form of divide. An internal division function for dividing APInts.
static APInt llvm::APInt::doubleToBits | ( | double | V | ) | [inline, static] |
The conversion does not do a translation from double to integer, it just re-interprets the bits of the double.
Converts a double to APInt bits.
void APInt::dump | ( | ) | const |
debug method
bool llvm::APInt::eq | ( | const APInt & | RHS | ) | const [inline] |
Compares this APInt with RHS for the validity of the equality relationship.
bool APInt::EqualSlowCase | ( | uint64_t | Val | ) | const [private] |
out-of-line slow case for operator==
bool APInt::EqualSlowCase | ( | const APInt & | RHS | ) | const [private] |
out-of-line slow case for operator==
int32_t llvm::APInt::exactLogBase2 | ( | ) | const [inline] |
void llvm::APInt::flipAllBits | ( | ) | [inline] |
Toggle every bit to its opposite value.
void APInt::flipBit | ( | unsigned | bitPosition | ) |
Toggle a given bit to its opposite value whose position is given as "bitPosition".
Toggle every bit to its opposite value.
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.
static APInt llvm::APInt::floatToBits | ( | float | V | ) | [inline, static] |
The conversion does not do a translation from float to integer, it just re-interprets the bits of the float.
Converts a float to APInt bits.
void APInt::fromString | ( | unsigned | numBits, | |
StringRef | str, | |||
uint8_t | radix | |||
) | [private] |
Converts a string into a number.
The string must be non-empty and well-formed as a number of the given base. The bit-width must be sufficient to hold the result.
This is used by the constructors that take string arguments.
StringRef::getAsInteger is superficially similar but (1) does not assume that the string is well-formed and (2) grows the result to hold the input.
radix | 2, 8, 10, 16, or 36 Convert a char array into an APInt |
unsigned llvm::APInt::getActiveBits | ( | ) | const [inline] |
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. Compute the number of active bits in the value
unsigned llvm::APInt::getActiveWords | ( | ) | const [inline] |
static APInt llvm::APInt::getAllOnesValue | ( | unsigned | numBits | ) | [inline, static] |
Get the all-ones value.
unsigned APInt::getBitsNeeded | ( | StringRef | str, | |
uint8_t | radix | |||
) | [static] |
This method determines how many bits are required to hold the APInt equivalent of the string given by.
static APInt llvm::APInt::getBitsSet | ( | unsigned | numBits, | |
unsigned | loBit, | |||
unsigned | hiBit | |||
) | [inline, static] |
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. If hiBit is less than loBit then the set bits "wrap". For example, with parameters (32, 28, 4), you would get 0xF000000F.
numBits | the intended bit width of the result | |
loBit | the index of the lowest bit set. | |
hiBit | the index of the highest bit set. |
unsigned llvm::APInt::getBitWidth | ( | ) | const [inline] |
bool llvm::APInt::getBoolValue | ( | ) | const [inline] |
This converts the APInt to a boolean value as a test against zero.
Boolean conversion function.
uint64_t APInt::getHashValue | ( | ) | const |
APInt APInt::getHiBits | ( | unsigned | numBits | ) | const |
static APInt llvm::APInt::getHighBitsSet | ( | unsigned | numBits, | |
unsigned | hiBitsSet | |||
) | [inline, static] |
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. Get a value with high bits set |
uint64_t llvm::APInt::getLimitedValue | ( | uint64_t | Limit = ~0ULL |
) | const [inline] |
getLimitedValue - 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.
APInt APInt::getLoBits | ( | unsigned | numBits | ) | const |
static APInt llvm::APInt::getLowBitsSet | ( | unsigned | numBits, | |
unsigned | loBitsSet | |||
) | [inline, static] |
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. Get a value with low bits set |
static APInt llvm::APInt::getMaxValue | ( | unsigned | numBits | ) | [inline, static] |
unsigned llvm::APInt::getMinSignedBits | ( | ) | const [inline] |
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. Get the minimum bit size for this signed APInt
static APInt llvm::APInt::getMinValue | ( | unsigned | numBits | ) | [inline, static] |
Gets minimum unsigned value of APInt for a specific bit width.
static APInt llvm::APInt::getNullValue | ( | unsigned | numBits | ) | [inline, static] |
Get the '0' value.
unsigned llvm::APInt::getNumSignBits | ( | ) | const [inline] |
Computes the number of leading bits of this APInt that are equal to its sign bit.
static unsigned llvm::APInt::getNumWords | ( | unsigned | BitWidth | ) | [inline, static] |
Here one word's bitwidth equals to that of uint64_t.
unsigned llvm::APInt::getNumWords | ( | ) | const [inline] |
Here one word's bitwidth equals to that of uint64_t.
static APInt llvm::APInt::getOneBitSet | ( | unsigned | numBits, | |
unsigned | BitNo | |||
) | [inline, static] |
getOneBitSet - Return an APInt with exactly one bit set in the result.
const uint64_t* llvm::APInt::getRawData | ( | ) | const [inline] |
int64_t llvm::APInt::getSExtValue | ( | ) | const [inline] |
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. Get sign extended value
static APInt llvm::APInt::getSignBit | ( | unsigned | BitWidth | ) | [inline, static] |
getSignBit - This is just a wrapper function of getSignedMinValue(), and it helps code readability when we want to get a SignBit.
Get the SignBit for a specific bit width.
static APInt llvm::APInt::getSignedMaxValue | ( | unsigned | numBits | ) | [inline, static] |
Gets maximum signed value of APInt for a specific bit width.
static APInt llvm::APInt::getSignedMinValue | ( | unsigned | numBits | ) | [inline, static] |
Gets minimum signed value of APInt for a specific bit width.
uint64_t llvm::APInt::getWord | ( | unsigned | bitPosition | ) | const [inline, private] |
Get the word corresponding to a bit position.
uint64_t llvm::APInt::getZExtValue | ( | ) | const [inline] |
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. Get zero extended value
void APInt::initFromArray | ( | ArrayRef< uint64_t > | array | ) | [private] |
shared code between two array constructors
void APInt::initSlowCase | ( | const APInt & | that | ) | [private] |
out-of-line slow case for inline copy constructor
void APInt::initSlowCase | ( | unsigned | numBits, | |
uint64_t | val, | |||
bool | isSigned | |||
) | [private] |
out-of-line slow case for inline constructor
bool llvm::APInt::intersects | ( | const APInt & | RHS | ) | const [inline] |
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are both set.
bool llvm::APInt::isAllOnesValue | ( | ) | const [inline] |
This checks to see if the value has all bits of the APInt are set or not.
Determine if all bits are set
bool llvm::APInt::isIntN | ( | unsigned | N | ) | const [inline] |
Check if this APInt has an N-bits unsigned integer value.
bool llvm::APInt::isMaxSignedValue | ( | ) | const [inline] |
This checks to see if the value of this APInt is the maximum signed value for the APInt's bit width.
Determine if this is the largest signed value.
bool llvm::APInt::isMaxValue | ( | ) | const [inline] |
This checks to see if the value of this APInt is the maximum unsigned value for the APInt's bit width.
Determine if this is the largest unsigned value.
bool llvm::APInt::isMinSignedValue | ( | ) | const [inline] |
This checks to see if the value of this APInt is the minimum signed value for the APInt's bit width.
Determine if this is the smallest signed value.
bool llvm::APInt::isMinValue | ( | ) | const [inline] |
This checks to see if the value of this APInt is the minimum unsigned value for the APInt's bit width.
Determine if this is the smallest unsigned value.
bool llvm::APInt::isNegative | ( | ) | const [inline] |
bool llvm::APInt::isNonNegative | ( | ) | const [inline] |
bool llvm::APInt::isPowerOf2 | ( | ) | const [inline] |
bool llvm::APInt::isSignBit | ( | ) | const [inline] |
isSignBit - Return true if this is the value returned by getSignBit.
bool llvm::APInt::isSignedIntN | ( | unsigned | N | ) | const [inline] |
Check if this APInt has an N-bits signed integer value.
bool llvm::APInt::isSingleWord | ( | ) | const [inline, private] |
Determine if this APInt just has one word to store value.
bool llvm::APInt::isStrictlyPositive | ( | ) | const [inline] |
unsigned llvm::APInt::logBase2 | ( | ) | const [inline] |
Logical right-shift this APInt by shiftAmt.
Logical right-shift function.
APInt APInt::lshr | ( | unsigned | shiftAmt | ) | const |
Logical right-shift this APInt by shiftAmt.
Logical right-shift function.
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.
APInt::mu APInt::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.
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.
static uint64_t llvm::APInt::maskBit | ( | unsigned | bitPosition | ) | [inline, static, private] |
This method generates and returns a uint64_t (word) mask for a single bit at a specific bit position.
This is used to mask the bit in the corresponding word.
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.
bool llvm::APInt::ne | ( | const APInt & | RHS | ) | const [inline] |
Compares this APInt with RHS for the validity of the inequality relationship.
bool APInt::operator! | ( | ) | const |
Performs logical negation operation on this APInt.
bool llvm::APInt::operator!= | ( | uint64_t | Val | ) | const [inline] |
Compares this APInt with a uint64_t for the validity of the inequality relationship.
bool llvm::APInt::operator!= | ( | const APInt & | RHS | ) | const [inline] |
Compares this APInt with RHS for the validity of the inequality relationship.
Reimplemented in llvm::APSInt.
Performs a bitwise AND operation on this APInt and RHS.
The result is assigned to *this.
Reimplemented in llvm::APSInt.
Multiplies this APInt by RHS and returns the result.
Multiplication operator.
Reimplemented in llvm::APSInt.
Multiplies this APInt by RHS and assigns the result to *this.
Reimplemented in llvm::APSInt.
APInt llvm::APInt::operator+ | ( | uint64_t | RHS | ) | const [inline] |
APInt & APInt::operator++ | ( | ) |
Prefix increment operator.
Prefix increment operator. Increments the APInt by one.
Reimplemented in llvm::APSInt.
const APInt llvm::APInt::operator++ | ( | int | ) | [inline] |
Reimplemented in llvm::APSInt.
Adds RHS to *this and assigns the result to *this.
Adds the RHS APint to this APInt.
Reimplemented in llvm::APSInt.
APInt llvm::APInt::operator- | ( | uint64_t | RHS | ) | const [inline] |
Subtracts RHS from this APInt and returns the result.
Subtraction operator.
Reimplemented in llvm::APSInt.
APInt llvm::APInt::operator- | ( | ) | const [inline] |
Negates *this using two's complement logic.
Reimplemented in llvm::APSInt.
APInt & APInt::operator-- | ( | ) |
Prefix decrement operator.
Prefix decrement operator. Decrements the APInt by one.
Reimplemented in llvm::APSInt.
const APInt llvm::APInt::operator-- | ( | int | ) | [inline] |
Postfix decrement operator.
Reimplemented in llvm::APSInt.
Subtracts RHS from *this and assigns the result to *this.
Subtracts the RHS APInt from this APInt.
Reimplemented in llvm::APSInt.
APInt llvm::APInt::operator<< | ( | unsigned | Bits | ) | const [inline] |
Reimplemented in llvm::APSInt.
APInt& llvm::APInt::operator<<= | ( | unsigned | shiftAmt | ) | [inline] |
Shifts *this left by shiftAmt and assigns the result to *this.
Reimplemented in llvm::APSInt.
APInt & APInt::operator= | ( | uint64_t | RHS | ) |
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.
Reimplemented in llvm::APSInt.
Reimplemented in llvm::APSInt.
bool llvm::APInt::operator== | ( | uint64_t | Val | ) | const [inline] |
Compares this APInt with a uint64_t for the validity of the equality relationship.
bool llvm::APInt::operator== | ( | const APInt & | RHS | ) | const [inline] |
bool APInt::operator[] | ( | unsigned | bitPosition | ) | const |
Array-indexing support.
Performs a bitwise XOR operation on *this and RHS.
Reimplemented in llvm::APSInt.
Performs a bitwise XOR operation on this APInt and RHS.
The result is assigned to *this.
Reimplemented in llvm::APSInt.
Performs a bitwise OR operation on *this and RHS.
Reimplemented in llvm::APSInt.
APInt& llvm::APInt::operator|= | ( | uint64_t | RHS | ) | [inline] |
Performs a bitwise OR operation on this APInt and RHS.
RHS is logically zero-extended or truncated to match the bit-width of the LHS.
Bitwise OR assignment operator.
Performs a bitwise OR operation on this APInt and RHS.
The result is assigned *this;
Reimplemented in llvm::APSInt.
APInt llvm::APInt::operator~ | ( | ) | const [inline] |
Performs a bitwise complement operation on this APInt.
Reimplemented in llvm::APSInt.
Reimplemented in llvm::APSInt.
void APInt::print | ( | std::ostream & | OS, | |
bool | isSigned | |||
) | const |
void llvm::APInt::Profile | ( | FoldingSetNodeID & | id | ) | const |
Profile - Used to insert APInt objects, or objects that contain APInt objects, into FoldingSets.
Reimplemented in llvm::APSInt.
APInt APInt::rotl | ( | unsigned | rotateAmt | ) | const |
Rotate left by rotateAmt.
APInt APInt::rotr | ( | unsigned | rotateAmt | ) | const |
Rotate right by rotateAmt.
double llvm::APInt::roundToDouble | ( | ) | const [inline] |
Converts this unsigned APInt to a double value.
double APInt::roundToDouble | ( | bool | isSigned | ) | const |
Converts this APInt to a double value.
RoundToDouble - This function converts this APInt to a double.
The layout for double is as following (IEEE Standard 754): -------------------------------------- | Sign Exponent Fraction Bias | |-------------------------------------- | | 1[63] 11[62-52] 52[51-00] 1023 | --------------------------------------
static void llvm::APInt::sdivrem | ( | const APInt & | LHS, | |
const APInt & | RHS, | |||
APInt & | Quotient, | |||
APInt & | Remainder | |||
) | [inline, static] |
void llvm::APInt::setAllBits | ( | ) | [inline] |
void APInt::setBit | ( | unsigned | bitPosition | ) |
Set the given bit to 1 whose position is given as "bitPosition".
Set a given bit to 1.
APInt APInt::sext | ( | unsigned | width | ) | const |
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. Sign extend to a new width.
APInt APInt::sextOrTrunc | ( | unsigned | width | ) | const |
Make this APInt have the bit width given by width
.
The value is sign extended, truncated, or left alone to make it that width. Sign extend or truncate to width
bool llvm::APInt::sge | ( | uint64_t | RHS | ) | const [inline] |
Regards both *this as a signed quantity and compares it with RHS for the validity of the greater-or-equal relationship.
bool llvm::APInt::sge | ( | const APInt & | RHS | ) | const [inline] |
Regards both *this and RHS as signed quantities and compares them for validity of the greater-or-equal relationship.
bool llvm::APInt::sgt | ( | uint64_t | RHS | ) | const [inline] |
Regards both *this as a signed quantity and compares it with RHS for the validity of the greater-than relationship.
bool llvm::APInt::sgt | ( | const APInt & | RHS | ) | const [inline] |
Regards both *this and RHS as signed quantities and compares them for the validity of the greater-than relationship.
Left-shift this APInt by shiftAmt.
Left-shift function.
APInt llvm::APInt::shl | ( | unsigned | shiftAmt | ) | const [inline] |
Left-shift this APInt by shiftAmt.
Left-shift function.
APInt APInt::shlSlowCase | ( | unsigned | shiftAmt | ) | const [private] |
out-of-line slow case for shl
double llvm::APInt::signedRoundToDouble | ( | ) | const [inline] |
Converts this signed APInt to a double value.
bool llvm::APInt::sle | ( | uint64_t | RHS | ) | const [inline] |
Regards both *this as a signed quantity and compares it with RHS for the validity of the less-or-equal relationship.
bool llvm::APInt::sle | ( | const APInt & | RHS | ) | const [inline] |
Regards both *this and RHS as signed quantities and compares them for validity of the less-or-equal relationship.
bool llvm::APInt::slt | ( | uint64_t | RHS | ) | const [inline] |
Regards both *this as a signed quantity and compares it with RHS for the validity of the less-than relationship.
bool APInt::slt | ( | const APInt & | RHS | ) | const |
Regards both *this and RHS as signed quantities and compares them for validity of the less-than relationship.
APInt APInt::sqrt | ( | ) | const |
Compute the square root.
Signed remainder operation on APInt.
Function for signed remainder operation.
APInt APInt::sshl_ov | ( | unsigned | Amt, | |
bool & | Overflow | |||
) | const |
static integerPart llvm::APInt::tcAdd | ( | integerPart * | , | |
const integerPart * | , | |||
integerPart | carry, | |||
unsigned | ||||
) | [static] |
DST += RHS + CARRY where CARRY is zero or one.
Returns the carry flag.
void APInt::tcAnd | ( | integerPart * | dst, | |
const integerPart * | rhs, | |||
unsigned int | parts | |||
) | [static] |
The obvious AND, OR and XOR and complement operations.
void APInt::tcAssign | ( | integerPart * | dst, | |
const integerPart * | src, | |||
unsigned int | parts | |||
) | [static] |
Assign one bignum to another.
void APInt::tcClearBit | ( | integerPart * | parts, | |
unsigned int | bit | |||
) | [static] |
Clear the given bit of a bignum. Zero-based.
int APInt::tcCompare | ( | const integerPart * | lhs, | |
const integerPart * | rhs, | |||
unsigned int | parts | |||
) | [static] |
Comparison (unsigned) of two bignums.
void APInt::tcComplement | ( | integerPart * | dst, | |
unsigned int | parts | |||
) | [static] |
int APInt::tcDivide | ( | integerPart * | lhs, | |
const integerPart * | rhs, | |||
integerPart * | remainder, | |||
integerPart * | scratch, | |||
unsigned int | parts | |||
) | [static] |
If RHS is zero LHS and REMAINDER are left unchanged, return one.
Otherwise set LHS to LHS / RHS with the fractional part discarded, set REMAINDER to the remainder, return zero. i.e.
OLD_LHS = RHS * LHS + REMAINDER
SCRATCH is a bignum of the same size as the operands and result for use by the routine; its contents need not be initialized and are destroyed. LHS, REMAINDER and SCRATCH must be distinct.
void APInt::tcExtract | ( | integerPart * | dst, | |
unsigned int | dstCount, | |||
const integerPart * | src, | |||
unsigned int | srcBits, | |||
unsigned int | srcLSB | |||
) | [static] |
Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to DST, of dstCOUNT parts, such that the bit srcLSB becomes the least significant bit of DST.
All high bits above srcBITS in DST are zero-filled.
int APInt::tcExtractBit | ( | const integerPart * | parts, | |
unsigned int | bit | |||
) | [static] |
Extract the given bit of a bignum; returns 0 or 1. Zero-based.
static unsigned int llvm::APInt::tcFullMultiply | ( | integerPart * | , | |
const integerPart * | , | |||
const integerPart * | , | |||
unsigned | , | |||
unsigned | ||||
) | [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. Returns the number of parts required to hold the result.
integerPart APInt::tcIncrement | ( | integerPart * | dst, | |
unsigned int | parts | |||
) | [static] |
Increment a bignum in-place. Return the carry flag.
bool APInt::tcIsZero | ( | const integerPart * | src, | |
unsigned int | parts | |||
) | [static] |
Returns true if a bignum is zero, false otherwise.
unsigned int APInt::tcLSB | ( | const integerPart * | parts, | |
unsigned int | n | |||
) | [static] |
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.
unsigned int APInt::tcMSB | ( | const integerPart * | parts, | |
unsigned int | n | |||
) | [static] |
static int llvm::APInt::tcMultiply | ( | integerPart * | , | |
const integerPart * | , | |||
const integerPart * | , | |||
unsigned | ||||
) | [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.
int APInt::tcMultiplyPart | ( | integerPart * | dst, | |
const integerPart * | src, | |||
integerPart | multiplier, | |||
integerPart | carry, | |||
unsigned int | srcParts, | |||
unsigned int | dstParts, | |||
bool | add | |||
) | [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.
void APInt::tcNegate | ( | integerPart * | dst, | |
unsigned int | parts | |||
) | [static] |
Negate a bignum in-place.
void APInt::tcOr | ( | integerPart * | dst, | |
const integerPart * | rhs, | |||
unsigned int | parts | |||
) | [static] |
void APInt::tcSet | ( | integerPart * | dst, | |
integerPart | part, | |||
unsigned int | parts | |||
) | [static] |
Sets the least significant part of a bignum to the input value, and zeroes out higher parts.
void APInt::tcSetBit | ( | integerPart * | parts, | |
unsigned int | bit | |||
) | [static] |
Set the given bit of a bignum. Zero-based.
void APInt::tcSetLeastSignificantBits | ( | integerPart * | dst, | |
unsigned int | parts, | |||
unsigned int | bits | |||
) | [static] |
Set the least significant BITS and clear the rest.
void APInt::tcShiftLeft | ( | integerPart * | dst, | |
unsigned int | parts, | |||
unsigned int | count | |||
) | [static] |
Shift a bignum left COUNT bits.
Shifted in bits are zero. There are no restrictions on COUNT.
void APInt::tcShiftRight | ( | integerPart * | dst, | |
unsigned int | parts, | |||
unsigned int | count | |||
) | [static] |
Shift a bignum right COUNT bits.
Shifted in bits are zero. There are no restrictions on COUNT.
static integerPart llvm::APInt::tcSubtract | ( | integerPart * | , | |
const integerPart * | , | |||
integerPart | carry, | |||
unsigned | ||||
) | [static] |
DST -= RHS + CARRY where CARRY is zero or one.
Returns the carry flag.
void APInt::tcXor | ( | integerPart * | dst, | |
const integerPart * | rhs, | |||
unsigned int | parts | |||
) | [static] |
std::string APInt::toString | ( | unsigned | Radix = 10 , |
|
bool | Signed = true | |||
) | const |
toString - This 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.
void APInt::toString | ( | SmallVectorImpl< char > & | Str, | |
unsigned | Radix, | |||
bool | Signed, | |||
bool | formatAsCLiteral = false | |||
) | const |
toString - Converts an APInt to a string and append it to Str.
Str is commonly a SmallString.
void llvm::APInt::toStringSigned | ( | SmallVectorImpl< char > & | Str, | |
unsigned | Radix = 10 | |||
) | const [inline] |
Considers the APInt to be signed and converts it into a string in the radix given.
The radix can be 2, 8, 10, 16, or 36.
void llvm::APInt::toStringUnsigned | ( | SmallVectorImpl< char > & | Str, | |
unsigned | Radix = 10 | |||
) | const [inline] |
Considers the APInt to be unsigned and converts it into a string in the radix given.
The radix can be 2, 8, 10 16, or 36.
APInt APInt::trunc | ( | unsigned | width | ) | const |
void APInt::udivrem | ( | const APInt & | LHS, | |
const APInt & | RHS, | |||
APInt & | Quotient, | |||
APInt & | Remainder | |||
) | [static] |
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. Dual division/remainder interface.
bool llvm::APInt::uge | ( | uint64_t | RHS | ) | const [inline] |
Regards both *this as an unsigned quantity and compares it with RHS for the validity of the greater-or-equal relationship.
bool llvm::APInt::uge | ( | const APInt & | RHS | ) | const [inline] |
Regards both *this and RHS as unsigned quantities and compares them for validity of the greater-or-equal relationship.
bool llvm::APInt::ugt | ( | uint64_t | RHS | ) | const [inline] |
Regards both *this as an unsigned quantity and compares it with RHS for the validity of the greater-than relationship.
bool llvm::APInt::ugt | ( | const APInt & | RHS | ) | const [inline] |
Regards both *this and RHS as unsigned quantities and compares them for the validity of the greater-than relationship.
bool llvm::APInt::ule | ( | uint64_t | RHS | ) | const [inline] |
Regards both *this as an unsigned quantity and compares it with RHS for the validity of the less-or-equal relationship.
bool llvm::APInt::ule | ( | const APInt & | RHS | ) | const [inline] |
Regards both *this and RHS as unsigned quantities and compares them for validity of the less-or-equal relationship.
bool llvm::APInt::ult | ( | uint64_t | RHS | ) | const [inline] |
Regards both *this as an unsigned quantity and compares it with RHS for the validity of the less-than relationship.
bool APInt::ult | ( | const APInt & | RHS | ) | const |
Regards both *this and RHS as unsigned quantities and compares them for the validity of the less-than relationship.
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.
static unsigned llvm::APInt::whichBit | ( | unsigned | bitPosition | ) | [inline, static, private] |
Determine which bit in a word a bit is in.
static unsigned llvm::APInt::whichWord | ( | unsigned | bitPosition | ) | [inline, static, private] |
Determine which word a bit is in.
Reimplemented in llvm::APSInt.
APInt APInt::zext | ( | unsigned | width | ) | const |
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. Zero extend to a new width.
APInt APInt::zextOrTrunc | ( | unsigned | width | ) | const |
Make this APInt have the bit width given by width
.
The value is zero extended, truncated, or left alone to make it that width. Zero extend or truncate to width
union { ... } [private] |
This union is used to store the integer value.
When the integer bit-width <= 64, it uses VAL, otherwise it uses pVal.
unsigned llvm::APInt::BitWidth [private] |
The number of bits in this APInt.
uint64_t* llvm::APInt::pVal |
Used to store the >64 bits integer value.
uint64_t llvm::APInt::VAL |
Used to store the <= 64 bits integer value.