42 : Lower(std::move(V)), Upper(Lower + 1) {}
45 : Lower(std::move(L)), Upper(std::move(U)) {
47 "ConstantRange with unequal bit widths");
49 "Lower == Upper, but they aren't min or max value!");
69 if (UMax.isMinValue())
75 if (SMax.isMinSignedValue())
81 if (UMax.isMaxValue())
87 if (SMax.isMaxSignedValue())
93 if (UMin.isMaxValue())
99 if (SMin.isMaxSignedValue())
105 if (UMin.isMinValue())
111 if (SMin.isMinSignedValue())
144 return Lower.
ugt(Upper);
225 return Lower.
ule(V) && V.
ult(Upper);
226 return Lower.
ule(V) || V.
ult(Upper);
274 "ConstantRange types don't agree!");
284 if (Lower.
ult(CR.Lower)) {
285 if (Upper.
ule(CR.Lower))
288 if (Upper.
ult(CR.Upper))
293 if (Upper.
ult(CR.Upper))
296 if (Lower.
ult(CR.Upper))
303 if (CR.Lower.
ult(Upper)) {
304 if (CR.Upper.
ult(Upper))
307 if (CR.Upper.
ule(Lower))
314 if (CR.Lower.
ult(Lower)) {
315 if (CR.Upper.
ule(Lower))
323 if (CR.Upper.
ult(Upper)) {
324 if (CR.Lower.
ult(Upper)) {
330 if (CR.Lower.
ult(Lower))
335 if (CR.Upper.
ule(Lower)) {
336 if (CR.Lower.
ult(Lower))
355 "ConstantRange types don't agree!");
363 if (CR.Upper.
ult(Lower) || Upper.
ult(CR.Lower)) {
365 APInt d1 = CR.Lower - Upper, d2 = Lower - CR.Upper;
371 APInt L = Lower, U = Upper;
374 if ((CR.Upper - 1).ugt(U - 1))
377 if (L == 0 && U == 0)
386 if (CR.Upper.
ule(Upper) || CR.Lower.
uge(Lower))
391 if (CR.Lower.
ule(Upper) && Lower.
ule(CR.Upper))
397 if (Upper.
ule(CR.Lower) && CR.Upper.
ule(Lower)) {
398 APInt d1 = CR.Lower - Upper, d2 = Lower - CR.Upper;
406 if (Upper.
ult(CR.Lower) && Lower.
ult(CR.Upper))
411 assert(CR.Lower.
ult(Upper) && CR.Upper.
ult(Lower) &&
412 "ConstantRange::unionWith missed a case with one range wrapped");
418 if (CR.Lower.
ule(Upper) || Lower.
ule(CR.Upper))
421 APInt L = Lower, U = Upper;
438 assert(SrcTySize < DstTySize &&
"Not a value extension");
441 APInt LowerExt(DstTySize, 0);
443 LowerExt = Lower.
zext(DstTySize);
458 assert(SrcTySize < DstTySize &&
"Not a value extension");
477 assert(
getBitWidth() > DstTySize &&
"Not a value truncation");
485 MaxBitValue.
setBit(DstTySize);
487 APInt LowerDiv(Lower), UpperDiv(Upper);
495 if (Upper.
uge(MaxValue))
503 if (LowerDiv == UpperDiv)
508 if (LowerDiv.uge(MaxValue)) {
511 UpperDiv = UpperDiv - MaxBitValue * Div;
514 if (UpperDiv.
ule(MaxValue))
519 APInt UpperModulo = UpperDiv - MaxBitValue;
520 if (UpperModulo.
ult(LowerDiv))
531 if (SrcTySize > DstTySize)
533 if (SrcTySize < DstTySize)
542 if (SrcTySize > DstTySize)
544 if (SrcTySize < DstTySize)
559 if (NewLower == NewUpper)
580 if (NewLower == NewUpper)
614 this_max * Other_max + 1);
628 auto L = {this_min * Other_min, this_min * Other_max,
629 this_max * Other_min, this_max * Other_max};
764 OS <<
"[" << Lower <<
"," << Upper <<
")";
APInt getSignedMin() const
Return the smallest signed value contained in the ConstantRange.
ConstantRange sextOrTrunc(uint32_t BitWidth) const
Make this range have the bit width given by BitWidth.
void setBit(unsigned bitPosition)
Set a given bit to 1.
uint32_t getBitWidth() const
Get the bit width of this ConstantRange.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Get a value with low bits set.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
APInt getSignedMax() const
Return the largest signed value contained in the ConstantRange.
bool isSingleElement() const
Return true if this set contains exactly one member.
static ConstantRange makeAllowedICmpRegion(CmpInst::Predicate Pred, const ConstantRange &Other)
Produce the smallest range such that all values that may satisfy the given predicate with any value c...
std::size_t countLeadingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the most significant bit to the least stopping at the first 1...
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
ConstantRange smax(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a signed maximum of a value in thi...
ConstantRange truncate(uint32_t BitWidth) const
Return a new range in the specified integer type, which must be strictly smaller than the current typ...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT lshr(unsigned shiftAmt) const
Logical right-shift function.
Number of individual test Apply this number of consecutive mutations to each input exit after the first new interesting input is found the minimized corpus is saved into the first input directory Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
APInt umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
ConstantRange signExtend(uint32_t BitWidth) const
Return a new range in the specified integer type, which must be strictly larger than the current type...
ConstantRange multiply(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a multiplication of a value in thi...
bool contains(const APInt &Val) const
Return true if the specified value is in the set.
ConstantRange unionWith(const ConstantRange &CR) const
Return the range that results from the union of this range with another range.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT shl(unsigned shiftAmt) const
Left-shift function.
void dump() const
Allow printing from a debugger easily.
ConstantRange subtract(const APInt &CI) const
Subtract the specified constant from the endpoints of this constant range.
bool ult(const APInt &RHS) const
Unsigned less than comparison.
static ConstantRange makeSatisfyingICmpRegion(CmpInst::Predicate Pred, const ConstantRange &Other)
Produce the largest range such that all values in the returned range satisfy the given predicate with...
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
ConstantRange intersectWith(const ConstantRange &CR) const
Return the range that results from the intersection of this range with another range.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT trunc(unsigned width) const
Truncate to new width.
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type. ...
ConstantRange lshr(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a logical right shift of a value i...
bool isWrappedSet() const
Return true if this set wraps around the top of the range.
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sext(unsigned width) const
Sign extend to a new width.
ConstantRange udiv(const ConstantRange &Other) const
Return a new range representing the possible values resulting from an unsigned division of a value in...
ConstantRange(uint32_t BitWidth, bool isFullSet=true)
Initialize a full (the default) or empty set for the specified bit width.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
bool isMaxValue() const
Determine if this is the largest unsigned value.
ConstantRange sub(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a subtraction of a value in this r...
void print(raw_ostream &OS) const
Print out the bounds to a stream.
ConstantRange zeroExtend(uint32_t BitWidth) const
Return a new range in the specified integer type, which must be strictly larger than the current type...
bool isEmptySet() const
Return true if this set contains no members.
ConstantRange difference(const ConstantRange &CR) const
Subtract the specified range from this range (aka relative complement of the sets).
ConstantRange add(const ConstantRange &Other) const
Return a new range representing the possible values resulting from an addition of a value in this ran...
bool ugt(const APInt &RHS) const
Unsigned greather than comparison.
bool slt(const APInt &RHS) const
Signed less than comparison.
bool isSignWrappedSet() const
Return true if this set wraps around the INT_MIN of its bitwidth.
APInt getSetSize() const
Return the number of elements in this set.
ConstantRange inverse() const
Return a new range that is the logical not of the current set.
This class represents a range of values.
const APInt & getLower() const
Return the lower value for this range.
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
APInt umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
APInt smax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be signed.
ConstantRange binaryOr(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a binary-or of a value in this ran...
Class for arbitrary precision integers.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
bool isMinValue() const
Determine if this is the smallest unsigned value.
ConstantRange shl(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a left shift of a value in this ra...
ConstantRange umax(const ConstantRange &Other) const
Return a new range representing the possible values resulting from an unsigned maximum of a value in ...
bool isAllOnesValue() const
Determine if all bits are set.
bool isMinSignedValue() const
Determine if this is the smallest signed value.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT udiv(const APInt &RHS) const
Unsigned division operation.
unsigned greater or equal
ConstantRange binaryAnd(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a binary-and of a value in this ra...
const APInt & getUpper() const
Return the upper value for this range.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
static void udivrem(const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
Dual division/remainder interface.
ConstantRange zextOrTrunc(uint32_t BitWidth) const
Make this range have the bit width given by BitWidth.
This class implements an extremely fast bulk output stream that can only output to a stream...
APInt LLVM_ATTRIBUTE_UNUSED_RESULT zext(unsigned width) const
Zero extend to a new width.
static APInt getNullValue(unsigned numBits)
Get the '0' value.
APInt getUnsignedMax() const
Return the largest unsigned value contained in the ConstantRange.
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
APInt getUnsignedMin() const
Return the smallest unsigned value contained in the ConstantRange.