MLIR
18.0.0git
|
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"
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... | |
![]() | |
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... | |
![]() | |
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... | |
![]() | |
const AbstractDenseLattice * | getLatticeFor (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... | |
![]() | |
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... | |
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 171 of file DenseAnalysis.h.
|
inlineoverrideprotectedvirtual |
Get the dense lattice after this program point.
Implements mlir::dataflow::AbstractDenseForwardDataFlowAnalysis.
Definition at line 243 of file DenseAnalysis.h.
|
inlineoverrideprotectedvirtual |
Set the dense lattice at control flow entry point and propagate an update if it changed.
Implements mlir::dataflow::AbstractDenseForwardDataFlowAnalysis.
Definition at line 250 of file DenseAnalysis.h.
References mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::setToEntryState().
|
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().
|
inlinefinalprotectedvirtual |
Propagate the dense lattice forward along the call control flow edge, which can be either entering or exiting the callee.
Default implementation 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.
Reimplemented from mlir::dataflow::AbstractDenseForwardDataFlowAnalysis.
Definition at line 261 of file DenseAnalysis.h.
References mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitCallControlFlowTransfer().
|
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 202 of file DenseAnalysis.h.
References mlir::dataflow::AbstractDenseForwardDataFlowAnalysis::visitCallControlFlowTransfer().
Referenced by mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitCallControlFlowTransfer().
|
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.
|
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 256 of file DenseAnalysis.h.
|
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 269 of file DenseAnalysis.h.
References mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitRegionBranchControlFlowTransfer().
|
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:
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.after
:regionTo
is a region, this is the lattice at the beginning of the entry block of that region;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 233 of file DenseAnalysis.h.
References mlir::dataflow::AbstractDenseForwardDataFlowAnalysis::visitRegionBranchControlFlowTransfer().
Referenced by mlir::dataflow::DenseForwardDataFlowAnalysis< LatticeT >::visitRegionBranchControlFlowTransfer().