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

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

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

+ Inheritance diagram for mlir::dataflow::AbstractDenseForwardDataFlowAnalysis:

Public Member Functions

LogicalResult initialize (Operation *top) override
 Initialize the analysis by visiting every program point whose execution may modify the program state; that is, every operation and block. More...
 
LogicalResult visit (ProgramPoint *point) override
 Visit a program point that modifies the state of the program. More...
 
 DataFlowAnalysis (DataFlowSolver &solver)
 Create an analysis with a reference to the parent solver. More...
 
- Public Member Functions inherited from mlir::DataFlowAnalysis
virtual ~DataFlowAnalysis ()
 
 DataFlowAnalysis (DataFlowSolver &solver)
 Create an analysis with a reference to the parent solver. More...
 

Protected Member Functions

virtual LogicalResult visitOperationImpl (Operation *op, const AbstractDenseLattice &before, AbstractDenseLattice *after)=0
 Propagate the dense lattice before the execution of an operation to the lattice after its execution. More...
 
virtual AbstractDenseLatticegetLattice (LatticeAnchor anchor)=0
 Get the dense lattice on the given lattice anchor. More...
 
const AbstractDenseLatticegetLatticeFor (ProgramPoint *dependent, LatticeAnchor anchor)
 Get the dense lattice on the given lattice anchor and add dependent as its dependency. More...
 
virtual void setToEntryState (AbstractDenseLattice *lattice)=0
 Set the dense lattice at control flow entry point and propagate an update if it changed. More...
 
void join (AbstractDenseLattice *lhs, const AbstractDenseLattice &rhs)
 Join a lattice with another and propagate an update if it changed. More...
 
virtual LogicalResult processOperation (Operation *op)
 Visit an operation. More...
 
virtual void visitRegionBranchControlFlowTransfer (RegionBranchOpInterface branch, std::optional< unsigned > regionFrom, std::optional< unsigned > regionTo, const AbstractDenseLattice &before, AbstractDenseLattice *after)
 Propagate the dense lattice forward along the control flow edge from regionFrom to regionTo regions of the branch operation. More...
 
virtual void visitCallControlFlowTransfer (CallOpInterface call, CallControlFlowAction action, const AbstractDenseLattice &before, AbstractDenseLattice *after)
 Propagate the dense lattice forward along the call control flow edge, which can be either entering or exiting the callee. More...
 
void visitRegionBranchOperation (ProgramPoint *point, RegionBranchOpInterface branch, AbstractDenseLattice *after)
 Visit a program point within a region branch operation with predecessors in it. 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 >
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 dense forward data-flow analyses.

Dense data-flow analysis attaches a lattice to program points and implements a transfer function from the lattice before each operation to the lattice after. The lattice contains information about the state of the program at that program point.

Visit a program point in forward dense 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 68 of file DenseAnalysis.h.

Member Function Documentation

◆ DataFlowAnalysis()

DataFlowAnalysis::DataFlowAnalysis
explicit

Create an analysis with a reference to the parent solver.

Definition at line 525 of file DataFlowFramework.cpp.

◆ getLattice()

virtual AbstractDenseLattice* mlir::dataflow::AbstractDenseForwardDataFlowAnalysis::getLattice ( LatticeAnchor  anchor)
protectedpure virtual

Get the dense lattice on the given lattice anchor.

Implemented in mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >.

Referenced by processOperation().

◆ getLatticeFor()

const AbstractDenseLattice * AbstractDenseForwardDataFlowAnalysis::getLatticeFor ( ProgramPoint dependent,
LatticeAnchor  anchor 
)
protected

Get the dense lattice on the given lattice anchor and add dependent as its dependency.

That is, every time the lattice after anchor is updated, the dependent program point must be visited, and the newly triggered visit might update the lattice on dependent.

Definition at line 244 of file DenseAnalysis.cpp.

Referenced by processOperation(), and visitRegionBranchOperation().

◆ initialize()

LogicalResult AbstractDenseForwardDataFlowAnalysis::initialize ( Operation top)
overridevirtual

Initialize the analysis by visiting every program point whose execution may modify the program state; that is, every operation and block.

Implements mlir::DataFlowAnalysis.

Definition at line 31 of file DenseAnalysis.cpp.

References mlir::Operation::getRegions(), and processOperation().

◆ join()

void mlir::dataflow::AbstractDenseForwardDataFlowAnalysis::join ( AbstractDenseLattice lhs,
const AbstractDenseLattice rhs 
)
inlineprotected

Join a lattice with another and propagate an update if it changed.

Definition at line 107 of file DenseAnalysis.h.

References mlir::dataflow::AbstractDenseLattice::join(), and mlir::DataFlowAnalysis::propagateIfChanged().

Referenced by visitCallControlFlowTransfer(), visitRegionBranchControlFlowTransfer(), and visitRegionBranchOperation().

