MLIR  19.0.0git
Public Member Functions | Protected Member Functions | List of all members
mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT > Class Template Referenceabstract

A dense forward data-flow analysis for propagating lattices before and after the execution of every operation across the IR by implementing transfer functions for operations. More...

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

+ Inheritance diagram for mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >:

Public Member Functions

virtual void visitOperation (Operation *op, const LatticeT &before, LatticeT *after)=0
 Visit an operation with the dense lattice before its execution. More...
 
virtual void visitCallControlFlowTransfer (CallOpInterface call, CallControlFlowAction action, const LatticeT &before, LatticeT *after)
 Hook for customizing the behavior of lattice propagation along the call control flow edges. More...
 
virtual void visitRegionBranchControlFlowTransfer (RegionBranchOpInterface branch, std::optional< unsigned > regionFrom, std::optional< unsigned > regionTo, const LatticeT &before, LatticeT *after)
 Hook for customizing the behavior of lattice propagation along the control flow edges between regions and their parent op. More...
 
- Public Member Functions inherited from mlir::dataflow::AbstractDenseForwardDataFlowAnalysis
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

LatticeT * getLattice (ProgramPoint point) override
 Get the dense lattice after this program point. More...
 
virtual void setToEntryState (LatticeT *lattice)=0
 Set the dense lattice at control flow entry point and propagate an update if it changed. More...
 
void setToEntryState (AbstractDenseLattice *lattice) override
 Set the dense lattice at control flow entry point and propagate an update if it changed. More...
 
void visitOperationImpl (Operation *op, const AbstractDenseLattice &before, AbstractDenseLattice *after) final
 Type-erased wrappers that convert the abstract dense lattice to a derived lattice and invoke the virtual hooks operating on the derived lattice. More...
 
void visitCallControlFlowTransfer (CallOpInterface call, CallControlFlowAction action, const AbstractDenseLattice &before, AbstractDenseLattice *after) final
 Propagate the dense lattice forward along the call control flow edge, which can be either entering or exiting the callee. More...
 
void visitRegionBranchControlFlowTransfer (RegionBranchOpInterface branch, std::optional< unsigned > regionFrom, std::optional< unsigned > regionTo, const AbstractDenseLattice &before, AbstractDenseLattice *after) final
 Propagate the dense lattice forward along the control flow edge from regionFrom to regionTo regions of the branch operation. More...
 
- Protected Member Functions inherited from mlir::dataflow::AbstractDenseForwardDataFlowAnalysis
const AbstractDenseLatticegetLatticeFor (ProgramPoint dependent, ProgramPoint point)
 Get the dense lattice after the execution of the given program point and add it as a dependency to a program point. More...
 
void join (AbstractDenseLattice *lhs, const AbstractDenseLattice &rhs)
 Join a lattice with another and propagate an update if it changed. More...
 
virtual void processOperation (Operation *op)
 Visit an operation. 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 program point on this analysis. More...
 
void propagateIfChanged (AnalysisState *state, ChangeResult changed)
 Propagate an update to a state if it changed. More...
 
template<typename PointT >
void registerPointKind ()
 Register a custom program point class. More...
 
template<typename PointT , typename... Args>
PointT * getProgramPoint (Args &&...args)
 Get or create a custom program point. More...
 
template<typename StateT , typename PointT >
StateT * getOrCreate (PointT point)
 Get the analysis state associated with the program point. More...
 
template<typename StateT , typename PointT >
const StateT * getOrCreateFor (ProgramPoint dependent, PointT point)
 Get a read-only analysis state for the given point and create a dependency on dependent. More...
 
const DataFlowConfiggetSolverConfig () const
 Return the configuration of the solver used for this analysis. More...
 

Detailed Description

template<typename LatticeT>
class mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >

A dense forward data-flow analysis for propagating lattices before and after the execution of every operation across the IR by implementing transfer functions for operations.

LatticeT is expected to be a subclass of AbstractDenseLattice.

Definition at line 181 of file DenseAnalysis.h.

Member Function Documentation

◆ getLattice()

template<typename LatticeT >
LatticeT* mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::getLattice ( ProgramPoint  point)
inlineoverrideprotectedvirtual

Get the dense lattice after this program point.

Implements mlir::dataflow::AbstractDenseForwardDataFlowAnalysis.

Definition at line 253 of file DenseAnalysis.h.

◆ setToEntryState() [1/2]

template<typename LatticeT >
void mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::setToEntryState ( AbstractDenseLattice lattice)
inlineoverrideprotectedvirtual

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

Implements mlir::dataflow::AbstractDenseForwardDataFlowAnalysis.

Definition at line 260 of file DenseAnalysis.h.

References mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::setToEntryState().

◆ setToEntryState() [2/2]

