15#ifndef LLVM_ADT_APSINT_H
16#define LLVM_ADT_APSINT_H
25 bool IsUnsigned =
false;
128 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
136 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
144 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
148 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
168 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
172 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
176 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
180 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
184 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
212 return APSInt(
static_cast<const APInt &
>(*
this) << Bits, IsUnsigned);
215 static_cast<APInt &
>(*this) <<= Amt;
224 ++(
static_cast<APInt &
>(*this));
228 --(
static_cast<APInt &
>(*this));
232 return APSInt(++
static_cast<APInt &
>(*
this), IsUnsigned);
235 return APSInt(--
static_cast<APInt &
>(*
this), IsUnsigned);
238 return APSInt(-
static_cast<const APInt &
>(*
this), IsUnsigned);
241 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
246 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
251 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
256 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
261 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
266 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
272 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
273 return APSInt(
static_cast<const APInt &
>(*
this) &
RHS, IsUnsigned);
277 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
278 return APSInt(
static_cast<const APInt &
>(*
this) |
RHS, IsUnsigned);
282 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
283 return APSInt(
static_cast<const APInt &
>(*
this) ^
RHS, IsUnsigned);
287 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
288 return APSInt(
static_cast<const APInt &
>(*
this) *
RHS, IsUnsigned);
291 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
292 return APSInt(
static_cast<const APInt &
>(*
this) +
RHS, IsUnsigned);
295 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
296 return APSInt(
static_cast<const APInt &
>(*
this) -
RHS, IsUnsigned);
299 return APSInt(~
static_cast<const APInt &
>(*
this), IsUnsigned);
327 return I1.IsUnsigned ? I1.compare(I2) : I1.compareSigned(I2);
347 return I1.compare(I2);
366 I.print(OS,
I.isSigned());
385 return LHS.getBitWidth() ==
RHS.getBitWidth() &&
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
static bool isSigned(unsigned int Opcode)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
LLVM_ABI APInt udiv(const APInt &RHS) const
Unsigned division operation.
APInt relativeLShr(int RelativeShift) const
relative logical shift right
LLVM_ABI APInt zext(unsigned width) const
Zero extend to a new width.
uint64_t getZExtValue() const
Get zero extended value.
LLVM_ABI APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
APInt relativeLShl(int RelativeShift) const
relative logical shift left
APInt & operator=(const APInt &RHS)
Copy assignment operator.
bool sgt(const APInt &RHS) const
Signed greater than comparison.
APInt(unsigned numBits, uint64_t val, bool isSigned=false, bool implicitTrunc=false)
Create a new APInt of numBits width, initialized as val.
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
LLVM_ABI APInt urem(const APInt &RHS) const
Unsigned remainder operation.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool ult(const APInt &RHS) const
Unsigned less than comparison.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
APInt relativeAShr(int RelativeShift) const
relative arithmetic shift right
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
bool isNegative() const
Determine sign of this APInt.
bool eq(const APInt &RHS) const
Equality comparison.
LLVM_ABI APInt sdiv(const APInt &RHS) const
Signed division function for APInt.
APInt relativeAShl(int RelativeShift) const
relative arithmetic shift left
void ashrInPlace(unsigned ShiftAmt)
Arithmetic right-shift this APInt by ShiftAmt in place.
bool sle(const APInt &RHS) const
Signed less or equal comparison.
bool isSignedIntN(unsigned N) const
Check if this APInt has an N-bits signed integer value.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
LLVM_ABI APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
APInt ashr(unsigned ShiftAmt) const
Arithmetic right-shift function.
LLVM_ABI APInt srem(const APInt &RHS) const
Function for signed remainder operation.
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
bool slt(const APInt &RHS) const
Signed less than comparison.
bool isIntN(unsigned N) const
Check if this APInt has an N-bits unsigned integer value.
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
int64_t getSExtValue() const
Get sign extended value.
void lshrInPlace(unsigned ShiftAmt)
Logical right-shift this APInt by ShiftAmt in place.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
LLVM_ABI void toString(SmallVectorImpl< char > &Str, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false) const
Converts an APInt to a string and append it to Str.
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
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)
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
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...