15 #ifndef LLVM_ADT_APSINT_H
16 #define LLVM_ADT_APSINT_H
32 :
APInt(BitWidth, 0), IsUnsigned(isUnsigned) {}
35 :
APInt(std::move(I)), IsUnsigned(isUnsigned) {}
77 assert(getMinSignedBits() <= 64 &&
"Too many bits for int64_t");
78 return isSigned() ? getSExtValue() : getZExtValue();
87 return APSInt(zext(width), IsUnsigned);
89 return APSInt(sext(width), IsUnsigned);
94 return APSInt(zextOrTrunc(width), IsUnsigned);
96 return APSInt(sextOrTrunc(width), IsUnsigned);
100 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
108 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
116 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
120 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
128 *
this = *
this >> Amt;
133 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
134 return IsUnsigned ? ult(RHS) : slt(RHS);
137 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
138 return IsUnsigned ? ugt(RHS) : sgt(RHS);
141 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
142 return IsUnsigned ? ule(RHS) : sle(RHS);
145 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
146 return IsUnsigned ? uge(RHS) : sge(RHS);
149 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
153 return !((*this) == RHS);
157 return compareValues(*
this,
get(RHS)) == 0;
160 return compareValues(*
this,
get(RHS)) != 0;
163 return compareValues(*
this,
get(RHS)) <= 0;
166 return compareValues(*
this,
get(RHS)) >= 0;
169 return compareValues(*
this,
get(RHS)) < 0;
172 return compareValues(*
this,
get(RHS)) > 0;
179 return APSInt(static_cast<const APInt&>(*
this) << Bits, IsUnsigned);
182 *
this = *
this << Amt;
187 ++(
static_cast<APInt&
>(*this));
191 --(
static_cast<APInt&
>(*this));
195 return APSInt(++static_cast<APInt&>(*
this), IsUnsigned);
198 return APSInt(--static_cast<APInt&>(*
this), IsUnsigned);
201 return APSInt(-static_cast<const APInt&>(*
this), IsUnsigned);
204 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
205 static_cast<APInt&
>(*this) += RHS;
209 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
210 static_cast<APInt&
>(*this) -= RHS;
214 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
215 static_cast<APInt&
>(*this) *= RHS;
219 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
220 static_cast<APInt&
>(*this) &= RHS;
224 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
225 static_cast<APInt&
>(*this) |= RHS;
229 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
230 static_cast<APInt&
>(*this) ^= RHS;
235 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
236 return APSInt(static_cast<const APInt&>(*
this) & RHS, IsUnsigned);
241 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
242 return APSInt(static_cast<const APInt&>(*
this) | RHS, IsUnsigned);
247 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
248 return APSInt(static_cast<const APInt&>(*
this) ^ RHS, IsUnsigned);
253 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
254 return APSInt(static_cast<const APInt&>(*
this) * RHS, IsUnsigned);
257 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
258 return APSInt(static_cast<const APInt&>(*
this) + RHS, IsUnsigned);
261 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
262 return APSInt(static_cast<const APInt&>(*
this) - RHS, IsUnsigned);
265 return APSInt(~static_cast<const APInt&>(*
this), IsUnsigned);
285 return !compareValues(I1, I2);
291 return I1 == I2 ? 0 : I1 > I2 ? 1 : -1;
311 return I1.
eq(I2) ? 0 : I1.
ugt(I2) ? 1 : -1;
APSInt operator-(const APSInt &RHS) const
const APSInt & operator/=(const APSInt &RHS)
APSInt & operator-=(const APSInt &RHS)
void print(raw_ostream &OS, bool isSigned) const
APSInt extend(uint32_t width) const
bool operator>(int64_t V1, const APSInt &V2)
SmallBitVector operator&(const SmallBitVector &LHS, const SmallBitVector &RHS)
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 Xor(const APSInt &RHS) const
APSInt & operator^=(const APSInt &RHS)
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
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 urem(const APInt &LHS, const APInt &RHS)
Function for unsigned remainder operation.
SmallBitVector operator|(const SmallBitVector &LHS, const SmallBitVector &RHS)
This file implements a class to represent arbitrary precision integral constant values and operations...
APInt lshr(const APInt &LHS, unsigned shiftAmt)
Logical right-shift function.
APSInt & operator<<=(unsigned Amt)
bool operator!=(int64_t RHS) const
APSInt & operator*=(const APSInt &RHS)
APInt udiv(const APInt &LHS, const APInt &RHS)
Unsigned division function for APInt.
APSInt operator|(const APSInt &RHS) const
Function Alias Analysis false
APInt sdiv(const APInt &LHS, const APInt &RHS)
Signed division function for APInt.
APSInt operator/(const APSInt &RHS) const
bool operator==(const APSInt &RHS) const
APInt ashr(const APInt &LHS, unsigned shiftAmt)
Arithmetic right-shift function.
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
APSInt trunc(uint32_t width) 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 srem(const APInt &LHS, const APInt &RHS)
Function for signed remainder operation.
APInt trunc(unsigned width) const
Truncate to new width.
APInt & operator=(const APInt &RHS)
Copy assignment operator.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
unsigned getBitWidth() const
Return the number of bits in the 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.
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...
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)
APSInt And(const APSInt &RHS) const
APSInt extOrTrunc(uint32_t width) const
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
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)
APSInt(APInt I, bool isUnsigned=true)
bool operator<=(int64_t RHS) const
SmallBitVector operator^(const SmallBitVector &LHS, const SmallBitVector &RHS)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
APSInt & operator+=(const APSInt &RHS)
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
APSInt Or(const APSInt &RHS) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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)
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)
bool operator==(uint64_t V1, const APInt &V2)
APSInt operator*(const APSInt &RHS) const
bool operator==(int64_t RHS) const
APSInt operator+(const APSInt &RHS) const
std::string toString(unsigned Radix) const
toString - Converts an APInt to a std::string.
APSInt operator^(const APSInt &RHS) const
APSInt & operator=(APInt RHS)