31#include <mlir/Analysis/DataFlow/SparseAnalysis.h>
32#include <mlir/Analysis/DataFlowFramework.h>
33#include <mlir/IR/SymbolTable.h>
34#include <mlir/Interfaces/CallInterfaces.h>
35#include <mlir/Interfaces/ControlFlowInterfaces.h>
37#include <llvm/ADT/SmallPtrSet.h>
65 mlir::LogicalResult
initialize(mlir::Operation *top)
override;
72 mlir::LogicalResult
visit(mlir::ProgramPoint *point)
override;
80 mlir::Operation *op, mlir::ArrayRef<const AbstractSparseLattice *> operandLattices,
81 mlir::ArrayRef<AbstractSparseLattice *> resultLattices
86 mlir::CallOpInterface call, mlir::ArrayRef<const AbstractSparseLattice *> argumentLattices,
87 mlir::ArrayRef<AbstractSparseLattice *> resultLattices
95 mlir::Operation *op,
const mlir::RegionSuccessor &successor,
96 mlir::ArrayRef<AbstractSparseLattice *> argLattices,
unsigned firstIndex
118 mlir::LogicalResult initializeRecursively(mlir::Operation *op);
123 mlir::LogicalResult visitOperation(mlir::Operation *op);
130 void visitBlock(mlir::Block *block);
136 void visitRegionSuccessors(
137 mlir::ProgramPoint *point, mlir::RegionBranchOpInterface branch,
138 mlir::RegionBranchPoint successor, mlir::ArrayRef<AbstractSparseLattice *> lattices
150template <
typename StateT>
153 std::is_base_of<AbstractSparseLattice, StateT>::value,
154 "analysis state class expected to subclass AbstractSparseLattice"
164 mlir::Operation *op, mlir::ArrayRef<const StateT *> operands, mlir::ArrayRef<StateT *> results
170 mlir::CallOpInterface call, mlir::ArrayRef<const StateT *> argumentLattices,
171 mlir::ArrayRef<StateT *> resultLattices
183 mlir::Operation *op,
const mlir::RegionSuccessor &successor,
184 mlir::ArrayRef<StateT *> argLattices,
unsigned firstIndex
187 setAllToEntryStates(argLattices.drop_front(firstIndex + successor.getSuccessorInputs().size()));
197 return static_cast<const StateT *
>(
213 llvm::LogicalResult visitOperationImpl(
214 mlir::Operation *op, mlir::ArrayRef<const AbstractSparseLattice *> operandLattices,
215 mlir::ArrayRef<AbstractSparseLattice *> resultLattices
219 {
reinterpret_cast<const StateT *
const *
>(operandLattices.begin()), operandLattices.size()},
220 {
reinterpret_cast<StateT *
const *
>(resultLattices.begin()), resultLattices.size()}
223 void visitExternalCallImpl(
224 mlir::CallOpInterface call, mlir::ArrayRef<const AbstractSparseLattice *> argumentLattices,
225 mlir::ArrayRef<AbstractSparseLattice *> resultLattices
229 {
reinterpret_cast<const StateT *
const *
>(argumentLattices.begin()),
230 argumentLattices.size()},
231 {
reinterpret_cast<StateT *
const *
>(resultLattices.begin()), resultLattices.size()}
234 void visitNonControlFlowArgumentsImpl(
235 mlir::Operation *op,
const mlir::RegionSuccessor &successor,
236 mlir::ArrayRef<AbstractSparseLattice *> argLattices,
unsigned firstIndex
239 op, successor, {
reinterpret_cast<StateT *
const *
>(argLattices.begin()), argLattices.size()},
mlir::LogicalResult visit(mlir::ProgramPoint *point) override
Visit a program point.
mlir::LogicalResult initialize(mlir::Operation *top) override
Initialize the analysis by visiting every owner of an SSA value: all operations and blocks.
virtual mlir::LogicalResult visitOperationImpl(mlir::Operation *op, mlir::ArrayRef< const AbstractSparseLattice * > operandLattices, mlir::ArrayRef< AbstractSparseLattice * > resultLattices)=0
The operation transfer function.
virtual AbstractSparseLattice * getLatticeElement(mlir::Value value)=0
Get the lattice element of a value.
AbstractSparseForwardDataFlowAnalysis(mlir::DataFlowSolver &solver)
void setAllToEntryStates(mlir::ArrayRef< AbstractSparseLattice * > lattices)
const AbstractSparseLattice * getLatticeElementFor(mlir::ProgramPoint *point, mlir::Value value)
Get a read-only lattice element for a value and add it as a dependency to a program point.
void join(AbstractSparseLattice *lhs, const AbstractSparseLattice &rhs)
Join the lattice element and propagate and update if it changed.
virtual void setToEntryState(AbstractSparseLattice *lattice)=0
Set the given lattice element(s) at control flow entry point(s).
mlir::SymbolTableCollection tables
LLZK: Added for use of symbol helper caching.
virtual void visitNonControlFlowArgumentsImpl(mlir::Operation *op, const mlir::RegionSuccessor &successor, mlir::ArrayRef< AbstractSparseLattice * > argLattices, unsigned firstIndex)=0
Given an operation with region control-flow, the lattices of the operands, and a region successor,...
virtual void visitExternalCallImpl(mlir::CallOpInterface call, mlir::ArrayRef< const AbstractSparseLattice * > argumentLattices, mlir::ArrayRef< AbstractSparseLattice * > resultLattices)=0
The transfer function for calls to external functions.
const StateT * getLatticeElementFor(mlir::ProgramPoint *point, mlir::Value value)
Get the lattice element for a value and create a dependency on the provided program point.
virtual void visitNonControlFlowArguments(mlir::Operation *op, const mlir::RegionSuccessor &successor, mlir::ArrayRef< StateT * > argLattices, unsigned firstIndex)
Given an operation with possible region control-flow, the lattices of the operands,...
SparseForwardDataFlowAnalysis(mlir::DataFlowSolver &s)
void setAllToEntryStates(mlir::ArrayRef< StateT * > lattices)
virtual void visitExternalCall(mlir::CallOpInterface call, mlir::ArrayRef< const StateT * > argumentLattices, mlir::ArrayRef< StateT * > resultLattices)
Visit a call operation to an externally defined function given the lattices of its arguments.
virtual mlir::LogicalResult visitOperation(mlir::Operation *op, mlir::ArrayRef< const StateT * > operands, mlir::ArrayRef< StateT * > results)=0
Visit an operation with the lattices of its operands.
virtual void setToEntryState(StateT *lattice)=0
Set the given lattice element(s) at control flow entry point(s).
StateT * getLatticeElement(mlir::Value value) override
Get the lattice element for a value.
mlir::dataflow::AbstractSparseLattice AbstractSparseLattice