Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
llvm::ValueLatticeElement Class Reference

This class represents lattice values for constants. More...

#include "llvm/Analysis/ValueLattice.h"

Classes

struct  MergeOptions
 Struct to control some aspects related to merging constant ranges. More...

Public Member Functions

 ValueLatticeElement ()
 ~ValueLatticeElement ()
 ValueLatticeElement (const ValueLatticeElement &Other)
 ValueLatticeElement (ValueLatticeElement &&Other)
ValueLatticeElementoperator= (const ValueLatticeElement &Other)
ValueLatticeElementoperator= (ValueLatticeElement &&Other)
bool isUndef () const
bool isUnknown () const
bool isUnknownOrUndef () const
bool isConstant () const
bool isNotConstant () const
bool isConstantRangeIncludingUndef () const
bool isConstantRange (bool UndefAllowed=true) const
 Returns true if this value is a constant range.
bool isOverdefined () const
ConstantgetConstant () const
ConstantgetNotConstant () const
const ConstantRangegetConstantRange (bool UndefAllowed=true) const
 Returns the constant range for this value.
std::optional< APIntasConstantInteger () const
ConstantRange asConstantRange (unsigned BW, bool UndefAllowed=false) const
ConstantRange asConstantRange (Type *Ty, bool UndefAllowed=false) const
bool markOverdefined ()
bool markUndef ()
bool markConstant (Constant *V, bool MayIncludeUndef=false)
bool markNotConstant (Constant *V)
bool markConstantRange (ConstantRange NewR, MergeOptions Opts=MergeOptions())
 Mark the object as constant range with NewR.
bool mergeIn (const ValueLatticeElement &RHS, MergeOptions Opts=MergeOptions())
 Updates this object to approximate both this object and RHS.
