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

A dense backward dataflow analysis propagating lattices after and before the execution of every operation across the IR by implementing transfer functions for opreations. More...

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

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

Public Member Functions

virtual LogicalResult visitOperation (Operation *op, const LatticeT &after, LatticeT *before)=0
 Transfer function. More...
 
virtual void visitCallControlFlowTransfer (CallOpInterface call, CallControlFlowAction action, const LatticeT &after, LatticeT *before)
 Hook for customizing the behavior of lattice propagation along the call control flow edges. More...
 
virtual void visitRegionBranchControlFlowTransfer (RegionBranchOpInterface branch, RegionBranchPoint regionFrom, RegionBranchPoint regionTo, const LatticeT &after, LatticeT *before)
 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::AbstractDenseBackwardDataFlowAnalysis
 AbstractDenseBackwardDataFlowAnalysis (DataFlowSolver &solver, SymbolTableCollection &symbolTable)
 Construct the analysis in the given solver. More...
 
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...
 
- 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 (LatticeAnchor anchor) override
 Get the dense lattice at the given lattice anchor. More...
 
virtual void setToExitState (LatticeT *lattice)=0
 Set the dense lattice at control flow exit point (after the terminator) and propagate an update if it changed. More...
 
void setToExitState (AbstractDenseLattice *lattice) final
 Set the dense lattice before at the control flow exit point and propagate the update if it changed. More...
 
LogicalResult visitOperationImpl (Operation *op, const AbstractDenseLattice &after, AbstractDenseLattice *before) 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 &after, AbstractDenseLattice *before) final
 Propagate the dense lattice backwards along the call control flow edge, which can be either entering or exiting the callee. More...
 
void visitRegionBranchControlFlowTransfer (RegionBranchOpInterface branch, RegionBranchPoint regionForm, RegionBranchPoint regionTo, const AbstractDenseLattice &after, AbstractDenseLattice *before) final
 Propagate the dense lattice backwards along the control flow edge from regionFrom to regionTo regions of the branch operation. More...
 
- Protected Member Functions inherited from mlir::dataflow::AbstractDenseBackwardDataFlowAnalysis
const AbstractDenseLatticegetLatticeFor (ProgramPoint *dependent, LatticeAnchor anchor)
 Get the dense lattice on the given lattice anchor and add dependent as its dependency. More...
 
void meet (AbstractDenseLattice *lhs, const AbstractDenseLattice &rhs)
 Meet a lattice with another lattice and propagate an update if it changed. More...
 
virtual LogicalResult processOperation (Operation *op)
 Visit an 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 >
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

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

A dense backward dataflow analysis propagating lattices after and before the execution of every operation across the IR by implementing transfer functions for opreations.

LatticeT is expected to be a subclass of AbstractDenseLattice.

Definition at line 431 of file DenseAnalysis.h.

Member Function Documentation

◆ getLattice()

template<typename LatticeT >
LatticeT* mlir::dataflow::DenseBackwardDataFlowAnalysis< LatticeT >::getLattice ( LatticeAnchor  anchor)
inlineoverrideprotectedvirtual

Get the dense lattice at the given lattice anchor.

Implements mlir::dataflow::AbstractDenseBackwardDataFlowAnalysis.

Definition at line 501 of file DenseAnalysis.h.

◆ setToExitState() [1/2]

template<typename LatticeT >
void mlir::dataflow::DenseBackwardDataFlowAnalysis< LatticeT >::setToExitState ( AbstractDenseLattice lattice)
inlinefinalprotectedvirtual

Set the dense lattice before at the control flow exit point and propagate the update if it changed.

Implements mlir::dataflow::AbstractDenseBackwardDataFlowAnalysis.

Definition at line 508 of file DenseAnalysis.h.

References mlir::dataflow::DenseBackwardDataFlowAnalysis< LatticeT >::setToExitState().

◆ setToExitState() [2/2]

template<typename LatticeT >
virtual void mlir::dataflow::DenseBackwardDataFlowAnalysis< LatticeT >::setToExitState ( LatticeT *  lattice)
protectedpure virtual

Set the dense lattice at control flow exit point (after the terminator) and propagate an update if it changed.

Referenced by mlir::dataflow::DenseBackwardDataFlowAnalysis< LatticeT >::setToExitState().

◆ visitCallControlFlowTransfer() [1/2]

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

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

Default implementation for enter and exit callee action 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 external callee action additional sets the result to the exit (fixpoint) state.

Reimplemented from mlir::dataflow::AbstractDenseBackwardDataFlowAnalysis.

Definition at line 520 of file DenseAnalysis.h.

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

◆ visitCallControlFlowTransfer() [2/2]

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

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

Two types of (back) propagation are possible here:

  • action == CallControlFlowAction::Enter indicates that:
    • after is the state at the top of the callee entry block;
    • before is the state before the call operation;
  • action == CallControlFlowAction::Exit indicates that:
    • after is the state after the call operation;
    • before is the state of exit blocks of the callee. By default, the before state is simply met with the after 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 461 of file DenseAnalysis.h.

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

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

◆ visitOperation()

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

Transfer function.

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

◆ visitOperationImpl()

template<typename LatticeT >
LogicalResult mlir::dataflow::DenseBackwardDataFlowAnalysis< LatticeT >::visitOperationImpl ( Operation op,
const AbstractDenseLattice after,
AbstractDenseLattice before 
)
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::AbstractDenseBackwardDataFlowAnalysis.

Definition at line 514 of file DenseAnalysis.h.

◆ visitRegionBranchControlFlowTransfer() [1/2]

template<typename LatticeT >
void mlir::dataflow::DenseBackwardDataFlowAnalysis< LatticeT >::visitRegionBranchControlFlowTransfer ( RegionBranchOpInterface  branch,
RegionBranchPoint  regionFrom,
RegionBranchPoint  regionTo,
const AbstractDenseLattice after,
AbstractDenseLattice before 
)
inlinefinalprotectedvirtual

Propagate the dense lattice backwards 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 meets 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::AbstractDenseBackwardDataFlowAnalysis.

Definition at line 528 of file DenseAnalysis.h.

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

◆ visitRegionBranchControlFlowTransfer() [2/2]

template<typename LatticeT >
virtual void mlir::dataflow::DenseBackwardDataFlowAnalysis< LatticeT >::visitRegionBranchControlFlowTransfer ( RegionBranchOpInterface  branch,
RegionBranchPoint  regionFrom,
RegionBranchPoint  regionTo,
const LatticeT &  after,
LatticeT *  before 
)
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 back along this edge. The lattices are as follows:

  • 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.
  • 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. By default, the before state is simply met with the after 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 492 of file DenseAnalysis.h.

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

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


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