MLIR 22.0.0git
mlir::dataflow::Lattice< ValueT > Class Template Reference

This class represents a lattice holding a specific value of type ValueT. More...

#include "mlir/Analysis/DataFlow/SparseAnalysis.h"

Inheritance diagram for mlir::dataflow::Lattice< ValueT >:

Public Types

using LatticeT = Lattice<ValueT>
template<typename T, typename... Args>
using has_meet = decltype(&T::meet)
 Trait to check if T provides a meet method.
template<typename T>
using lattice_has_meet = llvm::is_detected<has_meet, T>

Public Member Functions

Value getAnchor () const
 Return the value this lattice is located at.
ValueT & getValue ()
 Return the value held by this lattice.
const ValueT & getValue () const
ChangeResult join (const AbstractSparseLattice &rhs) override
 Join the information contained in the 'rhs' lattice into this lattice.
ChangeResult meet (const AbstractSparseLattice &rhs) override
 Meet (intersect) the information contained in the 'rhs' lattice with this lattice.
ChangeResult join (const ValueT &rhs)
 Join the information contained in the 'rhs' value into this lattice.
template<typename VT, std::enable_if_t< lattice_has_meet< VT >::value > * = nullptr>
ChangeResult meet (const VT &rhs)
 Meet (intersect) the information contained in the 'rhs' value with this lattice.
template<typename VT, std::enable_if_t<!lattice_has_meet< VT >::value > * = nullptr>
ChangeResult meet (const VT &rhs)
void print (raw_ostream &os) const override
 Print the lattice element.
 AbstractSparseLattice (Value value)
 Lattices can only be created for values.
Public Member Functions inherited from mlir::dataflow::AbstractSparseLattice
 AbstractSparseLattice (Value value)
 Lattices can only be created for values.
Value getAnchor () const
 Return the value this lattice is located at.
void onUpdate (DataFlowSolver *solver) const override
 When the lattice gets updated, propagate an update to users of the value using its use-def chain to subscribed analyses.
void useDefSubscribe (DataFlowAnalysis *analysis)
 Subscribe an analysis to updates of the lattice.
Public Member Functions inherited from mlir::AnalysisState
virtual ~AnalysisState ()
 AnalysisState (LatticeAnchor anchor)
 Create the analysis state on the given lattice anchor.
LatticeAnchor getAnchor () const
 Returns the lattice anchor this state is located at.
LLVM_DUMP_METHOD void dump () const
void addDependency (ProgramPoint *point, DataFlowAnalysis *analysis)
 Add a dependency to this analysis state on a lattice anchor and an analysis.

Additional Inherited Members

Protected Attributes inherited from mlir::AnalysisState
LatticeAnchor anchor
 The lattice anchor to which the state belongs.

Detailed Description

template<typename ValueT>
class mlir::dataflow::Lattice< ValueT >

This class represents a lattice holding a specific value of type ValueT.

Lattice values (ValueT) are required to adhere to the following:

  • static ValueT join(const ValueT &lhs, const ValueT &rhs);
    • This method conservatively joins the information held by lhs and rhs into a new value. This method is required to be monotonic.
  • bool operator==(const ValueT &rhs) const;

Definition at line 85 of file SparseAnalysis.h.

Member Typedef Documentation

◆ has_meet

template<typename ValueT>
template<typename T, typename... Args>
using mlir::dataflow::Lattice< ValueT >::has_meet = decltype(&T::meet)

Trait to check if T provides a meet method.

Needed since for forward analysis, lattices will only have a join, no meet, but we want to use the same Lattice class for both directions.

Definition at line 135 of file SparseAnalysis.h.

◆ lattice_has_meet

template<typename ValueT>
template<typename T>
using mlir::dataflow::Lattice< ValueT >::lattice_has_meet = llvm::is_detected<has_meet, T>

Definition at line 137 of file SparseAnalysis.h.

◆ LatticeT

template<typename ValueT>
using mlir::dataflow::Lattice< ValueT >::LatticeT = Lattice<ValueT>

Definition at line 99 of file SparseAnalysis.h.

Member Function Documentation

◆ AbstractSparseLattice()

template<typename ValueT>
mlir::dataflow::AbstractSparseLattice::AbstractSparseLattice ( Value value)
inline

Lattices can only be created for values.

Definition at line 37 of file SparseAnalysis.h.

Referenced by join(), and meet().

◆ getAnchor()

template<typename ValueT>
Value mlir::dataflow::Lattice< ValueT >::getAnchor ( ) const
inline

Return the value this lattice is located at.

Definition at line 90 of file SparseAnalysis.h.

References mlir::AnalysisState::anchor.

Referenced by mlir::dataflow::IntegerRangeAnalysis::setToEntryState(), and mlir::dataflow::StridedMetadataRangeAnalysis::setToEntryState().

◆ getValue() [1/2]

template<typename ValueT>
ValueT & mlir::dataflow::Lattice< ValueT >::getValue ( )
inline

◆ getValue() [2/2]

template<typename ValueT>
const ValueT & mlir::dataflow::Lattice< ValueT >::getValue ( ) const
inline

Definition at line 95 of file SparseAnalysis.h.

References getValue().

◆ join() [1/2]

◆ join() [2/2]

template<typename ValueT>
ChangeResult mlir::dataflow::Lattice< ValueT >::join ( const ValueT & rhs)
inline

Join the information contained in the 'rhs' value into this lattice.

Returns if the state of the current lattice changed.

Definition at line 115 of file SparseAnalysis.h.

References mlir::Change, mlir::NoChange, and rhs.

◆ meet() [1/3]

template<typename ValueT>
ChangeResult mlir::dataflow::Lattice< ValueT >::meet ( const AbstractSparseLattice< ValueT > & rhs)
inlineoverridevirtual

Meet (intersect) the information contained in the 'rhs' lattice with this lattice.

Returns if the state of the current lattice changed.

Reimplemented from mlir::dataflow::AbstractSparseLattice.

Definition at line 109 of file SparseAnalysis.h.

References AbstractSparseLattice(), getValue(), meet(), and rhs.

Referenced by meet().

◆ meet() [2/3]

template<typename ValueT>
template<typename VT, std::enable_if_t< lattice_has_meet< VT >::value > * = nullptr>
ChangeResult mlir::dataflow::Lattice< ValueT >::meet ( const VT & rhs)
inline

Meet (intersect) the information contained in the 'rhs' value with this lattice.

Returns if the state of the current lattice changed. If the lattice elements don't have a meet method, this is a no-op (see below.)

Definition at line 144 of file SparseAnalysis.h.

References mlir::Change, mlir::NoChange, and rhs.

◆ meet() [3/3]

template<typename ValueT>
template<typename VT, std::enable_if_t<!lattice_has_meet< VT >::value > * = nullptr>
ChangeResult mlir::dataflow::Lattice< ValueT >::meet ( const VT & rhs)
inline

Definition at line 161 of file SparseAnalysis.h.

References mlir::NoChange, and rhs.

◆ print()

template<typename ValueT>
void mlir::dataflow::Lattice< ValueT >::print ( raw_ostream & os) const
inlineoverridevirtual

Print the lattice element.

Implements mlir::AnalysisState.

Definition at line 166 of file SparseAnalysis.h.


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