14 #ifndef LLVM_ADT_APSINT_H 15 #define LLVM_ADT_APSINT_H 31 :
APInt(BitWidth, 0), IsUnsigned(isUnsigned) {}
34 :
APInt(
std::move(I)), IsUnsigned(isUnsigned) {}
94 assert(getMinSignedBits() <= 64 &&
"Too many bits for int64_t");
95 return isSigned() ? getSExtValue() : getZExtValue();
104 return APSInt(zext(width), IsUnsigned);
106 return APSInt(sext(width), IsUnsigned);
111 return APSInt(zextOrTrunc(width), IsUnsigned);
113 return APSInt(sextOrTrunc(width), IsUnsigned);
117 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
125 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
133 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
134 return IsUnsigned ?
APSInt(urem(RHS),
true) :
APSInt(srem(RHS),
false);
137 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
138 return IsUnsigned ?
APSInt(udiv(RHS),
true) :
APSInt(sdiv(RHS),
false);
142 return IsUnsigned ?
APSInt(lshr(Amt),
true) :
APSInt(ashr(Amt),
false);
153 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
154 return IsUnsigned ? ult(RHS) : slt(RHS);
157 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
158 return IsUnsigned ? ugt(RHS) : sgt(RHS);
161 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
162 return IsUnsigned ? ule(RHS) : sle(RHS);
165 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
166 return IsUnsigned ? uge(RHS) : sge(RHS);
169 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
173 return !((*this) == RHS);
177 return compareValues(*
this,
get(RHS)) == 0;
180 return compareValues(*
this,
get(RHS)) != 0;
183 return compareValues(*
this,
get(RHS)) <= 0;
186 return compareValues(*
this,
get(RHS)) >= 0;
189 return compareValues(*
this,
get(RHS)) < 0;
192 return compareValues(*
this,
get(RHS)) > 0;
199 return APSInt(static_cast<const APInt&>(*
this) << Bits, IsUnsigned);
202 static_cast<APInt&
>(*this) <<= Amt;
207 ++(
static_cast<APInt&
>(*this));
211 --(
static_cast<APInt&
>(*this));
215 return APSInt(++static_cast<APInt&>(*
this), IsUnsigned);
218 return APSInt(--static_cast<APInt&>(*
this), IsUnsigned);
221 return APSInt(-static_cast<const APInt&>(*
this), IsUnsigned);
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;
234 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
235 static_cast<APInt&
>(*this) *= RHS;
239 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
240 static_cast<APInt&
>(*this) &= RHS;
244 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
245 static_cast<APInt&
>(*this) |= RHS;
249 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
250 static_cast<APInt&
>(*this) ^= RHS;
255 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
256 return APSInt(static_cast<const APInt&>(*
this) & RHS, IsUnsigned);
260 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
261 return APSInt(static_cast<const APInt&>(*
this) | RHS, IsUnsigned);
265 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
266 return APSInt(static_cast<const APInt&>(*
this) ^ RHS, IsUnsigned);
270 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
271 return APSInt(static_cast<const APInt&>(*
this) * RHS, IsUnsigned);
274 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
275 return APSInt(static_cast<const APInt&>(*
this) + RHS, IsUnsigned);
278 assert(IsUnsigned == RHS.IsUnsigned &&
"Signedness mismatch!");
279 return APSInt(static_cast<const APInt&>(*
this) - RHS, IsUnsigned);
282 return APSInt(~static_cast<const APInt&>(*
this), IsUnsigned);
302 return !compareValues(I1, I2);
308 return I1.IsUnsigned ? I1.compare(I2) : I1.compareSigned(I2);
328 return I1.compare(I2);
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
const APSInt & operator/=(const APSInt &RHS)
bool isNonNegative() const
Determine if this APSInt Value is non-negative (>= 0)
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)
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...
bool isStrictlyPositive() const
Determine if this APSInt Value is positive.
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 isNegative() const
Determine sign of this APSInt.
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)
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
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)