17#include <mlir/Pass/AnalysisManager.h>
19#include <llvm/ADT/EquivalenceClasses.h>
72 mlir::SymbolTableCollection tables;
114 static mlir::FailureOr<ConstraintDependencyGraph>
compute(
116 mlir::AnalysisManager &am,
bool runIntraprocedural
123 void print(mlir::raw_ostream &os)
const;
153 : mod(other.mod), structDef(other.structDef), runIntraprocedural(other.runIntraprocedural),
154 signalSets(other.signalSets), constantSets(other.constantSets), ref2Val(other.ref2Val),
159 structDef = other.structDef;
160 runIntraprocedural = other.runIntraprocedural;
161 signalSets = other.signalSets;
162 constantSets = other.constantSets;
163 ref2Val = other.ref2Val;
173 bool runIntraprocedural;
176 llvm::EquivalenceClasses<ConstrainRef> signalSets;
179 std::unordered_map<ConstrainRef, ConstrainRefSet, ConstrainRef::Hash> constantSets;
185 mutable mlir::SymbolTableCollection tables;
195 : mod(m), structDef(s), runIntraprocedural(intraprocedural) {}
202 mlir::LogicalResult computeConstraints(mlir::DataFlowSolver &solver, mlir::AnalysisManager &am);
210 void walkConstrainOp(mlir::DataFlowSolver &solver, mlir::Operation *emitOp);
225 :
public StructAnalysis<ConstraintDependencyGraph, CDGAnalysisContext> {
231 mlir::DataFlowSolver &solver, mlir::AnalysisManager &moduleAnalysisManager,
240 mlir::DataFlowSolver &solver, mlir::AnalysisManager &moduleAnalysisManager,
241 bool runIntraprocedural
249 ConstraintDependencyGraph, CDGAnalysisContext, ConstraintDependencyGraphStructAnalysis> {
263 bool intraprocedural =
false;
Convenience classes for a frequent pattern of dataflow analysis used in LLZK, where an analysis is ru...
The dataflow analysis that computes the set of references that LLZK operations use and produce.
void visitCallControlFlowTransfer(mlir::CallOpInterface call, dataflow::CallControlFlowAction action, const ConstrainRefLattice &before, ConstrainRefLattice *after) override
Hook for customizing the behavior of lattice propagation along the call control flow edges.
mlir::ChangeResult fallbackOpUpdate(mlir::Operation *op, const ConstrainRefLattice::ValueMap &operandVals, const ConstrainRefLattice &before, ConstrainRefLattice *after)
void setToEntryState(ConstrainRefLattice *lattice) override
Set the dense lattice at control flow entry point and propagate an update if it changed.
void arraySubdivisionOpUpdate(array::ArrayAccessOpInterface op, const ConstrainRefLattice::ValueMap &operandVals, const ConstrainRefLattice &before, ConstrainRefLattice *after)
void visitOperation(mlir::Operation *op, const ConstrainRefLattice &before, ConstrainRefLattice *after) override
Propagate constrain reference lattice values from operands to results.
A lattice for use in dense analysis.
mlir::DenseMap< ValueTy, ConstrainRefLatticeValue > ValueMap
mlir::DenseMap< ConstrainRef, mlir::DenseSet< ValueTy > > Ref2Val
Defines a reference to a llzk object within a constrain function call.
A module-level analysis for constructing ConstraintDependencyGraph objects for all structs in the giv...
ModuleAnalysis(mlir::Operation *op)
Asserts that the analysis is being run on a ModuleOp.
CDGAnalysisContext getContext() override
Create and return a valid Context object.
virtual ~ConstraintDependencyGraphModuleAnalysis()=default
void setIntraprocedural(bool runIntraprocedural)
void initializeSolver() override
Initialize the shared dataflow solver with any common analyses required by the contained struct analy...
An analysis wrapper around the ConstraintDependencyGraph for a given struct.
mlir::LogicalResult runAnalysis(mlir::DataFlowSolver &solver, mlir::AnalysisManager &moduleAnalysisManager, CDGAnalysisContext &ctx) override
Perform the analysis and construct the Result output.
StructAnalysis(mlir::Operation *op)
Assert that this analysis is being run on a StructDefOp and initializes the analysis with the current...
virtual ~ConstraintDependencyGraphStructAnalysis()=default
static mlir::FailureOr< ConstraintDependencyGraph > compute(mlir::ModuleOp mod, component::StructDefOp s, mlir::DataFlowSolver &solver, mlir::AnalysisManager &am, bool runIntraprocedural)
Compute a ConstraintDependencyGraph (CDG)
ConstraintDependencyGraph & operator=(const ConstraintDependencyGraph &other)
void print(mlir::raw_ostream &os) const
Print the CDG to the specified output stream.
ConstraintDependencyGraph translate(ConstrainRefRemappings translation) const
Translate the ConstrainRefs in this CDG to that of a different context.
ConstrainRefSet getConstrainingValues(const ConstrainRef &ref) const
Get the values that are connected to the given ref via emitted constraints.
const ConstrainRefLattice::Ref2Val & getRef2Val() const
ConstraintDependencyGraph(const ConstraintDependencyGraph &other)
virtual ~ConstraintDependencyGraph()=default
void dump() const
Dumps the CDG to stderr.
mlir::DataFlowSolver solver
ModuleAnalysis(mlir::Operation *op)
Asserts that the analysis is being run on a ModuleOp.
StructAnalysis(mlir::Operation *op)
Assert that this analysis is being run on a StructDefOp and initializes the analysis with the current...
LLZK: This class has been ported so that it can inherit from our port of the AbstractDenseForwardData...
mlir::dataflow::CallControlFlowAction CallControlFlowAction
std::vector< std::pair< ConstrainRef, ConstrainRefLatticeValue > > ConstrainRefRemappings
Parameters and shared objects to pass to child analyses.
bool runIntraproceduralAnalysis() const