Go to the documentation of this file.
15 #ifndef LLVM_ADT_APSINT_H
16 #define LLVM_ADT_APSINT_H
90 assert(getMinSignedBits() <= 64 &&
"Too many bits for int64_t");
91 return isSigned() ? getSExtValue() : getZExtValue();
100 return APSInt(zext(width), IsUnsigned);
102 return APSInt(sext(width), IsUnsigned);
107 return APSInt(zextOrTrunc(width), IsUnsigned);
109 return APSInt(sextOrTrunc(width), IsUnsigned);
113 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
121 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
129 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
133 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
149 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
150 return IsUnsigned ? ult(
RHS) : slt(
RHS);
153 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
154 return IsUnsigned ? ugt(
RHS) : sgt(
RHS);
157 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
158 return IsUnsigned ? ule(
RHS) : sle(
RHS);
161 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
162 return IsUnsigned ? uge(
RHS) : sge(
RHS);
165 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
169 return !((*this) ==
RHS);
173 return compareValues(*
this,
get(
RHS)) == 0;
176 return compareValues(*
this,
get(
RHS)) != 0;
179 return compareValues(*
this,
get(
RHS)) <= 0;
182 return compareValues(*
this,
get(
RHS)) >= 0;
185 return compareValues(*
this,
get(
RHS)) < 0;
188 return compareValues(*
this,
get(
RHS)) > 0;
198 static_cast<APInt&
>(*this) <<= Amt;
203 ++(
static_cast<APInt&
>(*this));
207 --(
static_cast<APInt&
>(*this));
211 return APSInt(++
static_cast<APInt&
>(*
this), IsUnsigned);
214 return APSInt(--
static_cast<APInt&
>(*
this), IsUnsigned);
217 return APSInt(-
static_cast<const APInt&
>(*
this), IsUnsigned);
220 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
225 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
230 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
235 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
240 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
245 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
251 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
252 return APSInt(
static_cast<const APInt&
>(*
this) &
RHS, IsUnsigned);
256 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
257 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);
266 assert(IsUnsigned ==
RHS.IsUnsigned &&
"Signedness mismatch!");
267 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 return APSInt(~
static_cast<const APInt&
>(*
this), IsUnsigned);
298 return !compareValues(
I1, I2);
304 return I1.IsUnsigned ?
I1.compare(I2) :
I1.compareSigned(I2);
308 return compareValues(
I1, I2.
extend(
I1.getBitWidth()));
324 return I1.compare(I2);
343 I.print(OS,
I.isSigned());
362 return LHS.getBitWidth() ==
RHS.getBitWidth() &&
static bool isSameValue(const APSInt &I1, const APSInt &I2)
Determine if two APSInts have the same value, zero- or sign-extending as needed.
APSInt operator|(const APSInt &RHS) const
This is an optimization pass for GlobalISel generic memory operations.
APSInt operator-(const APSInt &RHS) const
APSInt(APInt I, bool isUnsigned=true)
bool operator<(int64_t RHS) const
bool operator<=(int64_t V1, const APSInt &V2)
static int compareValues(const APSInt &I1, const APSInt &I2)
Compare underlying values of two numbers.
bool operator==(const APSInt &RHS) const
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
APSInt(uint32_t BitWidth, bool isUnsigned=true)
Create an APSInt with the specified width, default to unsigned.
static APSInt getUnsigned(uint64_t X)
APSInt & operator=(uint64_t RHS)
bool isStrictlyPositive() const
Determine if this APSInt Value is positive.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
void setIsSigned(bool Val)
unsigned getBitWidth() const
Return the number of bits in the APInt.
APSInt extend(uint32_t width) const
bool operator==(int64_t RHS) const
bool operator!=(uint64_t V1, const APInt &V2)
bool operator!=(int64_t RHS) const
bool operator<=(int64_t RHS) const
const APSInt & operator/=(const APSInt &RHS)
APSInt operator>>(unsigned Amt) const
APSInt & operator^=(const APSInt &RHS)
An information struct used to provide DenseMap with the various necessary components for a given valu...
bool operator>=(const APSInt &RHS) const
bool isNegative() const
Determine sign of this APInt.
APSInt operator+(const APSInt &RHS) const
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
APSInt & operator*=(const APSInt &RHS)
static APSInt getTombstoneKey()
An arbitrary precision integer that knows its signedness.
This class implements an extremely fast bulk output stream that can only output to a stream.
void setIsUnsigned(bool Val)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
APSInt operator*(const APSInt &RHS) const
APSInt & operator-=(const APSInt &RHS)
void toString(SmallVectorImpl< char > &Str, unsigned Radix=10) const
Append this APSInt to the specified SmallString.
static APSInt getMinValue(uint32_t numBits, bool Unsigned)
Return the APSInt representing the minimum integer value with the given bit width and signedness.
APSInt operator/(const APSInt &RHS) const
APSInt operator%(const APSInt &RHS) const
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
bool operator!=(const APSInt &RHS) const
bool operator>(int64_t RHS) const
APSInt & operator<<=(unsigned Amt)
bool operator>=(int64_t V1, const APSInt &V2)
bool operator>=(int64_t RHS) const
static bool isEqual(const APSInt &LHS, const APSInt &RHS)
void toString(SmallVectorImpl< char > &Str, unsigned Radix, bool Signed, bool formatAsCLiteral=false) const
Converts an APInt to a string and append it to Str.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
bool operator<(int64_t V1, const APSInt &V2)
APSInt & operator=(APInt RHS)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool operator==(uint64_t V1, const APInt &V2)
APSInt & operator&=(const APSInt &RHS)
Class for arbitrary precision integers.
bool operator<=(const APSInt &RHS) const
static APSInt getMaxValue(uint32_t numBits, bool Unsigned)
Return the APSInt representing the maximum integer value with the given bit width and signedness.
StringRef - Represent a constant reference to a string, i.e.
static unsigned getHashValue(const APSInt &Key)
bool operator<(const APSInt &RHS) const
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
static APSInt getEmptyKey()
APSInt & operator+=(const APSInt &RHS)
APSInt()
Default constructor that creates an uninitialized APInt.
APSInt extOrTrunc(uint32_t width) const
APSInt trunc(uint32_t width) const
APSInt operator&(const APSInt &RHS) const
APInt trunc(unsigned width) const
Truncate to new width.
APInt & operator=(const APInt &RHS)
Copy assignment operator.
Should compile to something r4 addze r3 instead we get
constexpr unsigned BitWidth
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
APSInt & operator>>=(unsigned Amt)
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
APSInt operator<<(unsigned Bits) const
bool isNegative() const
Determine sign of this APSInt.
bool operator>(const APSInt &RHS) const
bool operator>(int64_t V1, const APSInt &V2)
APSInt operator^(const APSInt &RHS) const
int64_t getExtValue() const
Get the correctly-extended int64_t value.
APSInt & operator|=(const APSInt &RHS)
const APSInt & operator%=(const APSInt &RHS)
Vector Shift Left don t map to llvm shl and lshr
bool isNonNegative() const
Determine if this APSInt Value is non-negative (>= 0)
static APSInt get(int64_t X)