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<mlir::arith::ArithDialect>();
73 registry.insert<mlir::scf::SCFDialect>();
79 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CallGraphPrinterPassBase<DerivedT>)
85#undef GEN_PASS_DEF_CALLGRAPHPRINTERPASS
91#ifdef GEN_PASS_DECL_CALLGRAPHSCCSPRINTERPASS
92#undef GEN_PASS_DECL_CALLGRAPHSCCSPRINTERPASS
94#ifdef GEN_PASS_DEF_CALLGRAPHSCCSPRINTERPASS
97template <
typename DerivedT>
98class CallGraphSCCsPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
100 using Base = CallGraphSCCsPrinterPassBase;
102 CallGraphSCCsPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
103 CallGraphSCCsPrinterPassBase(
const CallGraphSCCsPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
104 CallGraphSCCsPrinterPassBase& operator=(
const CallGraphSCCsPrinterPassBase &) =
delete;
105 CallGraphSCCsPrinterPassBase(CallGraphSCCsPrinterPassBase &&) =
delete;
106 CallGraphSCCsPrinterPassBase& operator=(CallGraphSCCsPrinterPassBase &&) =
delete;
107 ~CallGraphSCCsPrinterPassBase() =
default;
110 static constexpr ::llvm::StringLiteral getArgumentName() {
111 return ::llvm::StringLiteral(
"llzk-print-call-graph-sccs");
113 ::llvm::StringRef getArgument()
const override {
return "llzk-print-call-graph-sccs"; }
115 ::llvm::StringRef getDescription()
const override {
return "Print the SCCs from the LLZK module's call graph."; }
118 static constexpr ::llvm::StringLiteral getPassName() {
119 return ::llvm::StringLiteral(
"CallGraphSCCsPrinterPass");
121 ::llvm::StringRef getName()
const override {
return "CallGraphSCCsPrinterPass"; }
124 static bool classof(const ::mlir::Pass *pass) {
125 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
129 std::unique_ptr<::mlir::Pass> clonePass()
const override {
130 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
134 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
135 registry.insert<llzk::LLZKDialect>();
136 registry.insert<llzk::boolean::BoolDialect>();
137 registry.insert<llzk::array::ArrayDialect>();
138 registry.insert<llzk::component::StructDialect>();
139 registry.insert<llzk::constrain::ConstrainDialect>();
140 registry.insert<llzk::felt::FeltDialect>();
141 registry.insert<llzk::global::GlobalDialect>();
142 registry.insert<llzk::include::IncludeDialect>();
143 registry.insert<llzk::function::FunctionDialect>();
144 registry.insert<llzk::string::StringDialect>();
145 registry.insert<llzk::polymorphic::PolymorphicDialect>();
146 registry.insert<mlir::arith::ArithDialect>();
147 registry.insert<mlir::scf::SCFDialect>();
153 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CallGraphSCCsPrinterPassBase<DerivedT>)
159#undef GEN_PASS_DEF_CALLGRAPHSCCSPRINTERPASS
165#ifdef GEN_PASS_DECL_CONSTRAINTDEPENDENCYGRAPHPRINTERPASS
166struct ConstraintDependencyGraphPrinterPassOptions {
167 bool runIntraprocedural =
false;
169#undef GEN_PASS_DECL_CONSTRAINTDEPENDENCYGRAPHPRINTERPASS
171#ifdef GEN_PASS_DEF_CONSTRAINTDEPENDENCYGRAPHPRINTERPASS
174template <
typename DerivedT>
175class ConstraintDependencyGraphPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
177 using Base = ConstraintDependencyGraphPrinterPassBase;
179 ConstraintDependencyGraphPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
180 ConstraintDependencyGraphPrinterPassBase(
const ConstraintDependencyGraphPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
181 ConstraintDependencyGraphPrinterPassBase& operator=(
const ConstraintDependencyGraphPrinterPassBase &) =
delete;
182 ConstraintDependencyGraphPrinterPassBase(ConstraintDependencyGraphPrinterPassBase &&) =
delete;
183 ConstraintDependencyGraphPrinterPassBase& operator=(ConstraintDependencyGraphPrinterPassBase &&) =
delete;
184 ~ConstraintDependencyGraphPrinterPassBase() =
default;
187 static constexpr ::llvm::StringLiteral getArgumentName() {
188 return ::llvm::StringLiteral(
"llzk-print-constraint-dependency-graphs");
190 ::llvm::StringRef getArgument()
const override {
return "llzk-print-constraint-dependency-graphs"; }
192 ::llvm::StringRef getDescription()
const override {
return "Print constraint dependency graph for all LLZK structs."; }
195 static constexpr ::llvm::StringLiteral getPassName() {
196 return ::llvm::StringLiteral(
"ConstraintDependencyGraphPrinterPass");
198 ::llvm::StringRef getName()
const override {
return "ConstraintDependencyGraphPrinterPass"; }
201 static bool classof(const ::mlir::Pass *pass) {
202 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
206 std::unique_ptr<::mlir::Pass> clonePass()
const override {
207 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
211 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
212 registry.insert<llzk::LLZKDialect>();
213 registry.insert<llzk::boolean::BoolDialect>();
214 registry.insert<llzk::array::ArrayDialect>();
215 registry.insert<llzk::component::StructDialect>();
216 registry.insert<llzk::constrain::ConstrainDialect>();
217 registry.insert<llzk::felt::FeltDialect>();
218 registry.insert<llzk::global::GlobalDialect>();
219 registry.insert<llzk::include::IncludeDialect>();
220 registry.insert<llzk::function::FunctionDialect>();
221 registry.insert<llzk::string::StringDialect>();
222 registry.insert<llzk::polymorphic::PolymorphicDialect>();
223 registry.insert<mlir::arith::ArithDialect>();
224 registry.insert<mlir::scf::SCFDialect>();
230 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ConstraintDependencyGraphPrinterPassBase<DerivedT>)
232 ConstraintDependencyGraphPrinterPassBase(ConstraintDependencyGraphPrinterPassOptions options) : ConstraintDependencyGraphPrinterPassBase() {
233 runIntraprocedural = std::move(options.runIntraprocedural);
236 ::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)};
240#undef GEN_PASS_DEF_CONSTRAINTDEPENDENCYGRAPHPRINTERPASS
246#ifdef GEN_PASS_DECL_INTERVALANALYSISPRINTERPASS
247struct IntervalAnalysisPrinterPassOptions {
248 std::string fieldName =
"bn128";
249 bool propagateInputConstraints =
false;
250 bool printSolverConstraints =
false;
251 bool printComputeIntervals =
false;
253#undef GEN_PASS_DECL_INTERVALANALYSISPRINTERPASS
255#ifdef GEN_PASS_DEF_INTERVALANALYSISPRINTERPASS
258template <
typename DerivedT>
259class IntervalAnalysisPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
261 using Base = IntervalAnalysisPrinterPassBase;
263 IntervalAnalysisPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
264 IntervalAnalysisPrinterPassBase(
const IntervalAnalysisPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
265 IntervalAnalysisPrinterPassBase& operator=(
const IntervalAnalysisPrinterPassBase &) =
delete;
266 IntervalAnalysisPrinterPassBase(IntervalAnalysisPrinterPassBase &&) =
delete;
267 IntervalAnalysisPrinterPassBase& operator=(IntervalAnalysisPrinterPassBase &&) =
delete;
268 ~IntervalAnalysisPrinterPassBase() =
default;
271 static constexpr ::llvm::StringLiteral getArgumentName() {
272 return ::llvm::StringLiteral(
"llzk-print-interval-analysis");
274 ::llvm::StringRef getArgument()
const override {
return "llzk-print-interval-analysis"; }
276 ::llvm::StringRef getDescription()
const override {
return "Print interval analysis results for all LLZK structs."; }
279 static constexpr ::llvm::StringLiteral getPassName() {
280 return ::llvm::StringLiteral(
"IntervalAnalysisPrinterPass");
282 ::llvm::StringRef getName()
const override {
return "IntervalAnalysisPrinterPass"; }
285 static bool classof(const ::mlir::Pass *pass) {
286 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
290 std::unique_ptr<::mlir::Pass> clonePass()
const override {
291 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
295 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
296 registry.insert<llzk::LLZKDialect>();
297 registry.insert<llzk::boolean::BoolDialect>();
298 registry.insert<llzk::array::ArrayDialect>();
299 registry.insert<llzk::component::StructDialect>();
300 registry.insert<llzk::constrain::ConstrainDialect>();
301 registry.insert<llzk::felt::FeltDialect>();
302 registry.insert<llzk::global::GlobalDialect>();
303 registry.insert<llzk::include::IncludeDialect>();
304 registry.insert<llzk::function::FunctionDialect>();
305 registry.insert<llzk::string::StringDialect>();
306 registry.insert<llzk::polymorphic::PolymorphicDialect>();
307 registry.insert<mlir::arith::ArithDialect>();
308 registry.insert<mlir::scf::SCFDialect>();
314 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(IntervalAnalysisPrinterPassBase<DerivedT>)
316 IntervalAnalysisPrinterPassBase(IntervalAnalysisPrinterPassOptions options) : IntervalAnalysisPrinterPassBase() {
317 fieldName = std::move(options.fieldName);
318 propagateInputConstraints = std::move(options.propagateInputConstraints);
319 printSolverConstraints = std::move(options.printSolverConstraints);
320 printComputeIntervals = std::move(options.printComputeIntervals);
323 ::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")};
324 ::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)};
325 ::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)};
326 ::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)};
330#undef GEN_PASS_DEF_INTERVALANALYSISPRINTERPASS
336#ifdef GEN_PASS_DECL_SYMBOLDEFTREEPRINTERPASS
337struct SymbolDefTreePrinterPassOptions {
339 bool saveDotGraph =
false;
341#undef GEN_PASS_DECL_SYMBOLDEFTREEPRINTERPASS
343#ifdef GEN_PASS_DEF_SYMBOLDEFTREEPRINTERPASS
346template <
typename DerivedT>
347class SymbolDefTreePrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
349 using Base = SymbolDefTreePrinterPassBase;
351 SymbolDefTreePrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
352 SymbolDefTreePrinterPassBase(
const SymbolDefTreePrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
353 SymbolDefTreePrinterPassBase& operator=(
const SymbolDefTreePrinterPassBase &) =
delete;
354 SymbolDefTreePrinterPassBase(SymbolDefTreePrinterPassBase &&) =
delete;
355 SymbolDefTreePrinterPassBase& operator=(SymbolDefTreePrinterPassBase &&) =
delete;
356 ~SymbolDefTreePrinterPassBase() =
default;
359 static constexpr ::llvm::StringLiteral getArgumentName() {
360 return ::llvm::StringLiteral(
"llzk-print-symbol-def-tree");
362 ::llvm::StringRef getArgument()
const override {
return "llzk-print-symbol-def-tree"; }
364 ::llvm::StringRef getDescription()
const override {
return "Print symbol definition tree."; }
367 static constexpr ::llvm::StringLiteral getPassName() {
368 return ::llvm::StringLiteral(
"SymbolDefTreePrinterPass");
370 ::llvm::StringRef getName()
const override {
return "SymbolDefTreePrinterPass"; }
373 static bool classof(const ::mlir::Pass *pass) {
374 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
378 std::unique_ptr<::mlir::Pass> clonePass()
const override {
379 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
383 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
384 registry.insert<llzk::LLZKDialect>();
385 registry.insert<llzk::boolean::BoolDialect>();
386 registry.insert<llzk::array::ArrayDialect>();
387 registry.insert<llzk::component::StructDialect>();
388 registry.insert<llzk::constrain::ConstrainDialect>();
389 registry.insert<llzk::felt::FeltDialect>();
390 registry.insert<llzk::global::GlobalDialect>();
391 registry.insert<llzk::include::IncludeDialect>();
392 registry.insert<llzk::function::FunctionDialect>();
393 registry.insert<llzk::string::StringDialect>();
394 registry.insert<llzk::polymorphic::PolymorphicDialect>();
395 registry.insert<mlir::arith::ArithDialect>();
396 registry.insert<mlir::scf::SCFDialect>();
402 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SymbolDefTreePrinterPassBase<DerivedT>)
404 SymbolDefTreePrinterPassBase(SymbolDefTreePrinterPassOptions options) : SymbolDefTreePrinterPassBase() {
405 outputStream = std::move(options.outputStream);
406 saveDotGraph = std::move(options.saveDotGraph);
409 ::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(
411 "Print pass output to 'llvm::outs()'"),
413 "Print pass output to 'llvm::errs()'"),
415 "Print pass output to 'llvm::dbgs()'")
417 ::mlir::Pass::Option<bool> saveDotGraph{*
this,
"saveDot", ::llvm::cl::desc(
"Whether to dump the graph to DOT format."), ::llvm::cl::init(
false)};
421#undef GEN_PASS_DEF_SYMBOLDEFTREEPRINTERPASS
427#ifdef GEN_PASS_DECL_SYMBOLUSEGRAPHPRINTERPASS
428struct SymbolUseGraphPrinterPassOptions {
430 bool saveDotGraph =
false;
432#undef GEN_PASS_DECL_SYMBOLUSEGRAPHPRINTERPASS
434#ifdef GEN_PASS_DEF_SYMBOLUSEGRAPHPRINTERPASS
437template <
typename DerivedT>
438class SymbolUseGraphPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
440 using Base = SymbolUseGraphPrinterPassBase;
442 SymbolUseGraphPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
443 SymbolUseGraphPrinterPassBase(
const SymbolUseGraphPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
444 SymbolUseGraphPrinterPassBase& operator=(
const SymbolUseGraphPrinterPassBase &) =
delete;
445 SymbolUseGraphPrinterPassBase(SymbolUseGraphPrinterPassBase &&) =
delete;
446 SymbolUseGraphPrinterPassBase& operator=(SymbolUseGraphPrinterPassBase &&) =
delete;
447 ~SymbolUseGraphPrinterPassBase() =
default;
450 static constexpr ::llvm::StringLiteral getArgumentName() {
451 return ::llvm::StringLiteral(
"llzk-print-symbol-use-graph");
453 ::llvm::StringRef getArgument()
const override {
return "llzk-print-symbol-use-graph"; }
455 ::llvm::StringRef getDescription()
const override {
return "Print symbol use graph."; }
458 static constexpr ::llvm::StringLiteral getPassName() {
459 return ::llvm::StringLiteral(
"SymbolUseGraphPrinterPass");
461 ::llvm::StringRef getName()
const override {
return "SymbolUseGraphPrinterPass"; }
464 static bool classof(const ::mlir::Pass *pass) {
465 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
469 std::unique_ptr<::mlir::Pass> clonePass()
const override {
470 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
474 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
475 registry.insert<llzk::LLZKDialect>();
476 registry.insert<llzk::boolean::BoolDialect>();
477 registry.insert<llzk::array::ArrayDialect>();
478 registry.insert<llzk::component::StructDialect>();
479 registry.insert<llzk::constrain::ConstrainDialect>();
480 registry.insert<llzk::felt::FeltDialect>();
481 registry.insert<llzk::global::GlobalDialect>();
482 registry.insert<llzk::include::IncludeDialect>();
483 registry.insert<llzk::function::FunctionDialect>();
484 registry.insert<llzk::string::StringDialect>();
485 registry.insert<llzk::polymorphic::PolymorphicDialect>();
486 registry.insert<mlir::arith::ArithDialect>();
487 registry.insert<mlir::scf::SCFDialect>();
493 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SymbolUseGraphPrinterPassBase<DerivedT>)
495 SymbolUseGraphPrinterPassBase(SymbolUseGraphPrinterPassOptions options) : SymbolUseGraphPrinterPassBase() {
496 outputStream = std::move(options.outputStream);
497 saveDotGraph = std::move(options.saveDotGraph);
500 ::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(
502 "Print pass output to 'llvm::outs()'"),
504 "Print pass output to 'llvm::errs()'"),
506 "Print pass output to 'llvm::dbgs()'")
508 ::mlir::Pass::Option<bool> saveDotGraph{*
this,
"saveDot", ::llvm::cl::desc(
"Whether to dump the graph to DOT format."), ::llvm::cl::init(
false)};
512#undef GEN_PASS_DEF_SYMBOLUSEGRAPHPRINTERPASS
514#ifdef GEN_PASS_REGISTRATION
521 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
528 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
538 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
545 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
555 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
562 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
572 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
579 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
589 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
596 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
606 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
613 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
630#undef GEN_PASS_REGISTRATION
633#ifdef GEN_PASS_CLASSES
635template <
typename DerivedT>
636class CallGraphPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
638 using Base = CallGraphPrinterPassBase;
640 CallGraphPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
641 CallGraphPrinterPassBase(
const CallGraphPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
642 CallGraphPrinterPassBase& operator=(
const CallGraphPrinterPassBase &) =
delete;
643 CallGraphPrinterPassBase(CallGraphPrinterPassBase &&) =
delete;
644 CallGraphPrinterPassBase& operator=(CallGraphPrinterPassBase &&) =
delete;
645 ~CallGraphPrinterPassBase() =
default;
648 static constexpr ::llvm::StringLiteral getArgumentName() {
649 return ::llvm::StringLiteral(
"llzk-print-call-graph");
651 ::llvm::StringRef getArgument()
const override {
return "llzk-print-call-graph"; }
653 ::llvm::StringRef getDescription()
const override {
return "Print the LLZK module's call graph."; }
656 static constexpr ::llvm::StringLiteral getPassName() {
657 return ::llvm::StringLiteral(
"CallGraphPrinterPass");
659 ::llvm::StringRef getName()
const override {
return "CallGraphPrinterPass"; }
662 static bool classof(const ::mlir::Pass *pass) {
663 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
667 std::unique_ptr<::mlir::Pass> clonePass()
const override {
668 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
672 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
673 registry.insert<llzk::LLZKDialect>();
674 registry.insert<llzk::boolean::BoolDialect>();
675 registry.insert<llzk::array::ArrayDialect>();
676 registry.insert<llzk::component::StructDialect>();
677 registry.insert<llzk::constrain::ConstrainDialect>();
678 registry.insert<llzk::felt::FeltDialect>();
679 registry.insert<llzk::global::GlobalDialect>();
680 registry.insert<llzk::include::IncludeDialect>();
681 registry.insert<llzk::function::FunctionDialect>();
682 registry.insert<llzk::string::StringDialect>();
683 registry.insert<llzk::polymorphic::PolymorphicDialect>();
684 registry.insert<mlir::arith::ArithDialect>();
685 registry.insert<mlir::scf::SCFDialect>();
691 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CallGraphPrinterPassBase<DerivedT>)
696template <
typename DerivedT>
697class CallGraphSCCsPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
699 using Base = CallGraphSCCsPrinterPassBase;
701 CallGraphSCCsPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
702 CallGraphSCCsPrinterPassBase(
const CallGraphSCCsPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
703 CallGraphSCCsPrinterPassBase& operator=(
const CallGraphSCCsPrinterPassBase &) =
delete;
704 CallGraphSCCsPrinterPassBase(CallGraphSCCsPrinterPassBase &&) =
delete;
705 CallGraphSCCsPrinterPassBase& operator=(CallGraphSCCsPrinterPassBase &&) =
delete;
706 ~CallGraphSCCsPrinterPassBase() =
default;
709 static constexpr ::llvm::StringLiteral getArgumentName() {
710 return ::llvm::StringLiteral(
"llzk-print-call-graph-sccs");
712 ::llvm::StringRef getArgument()
const override {
return "llzk-print-call-graph-sccs"; }
714 ::llvm::StringRef getDescription()
const override {
return "Print the SCCs from the LLZK module's call graph."; }
717 static constexpr ::llvm::StringLiteral getPassName() {
718 return ::llvm::StringLiteral(
"CallGraphSCCsPrinterPass");
720 ::llvm::StringRef getName()
const override {
return "CallGraphSCCsPrinterPass"; }
723 static bool classof(const ::mlir::Pass *pass) {
724 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
728 std::unique_ptr<::mlir::Pass> clonePass()
const override {
729 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
733 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
734 registry.insert<llzk::LLZKDialect>();
735 registry.insert<llzk::boolean::BoolDialect>();
736 registry.insert<llzk::array::ArrayDialect>();
737 registry.insert<llzk::component::StructDialect>();
738 registry.insert<llzk::constrain::ConstrainDialect>();
739 registry.insert<llzk::felt::FeltDialect>();
740 registry.insert<llzk::global::GlobalDialect>();
741 registry.insert<llzk::include::IncludeDialect>();
742 registry.insert<llzk::function::FunctionDialect>();
743 registry.insert<llzk::string::StringDialect>();
744 registry.insert<llzk::polymorphic::PolymorphicDialect>();
745 registry.insert<mlir::arith::ArithDialect>();
746 registry.insert<mlir::scf::SCFDialect>();
752 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CallGraphSCCsPrinterPassBase<DerivedT>)
757template <
typename DerivedT>
758class ConstraintDependencyGraphPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
760 using Base = ConstraintDependencyGraphPrinterPassBase;
762 ConstraintDependencyGraphPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
763 ConstraintDependencyGraphPrinterPassBase(
const ConstraintDependencyGraphPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
764 ConstraintDependencyGraphPrinterPassBase& operator=(
const ConstraintDependencyGraphPrinterPassBase &) =
delete;
765 ConstraintDependencyGraphPrinterPassBase(ConstraintDependencyGraphPrinterPassBase &&) =
delete;
766 ConstraintDependencyGraphPrinterPassBase& operator=(ConstraintDependencyGraphPrinterPassBase &&) =
delete;
767 ~ConstraintDependencyGraphPrinterPassBase() =
default;
770 static constexpr ::llvm::StringLiteral getArgumentName() {
771 return ::llvm::StringLiteral(
"llzk-print-constraint-dependency-graphs");
773 ::llvm::StringRef getArgument()
const override {
return "llzk-print-constraint-dependency-graphs"; }
775 ::llvm::StringRef getDescription()
const override {
return "Print constraint dependency graph for all LLZK structs."; }
778 static constexpr ::llvm::StringLiteral getPassName() {
779 return ::llvm::StringLiteral(
"ConstraintDependencyGraphPrinterPass");
781 ::llvm::StringRef getName()
const override {
return "ConstraintDependencyGraphPrinterPass"; }
784 static bool classof(const ::mlir::Pass *pass) {
785 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
789 std::unique_ptr<::mlir::Pass> clonePass()
const override {
790 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
794 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
795 registry.insert<llzk::LLZKDialect>();
796 registry.insert<llzk::boolean::BoolDialect>();
797 registry.insert<llzk::array::ArrayDialect>();
798 registry.insert<llzk::component::StructDialect>();
799 registry.insert<llzk::constrain::ConstrainDialect>();
800 registry.insert<llzk::felt::FeltDialect>();
801 registry.insert<llzk::global::GlobalDialect>();
802 registry.insert<llzk::include::IncludeDialect>();
803 registry.insert<llzk::function::FunctionDialect>();
804 registry.insert<llzk::string::StringDialect>();
805 registry.insert<llzk::polymorphic::PolymorphicDialect>();
806 registry.insert<mlir::arith::ArithDialect>();
807 registry.insert<mlir::scf::SCFDialect>();
813 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ConstraintDependencyGraphPrinterPassBase<DerivedT>)
816 ::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)};
819template <
typename DerivedT>
820class IntervalAnalysisPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
822 using Base = IntervalAnalysisPrinterPassBase;
824 IntervalAnalysisPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
825 IntervalAnalysisPrinterPassBase(
const IntervalAnalysisPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
826 IntervalAnalysisPrinterPassBase& operator=(
const IntervalAnalysisPrinterPassBase &) =
delete;
827 IntervalAnalysisPrinterPassBase(IntervalAnalysisPrinterPassBase &&) =
delete;
828 IntervalAnalysisPrinterPassBase& operator=(IntervalAnalysisPrinterPassBase &&) =
delete;
829 ~IntervalAnalysisPrinterPassBase() =
default;
832 static constexpr ::llvm::StringLiteral getArgumentName() {
833 return ::llvm::StringLiteral(
"llzk-print-interval-analysis");
835 ::llvm::StringRef getArgument()
const override {
return "llzk-print-interval-analysis"; }
837 ::llvm::StringRef getDescription()
const override {
return "Print interval analysis results for all LLZK structs."; }
840 static constexpr ::llvm::StringLiteral getPassName() {
841 return ::llvm::StringLiteral(
"IntervalAnalysisPrinterPass");
843 ::llvm::StringRef getName()
const override {
return "IntervalAnalysisPrinterPass"; }
846 static bool classof(const ::mlir::Pass *pass) {
847 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
851 std::unique_ptr<::mlir::Pass> clonePass()
const override {
852 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
856 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
857 registry.insert<llzk::LLZKDialect>();
858 registry.insert<llzk::boolean::BoolDialect>();
859 registry.insert<llzk::array::ArrayDialect>();
860 registry.insert<llzk::component::StructDialect>();
861 registry.insert<llzk::constrain::ConstrainDialect>();
862 registry.insert<llzk::felt::FeltDialect>();
863 registry.insert<llzk::global::GlobalDialect>();
864 registry.insert<llzk::include::IncludeDialect>();
865 registry.insert<llzk::function::FunctionDialect>();
866 registry.insert<llzk::string::StringDialect>();
867 registry.insert<llzk::polymorphic::PolymorphicDialect>();
868 registry.insert<mlir::arith::ArithDialect>();
869 registry.insert<mlir::scf::SCFDialect>();
875 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(IntervalAnalysisPrinterPassBase<DerivedT>)
878 ::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")};
879 ::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)};
880 ::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)};
881 ::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)};
884template <
typename DerivedT>
885class SymbolDefTreePrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
887 using Base = SymbolDefTreePrinterPassBase;
889 SymbolDefTreePrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
890 SymbolDefTreePrinterPassBase(
const SymbolDefTreePrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
891 SymbolDefTreePrinterPassBase& operator=(
const SymbolDefTreePrinterPassBase &) =
delete;
892 SymbolDefTreePrinterPassBase(SymbolDefTreePrinterPassBase &&) =
delete;
893 SymbolDefTreePrinterPassBase& operator=(SymbolDefTreePrinterPassBase &&) =
delete;
894 ~SymbolDefTreePrinterPassBase() =
default;
897 static constexpr ::llvm::StringLiteral getArgumentName() {
898 return ::llvm::StringLiteral(
"llzk-print-symbol-def-tree");
900 ::llvm::StringRef getArgument()
const override {
return "llzk-print-symbol-def-tree"; }
902 ::llvm::StringRef getDescription()
const override {
return "Print symbol definition tree."; }
905 static constexpr ::llvm::StringLiteral getPassName() {
906 return ::llvm::StringLiteral(
"SymbolDefTreePrinterPass");
908 ::llvm::StringRef getName()
const override {
return "SymbolDefTreePrinterPass"; }
911 static bool classof(const ::mlir::Pass *pass) {
912 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
916 std::unique_ptr<::mlir::Pass> clonePass()
const override {
917 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
921 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
922 registry.insert<llzk::LLZKDialect>();
923 registry.insert<llzk::boolean::BoolDialect>();
924 registry.insert<llzk::array::ArrayDialect>();
925 registry.insert<llzk::component::StructDialect>();
926 registry.insert<llzk::constrain::ConstrainDialect>();
927 registry.insert<llzk::felt::FeltDialect>();
928 registry.insert<llzk::global::GlobalDialect>();
929 registry.insert<llzk::include::IncludeDialect>();
930 registry.insert<llzk::function::FunctionDialect>();
931 registry.insert<llzk::string::StringDialect>();
932 registry.insert<llzk::polymorphic::PolymorphicDialect>();
933 registry.insert<mlir::arith::ArithDialect>();
934 registry.insert<mlir::scf::SCFDialect>();
940 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SymbolDefTreePrinterPassBase<DerivedT>)
943 ::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(
945 "Print pass output to 'llvm::outs()'"),
947 "Print pass output to 'llvm::errs()'"),
949 "Print pass output to 'llvm::dbgs()'")
951 ::mlir::Pass::Option<bool> saveDotGraph{*
this,
"saveDot", ::llvm::cl::desc(
"Whether to dump the graph to DOT format."), ::llvm::cl::init(
false)};
954template <
typename DerivedT>
955class SymbolUseGraphPrinterPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
957 using Base = SymbolUseGraphPrinterPassBase;
959 SymbolUseGraphPrinterPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
960 SymbolUseGraphPrinterPassBase(
const SymbolUseGraphPrinterPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
961 SymbolUseGraphPrinterPassBase& operator=(
const SymbolUseGraphPrinterPassBase &) =
delete;
962 SymbolUseGraphPrinterPassBase(SymbolUseGraphPrinterPassBase &&) =
delete;
963 SymbolUseGraphPrinterPassBase& operator=(SymbolUseGraphPrinterPassBase &&) =
delete;
964 ~SymbolUseGraphPrinterPassBase() =
default;
967 static constexpr ::llvm::StringLiteral getArgumentName() {
968 return ::llvm::StringLiteral(
"llzk-print-symbol-use-graph");
970 ::llvm::StringRef getArgument()
const override {
return "llzk-print-symbol-use-graph"; }
972 ::llvm::StringRef getDescription()
const override {
return "Print symbol use graph."; }
975 static constexpr ::llvm::StringLiteral getPassName() {
976 return ::llvm::StringLiteral(
"SymbolUseGraphPrinterPass");
978 ::llvm::StringRef getName()
const override {
return "SymbolUseGraphPrinterPass"; }
981 static bool classof(const ::mlir::Pass *pass) {
982 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
986 std::unique_ptr<::mlir::Pass> clonePass()
const override {
987 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
991 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
992 registry.insert<llzk::LLZKDialect>();
993 registry.insert<llzk::boolean::BoolDialect>();
994 registry.insert<llzk::array::ArrayDialect>();
995 registry.insert<llzk::component::StructDialect>();
996 registry.insert<llzk::constrain::ConstrainDialect>();
997 registry.insert<llzk::felt::FeltDialect>();
998 registry.insert<llzk::global::GlobalDialect>();
999 registry.insert<llzk::include::IncludeDialect>();
1000 registry.insert<llzk::function::FunctionDialect>();
1001 registry.insert<llzk::string::StringDialect>();
1002 registry.insert<llzk::polymorphic::PolymorphicDialect>();
1003 registry.insert<mlir::arith::ArithDialect>();
1004 registry.insert<mlir::scf::SCFDialect>();
1010 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SymbolUseGraphPrinterPassBase<DerivedT>)
1013 ::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(
1015 "Print pass output to 'llvm::outs()'"),
1017 "Print pass output to 'llvm::errs()'"),
1019 "Print pass output to 'llvm::dbgs()'")
1021 ::mlir::Pass::Option<bool> saveDotGraph{*
this,
"saveDot", ::llvm::cl::desc(
"Whether to dump the graph to DOT format."), ::llvm::cl::init(
false)};
1023#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()