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!");
117 return IsUnsigned ?
APSInt(urem(RHS),
true) :
APSInt(srem(RHS),
false);
120 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
121 return IsUnsigned ?
APSInt(udiv(RHS),
true) :
APSInt(sdiv(RHS),
false);
125 return IsUnsigned ?
APSInt(lshr(Amt),
true) :
APSInt(ashr(Amt),
false);
136 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
137 return IsUnsigned ? ult(RHS) : slt(RHS);
140 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
141 return IsUnsigned ? ugt(RHS) : sgt(RHS);
144 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
145 return IsUnsigned ? ule(RHS) : sle(RHS);
148 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
149 return IsUnsigned ? uge(RHS) : sge(RHS);
152 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
156 return !((*this) == RHS);
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;
175 return compareValues(*
this,
get(RHS)) > 0;
182 return APSInt(static_cast<const APInt&>(*
this) << Bits, IsUnsigned);
185 static_cast<APInt&
>(*this) <<= Amt;
190 ++(
static_cast<APInt&
>(*this));
194 --(
static_cast<APInt&
>(*this));
198 return APSInt(++static_cast<APInt&>(*
this), IsUnsigned);
201 return APSInt(--static_cast<APInt&>(*
this), IsUnsigned);
204 return APSInt(-static_cast<const APInt&>(*
this), IsUnsigned);
207 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
208 static_cast<APInt&
>(*this) += RHS;
212 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
213 static_cast<APInt&
>(*this) -= RHS;
217 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
218 static_cast<APInt&
>(*this) *= RHS;
222 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
223 static_cast<APInt&
>(*this) &= RHS;
227 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
228 static_cast<APInt&
>(*this) |= RHS;
232 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
233 static_cast<APInt&
>(*this) ^= RHS;
238 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
239 return APSInt(static_cast<const APInt&>(*
this) & RHS, IsUnsigned);
243 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
244 return APSInt(static_cast<const APInt&>(*
this) | RHS, IsUnsigned);
248 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
249 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.IsUnsigned ? I1.compare(I2) : I1.compareSigned(I2);
311 return I1.compare(I2);
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
const APSInt & operator/=(const APSInt &RHS)
APSInt & operator-=(const APSInt &RHS)
This class represents lattice values for constants.
APSInt operator/(const APSInt &RHS) const
bool operator>(int64_t V1, const APSInt &V2)
bool operator!=(int64_t RHS) const
APSInt()
Default constructor that creates an uninitialized APInt.
bool operator<=(int64_t RHS) const
APSInt(uint32_t BitWidth, bool isUnsigned=true)
APSInt ctor - Create an APSInt with the specified width, default to unsigned.
void setIsSigned(bool Val)
APInt trunc(unsigned width) const
Truncate to new width.
APInt operator &(APInt a, const APInt &b)
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)
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool operator<=(int64_t V1, const APSInt &V2)
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
bool operator>=(int64_t V1, const APSInt &V2)
APSInt extend(uint32_t width) const
APSInt extOrTrunc(uint32_t width) const
This file implements a class to represent arbitrary precision integral constant values and operations...
APSInt & operator<<=(unsigned Amt)
bool operator<=(const APSInt &RHS) const
APSInt operator^(const APSInt &RHS) const
APSInt & operator*=(const APSInt &RHS)
bool operator<(const APSInt &RHS) const
APSInt operator*(const APSInt &RHS) const
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 isNegative() const
Determine sign of this APInt.
APSInt trunc(uint32_t width) const
APInt & operator=(const APInt &RHS)
Copy assignment operator.
APSInt operator|(const APSInt &RHS) const
APSInt & operator=(uint64_t RHS)
int64_t getExtValue() const
Get the correctly-extended int64_t value.
bool operator>(const APSInt &RHS) const
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)
bool operator==(const APSInt &RHS) const
APSInt operator>>(unsigned Amt) const
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
void print(raw_ostream &OS, bool isSigned) const
std::string toString(unsigned Radix) const
toString - Converts an APInt to a std::string.
APSInt operator%(const APSInt &RHS) const
Class for arbitrary precision integers.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
bool operator>(int64_t RHS) const
const APSInt & operator%=(const APSInt &RHS)
bool operator!=(uint64_t V1, const APInt &V2)
APSInt operator<<(unsigned Bits) const
bool operator>=(int64_t RHS) const
bool operator>=(const APSInt &RHS) const
APSInt(APInt I, bool isUnsigned=true)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
APSInt & operator+=(const APSInt &RHS)
bool operator==(int64_t 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)
E & operator &=(E &LHS, E RHS)
APSInt operator+(const APSInt &RHS) const
void toString(SmallVectorImpl< char > &Str, unsigned Radix=10) const
toString - Append this APSInt to the specified SmallString.
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
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 operator<(int64_t RHS) const
APSInt & operator=(APInt RHS)