15#ifndef LLVM_ADT_APSINT_H
16#define LLVM_ADT_APSINT_H
24 bool IsUnsigned =
false;
66 APInt::operator=(std::move(
RHS));
72 APInt::operator=(
RHS);
84 APInt::toString(Str, Radix,
isSigned());
86 using APInt::toString;
99 assert(isRepresentableByInt64() &&
"Too many bits for int64_t");
100 return isSigned() ? getSExtValue() : getZExtValue();
104 return isRepresentableByInt64() ? std::optional<int64_t>(getExtValue())
109 return APSInt(APInt::trunc(width), IsUnsigned);
114 return APSInt(zext(width), IsUnsigned);
116 return APSInt(sext(width), IsUnsigned);
121 return APSInt(zextOrTrunc(width), IsUnsigned);
123 return APSInt(sextOrTrunc(width), IsUnsigned);
127 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
135 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
143 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
147 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
152 return IsUnsigned ?
APSInt(lshr(Amt),
true) :
APSInt(ashr(Amt),
false);
162 return IsUnsigned ?
APSInt(relativeLShr(Amt),
true)
163 :
APSInt(relativeAShr(Amt),
false);
167 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
168 return IsUnsigned ? ult(
RHS) : slt(
RHS);
171 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
172 return IsUnsigned ? ugt(
RHS) : sgt(
RHS);
175 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
176 return IsUnsigned ? ule(
RHS) : sle(
RHS);
179 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
180 return IsUnsigned ? uge(
RHS) : sge(
RHS);
183 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
189 return compareValues(*
this,
get(
RHS)) == 0;
192 return compareValues(*
this,
get(
RHS)) != 0;
195 return compareValues(*
this,
get(
RHS)) <= 0;
198 return compareValues(*
this,
get(
RHS)) >= 0;
201 return compareValues(*
this,
get(
RHS)) < 0;
204 return compareValues(*
this,
get(
RHS)) > 0;
211 return APSInt(
static_cast<const APInt &
>(*
this) << Bits, IsUnsigned);
214 static_cast<APInt &
>(*this) <<= Amt;
218 return IsUnsigned ?
APSInt(relativeLShl(Amt),
true)
219 :
APSInt(relativeAShl(Amt),
false);
223 ++(
static_cast<APInt &
>(*this));
227 --(
static_cast<APInt &
>(*this));
231 return APSInt(++
static_cast<APInt &
>(*
this), IsUnsigned);
234 return APSInt(--
static_cast<APInt &
>(*
this), IsUnsigned);
237 return APSInt(-
static_cast<const APInt &
>(*
this), IsUnsigned);
240 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
245 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
250 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
255 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
260 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
265 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
271 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
272 return APSInt(
static_cast<const APInt &
>(*
this) &
RHS, IsUnsigned);
276 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
277 return APSInt(
static_cast<const APInt &
>(*
this) |
RHS, IsUnsigned);
281 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
282 return APSInt(
static_cast<const APInt &
>(*
this) ^
RHS, IsUnsigned);
286 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
287 return APSInt(
static_cast<const APInt &
>(*
this) *
RHS, IsUnsigned);
290 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
291 return APSInt(
static_cast<const APInt &
>(*
this) +
RHS, IsUnsigned);
294 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
295 return APSInt(
static_cast<const APInt &
>(*
this) -
RHS, IsUnsigned);
298 return APSInt(~
static_cast<const APInt &
>(*
this), IsUnsigned);
305 : APInt::getSignedMaxValue(numBits),
313 : APInt::getSignedMinValue(numBits),
320 return !compareValues(I1, I2);
326 return I1.IsUnsigned ? I1.compare(I2) : I1.compareSigned(I2);
330 return compareValues(I1, I2.
extend(I1.getBitWidth()));
332 return compareValues(I1.extend(I2.
getBitWidth()), I2);
346 return I1.compare(I2);
365 I.print(
OS,
I.isSigned());
384 return LHS.getBitWidth() ==
RHS.getBitWidth() &&
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static bool isSigned(unsigned int Opcode)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Class for arbitrary precision integers.
unsigned getBitWidth() const
Return the number of bits in the APInt.
An arbitrary precision integer that knows its signedness.
APSInt extOrTrunc(uint32_t width) const
APSInt & operator+=(const APSInt &RHS)
APSInt operator-(const APSInt &RHS) const
APSInt & operator=(APInt RHS)
static APSInt getMinValue(uint32_t numBits, bool Unsigned)
Return the APSInt representing the minimum integer value with the given bit width and signedness.
bool operator==(int64_t RHS) const
static APSInt get(int64_t X)
bool operator==(const APSInt &RHS) const
bool isNegative() const
Determine sign of this APSInt.
APSInt operator>>(unsigned Amt) const
APSInt operator^(const APSInt &RHS) const
bool operator!=(int64_t RHS) const
APSInt operator*(const APSInt &RHS) const
APSInt & operator*=(const APSInt &RHS)
bool operator>(const APSInt &RHS) const
bool operator>(int64_t RHS) const
APSInt(uint32_t BitWidth, bool isUnsigned=true)
Create an APSInt with the specified width, default to unsigned.
APSInt relativeShr(unsigned Amt) const
bool operator<(const APSInt &RHS) const
static int compareValues(const APSInt &I1, const APSInt &I2)
Compare underlying values of two numbers.
int64_t getExtValue() const
Get the correctly-extended int64_t value.
APSInt operator+(const APSInt &RHS) const
const APSInt & operator/=(const APSInt &RHS)
bool isRepresentableByInt64() const
If this int is representable using an int64_t.
static APSInt getMaxValue(uint32_t numBits, bool Unsigned)
Return the APSInt representing the maximum integer value with the given bit width and signedness.
bool isNonNegative() const
Determine if this APSInt Value is non-negative (>= 0)
static APSInt getUnsigned(uint64_t X)
bool operator<=(int64_t RHS) const
APSInt operator<<(unsigned Bits) const
APSInt operator&(const APSInt &RHS) const
bool isStrictlyPositive() const
Determine if this APSInt Value is positive.
APSInt & operator&=(const APSInt &RHS)
void setIsSigned(bool Val)
bool operator>=(const APSInt &RHS) const
APSInt(APInt I, bool isUnsigned=true)
APSInt operator%(const APSInt &RHS) const
const APSInt & operator%=(const APSInt &RHS)
APSInt & operator|=(const APSInt &RHS)
APSInt relativeShl(unsigned Amt) const
void toString(SmallVectorImpl< char > &Str, unsigned Radix=10) const
Append this APSInt to the specified SmallString.
bool operator!=(const APSInt &RHS) const
std::optional< int64_t > tryExtValue() const
bool operator<(int64_t RHS) const
APSInt()=default
Default constructor that creates an uninitialized APInt.
APSInt & operator>>=(unsigned Amt)
void setIsUnsigned(bool Val)
static bool isSameValue(const APSInt &I1, const APSInt &I2)
Determine if two APSInts have the same value, zero- or sign-extending as needed.
APSInt extend(uint32_t width) const
APSInt & operator-=(const APSInt &RHS)
APSInt operator|(const APSInt &RHS) const
bool operator<=(const APSInt &RHS) const
APSInt operator/(const APSInt &RHS) const
APSInt & operator=(uint64_t RHS)
bool operator>=(int64_t RHS) const
APSInt trunc(uint32_t width) const
APSInt & operator^=(const APSInt &RHS)
APSInt & operator<<=(unsigned Amt)
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
bool operator!=(uint64_t V1, const APInt &V2)
bool operator>=(int64_t V1, const APSInt &V2)
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
bool operator>(int64_t V1, const APSInt &V2)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool operator<=(int64_t V1, const APSInt &V2)
Implement std::hash so that hash_code can be used in STL containers.
static APSInt getEmptyKey()
static bool isEqual(const APSInt &LHS, const APSInt &RHS)
static APSInt getTombstoneKey()
static unsigned getHashValue(const APSInt &Key)
An information struct used to provide DenseMap with the various necessary components for a given valu...