MLIR 24.0.0git
mlir::dataflow::SparseForwardDataFlowAnalysis< StateT > Class Template Referenceabstract

A sparse forward data-flow analysis for propagating SSA value lattices across the IR by implementing transfer functions for operations. More...

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

Inheritance diagram for mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >:

Public Types

using GetLatticeFn = function_ref<const StateT *(Value)>
 Read a value's lattice and register a dependency on the current visit.

Public Member Functions

 SparseForwardDataFlowAnalysis (DataFlowSolver &solver)
virtual LogicalResult visitOperation (Operation *op, ArrayRef< const StateT * > operands, ArrayRef< StateT * > results)=0
 Visit an operation with the lattices of its operands.
virtual void visitExternalCall (CallOpInterface call, ArrayRef< const StateT * > argumentLattices, ArrayRef< StateT * > resultLattices)
 Visit a call operation to an externally defined function given the lattices of its arguments.
virtual void visitNonControlFlowArguments (Operation *op, const RegionSuccessor &successor, ValueRange nonSuccessorInputs, ArrayRef< StateT * > nonSuccessorInputLattices, GetLatticeFn getLattice)
 Given an operation with possible region control-flow, the lattices of the operands, and a region successor, compute the lattice values for non-successor-inputs (ex.
Public Member Functions inherited from mlir::dataflow::AbstractSparseForwardDataFlowAnalysis
LogicalResult initialize (Operation *top) override
 Initialize the analysis by visiting every owner of an SSA value: all operations and blocks.
LogicalResult visit (ProgramPoint *point) override
 Visit a program point.
Public Member Functions inherited from mlir::DataFlowAnalysis
virtual ~DataFlowAnalysis ()
 DataFlowAnalysis (DataFlowSolver &solver)
 Create an analysis with a reference to the parent solver.
virtual void initializeEquivalentLatticeAnchor (Operation *top)
 Initialize lattice anchor equivalence class from the provided top-level operation.
TypeID getTypeID () const
 Return the TypeID of the concrete analysis class.

Protected Member Functions

StateT * getLatticeElement (Value value) override
 Get the lattice element for a value.
const StateT * getLatticeElementFor (ProgramPoint *point, Value value)
 Get the lattice element for a value and create a dependency on the provided program point.
virtual void setToEntryState (StateT *lattice)=0
 Set the given lattice element(s) at control flow entry point(s).
void setAllToEntryStates (ArrayRef< StateT * > lattices)
Protected Member Functions inherited from mlir::dataflow::AbstractSparseForwardDataFlowAnalysis
 AbstractSparseForwardDataFlowAnalysis (DataFlowSolver &solver)
const AbstractSparseLattice * getLatticeElementFor (ProgramPoint *point, Value value)
 Get a read-only lattice element for a value and add it as a dependency to a program point.
void setAllToEntryStates (ArrayRef< AbstractSparseLattice * > lattices)
void join (AbstractSparseLattice *lhs, const AbstractSparseLattice &rhs)
 Join the lattice element and propagate and update if it changed.
virtual LogicalResult visitCallOperation (CallOpInterface call, ArrayRef< const AbstractSparseLattice * > operandLattices, ArrayRef< AbstractSparseLattice * > resultLattices)
 Visits a call operation.
virtual void visitCallableOperation (CallableOpInterface callable, ArrayRef< AbstractSparseLattice * > argLattices)
 Visits a callable operation.
Protected Member Functions inherited from mlir::DataFlowAnalysis
void addDependency (AnalysisState *state, ProgramPoint *point)
 Create a dependency between the given analysis state and lattice anchor on this analysis.
void propagateIfChanged (AnalysisState *state, ChangeResult changed)
 Propagate an update to a state if it changed.
template<typename AnchorT>
void registerAnchorKind ()
 Register a custom lattice anchor class.
template<typename AnchorT, typename... Args>
AnchorT * getLatticeAnchor (Args &&...args)
 Get or create a custom lattice anchor.
template<typename StateT, typename AnchorT>
void unionLatticeAnchors (AnchorT anchor, AnchorT other)
 Union input anchors under the given state.
template<typename StateT, typename AnchorT>
StateT * getOrCreate (AnchorT anchor)
 Get the analysis state associated with the lattice anchor.
template<typename StateT, typename AnchorT>
const StateT * getOrCreateFor (ProgramPoint *dependent, AnchorT anchor)
 Get a read-only analysis state for the given point and create a dependency on dependent.
ProgramPoint * getProgramPointBefore (Operation *op)
 Get a uniqued program point instance.
ProgramPoint * getProgramPointBefore (Block *block)
ProgramPoint * getProgramPointAfter (Operation *op)
ProgramPoint * getProgramPointAfter (Block *block)
const DataFlowConfig & getSolverConfig () const
 Return the configuration of the solver used for this analysis.

Detailed Description

template<typename StateT>
class mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >

A sparse forward data-flow analysis for propagating SSA value lattices across the IR by implementing transfer functions for operations.

StateT is expected to be a subclass of AbstractSparseLattice.

Definition at line 299 of file SparseAnalysis.h.

Member Typedef Documentation

◆ GetLatticeFn

template<typename StateT>
using mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >::GetLatticeFn = function_ref<const StateT *(Value)>

Read a value's lattice and register a dependency on the current visit.

Definition at line 307 of file SparseAnalysis.h.

Constructor & Destructor Documentation

◆ SparseForwardDataFlowAnalysis()

template<typename StateT>
mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >::SparseForwardDataFlowAnalysis ( DataFlowSolver & solver)
inlineexplicit

Member Function Documentation

◆ getLatticeElement()

template<typename StateT>
StateT * mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >::getLatticeElement ( Value value)
inlineoverrideprotectedvirtual

Get the lattice element for a value.

Implements mlir::dataflow::AbstractSparseForwardDataFlowAnalysis.

Definition at line 353 of file SparseAnalysis.h.

References mlir::DataFlowAnalysis::getOrCreate().

◆ getLatticeElementFor()

template<typename StateT>
const StateT * mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >::getLatticeElementFor ( ProgramPoint * point,
Value value )
inlineprotected

Get the lattice element for a value and create a dependency on the provided program point.

Definition at line 359 of file SparseAnalysis.h.

References mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::getLatticeElementFor().

◆ setAllToEntryStates()

template<typename StateT>
void mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >::setAllToEntryStates ( ArrayRef< StateT * > lattices)
inlineprotected

◆ setToEntryState()

template<typename StateT>
virtual void mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >::setToEntryState ( StateT * lattice)
protectedpure virtual

◆ visitExternalCall()

template<typename StateT>
virtual void mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >::visitExternalCall ( CallOpInterface call,
ArrayRef< const StateT * > argumentLattices,
ArrayRef< StateT * > resultLattices )
inlinevirtual

Visit a call operation to an externally defined function given the lattices of its arguments.

Definition at line 320 of file SparseAnalysis.h.

References setAllToEntryStates().

◆ visitNonControlFlowArguments()

template<typename StateT>
virtual void mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >::visitNonControlFlowArguments ( Operation * op,
const RegionSuccessor & successor,
ValueRange nonSuccessorInputs,
ArrayRef< StateT * > nonSuccessorInputLattices,
GetLatticeFn getLattice )
inlinevirtual

Given an operation with possible region control-flow, the lattices of the operands, and a region successor, compute the lattice values for non-successor-inputs (ex.

loop induction variables) of a given region successor. Use getLattice to read lattices, including those of captured values. Changes to the lattices read through this callback revisit this hook. The callback is valid only for the duration of this call.

For example, for an scf.for body, the region successor is the loop body and the non-successor input is the induction variable. Its lattice is in nonSuccessorInputLattices and must be computed or updated by this hook. Use getLattice to read the lattices of the lower bound, upper bound, and step when they are needed to infer the induction variable's lattice.

By default, this method marks all lattice elements as having reached a pessimistic fixpoint.

Definition at line 342 of file SparseAnalysis.h.

References setAllToEntryStates().

Referenced by mlir::dataflow::IntegerDivisibilityAnalysis::visitNonControlFlowArguments(), and mlir::dataflow::IntegerRangeAnalysis::visitNonControlFlowArguments().

◆ visitOperation()

template<typename StateT>
virtual LogicalResult mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >::visitOperation ( Operation * op,
ArrayRef< const StateT * > operands,
ArrayRef< StateT * > results )
pure virtual

Visit an operation with the lattices of its operands.

This function is expected to set the lattices of the operation's results.

Implemented in mlir::dataflow::IntegerDivisibilityAnalysis, mlir::dataflow::IntegerRangeAnalysis, mlir::dataflow::SparseConstantPropagation, and mlir::dataflow::StridedMetadataRangeAnalysis.


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