15 #ifndef LLVM_ADT_APSINT_H
16 #define LLVM_ADT_APSINT_H
99 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
107 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
115 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
119 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
127 *
this = *
this >> Amt;
132 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
133 return IsUnsigned ?
ult(RHS) :
slt(RHS);
136 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
137 return IsUnsigned ?
ugt(RHS) :
sgt(RHS);
140 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
141 return IsUnsigned ?
ule(RHS) :
sle(RHS);
144 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
145 return IsUnsigned ?
uge(RHS) :
sge(RHS);
148 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
152 return !((*this) == RHS);
178 return APSInt(static_cast<const APInt&>(*
this) << Bits, IsUnsigned);
181 *
this = *
this << Amt;
186 ++(
static_cast<APInt&
>(*this));
190 --(
static_cast<APInt&
>(*this));
194 return APSInt(++static_cast<APInt&>(*
this), IsUnsigned);
197 return APSInt(--static_cast<APInt&>(*
this), IsUnsigned);
200 return APSInt(-static_cast<const APInt&>(*
this), IsUnsigned);
203 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
204 static_cast<APInt&
>(*this) += RHS;
208 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
209 static_cast<APInt&
>(*this) -= RHS;
213 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
214 static_cast<APInt&
>(*this) *= RHS;
218 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
219 static_cast<APInt&
>(*this) &= RHS;
223 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
224 static_cast<APInt&
>(*this) |= RHS;
228 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
229 static_cast<APInt&
>(*this) ^= RHS;
234 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
235 return APSInt(static_cast<const APInt&>(*
this) & RHS, IsUnsigned);
242 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
243 return APSInt(static_cast<const APInt&>(*
this) | RHS, IsUnsigned);
251 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
252 return APSInt(static_cast<const APInt&>(*
this) ^ RHS, IsUnsigned);
259 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
260 return APSInt(static_cast<const APInt&>(*
this) * RHS, IsUnsigned);
263 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
264 return APSInt(static_cast<const APInt&>(*
this) + RHS, IsUnsigned);
267 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
268 return APSInt(static_cast<const APInt&>(*
this) - RHS, IsUnsigned);
271 return APSInt(~static_cast<const APInt&>(*
this), IsUnsigned);
297 return I1 == I2 ? 0 : I1 > I2 ? 1 : -1;
308 assert(!I2.
isSigned() &&
"Expected signed mismatch");
312 assert(I2.
isSigned() &&
"Expected signed mismatch");
317 return I1.
eq(I2) ? 0 : I1.
ugt(I2) ? 1 : -1;
APSInt operator-(const APSInt &RHS) const
APInt LLVM_ATTRIBUTE_UNUSED_RESULT ashr(unsigned shiftAmt) const
Arithmetic right-shift function.
const APSInt & operator/=(const APSInt &RHS)
#define LLVM_ATTRIBUTE_UNUSED_RESULT
uint64_t getZExtValue() const
Get zero extended value.
APSInt & operator-=(const APSInt &RHS)
void print(raw_ostream &OS, bool isSigned) const
bool operator>(int64_t V1, const APSInt &V2)
APSInt()
Default constructor that creates an uninitialized APInt.
APSInt(uint32_t BitWidth, bool isUnsigned=true)
APSInt ctor - Create an APSInt with the specified width, default to unsigned.
APSInt operator>>(unsigned Amt) const
void setIsSigned(bool Val)
APSInt & operator^=(const APSInt &RHS)
APInt LLVM_ATTRIBUTE_UNUSED_RESULT zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
void setIsUnsigned(bool Val)
APSInt operator&(const APSInt &RHS) const
bool operator>=(int64_t RHS) const
bool operator<=(int64_t V1, const APSInt &V2)
bool isNegative() const
Determine sign of this APInt.
APSInt operator<<(unsigned Bits) const
APInt LLVM_ATTRIBUTE_UNUSED_RESULT urem(const APInt &RHS) const
Unsigned remainder operation.
int64_t getExtValue() const
Get the correctly-extended int64_t value.
bool operator>=(const APSInt &RHS) const
bool operator<=(const APSInt &RHS) const
bool operator>=(int64_t V1, const APSInt &V2)
APInt()
Default constructor that creates an uninitialized APInt.
APSInt LLVM_ATTRIBUTE_UNUSED_RESULT extend(uint32_t width) const
APInt LLVM_ATTRIBUTE_UNUSED_RESULT lshr(unsigned shiftAmt) const
Logical right-shift function.
This file implements a class to represent arbitrary precision integral constant values and operations...
APSInt & operator<<=(unsigned Amt)
bool operator!=(int64_t RHS) const
APSInt & operator*=(const APSInt &RHS)
APSInt operator|(const APSInt &RHS) const
bool sgt(const APInt &RHS) const
Signed greather than comparison.
APSInt operator/(const APSInt &RHS) const
bool operator==(const APSInt &RHS) const
unsigned getMinSignedBits() const
Get the minimum bit size for this signed APInt.
bool ult(const APInt &RHS) const
Unsigned less than comparison.
bool operator>(const APSInt &RHS) const
static bool isSameValue(const APSInt &I1, const APSInt &I2)
Determine if two APSInts have the same value, zero- or sign-extending as needed.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
bool operator<(int64_t RHS) 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.
bool eq(const APInt &RHS) const
Equality comparison.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT trunc(unsigned width) const
Truncate to new width.
bool sge(const APInt &RHS) const
Signed greather or equal comparison.
int64_t getSExtValue() const
Get sign extended value.
APSInt LLVM_ATTRIBUTE_UNUSED_RESULT Xor(const APSInt &RHS) const
APInt & operator=(const APInt &RHS)
Copy assignment operator.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sext(unsigned width) const
Sign extend to a new width.
bool sle(const APInt &RHS) const
Signed less or equal comparison.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sdiv(const APInt &RHS) const
Signed division function for APInt.
bool operator>(int64_t RHS) const
APSInt & operator=(uint64_t RHS)
bool operator!=(const APSInt &RHS) const
void toString(SmallVectorImpl< char > &Str, unsigned Radix=10) const
toString - Append this APSInt to the specified SmallString.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT srem(const APInt &RHS) const
Function for signed remainder operation.
APSInt & operator&=(const APSInt &RHS)
bool ugt(const APInt &RHS) const
Unsigned greather than comparison.
static APSInt getMaxValue(uint32_t numBits, bool Unsigned)
getMaxValue - Return the APSInt representing the maximum integer value with the given bit width and s...
bool slt(const APInt &RHS) const
Signed less than comparison.
APSInt LLVM_ATTRIBUTE_UNUSED_RESULT extOrTrunc(uint32_t width) const
static APSInt getMinValue(uint32_t numBits, bool Unsigned)
getMinValue - Return the APSInt representing the minimum integer value with the given bit width and s...
APSInt & operator|=(const APSInt &RHS)
void Profile(FoldingSetNodeID &ID) const
Profile - Used to insert APSInt objects, or objects that contain APSInt objects, into FoldingSets...
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
APSInt LLVM_ATTRIBUTE_UNUSED_RESULT trunc(uint32_t width) const
Class for arbitrary precision integers.
APSInt operator%(const APSInt &RHS) const
bool operator<(const APSInt &RHS) const
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
const APSInt & operator%=(const APSInt &RHS)
bool operator!=(uint64_t V1, const APInt &V2)
APInt LLVM_ATTRIBUTE_UNUSED_RESULT udiv(const APInt &RHS) const
Unsigned division operation.
APSInt(APInt I, bool isUnsigned=true)
bool operator<=(int64_t RHS) const
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
APSInt & operator+=(const APSInt &RHS)
static APSInt getUnsigned(uint64_t X)
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
bool operator<(int64_t V1, const APSInt &V2)
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
APSInt LLVM_ATTRIBUTE_UNUSED_RESULT Or(const APSInt &RHS) const
static int compareValues(const APSInt &I1, const APSInt &I2)
Compare underlying values of two numbers.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
APSInt & operator>>=(unsigned Amt)
APInt LLVM_ATTRIBUTE_UNUSED_RESULT zext(unsigned width) const
Zero extend to a new width.
bool operator==(uint64_t V1, const APInt &V2)
APSInt operator*(const APSInt &RHS) const
APSInt LLVM_ATTRIBUTE_UNUSED_RESULT And(const APSInt &RHS) const
bool operator==(int64_t RHS) const
APSInt operator+(const APSInt &RHS) const
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
std::string toString(unsigned Radix) const
toString - Converts an APInt to a std::string.
APSInt operator^(const APSInt &RHS) const
APSInt & operator=(APInt RHS)