template<typename LatticeT >
virtual void mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::setToEntryState ( LatticeT *  lattice)
protectedpure virtual

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

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

◆ visitCallControlFlowTransfer() [1/2]

template<typename LatticeT >
void mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitCallControlFlowTransfer ( CallOpInterface  call,
CallControlFlowAction  action,
const AbstractDenseLattice before,
AbstractDenseLattice after 
)
inlinefinalprotectedvirtual

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 from mlir::dataflow::AbstractDenseForwardDataFlowAnalysis.

Definition at line 271 of file DenseAnalysis.h.

References mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitCallControlFlowTransfer().

◆ visitCallControlFlowTransfer() [2/2]

template<typename LatticeT >
virtual void mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitCallControlFlowTransfer ( CallOpInterface  call,
CallControlFlowAction  action,
const LatticeT &  before,
LatticeT *  after 
)
inlinevirtual

Hook for customizing the behavior of lattice propagation along the call control flow edges.

Two types of (forward) propagation are possible here:

  • action == CallControlFlowAction::Enter indicates that:
    • before is the state before the call operation;
    • after is the state at the beginning of the callee entry block;
  • action == CallControlFlowAction::Exit indicates that:
    • before is the state at the end of a callee exit block;
    • after is the state after the call operation. By default, the after state is simply joined with the before state. Concrete analyses can override this behavior or delegate to the parent call for the default behavior. Specifically, if the call op may affect the lattice prior to entering the callee, the custom behavior can be added for action == CallControlFlowAction::Enter. If the call op may affect the lattice post exiting the callee, the custom behavior can be added for action == CallControlFlowAction::Exit.

Definition at line 212 of file DenseAnalysis.h.

References mlir::dataflow::AbstractDenseForwardDataFlowAnalysis::visitCallControlFlowTransfer().

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

◆ visitOperation()

template<typename LatticeT >
virtual void mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitOperation ( Operation op,
const LatticeT &  before,
LatticeT *  after 
)
pure virtual

Visit an operation with the dense lattice before its execution.

This function is expected to set the dense lattice after its execution and trigger change propagation in case of change.

◆ visitOperationImpl()

template<typename LatticeT >
void mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitOperationImpl ( Operation op,
const AbstractDenseLattice before,
AbstractDenseLattice after 
)
inlinefinalprotectedvirtual

Type-erased wrappers that convert the abstract dense lattice to a derived lattice and invoke the virtual hooks operating on the derived lattice.

Implements mlir::dataflow::AbstractDenseForwardDataFlowAnalysis.

Definition at line 266 of file DenseAnalysis.h.

◆ visitRegionBranchControlFlowTransfer() [1/2]

template<typename LatticeT >
void mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitRegionBranchControlFlowTransfer ( RegionBranchOpInterface  branch,
std::optional< unsigned >  regionFrom,
std::optional< unsigned >  regionTo,
const AbstractDenseLattice before,
AbstractDenseLattice after 
)
inlinefinalprotectedvirtual

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 from mlir::dataflow::AbstractDenseForwardDataFlowAnalysis.

Definition at line 279 of file DenseAnalysis.h.

References mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitRegionBranchControlFlowTransfer().

◆ visitRegionBranchControlFlowTransfer() [2/2]

template<typename LatticeT >
virtual void mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitRegionBranchControlFlowTransfer ( RegionBranchOpInterface  branch,
std::optional< unsigned >  regionFrom,
std::optional< unsigned >  regionTo,
const LatticeT &  before,
LatticeT *  after 
)
inlinevirtual

Hook for customizing the behavior of lattice propagation along the control flow edges between regions and their parent op.

The control flows from regionFrom to regionTo, both of which may be nullopt to indicate the parent op. The lattice is propagated forward along this edge. The lattices are as follows:

  • before:
    • if regionFrom is a region, this is the lattice at the end of the block that exits the region; note that for multi-exit regions, the lattices are equal at the end of all exiting blocks, but they are associated with different program points.
    • otherwise, this is the lattice before the parent op.
  • after:
    • if regionTo is a region, this is the lattice at the beginning of the entry block of that region;
    • otherwise, this is the lattice after the parent op. By default, the after state is simply joined with the before state. Concrete analyses can override this behavior or delegate to the parent call for the default behavior. Specifically, if the branch op may affect the lattice before entering any region, the custom behavior can be added for regionFrom == nullopt. If the branch op may affect the lattice after all terminated, the custom behavior can be added for regionTo == nullptr. The behavior can be further refined for specific pairs of "from" and "to" regions.

Definition at line 243 of file DenseAnalysis.h.

References mlir::dataflow::AbstractDenseForwardDataFlowAnalysis::visitRegionBranchControlFlowTransfer().

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


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