9#ifndef LLVM_ANALYSIS_VALUELATTICE_H 
   10#define LLVM_ANALYSIS_VALUELATTICE_H 
   28  enum ValueLatticeElementTy {
 
   72    constantrange_including_undef,
 
   79  ValueLatticeElementTy Tag : 8;
 
   81  unsigned NumRangeExtensions : 8;
 
  100    case constantrange_including_undef:
 
  102      Range.~ConstantRange();
 
  151      : Tag(
Other.Tag), NumRangeExtensions(0) {
 
  154    case constantrange_including_undef:
 
  155      new (&Range) ConstantRange(Other.Range);
 
  156      NumRangeExtensions = Other.NumRangeExtensions;
 
  160      ConstVal = Other.ConstVal;
 
 
  170      : Tag(
Other.Tag), NumRangeExtensions(0) {
 
  173    case constantrange_including_undef:
 
  174      new (&Range) ConstantRange(std::move(Other.Range));
 
  175      NumRangeExtensions = Other.NumRangeExtensions;
 
  179      ConstVal = Other.ConstVal;
 
 
  213                                      bool MayIncludeUndef = 
false) {
 
 
  241    return Tag == constantrange_including_undef;
 
 
  248    return Tag == constantrange || (Tag == constantrange_including_undef &&
 
  249                                    (UndefAllowed || 
Range.isSingleElement()));
 
 
  269           "Cannot get the constant-range of a non-constant-range!");
 
 
  288      return ConstantRange::getEmpty(BW);
 
  289    return ConstantRange::getFull(BW);
 
 
  293    assert(Ty->isIntOrIntVectorTy() && 
"Must be integer type");
 
 
  335    assert(V && 
"Marking constant with NULL");
 
 
  367    ValueLatticeElementTy OldTag = Tag;
 
  368    ValueLatticeElementTy NewTag =
 
  370            ? constantrange_including_undef
 
  375        return Tag != OldTag;
 
  379      if (Opts.CheckWiden && ++NumRangeExtensions > Opts.MaxWidenSteps)
 
  383             "Existing range must be a subset of NewR");
 
  384      Range = std::move(NewR);
 
  390           "Constant must be subset of new range");
 
  392    NumRangeExtensions = 0;
 
 
  404    if (
RHS.isOverdefined()) {
 
  413      if (
RHS.isConstant())
 
  415      if (
RHS.isConstantRange())
 
  417                                 Opts.setMayIncludeUndef());
 
  422      assert(!
RHS.isUnknown() && 
"Unknow RHS should be handled earlier");
 
  437            RHS.asConstantRange(L.getBitWidth(), 
true));
 
  440            Opts.setMayIncludeUndef(
RHS.isConstantRangeIncludingUndef()));
 
  456      Tag = constantrange_including_undef;
 
  457      return OldTag != Tag;
 
  462        RHS.asConstantRange(L.getBitWidth(), 
true));
 
  465        Opts.setMayIncludeUndef(
RHS.isConstantRangeIncludingUndef()));
 
 
 
  497static_assert(
sizeof(ValueLatticeElement) <= 40,
 
  498              "size of ValueLatticeElement changed unexpectedly");
 
  501                                 const ValueLatticeElement &Val);
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
 
This file contains the declarations for the subclasses of Constant, which represent the different fla...
 
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
 
static SymbolRef::Type getType(const Symbol *Sym)
 
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.
 
LLVM_ABI bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type.
 
LLVM_ABI bool isEmptySet() const
Return true if this set contains no members.
 
LLVM_ABI bool contains(const APInt &Val) const
Return true if the specified value is in the set.
 
This is an important base class in LLVM.
 
LLVM_ABI ConstantRange toConstantRange() const
Convert constant to an approximate constant range.
 
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
 
LLVM_ABI 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)
 
ConstantRange asConstantRange(unsigned BW, bool UndefAllowed=false) const
 
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
 
LLVM_ABI ValueLatticeElement intersect(const ValueLatticeElement &Other) const
Combine two sets of facts about the same value into a single set of facts.
 
bool isUnknownOrUndef() const
 
ConstantRange asConstantRange(Type *Ty, bool UndefAllowed=false) 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.
 
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
 
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
 
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
 
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
 
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).