17#include <mlir/Pass/AnalysisManager.h>
19#include <llvm/ADT/EquivalenceClasses.h>
72 mlir::SymbolTableCollection
tables;
86template <>
struct std::hash<
llzk::CDGAnalysisContext> {
132 static mlir::FailureOr<ConstraintDependencyGraph>
compute(
141 void print(mlir::raw_ostream &os)
const;
171 : mod(other.mod), structDef(other.structDef), ctx(other.ctx), signalSets(other.signalSets),
172 constantSets(other.constantSets), ref2Val(other.ref2Val), tables() {}
176 structDef = other.structDef;
178 signalSets = other.signalSets;
179 constantSets = other.constantSets;
180 ref2Val = other.ref2Val;
193 llvm::EquivalenceClasses<SourceRef> signalSets;
196 std::unordered_map<SourceRef, SourceRefSet, SourceRef::Hash> constantSets;
202 mutable mlir::SymbolTableCollection tables;
210 : mod(m), structDef(s), ctx(c) {}
217 mlir::LogicalResult computeConstraints(mlir::DataFlowSolver &solver, mlir::AnalysisManager &am);
225 void walkConstrainOp(mlir::DataFlowSolver &solver, mlir::Operation *emitOp);
233 :
public StructAnalysis<ConstraintDependencyGraph, CDGAnalysisContext> {
241 mlir::DataFlowSolver &solver, mlir::AnalysisManager &moduleAnalysisManager,
250 ConstraintDependencyGraph, CDGAnalysisContext, ConstraintDependencyGraphStructAnalysis> {
257 ctx = {.runIntraprocedural = runIntraprocedural};
Convenience classes for a frequent pattern of dataflow analysis used in LLZK, where an analysis is ru...
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.
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...
const CDGAnalysisContext & getContext() const override
Return the current Context object.
An analysis wrapper around the ConstraintDependencyGraph for a given struct.
StructAnalysis(mlir::Operation *op)
Assert that this analysis is being run on a StructDefOp and initializes the analysis with the current...
mlir::LogicalResult runAnalysis(mlir::DataFlowSolver &solver, mlir::AnalysisManager &moduleAnalysisManager, const CDGAnalysisContext &ctx) override
Construct a CDG, using the module's analysis manager to query ConstraintDependencyGraph objects for n...
virtual ~ConstraintDependencyGraphStructAnalysis()=default
ConstraintDependencyGraph & operator=(const ConstraintDependencyGraph &other)
void print(mlir::raw_ostream &os) const
Print the CDG to the specified output stream.
static mlir::FailureOr< ConstraintDependencyGraph > compute(mlir::ModuleOp mod, component::StructDefOp s, mlir::DataFlowSolver &solver, mlir::AnalysisManager &am, const CDGAnalysisContext &ctx)
Compute a ConstraintDependencyGraph (CDG)
ConstraintDependencyGraph(const ConstraintDependencyGraph &other)
virtual ~ConstraintDependencyGraph()=default
SourceRefSet getConstrainingValues(const SourceRef &ref) const
Get the values that are connected to the given ref via emitted constraints.
void dump() const
Dumps the CDG to stderr.
const SourceRefLattice::Ref2Val & getRef2Val() const
ConstraintDependencyGraph translate(SourceRefRemappings translation) const
Translate the SourceRefs in this CDG to that of a different context.
mlir::DataFlowSolver solver
ModuleAnalysis(mlir::Operation *op)
Asserts that the analysis is being run on a ModuleOp.
The dataflow analysis that computes the set of references that LLZK operations use and produce.
mlir::ChangeResult fallbackOpUpdate(mlir::Operation *op, const SourceRefLattice::ValueMap &operandVals, const SourceRefLattice &before, SourceRefLattice *after)
mlir::LogicalResult visitOperation(mlir::Operation *op, const SourceRefLattice &before, SourceRefLattice *after) override
Propagate SourceRef lattice values from operands to results.
void setToEntryState(SourceRefLattice *lattice) override
Set the dense lattice at control flow entry point and propagate an update if it changed.
void arraySubdivisionOpUpdate(array::ArrayAccessOpInterface op, const SourceRefLattice::ValueMap &operandVals, const SourceRefLattice &before, SourceRefLattice *after)
void visitCallControlFlowTransfer(mlir::CallOpInterface call, dataflow::CallControlFlowAction action, const SourceRefLattice &before, SourceRefLattice *after) override
Hook for customizing the behavior of lattice propagation along the call control flow edges.
A lattice for use in dense analysis.
mlir::DenseMap< SourceRef, mlir::DenseSet< ValueTy > > Ref2Val
mlir::DenseMap< ValueTy, SourceRefLatticeValue > ValueMap
A reference to a "source", which is the base value from which other SSA values are derived.
StructAnalysis(mlir::Operation *op)
Assert that this analysis is being run on a StructDefOp and initializes the analysis with the current...
mlir::SymbolTableCollection tables
LLZK: Added for use of symbol helper caching.
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< SourceRef, SourceRefLatticeValue > > SourceRefRemappings
Parameters and shared objects to pass to child analyses.
friend bool operator==(const CDGAnalysisContext &a, const CDGAnalysisContext &b)=default
bool runIntraproceduralAnalysis() const
size_t operator()(const llzk::CDGAnalysisContext &c) const