MLIR
21.0.0git
|
Base class for sparse forward data-flow analyses. More...
#include "mlir/Analysis/DataFlow/SparseAnalysis.h"
Public Member Functions | |
LogicalResult | initialize (Operation *top) override |
Initialize the analysis by visiting every owner of an SSA value: all operations and blocks. More... | |
LogicalResult | visit (ProgramPoint *point) override |
Visit a program point. More... | |
![]() | |
virtual | ~DataFlowAnalysis () |
DataFlowAnalysis (DataFlowSolver &solver) | |
Create an analysis with a reference to the parent solver. More... | |
virtual void | initializeEquivalentLatticeAnchor (Operation *top) |
Initialize lattice anchor equivalence class from the provided top-level operation. More... | |
Protected Member Functions | |
AbstractSparseForwardDataFlowAnalysis (DataFlowSolver &solver) | |
virtual LogicalResult | visitOperationImpl (Operation *op, ArrayRef< const AbstractSparseLattice * > operandLattices, ArrayRef< AbstractSparseLattice * > resultLattices)=0 |
The operation transfer function. More... | |
virtual void | visitExternalCallImpl (CallOpInterface call, ArrayRef< const AbstractSparseLattice * > argumentLattices, ArrayRef< AbstractSparseLattice * > resultLattices)=0 |
The transfer function for calls to external functions. More... | |
virtual void | visitNonControlFlowArgumentsImpl (Operation *op, const RegionSuccessor &successor, ArrayRef< AbstractSparseLattice * > argLattices, unsigned firstIndex)=0 |
Given an operation with region control-flow, the lattices of the operands, and a region successor, compute the lattice values for block arguments that are not accounted for by the branching control flow (ex. More... | |
virtual AbstractSparseLattice * | getLatticeElement (Value value)=0 |
Get the lattice element of a value. More... | |
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. More... | |
virtual void | setToEntryState (AbstractSparseLattice *lattice)=0 |
Set the given lattice element(s) at control flow entry point(s). More... | |
void | setAllToEntryStates (ArrayRef< AbstractSparseLattice * > lattices) |
void | join (AbstractSparseLattice *lhs, const AbstractSparseLattice &rhs) |
Join the lattice element and propagate and update if it changed. More... | |
virtual LogicalResult | visitCallOperation (CallOpInterface call, ArrayRef< const AbstractSparseLattice * > operandLattices, ArrayRef< AbstractSparseLattice * > resultLattices) |
Visits a call operation. More... | |
virtual void | visitCallableOperation (CallableOpInterface callable, ArrayRef< AbstractSparseLattice * > argLattices) |
Visits a callable operation. More... | |
![]() | |
void | addDependency (AnalysisState *state, ProgramPoint *point) |
Create a dependency between the given analysis state and lattice anchor on this analysis. More... | |
void | propagateIfChanged (AnalysisState *state, ChangeResult changed) |
Propagate an update to a state if it changed. More... | |
template<typename AnchorT > | |
void | registerAnchorKind () |
Register a custom lattice anchor class. More... | |
template<typename AnchorT , typename... Args> | |
AnchorT * | getLatticeAnchor (Args &&...args) |
Get or create a custom lattice anchor. More... | |
template<typename StateT , typename AnchorT > | |
void | unionLatticeAnchors (AnchorT anchor, AnchorT other) |
Union input anchors under the given state. More... | |
template<typename StateT , typename AnchorT > | |
StateT * | getOrCreate (AnchorT anchor) |
Get the analysis state associated with the lattice anchor. More... | |
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 . More... | |
ProgramPoint * | getProgramPointBefore (Operation *op) |
Get a uniqued program point instance. More... | |
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. More... | |
Base class for sparse forward data-flow analyses.
A sparse analysis implements a transfer function on operations from the lattices of the operands to the lattices of the results. This analysis will propagate lattices across control-flow edges and the callgraph using liveness information.
Visit a program point in sparse forward data-flow analysis will invoke the transfer function of the operation preceding the program point iterator. Visit a program point at the begining of block will visit the block itself.
Definition at line 186 of file SparseAnalysis.h.
|
explicitprotected |
Definition at line 46 of file SparseAnalysis.cpp.
|
protectedpure virtual |
Get the lattice element of a value.
Implemented in mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >, mlir::dataflow::SparseForwardDataFlowAnalysis< IntegerValueRangeLattice >, and mlir::dataflow::SparseForwardDataFlowAnalysis< Lattice< ConstantValue > >.
Referenced by initialize().
|
protected |
Get a read-only lattice element for a value and add it as a dependency to a program point.
Definition at line 319 of file SparseAnalysis.cpp.
Referenced by mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >::getLatticeElementFor(), visitCallableOperation(), and visitCallOperation().
|
overridevirtual |
Initialize the analysis by visiting every owner of an SSA value: all operations and blocks.
Implements mlir::DataFlowAnalysis.
Definition at line 53 of file SparseAnalysis.cpp.
References getLatticeElement(), mlir::Operation::getRegions(), and setToEntryState().
|
protected |
Join the lattice element and propagate and update if it changed.
Definition at line 332 of file SparseAnalysis.cpp.
References mlir::dataflow::AbstractSparseLattice::join(), and mlir::DataFlowAnalysis::propagateIfChanged().
Referenced by visitCallableOperation(), visitCallOperation(), and mlir::dataflow::SparseConstantPropagation::visitOperation().
|
protected |
Definition at line 326 of file SparseAnalysis.cpp.
References setToEntryState().
Referenced by mlir::dataflow::SparseForwardDataFlowAnalysis< StateT >::setAllToEntryStates(), visitCallableOperation(), and visitCallOperation().
|
protectedpure virtual |
Set the given lattice element(s) at control flow entry point(s).
Referenced by initialize(), and setAllToEntryStates().
|
overridevirtual |
Visit a program point.
If this is at beginning of block and all control-flow predecessors or callsites are known, then the arguments lattices are propagated from them. If this is after call operation or an operation with region control-flow, then its result lattices are set accordingly. Otherwise, the operation transfer function is invoked.
Implements mlir::DataFlowAnalysis.
Definition at line 88 of file SparseAnalysis.cpp.
References mlir::ProgramPoint::getBlock(), mlir::ProgramPoint::getPrevOp(), and mlir::ProgramPoint::isBlockStart().
|
protectedvirtual |
Visits a callable operation.
Computes the argument lattices from call sites if all call sites are known; otherwise, conservatively marks them as having reached their pessimistic fixpoints. This method can be overridden to, for example, be less conservative and propagate the information even if some call sites are unknown.
Definition at line 241 of file SparseAnalysis.cpp.
References mlir::Block::front(), getLatticeElementFor(), mlir::DataFlowAnalysis::getProgramPointAfter(), mlir::DataFlowAnalysis::getProgramPointBefore(), mlir::DataFlowAnalysis::getSolverConfig(), join(), and setAllToEntryStates().
|
protectedvirtual |
Visits a call operation.
Given the operand lattices, sets the result lattices. Performs interprocedural data flow as follows: if the call operation targets an external function, or if the solver is not interprocedural, attempts to infer the results from the call arguments using the user-provided visitExternalCallImpl
. Otherwise, computes the result lattices from the return sites if all return sites are known; otherwise, conservatively marks the result lattices as having reached their pessimistic fixpoints. This method can be overridden to, for example, be less conservative and propagate the information even if some return sites are unknown.
Definition at line 209 of file SparseAnalysis.cpp.
References getLatticeElementFor(), mlir::DataFlowAnalysis::getProgramPointAfter(), mlir::DataFlowAnalysis::getSolverConfig(), join(), setAllToEntryStates(), and visitExternalCallImpl().
|
protectedpure virtual |
The transfer function for calls to external functions.
Referenced by visitCallOperation().
|
protectedpure virtual |
Given an operation with region control-flow, the lattices of the operands, and a region successor, compute the lattice values for block arguments that are not accounted for by the branching control flow (ex.
the bounds of loops).
|
protectedpure virtual |
The operation transfer function.
Given the operand lattices, this function is expected to set the result lattices.