◆ processOperation()

LogicalResult AbstractDenseForwardDataFlowAnalysis::processOperation ( Operation op)
protectedvirtual

Visit an operation.

If this is a call operation or region control-flow operation, then the state after the execution of the operation is set by control-flow or the callgraph. Otherwise, this function invokes the operation transfer function.

Definition at line 98 of file DenseAnalysis.cpp.

References mlir::Operation::getBlock(), getLattice(), getLatticeFor(), mlir::DataFlowAnalysis::getProgramPointAfter(), mlir::DataFlowAnalysis::getProgramPointBefore(), visitOperationImpl(), and visitRegionBranchOperation().

Referenced by initialize(), and visit().

◆ setToEntryState()

virtual void mlir::dataflow::AbstractDenseForwardDataFlowAnalysis::setToEntryState ( AbstractDenseLattice lattice)
protectedpure virtual

Set the dense lattice at control flow entry point and propagate an update if it changed.

Implemented in mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >.

Referenced by visitCallControlFlowTransfer().

◆ visit()

LogicalResult AbstractDenseForwardDataFlowAnalysis::visit ( ProgramPoint point)
overridevirtual

Visit a program point that modifies the state of the program.

If the program point is at the beginning of a block, then the state is propagated from control-flow predecessors or callsites. If the operation before program point iterator is a call operation or region control-flow operation, then the state after the execution of the operation is set by control-flow or the callgraph. Otherwise, this function invokes the operation transfer function before the program point iterator.

Implements mlir::DataFlowAnalysis.

Definition at line 47 of file DenseAnalysis.cpp.

References mlir::ProgramPoint::getBlock(), mlir::ProgramPoint::getPrevOp(), mlir::ProgramPoint::isBlockStart(), and processOperation().

◆ visitCallControlFlowTransfer()

virtual void mlir::dataflow::AbstractDenseForwardDataFlowAnalysis::visitCallControlFlowTransfer ( CallOpInterface  call,
CallControlFlowAction  action,
const AbstractDenseLattice before,
AbstractDenseLattice after 
)
inlineprotectedvirtual

Propagate the dense lattice forward along the call control flow edge, which can be either entering or exiting the callee.

Default implementation for enter and exit callee actions just meets the states, meaning that operations implementing CallOpInterface don't have any effect on the lattice that isn't already expressed by the interface itself. Default implementation for the external callee action additionally sets the "after" lattice to the entry state.

Reimplemented in mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >.

Definition at line 138 of file DenseAnalysis.h.

References mlir::dataflow::ExternalCallee, join(), and setToEntryState().

Referenced by mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitCallControlFlowTransfer().

◆ visitOperationImpl()

virtual LogicalResult mlir::dataflow::AbstractDenseForwardDataFlowAnalysis::visitOperationImpl ( Operation op,
const AbstractDenseLattice before,
AbstractDenseLattice after 
)
protectedpure virtual

Propagate the dense lattice before the execution of an operation to the lattice after its execution.

Implemented in mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >.

Referenced by processOperation().

◆ visitRegionBranchControlFlowTransfer()

virtual void mlir::dataflow::AbstractDenseForwardDataFlowAnalysis::visitRegionBranchControlFlowTransfer ( RegionBranchOpInterface  branch,
std::optional< unsigned >  regionFrom,
std::optional< unsigned >  regionTo,
const AbstractDenseLattice before,
AbstractDenseLattice after 
)
inlineprotectedvirtual

Propagate the dense lattice forward along the control flow edge from regionFrom to regionTo regions of the branch operation.

nullopt values correspond to control flow branches originating at or targeting the branch operation itself. Default implementation just joins the states, meaning that operations implementing RegionBranchOpInterface don't have any effect on the lattice that isn't already expressed by the interface itself.

Reimplemented in mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >.

Definition at line 124 of file DenseAnalysis.h.

References join().

Referenced by mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitRegionBranchControlFlowTransfer(), and visitRegionBranchOperation().

◆ visitRegionBranchOperation()

void AbstractDenseForwardDataFlowAnalysis::visitRegionBranchOperation ( ProgramPoint point,
RegionBranchOpInterface  branch,
AbstractDenseLattice after 
)
protected

Visit a program point within a region branch operation with predecessors in it.

This can either be an entry block of one of the regions of the parent operation itself.

Definition at line 190 of file DenseAnalysis.cpp.

References mlir::ProgramPoint::getBlock(), getLatticeFor(), mlir::Block::getParent(), mlir::ProgramPoint::getPrevOp(), mlir::DataFlowAnalysis::getProgramPointAfter(), mlir::DataFlowAnalysis::getProgramPointBefore(), mlir::Region::getRegionNumber(), mlir::ProgramPoint::isBlockStart(), join(), and visitRegionBranchControlFlowTransfer().

Referenced by processOperation().


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