MLIR  21.0.0git
Public Member Functions | Protected Member Functions | List of all members
mlir::dataflow::AbstractSparseForwardDataFlowAnalysis Class Referenceabstract

Base class for sparse forward data-flow analyses. More...

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

+ Inheritance diagram for mlir::dataflow::AbstractSparseForwardDataFlowAnalysis:

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...
 
- Public Member Functions inherited from mlir::DataFlowAnalysis
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 AbstractSparseLatticegetLatticeElement (Value value)=0
 Get the lattice element of a value. More...
 
const AbstractSparseLatticegetLatticeElementFor (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...
 
- 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. 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...
 
ProgramPointgetProgramPointBefore (Operation *op)
 Get a uniqued program point instance. More...
 
ProgramPointgetProgramPointBefore (Block *block)
 
ProgramPointgetProgramPointAfter (Operation *op)
 
ProgramPointgetProgramPointAfter (Block *block)
 
const DataFlowConfiggetSolverConfig () const
 Return the configuration of the solver used for this analysis. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ AbstractSparseForwardDataFlowAnalysis()

AbstractSparseForwardDataFlowAnalysis::AbstractSparseForwardDataFlowAnalysis ( DataFlowSolver solver)
explicitprotected

Definition at line 46 of file SparseAnalysis.cpp.

Member Function Documentation

◆ getLatticeElement()

virtual AbstractSparseLattice* mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::getLatticeElement ( Value  value)
protectedpure virtual

◆ getLatticeElementFor()

const AbstractSparseLattice * AbstractSparseForwardDataFlowAnalysis::getLatticeElementFor ( ProgramPoint point,
Value  value 
)
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().

◆ initialize()

LogicalResult AbstractSparseForwardDataFlowAnalysis::initialize ( Operation top)
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().

◆ join()

void AbstractSparseForwardDataFlowAnalysis::join ( AbstractSparseLattice lhs,
const AbstractSparseLattice rhs 
)
protected

◆ setAllToEntryStates()

void AbstractSparseForwardDataFlowAnalysis::setAllToEntryStates ( ArrayRef< AbstractSparseLattice * >  lattices)
protected

◆ setToEntryState()

virtual void mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::setToEntryState ( AbstractSparseLattice lattice)
protectedpure virtual

Set the given lattice element(s) at control flow entry point(s).

Referenced by initialize(), and setAllToEntryStates().

◆ visit()

LogicalResult AbstractSparseForwardDataFlowAnalysis::visit ( ProgramPoint point)
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().

◆ visitCallableOperation()

void AbstractSparseForwardDataFlowAnalysis::visitCallableOperation ( CallableOpInterface  callable,
ArrayRef< AbstractSparseLattice * >  argLattices 
)
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().

◆ visitCallOperation()

LogicalResult AbstractSparseForwardDataFlowAnalysis::visitCallOperation ( CallOpInterface  call,
ArrayRef< const AbstractSparseLattice * >  operandLattices,
ArrayRef< AbstractSparseLattice * >  resultLattices 
)
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().

◆ visitExternalCallImpl()

virtual void mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::visitExternalCallImpl ( CallOpInterface  call,
ArrayRef< const AbstractSparseLattice * >  argumentLattices,
ArrayRef< AbstractSparseLattice * >  resultLattices 
)
protectedpure virtual

The transfer function for calls to external functions.

Referenced by visitCallOperation().

◆ visitNonControlFlowArgumentsImpl()

virtual void mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::visitNonControlFlowArgumentsImpl ( Operation op,
const RegionSuccessor successor,
ArrayRef< AbstractSparseLattice * >  argLattices,
unsigned  firstIndex 
)
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).

◆ visitOperationImpl()

virtual LogicalResult mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::visitOperationImpl ( Operation op,
ArrayRef< const AbstractSparseLattice * >  operandLattices,
ArrayRef< AbstractSparseLattice * >  resultLattices 
)
protectedpure virtual

The operation transfer function.

Given the operand lattices, this function is expected to set the result lattices.


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