9#ifndef LLVM_ANALYSIS_VALUELATTICE_H
10#define LLVM_ANALYSIS_VALUELATTICE_H
30 enum ValueLatticeElementTy {
74 constantrange_including_undef,
81 ValueLatticeElementTy
Tag : 8;
83 unsigned NumRangeExtensions : 8;
102 case constantrange_including_undef:
104 Range.~ConstantRange();
156 case constantrange_including_undef:
158 NumRangeExtensions =
Other.NumRangeExtensions;
175 case constantrange_including_undef:
177 NumRangeExtensions =
Other.NumRangeExtensions;
205 if (isa<UndefValue>(
C))
213 assert(!isa<UndefValue>(
C) &&
"!= undef is not supported");
218 bool MayIncludeUndef =
false) {
246 return Tag == constantrange_including_undef;
253 return Tag == constantrange || (
Tag == constantrange_including_undef &&
274 "Cannot get the constant-range of a non-constant-range!");
280 return cast<ConstantInt>(
getConstant())->getValue();
305 if (isa<UndefValue>(V))
325 assert(V &&
"Marking constant with NULL");
330 if (isa<UndefValue>(V))
357 ValueLatticeElementTy OldTag =
Tag;
358 ValueLatticeElementTy NewTag =
360 ? constantrange_including_undef
365 return Tag != OldTag;
369 if (Opts.CheckWiden && ++NumRangeExtensions > Opts.MaxWidenSteps)
373 "Existing range must be a subset of NewR");
374 Range = std::move(NewR);
380 NumRangeExtensions = 0;
392 if (
RHS.isOverdefined()) {
401 if (
RHS.isConstant())
403 if (
RHS.isConstantRange())
405 Opts.setMayIncludeUndef());
410 assert(!
RHS.isUnknown() &&
"Unknow RHS should be handled earlier");
434 Tag = constantrange_including_undef;
435 return OldTag !=
Tag;
438 if (!
RHS.isConstantRange()) {
448 Opts.setMayIncludeUndef(
RHS.isConstantRangeIncludingUndef()));
462static_assert(
sizeof(ValueLatticeElement) <= 40,
463 "size of ValueLatticeElement changed unexpectedly");
465raw_ostream &
operator<<(raw_ostream &
OS,
const ValueLatticeElement &Val);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the declarations for the subclasses of Constant, which represent the different fla...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
This is the shared class of boolean and integer constants.
This class represents a range of values.
const APInt * getSingleElement() const
If this set contains a single element, return it, otherwise return null.
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type.
bool isEmptySet() const
Return true if this set contains no members.
bool isSingleElement() const
Return true if this set contains exactly one member.
ConstantRange unionWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the union of this range with another range.
bool contains(const APInt &Val) const
Return true if the specified value is in the set.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
The instances of the Type class are immutable: once they are created, they are never changed.
This class represents lattice values for constants.
bool markNotConstant(Constant *V)
static ValueLatticeElement getRange(ConstantRange CR, bool MayIncludeUndef=false)
bool isOverdefined() const
Constant * getCompare(CmpInst::Predicate Pred, Type *Ty, const ValueLatticeElement &Other, const DataLayout &DL) const
true, false or undef constants, or nullptr if the comparison cannot be evaluated.
bool isConstantRangeIncludingUndef() const
ValueLatticeElement(const ValueLatticeElement &Other)
static ValueLatticeElement getNot(Constant *C)
bool isNotConstant() const
std::optional< APInt > asConstantInteger() const
ValueLatticeElement & operator=(const ValueLatticeElement &Other)
ValueLatticeElement(ValueLatticeElement &&Other)
void setNumRangeExtensions(unsigned N)
const ConstantRange & getConstantRange(bool UndefAllowed=true) const
Returns the constant range for this value.
bool isConstantRange(bool UndefAllowed=true) const
Returns true if this value is a constant range.
static ValueLatticeElement get(Constant *C)
unsigned getNumRangeExtensions() const
Constant * getNotConstant() const
bool isUnknownOrUndef() const
Constant * getConstant() const
bool mergeIn(const ValueLatticeElement &RHS, MergeOptions Opts=MergeOptions())
Updates this object to approximate both this object and RHS.
ValueLatticeElement & operator=(ValueLatticeElement &&Other)
bool markConstant(Constant *V, bool MayIncludeUndef=false)
static ValueLatticeElement getOverdefined()
bool markConstantRange(ConstantRange NewR, MergeOptions Opts=MergeOptions())
Mark the object as constant range with NewR.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Struct to control some aspects related to merging constant ranges.
bool MayIncludeUndef
The merge value may include undef.
MergeOptions & setMayIncludeUndef(bool V=true)
bool CheckWiden
Handle repeatedly extending a range by going to overdefined after a number of steps.
MergeOptions & setMaxWidenSteps(unsigned Steps=1)
MergeOptions & setCheckWiden(bool V=true)
MergeOptions(bool MayIncludeUndef, bool CheckWiden, unsigned MaxWidenSteps=1)
unsigned MaxWidenSteps
The number of allowed widening steps (including setting the range initially).