5#define GEN_PASS_DECL_CALLGRAPHPRINTERPASS
6#define GEN_PASS_DECL_CALLGRAPHSCCSPRINTERPASS
7#define GEN_PASS_DECL_CONSTRAINTDEPENDENCYGRAPHPRINTERPASS
8#define GEN_PASS_DECL_INTERVALANALYSISPRINTERPASS
9#define GEN_PASS_DECL_SYMBOLDEFTREEPRINTERPASS
10#define GEN_PASS_DECL_SYMBOLUSEGRAPHPRINTERPASS
17#ifdef GEN_PASS_DECL_CALLGRAPHPRINTERPASS
18#undef GEN_PASS_DECL_CALLGRAPHPRINTERPASS
20#ifdef GEN_PASS_DEF_CALLGRAPHPRINTERPASS
23template <
typename DerivedT>
24class CallGraphPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
26 using Base = CallGraphPrinterPassBase;
28 CallGraphPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
29 CallGraphPrinterPassBase(
const CallGraphPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
30 CallGraphPrinterPassBase& operator=(
const CallGraphPrinterPassBase &) =
delete;
31 CallGraphPrinterPassBase(CallGraphPrinterPassBase &&) =
delete;
32 CallGraphPrinterPassBase& operator=(CallGraphPrinterPassBase &&) =
delete;
33 ~CallGraphPrinterPassBase() =
default;
36 static constexpr ::llvm::StringLiteral getArgumentName() {
37 return ::llvm::StringLiteral(
"llzk-print-call-graph");
39 ::llvm::StringRef getArgument()
const override {
return "llzk-print-call-graph"; }
41 ::llvm::StringRef getDescription()
const override {
return "Print the LLZK module's call graph."; }
44 static constexpr ::llvm::StringLiteral getPassName() {
45 return ::llvm::StringLiteral(
"CallGraphPrinterPass");
47 ::llvm::StringRef getName()
const override {
return "CallGraphPrinterPass"; }
50 static bool classof(const ::mlir::Pass *pass) {
51 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
55 std::unique_ptr<::mlir::Pass> clonePass()
const override {
56 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
60 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
61 registry.insert<llzk::LLZKDialect>();
62 registry.insert<llzk::boolean::BoolDialect>();
63 registry.insert<llzk::array::ArrayDialect>();
64 registry.insert<llzk::component::StructDialect>();
65 registry.insert<llzk::constrain::ConstrainDialect>();
66 registry.insert<llzk::felt::FeltDialect>();
67 registry.insert<llzk::global::GlobalDialect>();
68 registry.insert<llzk::include::IncludeDialect>();
69 registry.insert<llzk::function::FunctionDialect>();
70 registry.insert<llzk::string::StringDialect>();
71 registry.insert<llzk::polymorphic::PolymorphicDialect>();
72 registry.insert<llzk::undef::UndefDialect>();
73 registry.insert<mlir::arith::ArithDialect>();
74 registry.insert<mlir::scf::SCFDialect>();
80 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CallGraphPrinterPassBase<DerivedT>)
86#undef GEN_PASS_DEF_CALLGRAPHPRINTERPASS
92#ifdef GEN_PASS_DECL_CALLGRAPHSCCSPRINTERPASS
93#undef GEN_PASS_DECL_CALLGRAPHSCCSPRINTERPASS
95#ifdef GEN_PASS_DEF_CALLGRAPHSCCSPRINTERPASS
98template <
typename DerivedT>
99class CallGraphSCCsPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
101 using Base = CallGraphSCCsPrinterPassBase;
103 CallGraphSCCsPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
104 CallGraphSCCsPrinterPassBase(
const CallGraphSCCsPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
105 CallGraphSCCsPrinterPassBase& operator=(
const CallGraphSCCsPrinterPassBase &) =
delete;
106 CallGraphSCCsPrinterPassBase(CallGraphSCCsPrinterPassBase &&) =
delete;
107 CallGraphSCCsPrinterPassBase& operator=(CallGraphSCCsPrinterPassBase &&) =
delete;
108 ~CallGraphSCCsPrinterPassBase() =
default;
111 static constexpr ::llvm::StringLiteral getArgumentName() {
112 return ::llvm::StringLiteral(
"llzk-print-call-graph-sccs");
114 ::llvm::StringRef getArgument()
const override {
return "llzk-print-call-graph-sccs"; }
116 ::llvm::StringRef getDescription()
const override {
return "Print the SCCs from the LLZK module's call graph."; }
119 static constexpr ::llvm::StringLiteral getPassName() {
120 return ::llvm::StringLiteral(
"CallGraphSCCsPrinterPass");
122 ::llvm::StringRef getName()
const override {
return "CallGraphSCCsPrinterPass"; }
125 static bool classof(const ::mlir::Pass *pass) {
126 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
130 std::unique_ptr<::mlir::Pass> clonePass()
const override {
131 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
135 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
136 registry.insert<llzk::LLZKDialect>();
137 registry.insert<llzk::boolean::BoolDialect>();
138 registry.insert<llzk::array::ArrayDialect>();
139 registry.insert<llzk::component::StructDialect>();
140 registry.insert<llzk::constrain::ConstrainDialect>();
141 registry.insert<llzk::felt::FeltDialect>();
142 registry.insert<llzk::global::GlobalDialect>();
143 registry.insert<llzk::include::IncludeDialect>();
144 registry.insert<llzk::function::FunctionDialect>();
145 registry.insert<llzk::string::StringDialect>();
146 registry.insert<llzk::polymorphic::PolymorphicDialect>();
147 registry.insert<llzk::undef::UndefDialect>();
148 registry.insert<mlir::arith::ArithDialect>();
149 registry.insert<mlir::scf::SCFDialect>();
155 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CallGraphSCCsPrinterPassBase<DerivedT>)
161#undef GEN_PASS_DEF_CALLGRAPHSCCSPRINTERPASS
167#ifdef GEN_PASS_DECL_CONSTRAINTDEPENDENCYGRAPHPRINTERPASS
168struct ConstraintDependencyGraphPrinterPassOptions {
169 bool runIntraprocedural =
false;
171#undef GEN_PASS_DECL_CONSTRAINTDEPENDENCYGRAPHPRINTERPASS
173#ifdef GEN_PASS_DEF_CONSTRAINTDEPENDENCYGRAPHPRINTERPASS
176template <
typename DerivedT>
177class ConstraintDependencyGraphPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
179 using Base = ConstraintDependencyGraphPrinterPassBase;
181 ConstraintDependencyGraphPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
182 ConstraintDependencyGraphPrinterPassBase(
const ConstraintDependencyGraphPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
183 ConstraintDependencyGraphPrinterPassBase& operator=(
const ConstraintDependencyGraphPrinterPassBase &) =
delete;
184 ConstraintDependencyGraphPrinterPassBase(ConstraintDependencyGraphPrinterPassBase &&) =
delete;
185 ConstraintDependencyGraphPrinterPassBase& operator=(ConstraintDependencyGraphPrinterPassBase &&) =
delete;
186 ~ConstraintDependencyGraphPrinterPassBase() =
default;
189 static constexpr ::llvm::StringLiteral getArgumentName() {
190 return ::llvm::StringLiteral(
"llzk-print-constraint-dependency-graphs");
192 ::llvm::StringRef getArgument()
const override {
return "llzk-print-constraint-dependency-graphs"; }
194 ::llvm::StringRef getDescription()
const override {
return "Print constraint dependency graph for all LLZK structs."; }
197 static constexpr ::llvm::StringLiteral getPassName() {
198 return ::llvm::StringLiteral(
"ConstraintDependencyGraphPrinterPass");
200 ::llvm::StringRef getName()
const override {
return "ConstraintDependencyGraphPrinterPass"; }
203 static bool classof(const ::mlir::Pass *pass) {
204 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
208 std::unique_ptr<::mlir::Pass> clonePass()
const override {
209 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
213 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
214 registry.insert<llzk::LLZKDialect>();
215 registry.insert<llzk::boolean::BoolDialect>();
216 registry.insert<llzk::array::ArrayDialect>();
217 registry.insert<llzk::component::StructDialect>();
218 registry.insert<llzk::constrain::ConstrainDialect>();
219 registry.insert<llzk::felt::FeltDialect>();
220 registry.insert<llzk::global::GlobalDialect>();
221 registry.insert<llzk::include::IncludeDialect>();
222 registry.insert<llzk::function::FunctionDialect>();
223 registry.insert<llzk::string::StringDialect>();
224 registry.insert<llzk::polymorphic::PolymorphicDialect>();
225 registry.insert<llzk::undef::UndefDialect>();
226 registry.insert<mlir::arith::ArithDialect>();
227 registry.insert<mlir::scf::SCFDialect>();
233 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ConstraintDependencyGraphPrinterPassBase<DerivedT>)
235 ConstraintDependencyGraphPrinterPassBase(ConstraintDependencyGraphPrinterPassOptions options) : ConstraintDependencyGraphPrinterPassBase() {
236 runIntraprocedural = std::move(options.runIntraprocedural);
239 ::mlir::Pass::Option<bool> runIntraprocedural{*
this,
"intraprocedural", ::llvm::cl::desc(
"Whether to run the analysis intra-procedurally only (default is false)."), ::llvm::cl::init(
false)};
243#undef GEN_PASS_DEF_CONSTRAINTDEPENDENCYGRAPHPRINTERPASS
249#ifdef GEN_PASS_DECL_INTERVALANALYSISPRINTERPASS
250struct IntervalAnalysisPrinterPassOptions {
251 std::string fieldName =
"bn128";
252 bool propagateInputConstraints =
false;
253 bool printSolverConstraints =
false;
254 bool printComputeIntervals =
false;
256#undef GEN_PASS_DECL_INTERVALANALYSISPRINTERPASS
258#ifdef GEN_PASS_DEF_INTERVALANALYSISPRINTERPASS
261template <
typename DerivedT>
262class IntervalAnalysisPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
264 using Base = IntervalAnalysisPrinterPassBase;
266 IntervalAnalysisPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
267 IntervalAnalysisPrinterPassBase(
const IntervalAnalysisPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
268 IntervalAnalysisPrinterPassBase& operator=(
const IntervalAnalysisPrinterPassBase &) =
delete;
269 IntervalAnalysisPrinterPassBase(IntervalAnalysisPrinterPassBase &&) =
delete;
270 IntervalAnalysisPrinterPassBase& operator=(IntervalAnalysisPrinterPassBase &&) =
delete;
271 ~IntervalAnalysisPrinterPassBase() =
default;
274 static constexpr ::llvm::StringLiteral getArgumentName() {
275 return ::llvm::StringLiteral(
"llzk-print-interval-analysis");
277 ::llvm::StringRef getArgument()
const override {
return "llzk-print-interval-analysis"; }
279 ::llvm::StringRef getDescription()
const override {
return "Print interval analysis results for all LLZK structs."; }
282 static constexpr ::llvm::StringLiteral getPassName() {
283 return ::llvm::StringLiteral(
"IntervalAnalysisPrinterPass");
285 ::llvm::StringRef getName()
const override {
return "IntervalAnalysisPrinterPass"; }
288 static bool classof(const ::mlir::Pass *pass) {
289 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
293 std::unique_ptr<::mlir::Pass> clonePass()
const override {
294 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
298 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
299 registry.insert<llzk::LLZKDialect>();
300 registry.insert<llzk::boolean::BoolDialect>();
301 registry.insert<llzk::array::ArrayDialect>();
302 registry.insert<llzk::component::StructDialect>();
303 registry.insert<llzk::constrain::ConstrainDialect>();
304 registry.insert<llzk::felt::FeltDialect>();
305 registry.insert<llzk::global::GlobalDialect>();
306 registry.insert<llzk::include::IncludeDialect>();
307 registry.insert<llzk::function::FunctionDialect>();
308 registry.insert<llzk::string::StringDialect>();
309 registry.insert<llzk::polymorphic::PolymorphicDialect>();
310 registry.insert<llzk::undef::UndefDialect>();
311 registry.insert<mlir::arith::ArithDialect>();
312 registry.insert<mlir::scf::SCFDialect>();
318 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(IntervalAnalysisPrinterPassBase<DerivedT>)
320 IntervalAnalysisPrinterPassBase(IntervalAnalysisPrinterPassOptions options) : IntervalAnalysisPrinterPassBase() {
321 fieldName = std::move(options.fieldName);
322 propagateInputConstraints = std::move(options.propagateInputConstraints);
323 printSolverConstraints = std::move(options.printSolverConstraints);
324 printComputeIntervals = std::move(options.printComputeIntervals);
327 ::mlir::Pass::Option<std::string> fieldName{*
this,
"field", ::llvm::cl::desc(
"The field to use for interval analysis. Supported fields: bn128/bn254, babybear, goldilocks, mersenne31"), ::llvm::cl::init(
"bn128")};
328 ::mlir::Pass::Option<bool> propagateInputConstraints{*
this,
"propagate-input-constraints", ::llvm::cl::desc(
"Whether to propagate constraints on inputs from @constrain to @compute functions. This allows for tighter intervals to possibly be found for computed values, assuming that the witness generator would include constraints as assertions during the computation."), ::llvm::cl::init(
false)};
329 ::mlir::Pass::Option<bool> printSolverConstraints{*
this,
"print-solver-constraints", ::llvm::cl::desc(
"Whether to output SMT solver constraints along with intervals."), ::llvm::cl::init(
false)};
330 ::mlir::Pass::Option<bool> printComputeIntervals{*
this,
"print-compute-intervals", ::llvm::cl::desc(
"Whether to print compute function intervals (default only prints constrain function intervals)."), ::llvm::cl::init(
false)};
334#undef GEN_PASS_DEF_INTERVALANALYSISPRINTERPASS
340#ifdef GEN_PASS_DECL_SYMBOLDEFTREEPRINTERPASS
341struct SymbolDefTreePrinterPassOptions {
343 bool saveDotGraph =
false;
345#undef GEN_PASS_DECL_SYMBOLDEFTREEPRINTERPASS
347#ifdef GEN_PASS_DEF_SYMBOLDEFTREEPRINTERPASS
350template <
typename DerivedT>
351class SymbolDefTreePrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
353 using Base = SymbolDefTreePrinterPassBase;
355 SymbolDefTreePrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
356 SymbolDefTreePrinterPassBase(
const SymbolDefTreePrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
357 SymbolDefTreePrinterPassBase& operator=(
const SymbolDefTreePrinterPassBase &) =
delete;
358 SymbolDefTreePrinterPassBase(SymbolDefTreePrinterPassBase &&) =
delete;
359 SymbolDefTreePrinterPassBase& operator=(SymbolDefTreePrinterPassBase &&) =
delete;
360 ~SymbolDefTreePrinterPassBase() =
default;
363 static constexpr ::llvm::StringLiteral getArgumentName() {
364 return ::llvm::StringLiteral(
"llzk-print-symbol-def-tree");
366 ::llvm::StringRef getArgument()
const override {
return "llzk-print-symbol-def-tree"; }
368 ::llvm::StringRef getDescription()
const override {
return "Print symbol definition tree."; }
371 static constexpr ::llvm::StringLiteral getPassName() {
372 return ::llvm::StringLiteral(
"SymbolDefTreePrinterPass");
374 ::llvm::StringRef getName()
const override {
return "SymbolDefTreePrinterPass"; }
377 static bool classof(const ::mlir::Pass *pass) {
378 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
382 std::unique_ptr<::mlir::Pass> clonePass()
const override {
383 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
387 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
388 registry.insert<llzk::LLZKDialect>();
389 registry.insert<llzk::boolean::BoolDialect>();
390 registry.insert<llzk::array::ArrayDialect>();
391 registry.insert<llzk::component::StructDialect>();
392 registry.insert<llzk::constrain::ConstrainDialect>();
393 registry.insert<llzk::felt::FeltDialect>();
394 registry.insert<llzk::global::GlobalDialect>();
395 registry.insert<llzk::include::IncludeDialect>();
396 registry.insert<llzk::function::FunctionDialect>();
397 registry.insert<llzk::string::StringDialect>();
398 registry.insert<llzk::polymorphic::PolymorphicDialect>();
399 registry.insert<llzk::undef::UndefDialect>();
400 registry.insert<mlir::arith::ArithDialect>();
401 registry.insert<mlir::scf::SCFDialect>();
407 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SymbolDefTreePrinterPassBase<DerivedT>)
409 SymbolDefTreePrinterPassBase(SymbolDefTreePrinterPassOptions options) : SymbolDefTreePrinterPassBase() {
410 outputStream = std::move(options.outputStream);
411 saveDotGraph = std::move(options.saveDotGraph);
414 ::mlir::Pass::Option<::llzk::OutputStream> outputStream{*
this,
"stream", ::llvm::cl::desc(
"Specifies the stream to which the pass prints."), ::llvm::cl::init(
::llzk::OutputStream::Errs), ::llvm::cl::values(
416 "Print pass output to 'llvm::outs()'"),
418 "Print pass output to 'llvm::errs()'"),
420 "Print pass output to 'llvm::dbgs()'")
422 ::mlir::Pass::Option<bool> saveDotGraph{*
this,
"saveDot", ::llvm::cl::desc(
"Whether to dump the graph to DOT format."), ::llvm::cl::init(
false)};
426#undef GEN_PASS_DEF_SYMBOLDEFTREEPRINTERPASS
432#ifdef GEN_PASS_DECL_SYMBOLUSEGRAPHPRINTERPASS
433struct SymbolUseGraphPrinterPassOptions {
435 bool saveDotGraph =
false;
437#undef GEN_PASS_DECL_SYMBOLUSEGRAPHPRINTERPASS
439#ifdef GEN_PASS_DEF_SYMBOLUSEGRAPHPRINTERPASS
442template <
typename DerivedT>
443class SymbolUseGraphPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
445 using Base = SymbolUseGraphPrinterPassBase;
447 SymbolUseGraphPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
448 SymbolUseGraphPrinterPassBase(
const SymbolUseGraphPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
449 SymbolUseGraphPrinterPassBase& operator=(
const SymbolUseGraphPrinterPassBase &) =
delete;
450 SymbolUseGraphPrinterPassBase(SymbolUseGraphPrinterPassBase &&) =
delete;
451 SymbolUseGraphPrinterPassBase& operator=(SymbolUseGraphPrinterPassBase &&) =
delete;
452 ~SymbolUseGraphPrinterPassBase() =
default;
455 static constexpr ::llvm::StringLiteral getArgumentName() {
456 return ::llvm::StringLiteral(
"llzk-print-symbol-use-graph");
458 ::llvm::StringRef getArgument()
const override {
return "llzk-print-symbol-use-graph"; }
460 ::llvm::StringRef getDescription()
const override {
return "Print symbol use graph."; }
463 static constexpr ::llvm::StringLiteral getPassName() {
464 return ::llvm::StringLiteral(
"SymbolUseGraphPrinterPass");
466 ::llvm::StringRef getName()
const override {
return "SymbolUseGraphPrinterPass"; }
469 static bool classof(const ::mlir::Pass *pass) {
470 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
474 std::unique_ptr<::mlir::Pass> clonePass()
const override {
475 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
479 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
480 registry.insert<llzk::LLZKDialect>();
481 registry.insert<llzk::boolean::BoolDialect>();
482 registry.insert<llzk::array::ArrayDialect>();
483 registry.insert<llzk::component::StructDialect>();
484 registry.insert<llzk::constrain::ConstrainDialect>();
485 registry.insert<llzk::felt::FeltDialect>();
486 registry.insert<llzk::global::GlobalDialect>();
487 registry.insert<llzk::include::IncludeDialect>();
488 registry.insert<llzk::function::FunctionDialect>();
489 registry.insert<llzk::string::StringDialect>();
490 registry.insert<llzk::polymorphic::PolymorphicDialect>();
491 registry.insert<llzk::undef::UndefDialect>();
492 registry.insert<mlir::arith::ArithDialect>();
493 registry.insert<mlir::scf::SCFDialect>();
499 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SymbolUseGraphPrinterPassBase<DerivedT>)
501 SymbolUseGraphPrinterPassBase(SymbolUseGraphPrinterPassOptions options) : SymbolUseGraphPrinterPassBase() {
502 outputStream = std::move(options.outputStream);
503 saveDotGraph = std::move(options.saveDotGraph);
506 ::mlir::Pass::Option<::llzk::OutputStream> outputStream{*
this,
"stream", ::llvm::cl::desc(
"Specifies the stream to which the pass prints."), ::llvm::cl::init(
::llzk::OutputStream::Errs), ::llvm::cl::values(
508 "Print pass output to 'llvm::outs()'"),
510 "Print pass output to 'llvm::errs()'"),
512 "Print pass output to 'llvm::dbgs()'")
514 ::mlir::Pass::Option<bool> saveDotGraph{*
this,
"saveDot", ::llvm::cl::desc(
"Whether to dump the graph to DOT format."), ::llvm::cl::init(
false)};
518#undef GEN_PASS_DEF_SYMBOLUSEGRAPHPRINTERPASS
520#ifdef GEN_PASS_REGISTRATION
527 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
534 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
544 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
551 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
561 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
568 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
578 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
585 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
595 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
602 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
612 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
619 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
636#undef GEN_PASS_REGISTRATION
639#ifdef GEN_PASS_CLASSES
641template <
typename DerivedT>
642class CallGraphPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
644 using Base = CallGraphPrinterPassBase;
646 CallGraphPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
647 CallGraphPrinterPassBase(
const CallGraphPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
648 CallGraphPrinterPassBase& operator=(
const CallGraphPrinterPassBase &) =
delete;
649 CallGraphPrinterPassBase(CallGraphPrinterPassBase &&) =
delete;
650 CallGraphPrinterPassBase& operator=(CallGraphPrinterPassBase &&) =
delete;
651 ~CallGraphPrinterPassBase() =
default;
654 static constexpr ::llvm::StringLiteral getArgumentName() {
655 return ::llvm::StringLiteral(
"llzk-print-call-graph");
657 ::llvm::StringRef getArgument()
const override {
return "llzk-print-call-graph"; }
659 ::llvm::StringRef getDescription()
const override {
return "Print the LLZK module's call graph."; }
662 static constexpr ::llvm::StringLiteral getPassName() {
663 return ::llvm::StringLiteral(
"CallGraphPrinterPass");
665 ::llvm::StringRef getName()
const override {
return "CallGraphPrinterPass"; }
668 static bool classof(const ::mlir::Pass *pass) {
669 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
673 std::unique_ptr<::mlir::Pass> clonePass()
const override {
674 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
678 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
679 registry.insert<llzk::LLZKDialect>();
680 registry.insert<llzk::boolean::BoolDialect>();
681 registry.insert<llzk::array::ArrayDialect>();
682 registry.insert<llzk::component::StructDialect>();
683 registry.insert<llzk::constrain::ConstrainDialect>();
684 registry.insert<llzk::felt::FeltDialect>();
685 registry.insert<llzk::global::GlobalDialect>();
686 registry.insert<llzk::include::IncludeDialect>();
687 registry.insert<llzk::function::FunctionDialect>();
688 registry.insert<llzk::string::StringDialect>();
689 registry.insert<llzk::polymorphic::PolymorphicDialect>();
690 registry.insert<llzk::undef::UndefDialect>();
691 registry.insert<mlir::arith::ArithDialect>();
692 registry.insert<mlir::scf::SCFDialect>();
698 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CallGraphPrinterPassBase<DerivedT>)
703template <
typename DerivedT>
704class CallGraphSCCsPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
706 using Base = CallGraphSCCsPrinterPassBase;
708 CallGraphSCCsPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
709 CallGraphSCCsPrinterPassBase(
const CallGraphSCCsPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
710 CallGraphSCCsPrinterPassBase& operator=(
const CallGraphSCCsPrinterPassBase &) =
delete;
711 CallGraphSCCsPrinterPassBase(CallGraphSCCsPrinterPassBase &&) =
delete;
712 CallGraphSCCsPrinterPassBase& operator=(CallGraphSCCsPrinterPassBase &&) =
delete;
713 ~CallGraphSCCsPrinterPassBase() =
default;
716 static constexpr ::llvm::StringLiteral getArgumentName() {
717 return ::llvm::StringLiteral(
"llzk-print-call-graph-sccs");
719 ::llvm::StringRef getArgument()
const override {
return "llzk-print-call-graph-sccs"; }
721 ::llvm::StringRef getDescription()
const override {
return "Print the SCCs from the LLZK module's call graph."; }
724 static constexpr ::llvm::StringLiteral getPassName() {
725 return ::llvm::StringLiteral(
"CallGraphSCCsPrinterPass");
727 ::llvm::StringRef getName()
const override {
return "CallGraphSCCsPrinterPass"; }
730 static bool classof(const ::mlir::Pass *pass) {
731 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
735 std::unique_ptr<::mlir::Pass> clonePass()
const override {
736 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
740 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
741 registry.insert<llzk::LLZKDialect>();
742 registry.insert<llzk::boolean::BoolDialect>();
743 registry.insert<llzk::array::ArrayDialect>();
744 registry.insert<llzk::component::StructDialect>();
745 registry.insert<llzk::constrain::ConstrainDialect>();
746 registry.insert<llzk::felt::FeltDialect>();
747 registry.insert<llzk::global::GlobalDialect>();
748 registry.insert<llzk::include::IncludeDialect>();
749 registry.insert<llzk::function::FunctionDialect>();
750 registry.insert<llzk::string::StringDialect>();
751 registry.insert<llzk::polymorphic::PolymorphicDialect>();
752 registry.insert<llzk::undef::UndefDialect>();
753 registry.insert<mlir::arith::ArithDialect>();
754 registry.insert<mlir::scf::SCFDialect>();
760 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CallGraphSCCsPrinterPassBase<DerivedT>)
765template <
typename DerivedT>
766class ConstraintDependencyGraphPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
768 using Base = ConstraintDependencyGraphPrinterPassBase;
770 ConstraintDependencyGraphPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
771 ConstraintDependencyGraphPrinterPassBase(
const ConstraintDependencyGraphPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
772 ConstraintDependencyGraphPrinterPassBase& operator=(
const ConstraintDependencyGraphPrinterPassBase &) =
delete;
773 ConstraintDependencyGraphPrinterPassBase(ConstraintDependencyGraphPrinterPassBase &&) =
delete;
774 ConstraintDependencyGraphPrinterPassBase& operator=(ConstraintDependencyGraphPrinterPassBase &&) =
delete;
775 ~ConstraintDependencyGraphPrinterPassBase() =
default;
778 static constexpr ::llvm::StringLiteral getArgumentName() {
779 return ::llvm::StringLiteral(
"llzk-print-constraint-dependency-graphs");
781 ::llvm::StringRef getArgument()
const override {
return "llzk-print-constraint-dependency-graphs"; }
783 ::llvm::StringRef getDescription()
const override {
return "Print constraint dependency graph for all LLZK structs."; }
786 static constexpr ::llvm::StringLiteral getPassName() {
787 return ::llvm::StringLiteral(
"ConstraintDependencyGraphPrinterPass");
789 ::llvm::StringRef getName()
const override {
return "ConstraintDependencyGraphPrinterPass"; }
792 static bool classof(const ::mlir::Pass *pass) {
793 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
797 std::unique_ptr<::mlir::Pass> clonePass()
const override {
798 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
802 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
803 registry.insert<llzk::LLZKDialect>();
804 registry.insert<llzk::boolean::BoolDialect>();
805 registry.insert<llzk::array::ArrayDialect>();
806 registry.insert<llzk::component::StructDialect>();
807 registry.insert<llzk::constrain::ConstrainDialect>();
808 registry.insert<llzk::felt::FeltDialect>();
809 registry.insert<llzk::global::GlobalDialect>();
810 registry.insert<llzk::include::IncludeDialect>();
811 registry.insert<llzk::function::FunctionDialect>();
812 registry.insert<llzk::string::StringDialect>();
813 registry.insert<llzk::polymorphic::PolymorphicDialect>();
814 registry.insert<llzk::undef::UndefDialect>();
815 registry.insert<mlir::arith::ArithDialect>();
816 registry.insert<mlir::scf::SCFDialect>();
822 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ConstraintDependencyGraphPrinterPassBase<DerivedT>)
825 ::mlir::Pass::Option<bool> runIntraprocedural{*
this,
"intraprocedural", ::llvm::cl::desc(
"Whether to run the analysis intra-procedurally only (default is false)."), ::llvm::cl::init(
false)};
828template <
typename DerivedT>
829class IntervalAnalysisPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
831 using Base = IntervalAnalysisPrinterPassBase;
833 IntervalAnalysisPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
834 IntervalAnalysisPrinterPassBase(
const IntervalAnalysisPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
835 IntervalAnalysisPrinterPassBase& operator=(
const IntervalAnalysisPrinterPassBase &) =
delete;
836 IntervalAnalysisPrinterPassBase(IntervalAnalysisPrinterPassBase &&) =
delete;
837 IntervalAnalysisPrinterPassBase& operator=(IntervalAnalysisPrinterPassBase &&) =
delete;
838 ~IntervalAnalysisPrinterPassBase() =
default;
841 static constexpr ::llvm::StringLiteral getArgumentName() {
842 return ::llvm::StringLiteral(
"llzk-print-interval-analysis");
844 ::llvm::StringRef getArgument()
const override {
return "llzk-print-interval-analysis"; }
846 ::llvm::StringRef getDescription()
const override {
return "Print interval analysis results for all LLZK structs."; }
849 static constexpr ::llvm::StringLiteral getPassName() {
850 return ::llvm::StringLiteral(
"IntervalAnalysisPrinterPass");
852 ::llvm::StringRef getName()
const override {
return "IntervalAnalysisPrinterPass"; }
855 static bool classof(const ::mlir::Pass *pass) {
856 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
860 std::unique_ptr<::mlir::Pass> clonePass()
const override {
861 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
865 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
866 registry.insert<llzk::LLZKDialect>();
867 registry.insert<llzk::boolean::BoolDialect>();
868 registry.insert<llzk::array::ArrayDialect>();
869 registry.insert<llzk::component::StructDialect>();
870 registry.insert<llzk::constrain::ConstrainDialect>();
871 registry.insert<llzk::felt::FeltDialect>();
872 registry.insert<llzk::global::GlobalDialect>();
873 registry.insert<llzk::include::IncludeDialect>();
874 registry.insert<llzk::function::FunctionDialect>();
875 registry.insert<llzk::string::StringDialect>();
876 registry.insert<llzk::polymorphic::PolymorphicDialect>();
877 registry.insert<llzk::undef::UndefDialect>();
878 registry.insert<mlir::arith::ArithDialect>();
879 registry.insert<mlir::scf::SCFDialect>();
885 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(IntervalAnalysisPrinterPassBase<DerivedT>)
888 ::mlir::Pass::Option<std::string> fieldName{*
this,
"field", ::llvm::cl::desc(
"The field to use for interval analysis. Supported fields: bn128/bn254, babybear, goldilocks, mersenne31"), ::llvm::cl::init(
"bn128")};
889 ::mlir::Pass::Option<bool> propagateInputConstraints{*
this,
"propagate-input-constraints", ::llvm::cl::desc(
"Whether to propagate constraints on inputs from @constrain to @compute functions. This allows for tighter intervals to possibly be found for computed values, assuming that the witness generator would include constraints as assertions during the computation."), ::llvm::cl::init(
false)};
890 ::mlir::Pass::Option<bool> printSolverConstraints{*
this,
"print-solver-constraints", ::llvm::cl::desc(
"Whether to output SMT solver constraints along with intervals."), ::llvm::cl::init(
false)};
891 ::mlir::Pass::Option<bool> printComputeIntervals{*
this,
"print-compute-intervals", ::llvm::cl::desc(
"Whether to print compute function intervals (default only prints constrain function intervals)."), ::llvm::cl::init(
false)};
894template <
typename DerivedT>
895class SymbolDefTreePrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
897 using Base = SymbolDefTreePrinterPassBase;
899 SymbolDefTreePrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
900 SymbolDefTreePrinterPassBase(
const SymbolDefTreePrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
901 SymbolDefTreePrinterPassBase& operator=(
const SymbolDefTreePrinterPassBase &) =
delete;
902 SymbolDefTreePrinterPassBase(SymbolDefTreePrinterPassBase &&) =
delete;
903 SymbolDefTreePrinterPassBase& operator=(SymbolDefTreePrinterPassBase &&) =
delete;
904 ~SymbolDefTreePrinterPassBase() =
default;
907 static constexpr ::llvm::StringLiteral getArgumentName() {
908 return ::llvm::StringLiteral(
"llzk-print-symbol-def-tree");
910 ::llvm::StringRef getArgument()
const override {
return "llzk-print-symbol-def-tree"; }
912 ::llvm::StringRef getDescription()
const override {
return "Print symbol definition tree."; }
915 static constexpr ::llvm::StringLiteral getPassName() {
916 return ::llvm::StringLiteral(
"SymbolDefTreePrinterPass");
918 ::llvm::StringRef getName()
const override {
return "SymbolDefTreePrinterPass"; }
921 static bool classof(const ::mlir::Pass *pass) {
922 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
926 std::unique_ptr<::mlir::Pass> clonePass()
const override {
927 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
931 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
932 registry.insert<llzk::LLZKDialect>();
933 registry.insert<llzk::boolean::BoolDialect>();
934 registry.insert<llzk::array::ArrayDialect>();
935 registry.insert<llzk::component::StructDialect>();
936 registry.insert<llzk::constrain::ConstrainDialect>();
937 registry.insert<llzk::felt::FeltDialect>();
938 registry.insert<llzk::global::GlobalDialect>();
939 registry.insert<llzk::include::IncludeDialect>();
940 registry.insert<llzk::function::FunctionDialect>();
941 registry.insert<llzk::string::StringDialect>();
942 registry.insert<llzk::polymorphic::PolymorphicDialect>();
943 registry.insert<llzk::undef::UndefDialect>();
944 registry.insert<mlir::arith::ArithDialect>();
945 registry.insert<mlir::scf::SCFDialect>();
951 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SymbolDefTreePrinterPassBase<DerivedT>)
954 ::mlir::Pass::Option<::llzk::OutputStream> outputStream{*
this,
"stream", ::llvm::cl::desc(
"Specifies the stream to which the pass prints."), ::llvm::cl::init(
::llzk::OutputStream::Errs), ::llvm::cl::values(
956 "Print pass output to 'llvm::outs()'"),
958 "Print pass output to 'llvm::errs()'"),
960 "Print pass output to 'llvm::dbgs()'")
962 ::mlir::Pass::Option<bool> saveDotGraph{*
this,
"saveDot", ::llvm::cl::desc(
"Whether to dump the graph to DOT format."), ::llvm::cl::init(
false)};
965template <
typename DerivedT>
966class SymbolUseGraphPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
968 using Base = SymbolUseGraphPrinterPassBase;
970 SymbolUseGraphPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
971 SymbolUseGraphPrinterPassBase(
const SymbolUseGraphPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
972 SymbolUseGraphPrinterPassBase& operator=(
const SymbolUseGraphPrinterPassBase &) =
delete;
973 SymbolUseGraphPrinterPassBase(SymbolUseGraphPrinterPassBase &&) =
delete;
974 SymbolUseGraphPrinterPassBase& operator=(SymbolUseGraphPrinterPassBase &&) =
delete;
975 ~SymbolUseGraphPrinterPassBase() =
default;
978 static constexpr ::llvm::StringLiteral getArgumentName() {
979 return ::llvm::StringLiteral(
"llzk-print-symbol-use-graph");
981 ::llvm::StringRef getArgument()
const override {
return "llzk-print-symbol-use-graph"; }
983 ::llvm::StringRef getDescription()
const override {
return "Print symbol use graph."; }
986 static constexpr ::llvm::StringLiteral getPassName() {
987 return ::llvm::StringLiteral(
"SymbolUseGraphPrinterPass");
989 ::llvm::StringRef getName()
const override {
return "SymbolUseGraphPrinterPass"; }
992 static bool classof(const ::mlir::Pass *pass) {
993 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
997 std::unique_ptr<::mlir::Pass> clonePass()
const override {
998 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
1002 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
1003 registry.insert<llzk::LLZKDialect>();
1004 registry.insert<llzk::boolean::BoolDialect>();
1005 registry.insert<llzk::array::ArrayDialect>();
1006 registry.insert<llzk::component::StructDialect>();
1007 registry.insert<llzk::constrain::ConstrainDialect>();
1008 registry.insert<llzk::felt::FeltDialect>();
1009 registry.insert<llzk::global::GlobalDialect>();
1010 registry.insert<llzk::include::IncludeDialect>();
1011 registry.insert<llzk::function::FunctionDialect>();
1012 registry.insert<llzk::string::StringDialect>();
1013 registry.insert<llzk::polymorphic::PolymorphicDialect>();
1014 registry.insert<llzk::undef::UndefDialect>();
1015 registry.insert<mlir::arith::ArithDialect>();
1016 registry.insert<mlir::scf::SCFDialect>();
1022 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SymbolUseGraphPrinterPassBase<DerivedT>)
1025 ::mlir::Pass::Option<::llzk::OutputStream> outputStream{*
this,
"stream", ::llvm::cl::desc(
"Specifies the stream to which the pass prints."), ::llvm::cl::init(
::llzk::OutputStream::Errs), ::llvm::cl::values(
1027 "Print pass output to 'llvm::outs()'"),
1029 "Print pass output to 'llvm::errs()'"),
1031 "Print pass output to 'llvm::dbgs()'")
1033 ::mlir::Pass::Option<bool> saveDotGraph{*
this,
"saveDot", ::llvm::cl::desc(
"Whether to dump the graph to DOT format."), ::llvm::cl::init(
false)};
1035#undef GEN_PASS_CLASSES
void registerIntervalAnalysisPrinterPassPass()
void registerSymbolDefTreePrinterPassPass()
void registerIntervalAnalysisPrinterPass()
std::unique_ptr< mlir::Pass > createSymbolUseGraphPrinterPass()
void registerSymbolUseGraphPrinterPassPass()
std::unique_ptr< mlir::Pass > createConstraintDependencyGraphPrinterPass(llvm::raw_ostream &os=llvm::errs())
std::unique_ptr< mlir::Pass > createIntervalAnalysisPrinterPass(llvm::raw_ostream &os=llvm::errs())
void registerCallGraphPrinterPass()
void registerConstraintDependencyGraphPrinterPass()
void registerSymbolUseGraphPrinterPass()
std::unique_ptr< mlir::Pass > createSymbolDefTreePrinterPass()
std::unique_ptr< mlir::Pass > createCallGraphSCCsPrinterPass(llvm::raw_ostream &os=llvm::errs())
std::unique_ptr< mlir::Pass > createCallGraphPrinterPass(llvm::raw_ostream &os=llvm::errs())
void registerCallGraphPrinterPassPass()
::llvm::StringRef stringifyOutputStream(OutputStream val)
void registerCallGraphSCCsPrinterPass()
void registerConstraintDependencyGraphPrinterPassPass()
void registerCallGraphSCCsPrinterPassPass()
void registerAnalysisPasses()
void registerSymbolDefTreePrinterPass()