LLVM_ABI ConstantgetCompare (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.
LLVM_ABI ValueLatticeElement intersect (const ValueLatticeElement &Other) const
 Combine two sets of facts about the same value into a single set of facts.
unsigned getNumRangeExtensions () const
void setNumRangeExtensions (unsigned N)

Static Public Member Functions

static ValueLatticeElement get (Constant *C)
static ValueLatticeElement getNot (Constant *C)
static ValueLatticeElement getRange (ConstantRange CR, bool MayIncludeUndef=false)
static ValueLatticeElement getOverdefined ()

Detailed Description

This class represents lattice values for constants.

FIXME: This is basically just for bringup, this can be made a lot more rich in the future.

Definition at line 27 of file ValueLattice.h.

Constructor & Destructor Documentation

◆ ValueLatticeElement() [1/3]

llvm::ValueLatticeElement::ValueLatticeElement ( )
inline

◆ ~ValueLatticeElement()

llvm::ValueLatticeElement::~ValueLatticeElement ( )
inline

Definition at line 148 of file ValueLattice.h.

◆ ValueLatticeElement() [2/3]

llvm::ValueLatticeElement::ValueLatticeElement ( const ValueLatticeElement & Other)
inline

Definition at line 150 of file ValueLattice.h.

References llvm::Other, and ValueLatticeElement().

◆ ValueLatticeElement() [3/3]

llvm::ValueLatticeElement::ValueLatticeElement ( ValueLatticeElement && Other)
inline

Definition at line 169 of file ValueLattice.h.

References llvm::Other, and ValueLatticeElement().

Member Function Documentation

◆ asConstantInteger()

std::optional< APInt > llvm::ValueLatticeElement::asConstantInteger ( ) const
inline

◆ asConstantRange() [1/2]

ConstantRange llvm::ValueLatticeElement::asConstantRange ( Type * Ty,
bool UndefAllowed = false ) const
inline

Definition at line 292 of file ValueLattice.h.

References asConstantRange(), and assert().

◆ asConstantRange() [2/2]

ConstantRange llvm::ValueLatticeElement::asConstantRange ( unsigned BW,
bool UndefAllowed = false ) const
inline

◆ get()

ValueLatticeElement llvm::ValueLatticeElement::get ( Constant * C)
inlinestatic

◆ getCompare()

◆ getConstant()

Constant * llvm::ValueLatticeElement::getConstant ( ) const
inline

◆ getConstantRange()

const ConstantRange & llvm::ValueLatticeElement::getConstantRange ( bool UndefAllowed = true) const
inline

Returns the constant range for this value.

Use UndefAllowed to exclude non-singleton constant ranges that may also be undef. Note that this function also returns a range if the range may include undef, but only contains a single element. In that case, it can be replaced by a constant.

Definition at line 267 of file ValueLattice.h.

References assert(), isConstantRange(), and Range.

Referenced by asConstantInteger(), asConstantRange(), getCompare(), llvm::SCCPInstVisitor::getConstant(), getPredicateResult(), hasSingleValue(), llvm::hasSingleValue(), llvm::inferAttribute(), intersect(), llvm::SCCPSolver::isConstant(), markConstantRange(), mergeIn(), and llvm::operator<<().

◆ getNot()

ValueLatticeElement llvm::ValueLatticeElement::getNot ( Constant * C)
inlinestatic

◆ getNotConstant()

Constant * llvm::ValueLatticeElement::getNotConstant ( ) const
inline

◆ getNumRangeExtensions()

unsigned llvm::ValueLatticeElement::getNumRangeExtensions ( ) const
inline

Definition at line 493 of file ValueLattice.h.

◆ getOverdefined()

◆ getRange()

◆ intersect()

ValueLatticeElement llvm::ValueLatticeElement::intersect ( const ValueLatticeElement & Other) const

Combine two sets of facts about the same value into a single set of facts.

Note that this method is not suitable for merging facts along different paths in a CFG; that's what the mergeIn function is for. This is for merging facts gathered about the same value at the same location through two independent means. Notes:

  • This method does not promise to return the most precise possible lattice value implied by A and B. It is allowed to return any lattice element which is at least as strong as either A or B (unless our facts conflict, see below).
  • Due to unreachable code, the intersection of two lattice values could be contradictory. If this happens, we return some valid lattice value so as not confuse the rest of LVI. Ideally, we'd always return Undefined, but we do not make this guarantee. TODO: This would be a useful enhancement.

Definition at line 78 of file ValueLattice.cpp.

References getConstantRange(), getRange(), llvm::hasSingleValue(), llvm::ConstantRange::intersectWith(), isConstantRange(), isConstantRangeIncludingUndef(), isOverdefined(), isUnknown(), llvm::Other, Range, and ValueLatticeElement().

Referenced by llvm::LazyValueInfoImpl::getValueAtUse().

◆ isConstant()

◆ isConstantRange()

bool llvm::ValueLatticeElement::isConstantRange ( bool UndefAllowed = true) const
inline

Returns true if this value is a constant range.

Use UndefAllowed to exclude non-singleton constant ranges that may also be undef. Note that this function also returns true if the range may include undef, but only contains a single element. In that case, it can be replaced by a constant.

Definition at line 247 of file ValueLattice.h.

References Range.

Referenced by asConstantInteger(), asConstantRange(), getCompare(), llvm::SCCPInstVisitor::getConstant(), getConstantRange(), getPredicateResult(), hasSingleValue(), llvm::hasSingleValue(), llvm::inferAttribute(), intersect(), llvm::SCCPSolver::isConstant(), markConstantRange(), mergeIn(), and llvm::operator<<().

◆ isConstantRangeIncludingUndef()

bool llvm::ValueLatticeElement::isConstantRangeIncludingUndef ( ) const
inline

◆ isNotConstant()

bool llvm::ValueLatticeElement::isNotConstant ( ) const
inline

◆ isOverdefined()

bool llvm::ValueLatticeElement::isOverdefined ( ) const
inline

Definition at line 251 of file ValueLattice.h.

Referenced by intersect(), markOverdefined(), mergeIn(), and llvm::operator<<().

◆ isUndef()

bool llvm::ValueLatticeElement::isUndef ( ) const
inline

◆ isUnknown()

◆ isUnknownOrUndef()

bool llvm::ValueLatticeElement::isUnknownOrUndef ( ) const
inline

Definition at line 237 of file ValueLattice.h.

Referenced by llvm::SCCPSolver::isOverdefined().

◆ markConstant()

bool llvm::ValueLatticeElement::markConstant ( Constant * V,
bool MayIncludeUndef = false )
inline

◆ markConstantRange()

bool llvm::ValueLatticeElement::markConstantRange ( ConstantRange NewR,
MergeOptions Opts = MergeOptions() )
inline

Mark the object as constant range with NewR.

If the object is already a constant range, nothing changes if the existing range is equal to NewR and the tag. Otherwise NewR must be a superset of the existing range or the object must be undef. The tag is set to constant_range_including_undef if either the existing value or the new range may include undef.

Definition at line 360 of file ValueLattice.h.

References assert(), llvm::ConstantRange::contains(), getConstant(), getConstantRange(), isConstant(), isConstantRange(), isConstantRangeIncludingUndef(), llvm::ConstantRange::isEmptySet(), llvm::ConstantRange::isFullSet(), isUndef(), isUnknown(), markOverdefined(), and Range.

Referenced by getRange(), markConstant(), markNotConstant(), and mergeIn().

◆ markNotConstant()

bool llvm::ValueLatticeElement::markNotConstant ( Constant * V)
inline

◆ markOverdefined()

bool llvm::ValueLatticeElement::markOverdefined ( )
inline

Definition at line 297 of file ValueLattice.h.

References isOverdefined().

Referenced by getOverdefined(), markConstantRange(), and mergeIn().

◆ markUndef()

bool llvm::ValueLatticeElement::markUndef ( )
inline

Definition at line 305 of file ValueLattice.h.

References assert(), isUndef(), and isUnknown().

Referenced by getRange(), and markConstant().

◆ mergeIn()

bool llvm::ValueLatticeElement::mergeIn ( const ValueLatticeElement & RHS,
MergeOptions Opts = MergeOptions() )
inline

Updates this object to approximate both this object and RHS.

Returns true if this object has been changed.

Definition at line 400 of file ValueLattice.h.

References assert(), getConstant(), getConstantRange(), getNotConstant(), getType(), isConstant(), isConstantRange(), isNotConstant(), isOverdefined(), isUndef(), isUnknown(), markConstant(), markConstantRange(), markOverdefined(), RHS, llvm::Constant::toConstantRange(), and ValueLatticeElement().

◆ operator=() [1/2]

ValueLatticeElement & llvm::ValueLatticeElement::operator= ( const ValueLatticeElement & Other)
inline

Definition at line 189 of file ValueLattice.h.

References llvm::Other, and ValueLatticeElement().

◆ operator=() [2/2]

ValueLatticeElement & llvm::ValueLatticeElement::operator= ( ValueLatticeElement && Other)
inline

Definition at line 195 of file ValueLattice.h.

References llvm::Other, and ValueLatticeElement().

◆ setNumRangeExtensions()

void llvm::ValueLatticeElement::setNumRangeExtensions ( unsigned N)
inline

Definition at line 494 of file ValueLattice.h.

References N.

Member Data Documentation

◆ ConstVal

Constant* llvm::ValueLatticeElement::ConstVal

Definition at line 87 of file ValueLattice.h.

Referenced by getConstant(), getNotConstant(), markConstant(), and markNotConstant().

◆ Range

ConstantRange llvm::ValueLatticeElement::Range

Definition at line 88 of file ValueLattice.h.

Referenced by getConstantRange(), intersect(), isConstantRange(), and markConstantRange().


The documentation for this class was generated from the following files: