15#ifndef MLIR_ANALYSIS_DENSEDATAFLOWANALYSIS_H
16#define MLIR_ANALYSIS_DENSEDATAFLOWANALYSIS_H
150 RegionBranchOpInterface branch, std::optional<unsigned> regionFrom,
179 RegionBranchOpInterface branch,
185 void visitBlock(
Block *block);
189 void visitCallOperation(CallOpInterface call,
203template <
typename LatticeT>
207 std::is_base_of<AbstractDenseLattice, LatticeT>::value,
208 "analysis state class expected to subclass AbstractDenseLattice");
212 AbstractDenseForwardDataFlowAnalysis;
218 LatticeT *after) = 0;
237 const LatticeT &before,
240 call, action, before, after);
267 RegionBranchOpInterface branch, std::optional<unsigned> regionFrom,
268 std::optional<unsigned> regionTo,
const LatticeT &before,
271 branch, regionFrom, regionTo, before, after);
284 Block *predecessor,
const LatticeT &before,
287 block, point, predecessor, before, after);
318 static_cast<LatticeT *
>(after));
325 static_cast<const LatticeT &
>(before),
326 static_cast<LatticeT *
>(after));
329 std::optional<unsigned> regionFrom,
330 std::optional<unsigned> regionTo,
334 static_cast<const LatticeT &
>(before),
335 static_cast<LatticeT *
>(after));
341 static_cast<const LatticeT &
>(before),
342 static_cast<LatticeT *
>(after));
474 void visitBlock(
Block *block);
481 RegionBranchOpInterface branch,
494 void visitCallOperation(CallOpInterface call,
511template <
typename LatticeT>
514 static_assert(std::is_base_of_v<AbstractDenseLattice, LatticeT>,
515 "analysis state expected to subclass AbstractDenseLattice");
519 AbstractDenseBackwardDataFlowAnalysis;
525 LatticeT *before) = 0;
544 const LatticeT &after,
547 call, action, after, before);
577 branch, regionFrom, regionTo, after, before);
590 Block *successor,
const LatticeT &after,
593 block, point, successor, after, before);
624 static_cast<LatticeT *
>(before));
631 static_cast<const LatticeT &
>(after),
632 static_cast<LatticeT *
>(before));
639 static_cast<const LatticeT &
>(after),
640 static_cast<LatticeT *
>(before));
646 static_cast<const LatticeT &
>(after),
647 static_cast<LatticeT *
>(before));
AnalysisState(LatticeAnchor anchor)
Create the analysis state on the given lattice anchor.
Block represents an ordered list of Operations.
void propagateIfChanged(AnalysisState *state, ChangeResult changed)
Propagate an update to a state if it changed.
StateT * getOrCreate(AnchorT anchor)
Get the analysis state associated with the lattice anchor.
DataFlowAnalysis(DataFlowSolver &solver)
Create an analysis with a reference to the parent solver.
friend class DataFlowSolver
Allow the data-flow solver to access the internals of this class.
const StateT * getOrCreateFor(ProgramPoint *dependent, AnchorT anchor)
Get a read-only analysis state for the given point and create a dependency on dependent.
Operation is the basic unit of execution within MLIR.
This class represents a point being branched from in the methods of the RegionBranchOpInterface.
This class represents a successor of a region.
This class represents a collection of SymbolTables.
virtual void setToExitState(AbstractDenseLattice *lattice)=0
Set the dense lattice before at the control flow exit point and propagate the update if it changed.
LogicalResult initialize(Operation *top) override
Initialize the analysis by visiting every program point whose execution may modify the program state;...
virtual void visitCallControlFlowTransfer(CallOpInterface call, CallControlFlowAction action, const AbstractDenseLattice &after, AbstractDenseLattice *before)
Propagate the dense lattice backwards along the call control flow edge, which can be either entering ...
virtual void initializeEquivalentLatticeAnchor(Operation *top) override
Initialize lattice anchor equivalence class from the provided top-level operation.
virtual void buildOperationEquivalentLatticeAnchor(Operation *op)
Visit an operation.
virtual void visitBlockTransfer(Block *block, ProgramPoint *point, Block *successor, const AbstractDenseLattice &after, AbstractDenseLattice *before)
Visit a block and propagate the dense lattice backward along the control flow edge from successor to ...
virtual AbstractDenseLattice * getLattice(LatticeAnchor anchor)=0
Get the dense lattice before the execution of the lattice anchor.
LogicalResult visit(ProgramPoint *point) override
Visit a program point that modifies the state of the program.
virtual LogicalResult visitOperationImpl(Operation *op, const AbstractDenseLattice &after, AbstractDenseLattice *before)=0
Propagate the dense lattice after the execution of an operation to the lattice before its execution.
void meet(AbstractDenseLattice *lhs, const AbstractDenseLattice &rhs)
Meet a lattice with another lattice and propagate an update if it changed.
virtual LogicalResult processOperation(Operation *op)
Visit an operation.
virtual void visitRegionBranchControlFlowTransfer(RegionBranchOpInterface branch, RegionBranchPoint regionFrom, RegionSuccessor regionTo, const AbstractDenseLattice &after, AbstractDenseLattice *before)
Propagate the dense lattice backwards along the control flow edge from regionFrom to regionTo regions...
virtual const AbstractDenseLattice * getLatticeFor(ProgramPoint *dependent, LatticeAnchor anchor)=0
Get the dense lattice on the given lattice anchor and add dependent as its dependency.
AbstractDenseBackwardDataFlowAnalysis(DataFlowSolver &solver, SymbolTableCollection &symbolTable)
Construct the analysis in the given solver.
Base class for dense forward data-flow analyses.
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.
virtual const AbstractDenseLattice * getLatticeFor(ProgramPoint *dependent, LatticeAnchor anchor)=0
Get the dense lattice on the given lattice anchor and add dependent as its dependency.
void visitRegionBranchOperation(ProgramPoint *point, RegionBranchOpInterface branch, AbstractDenseLattice *after)
Visit a program point within a region branch operation with predecessors in it.
virtual void initializeEquivalentLatticeAnchor(Operation *top) override
Initialize lattice anchor equivalence class from the provided top-level operation.
void join(AbstractDenseLattice *lhs, const AbstractDenseLattice &rhs)
Join a lattice with another and propagate an update if it changed.
virtual void setToEntryState(AbstractDenseLattice *lattice)=0
Set the dense lattice at control flow entry point and propagate an update if it changed.
LogicalResult initialize(Operation *top) override
Initialize the analysis by visiting every program point whose execution may modify the program state;...
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...
virtual AbstractDenseLattice * getLattice(LatticeAnchor anchor)=0
Get the dense lattice on the given lattice anchor.
virtual LogicalResult processOperation(Operation *op)
Visit an operation.
DataFlowAnalysis(DataFlowSolver &solver)
Create an analysis with a reference to the parent solver.
virtual void visitBlockTransfer(Block *block, ProgramPoint *point, Block *predecessor, const AbstractDenseLattice &before, AbstractDenseLattice *after)
Visit a block and propagate the dense lattice forward along the control flow edge from predecessor to...
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 o...
virtual void buildOperationEquivalentLatticeAnchor(Operation *op)
Visit an operation.
LogicalResult visit(ProgramPoint *point) override
Visit a program point that modifies the state of the program.
This class represents a dense lattice.
virtual ChangeResult join(const AbstractDenseLattice &rhs)
Join the lattice across control-flow or callgraph edges.
AnalysisState(LatticeAnchor anchor)
A dense lattice can only be created for operations and blocks.
virtual ChangeResult meet(const AbstractDenseLattice &rhs)
A dense backward dataflow analysis propagating lattices after and before the execution of every opera...
virtual void setToExitState(LatticeT *lattice)=0
Set the dense lattice at control flow exit point (after the terminator) and propagate an update if it...
void visitBlockTransfer(Block *block, ProgramPoint *point, Block *successor, const AbstractDenseLattice &after, AbstractDenseLattice *before) final
Visit a block and propagate the dense lattice backward along the control flow edge from successor to ...
virtual const AbstractDenseLattice * getLatticeFor(ProgramPoint *dependent, LatticeAnchor anchor) override
Get the dense lattice on the given lattice anchor and add dependent as its dependency.
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 virt...
LatticeT * getLattice(LatticeAnchor anchor) override
Get the dense lattice at the given lattice anchor.
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.
virtual void visitBlockTransfer(Block *block, ProgramPoint *point, Block *successor, const LatticeT &after, LatticeT *before)
Hook for customizing the behavior of lattice propagation along the control flow edges between blocks.
void setToExitState(AbstractDenseLattice *lattice) final
Set the dense lattice before at the control flow exit point and propagate the update if it changed.
void visitRegionBranchControlFlowTransfer(RegionBranchOpInterface branch, RegionBranchPoint regionForm, RegionSuccessor regionTo, const AbstractDenseLattice &after, AbstractDenseLattice *before) final
Propagate the dense lattice backwards along the control flow edge from regionFrom to regionTo regions...
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 ...
virtual LogicalResult visitOperation(Operation *op, const LatticeT &after, LatticeT *before)=0
Transfer function.
virtual void visitRegionBranchControlFlowTransfer(RegionBranchOpInterface branch, RegionBranchPoint regionFrom, RegionSuccessor regionTo, const LatticeT &after, LatticeT *before)
Hook for customizing the behavior of lattice propagation along the control flow edges between regions...
A dense forward data-flow analysis for propagating lattices before and after the execution of every o...
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.
void setToEntryState(AbstractDenseLattice *lattice) override
Set the dense lattice at control flow entry point and propagate an update if it changed.
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...
const AbstractDenseLattice * getLatticeFor(ProgramPoint *dependent, LatticeAnchor anchor) override
Get the dense lattice on the given lattice anchor and add dependent as its dependency.
virtual void setToEntryState(LatticeT *lattice)=0
Set the dense lattice at control flow entry point and propagate an update if it changed.
virtual void visitBlockTransfer(Block *block, ProgramPoint *point, Block *predecessor, const LatticeT &before, LatticeT *after)
Hook for customizing the behavior of lattice propagation along the control flow edges between blocks.
LatticeT * getLattice(LatticeAnchor anchor) override
Get the dense lattice on this lattice anchor.
LogicalResult 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 virt...
virtual LogicalResult visitOperation(Operation *op, const LatticeT &before, LatticeT *after)=0
Visit an operation with the dense lattice before its execution.
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 o...
void visitBlockTransfer(Block *block, ProgramPoint *point, Block *predecessor, const AbstractDenseLattice &before, AbstractDenseLattice *after) final
Visit a block and propagate the dense lattice forward along the control flow edge from predecessor to...
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...
CallControlFlowAction
Indicates whether the control enters, exits, or skips over the callee (in the case of external functi...
Include the generated interface declarations.
ChangeResult
A result type used to indicate if a change happened.
Fundamental IR components are supported as first-class lattice anchor.
Program point represents a specific location in the execution of a program.