LLZK 2.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
LLZKTransformationPasses.h.inc
Go to the documentation of this file.
1/* Autogenerated by mlir-tblgen; don't manually edit */
2
3#ifdef GEN_PASS_DECL
4// Generate declarations for all passes.
5#define GEN_PASS_DECL_COMPUTECONSTRAINTOPRODUCTPASS
6#define GEN_PASS_DECL_ENFORCENOMEMBEROVERWRITEPASS
7#define GEN_PASS_DECL_FUSEPRODUCTLOOPSPASS
8#define GEN_PASS_DECL_INLINESTRUCTSPASS
9#define GEN_PASS_DECL_POLYLOWERINGPASS
10#define GEN_PASS_DECL_REDUNDANTOPERATIONELIMINATIONPASS
11#define GEN_PASS_DECL_REDUNDANTREADANDWRITEELIMINATIONPASS
12#define GEN_PASS_DECL_UNUSEDDECLARATIONELIMINATIONPASS
13#undef GEN_PASS_DECL
14#endif // GEN_PASS_DECL
15
16//===----------------------------------------------------------------------===//
17// ComputeConstrainToProductPass
18//===----------------------------------------------------------------------===//
19#ifdef GEN_PASS_DECL_COMPUTECONSTRAINTOPRODUCTPASS
20struct ComputeConstrainToProductPassOptions {
21 std::string rootStruct = "@Main";
22};
23#undef GEN_PASS_DECL_COMPUTECONSTRAINTOPRODUCTPASS
24#endif // GEN_PASS_DECL_COMPUTECONSTRAINTOPRODUCTPASS
25#ifdef GEN_PASS_DEF_COMPUTECONSTRAINTOPRODUCTPASS
26namespace impl {
27
28template <typename DerivedT>
29class ComputeConstrainToProductPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
30public:
31 using Base = ComputeConstrainToProductPassBase;
32
33 ComputeConstrainToProductPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
34 ComputeConstrainToProductPassBase(const ComputeConstrainToProductPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
35 ComputeConstrainToProductPassBase& operator=(const ComputeConstrainToProductPassBase &) = delete;
36 ComputeConstrainToProductPassBase(ComputeConstrainToProductPassBase &&) = delete;
37 ComputeConstrainToProductPassBase& operator=(ComputeConstrainToProductPassBase &&) = delete;
38 ~ComputeConstrainToProductPassBase() = default;
39
41 static constexpr ::llvm::StringLiteral getArgumentName() {
42 return ::llvm::StringLiteral("llzk-compute-constrain-to-product");
43 }
44 ::llvm::StringRef getArgument() const override { return "llzk-compute-constrain-to-product"; }
45
46 ::llvm::StringRef getDescription() const override { return "Replace separate @compute and @constrain functions in a struct with a single @product function"; }
47
49 static constexpr ::llvm::StringLiteral getPassName() {
50 return ::llvm::StringLiteral("ComputeConstrainToProductPass");
51 }
52 ::llvm::StringRef getName() const override { return "ComputeConstrainToProductPass"; }
53
55 static bool classof(const ::mlir::Pass *pass) {
56 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
57 }
58
60 std::unique_ptr<::mlir::Pass> clonePass() const override {
61 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
62 }
63
65 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
66 registry.insert<llzk::LLZKDialect>();
67 registry.insert<llzk::boolean::BoolDialect>();
68 registry.insert<llzk::array::ArrayDialect>();
69 registry.insert<llzk::component::StructDialect>();
70 registry.insert<llzk::constrain::ConstrainDialect>();
71 registry.insert<llzk::felt::FeltDialect>();
72 registry.insert<llzk::global::GlobalDialect>();
73 registry.insert<llzk::include::IncludeDialect>();
74 registry.insert<llzk::function::FunctionDialect>();
75 registry.insert<llzk::string::StringDialect>();
76 registry.insert<llzk::polymorphic::PolymorphicDialect>();
77 registry.insert<mlir::arith::ArithDialect>();
78 registry.insert<mlir::scf::SCFDialect>();
79 }
80
84 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ComputeConstrainToProductPassBase<DerivedT>)
85
86 ComputeConstrainToProductPassBase(ComputeConstrainToProductPassOptions options) : ComputeConstrainToProductPassBase() {
87 rootStruct = std::move(options.rootStruct);
88 }
89protected:
90 ::mlir::Pass::Option<std::string> rootStruct{*this, "root-struct", ::llvm::cl::desc("Root struct at which to start alignment (default to `@Main`)"), ::llvm::cl::init("@Main")};
91private:
92};
93} // namespace impl
94#undef GEN_PASS_DEF_COMPUTECONSTRAINTOPRODUCTPASS
95#endif // GEN_PASS_DEF_COMPUTECONSTRAINTOPRODUCTPASS
96
97//===----------------------------------------------------------------------===//
98// EnforceNoMemberOverwritePass
99//===----------------------------------------------------------------------===//
100#ifdef GEN_PASS_DECL_ENFORCENOMEMBEROVERWRITEPASS
101#undef GEN_PASS_DECL_ENFORCENOMEMBEROVERWRITEPASS
102#endif // GEN_PASS_DECL_ENFORCENOMEMBEROVERWRITEPASS
103#ifdef GEN_PASS_DEF_ENFORCENOMEMBEROVERWRITEPASS
104namespace impl {
105
106template <typename DerivedT>
107class EnforceNoMemberOverwritePassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
108public:
109 using Base = EnforceNoMemberOverwritePassBase;
110
111 EnforceNoMemberOverwritePassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
112 EnforceNoMemberOverwritePassBase(const EnforceNoMemberOverwritePassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
113 EnforceNoMemberOverwritePassBase& operator=(const EnforceNoMemberOverwritePassBase &) = delete;
114 EnforceNoMemberOverwritePassBase(EnforceNoMemberOverwritePassBase &&) = delete;
115 EnforceNoMemberOverwritePassBase& operator=(EnforceNoMemberOverwritePassBase &&) = delete;
116 ~EnforceNoMemberOverwritePassBase() = default;
117
119 static constexpr ::llvm::StringLiteral getArgumentName() {
120 return ::llvm::StringLiteral("llzk-enforce-no-overwrite");
121 }
122 ::llvm::StringRef getArgument() const override { return "llzk-enforce-no-overwrite"; }
123
124 ::llvm::StringRef getDescription() const override { return "Checks that every struct member is written exactly once"; }
125
127 static constexpr ::llvm::StringLiteral getPassName() {
128 return ::llvm::StringLiteral("EnforceNoMemberOverwritePass");
129 }
130 ::llvm::StringRef getName() const override { return "EnforceNoMemberOverwritePass"; }
131
133 static bool classof(const ::mlir::Pass *pass) {
134 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
135 }
136
138 std::unique_ptr<::mlir::Pass> clonePass() const override {
139 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
140 }
141
143 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
144 registry.insert<llzk::LLZKDialect>();
145 registry.insert<llzk::boolean::BoolDialect>();
146 registry.insert<llzk::array::ArrayDialect>();
147 registry.insert<llzk::component::StructDialect>();
148 registry.insert<llzk::constrain::ConstrainDialect>();
149 registry.insert<llzk::felt::FeltDialect>();
150 registry.insert<llzk::global::GlobalDialect>();
151 registry.insert<llzk::include::IncludeDialect>();
152 registry.insert<llzk::function::FunctionDialect>();
153 registry.insert<llzk::string::StringDialect>();
154 registry.insert<llzk::polymorphic::PolymorphicDialect>();
155 registry.insert<mlir::arith::ArithDialect>();
156 registry.insert<mlir::scf::SCFDialect>();
157 }
158
162 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(EnforceNoMemberOverwritePassBase<DerivedT>)
163
164protected:
165private:
166};
167} // namespace impl
168#undef GEN_PASS_DEF_ENFORCENOMEMBEROVERWRITEPASS
169#endif // GEN_PASS_DEF_ENFORCENOMEMBEROVERWRITEPASS
170
171//===----------------------------------------------------------------------===//
172// FuseProductLoopsPass
173//===----------------------------------------------------------------------===//
174#ifdef GEN_PASS_DECL_FUSEPRODUCTLOOPSPASS
175#undef GEN_PASS_DECL_FUSEPRODUCTLOOPSPASS
176#endif // GEN_PASS_DECL_FUSEPRODUCTLOOPSPASS
177#ifdef GEN_PASS_DEF_FUSEPRODUCTLOOPSPASS
178namespace impl {
179
180template <typename DerivedT>
181class FuseProductLoopsPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
182public:
183 using Base = FuseProductLoopsPassBase;
184
185 FuseProductLoopsPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
186 FuseProductLoopsPassBase(const FuseProductLoopsPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
187 FuseProductLoopsPassBase& operator=(const FuseProductLoopsPassBase &) = delete;
188 FuseProductLoopsPassBase(FuseProductLoopsPassBase &&) = delete;
189 FuseProductLoopsPassBase& operator=(FuseProductLoopsPassBase &&) = delete;
190 ~FuseProductLoopsPassBase() = default;
191
193 static constexpr ::llvm::StringLiteral getArgumentName() {
194 return ::llvm::StringLiteral("llzk-fuse-product-loops");
195 }
196 ::llvm::StringRef getArgument() const override { return "llzk-fuse-product-loops"; }
197
198 ::llvm::StringRef getDescription() const override { return "Fuse matching witness/constraint loops in a @product function"; }
199
201 static constexpr ::llvm::StringLiteral getPassName() {
202 return ::llvm::StringLiteral("FuseProductLoopsPass");
203 }
204 ::llvm::StringRef getName() const override { return "FuseProductLoopsPass"; }
205
207 static bool classof(const ::mlir::Pass *pass) {
208 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
209 }
210
212 std::unique_ptr<::mlir::Pass> clonePass() const override {
213 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
214 }
215
217 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
218 registry.insert<llzk::LLZKDialect>();
219 registry.insert<llzk::boolean::BoolDialect>();
220 registry.insert<llzk::array::ArrayDialect>();
221 registry.insert<llzk::component::StructDialect>();
222 registry.insert<llzk::constrain::ConstrainDialect>();
223 registry.insert<llzk::felt::FeltDialect>();
224 registry.insert<llzk::global::GlobalDialect>();
225 registry.insert<llzk::include::IncludeDialect>();
226 registry.insert<llzk::function::FunctionDialect>();
227 registry.insert<llzk::string::StringDialect>();
228 registry.insert<llzk::polymorphic::PolymorphicDialect>();
229 registry.insert<mlir::arith::ArithDialect>();
230 registry.insert<mlir::scf::SCFDialect>();
231 }
232
236 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FuseProductLoopsPassBase<DerivedT>)
237
238protected:
239private:
240};
241} // namespace impl
242#undef GEN_PASS_DEF_FUSEPRODUCTLOOPSPASS
243#endif // GEN_PASS_DEF_FUSEPRODUCTLOOPSPASS
244
245//===----------------------------------------------------------------------===//
246// InlineStructsPass
247//===----------------------------------------------------------------------===//
248#ifdef GEN_PASS_DECL_INLINESTRUCTSPASS
249struct InlineStructsPassOptions {
250 uint64_t maxComplexity = 0;
251};
252#undef GEN_PASS_DECL_INLINESTRUCTSPASS
253#endif // GEN_PASS_DECL_INLINESTRUCTSPASS
254#ifdef GEN_PASS_DEF_INLINESTRUCTSPASS
255namespace impl {
256
257template <typename DerivedT>
258class InlineStructsPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
259public:
260 using Base = InlineStructsPassBase;
261
262 InlineStructsPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
263 InlineStructsPassBase(const InlineStructsPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
264 InlineStructsPassBase& operator=(const InlineStructsPassBase &) = delete;
265 InlineStructsPassBase(InlineStructsPassBase &&) = delete;
266 InlineStructsPassBase& operator=(InlineStructsPassBase &&) = delete;
267 ~InlineStructsPassBase() = default;
268
270 static constexpr ::llvm::StringLiteral getArgumentName() {
271 return ::llvm::StringLiteral("llzk-inline-structs");
272 }
273 ::llvm::StringRef getArgument() const override { return "llzk-inline-structs"; }
274
275 ::llvm::StringRef getDescription() const override { return "Inlines nested structs (i.e., subcomponents)."; }
276
278 static constexpr ::llvm::StringLiteral getPassName() {
279 return ::llvm::StringLiteral("InlineStructsPass");
280 }
281 ::llvm::StringRef getName() const override { return "InlineStructsPass"; }
282
284 static bool classof(const ::mlir::Pass *pass) {
285 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
286 }
287
289 std::unique_ptr<::mlir::Pass> clonePass() const override {
290 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
291 }
292
294 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
295 registry.insert<llzk::LLZKDialect>();
296 registry.insert<llzk::boolean::BoolDialect>();
297 registry.insert<llzk::array::ArrayDialect>();
298 registry.insert<llzk::component::StructDialect>();
299 registry.insert<llzk::constrain::ConstrainDialect>();
300 registry.insert<llzk::felt::FeltDialect>();
301 registry.insert<llzk::global::GlobalDialect>();
302 registry.insert<llzk::include::IncludeDialect>();
303 registry.insert<llzk::function::FunctionDialect>();
304 registry.insert<llzk::string::StringDialect>();
305 registry.insert<llzk::polymorphic::PolymorphicDialect>();
306 registry.insert<mlir::arith::ArithDialect>();
307 registry.insert<mlir::scf::SCFDialect>();
308 }
309
313 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(InlineStructsPassBase<DerivedT>)
314
315 InlineStructsPassBase(InlineStructsPassOptions options) : InlineStructsPassBase() {
316 maxComplexity = std::move(options.maxComplexity);
317 }
318protected:
319 ::mlir::Pass::Option<uint64_t> maxComplexity{*this, "max-merge-complexity", ::llvm::cl::desc("Maximum allowed constraint+multiplications in merged @constrain functions"), ::llvm::cl::init(0)};
320private:
321};
322} // namespace impl
323#undef GEN_PASS_DEF_INLINESTRUCTSPASS
324#endif // GEN_PASS_DEF_INLINESTRUCTSPASS
325
326//===----------------------------------------------------------------------===//
327// PolyLoweringPass
328//===----------------------------------------------------------------------===//
329#ifdef GEN_PASS_DECL_POLYLOWERINGPASS
330struct PolyLoweringPassOptions {
331 unsigned maxDegree = 2;
332};
333#undef GEN_PASS_DECL_POLYLOWERINGPASS
334#endif // GEN_PASS_DECL_POLYLOWERINGPASS
335#ifdef GEN_PASS_DEF_POLYLOWERINGPASS
336namespace impl {
337
338template <typename DerivedT>
339class PolyLoweringPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
340public:
341 using Base = PolyLoweringPassBase;
342
343 PolyLoweringPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
344 PolyLoweringPassBase(const PolyLoweringPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
345 PolyLoweringPassBase& operator=(const PolyLoweringPassBase &) = delete;
346 PolyLoweringPassBase(PolyLoweringPassBase &&) = delete;
347 PolyLoweringPassBase& operator=(PolyLoweringPassBase &&) = delete;
348 ~PolyLoweringPassBase() = default;
349
351 static constexpr ::llvm::StringLiteral getArgumentName() {
352 return ::llvm::StringLiteral("llzk-poly-lowering-pass");
353 }
354 ::llvm::StringRef getArgument() const override { return "llzk-poly-lowering-pass"; }
355
356 ::llvm::StringRef getDescription() const override { return "Lower the degree of all polynomial equations to a specified maximum"; }
357
359 static constexpr ::llvm::StringLiteral getPassName() {
360 return ::llvm::StringLiteral("PolyLoweringPass");
361 }
362 ::llvm::StringRef getName() const override { return "PolyLoweringPass"; }
363
365 static bool classof(const ::mlir::Pass *pass) {
366 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
367 }
368
370 std::unique_ptr<::mlir::Pass> clonePass() const override {
371 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
372 }
373
375 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
376 registry.insert<llzk::LLZKDialect>();
377 registry.insert<llzk::boolean::BoolDialect>();
378 registry.insert<llzk::array::ArrayDialect>();
379 registry.insert<llzk::component::StructDialect>();
380 registry.insert<llzk::constrain::ConstrainDialect>();
381 registry.insert<llzk::felt::FeltDialect>();
382 registry.insert<llzk::global::GlobalDialect>();
383 registry.insert<llzk::include::IncludeDialect>();
384 registry.insert<llzk::function::FunctionDialect>();
385 registry.insert<llzk::string::StringDialect>();
386 registry.insert<llzk::polymorphic::PolymorphicDialect>();
387 registry.insert<mlir::arith::ArithDialect>();
388 registry.insert<mlir::scf::SCFDialect>();
389 }
390
394 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PolyLoweringPassBase<DerivedT>)
395
396 PolyLoweringPassBase(PolyLoweringPassOptions options) : PolyLoweringPassBase() {
397 maxDegree = std::move(options.maxDegree);
398 }
399protected:
400 ::mlir::Pass::Option<unsigned> maxDegree{*this, "max-degree", ::llvm::cl::desc("Maximum degree of constraint polynomials (default 2, minimum 2)"), ::llvm::cl::init(2)};
401private:
402};
403} // namespace impl
404#undef GEN_PASS_DEF_POLYLOWERINGPASS
405#endif // GEN_PASS_DEF_POLYLOWERINGPASS
406
407//===----------------------------------------------------------------------===//
408// RedundantOperationEliminationPass
409//===----------------------------------------------------------------------===//
410#ifdef GEN_PASS_DECL_REDUNDANTOPERATIONELIMINATIONPASS
411#undef GEN_PASS_DECL_REDUNDANTOPERATIONELIMINATIONPASS
412#endif // GEN_PASS_DECL_REDUNDANTOPERATIONELIMINATIONPASS
413#ifdef GEN_PASS_DEF_REDUNDANTOPERATIONELIMINATIONPASS
414namespace impl {
415
416template <typename DerivedT>
417class RedundantOperationEliminationPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
418public:
419 using Base = RedundantOperationEliminationPassBase;
420
421 RedundantOperationEliminationPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
422 RedundantOperationEliminationPassBase(const RedundantOperationEliminationPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
423 RedundantOperationEliminationPassBase& operator=(const RedundantOperationEliminationPassBase &) = delete;
424 RedundantOperationEliminationPassBase(RedundantOperationEliminationPassBase &&) = delete;
425 RedundantOperationEliminationPassBase& operator=(RedundantOperationEliminationPassBase &&) = delete;
426 ~RedundantOperationEliminationPassBase() = default;
427
429 static constexpr ::llvm::StringLiteral getArgumentName() {
430 return ::llvm::StringLiteral("llzk-duplicate-op-elim");
431 }
432 ::llvm::StringRef getArgument() const override { return "llzk-duplicate-op-elim"; }
433
434 ::llvm::StringRef getDescription() const override { return "Remove redundant operations"; }
435
437 static constexpr ::llvm::StringLiteral getPassName() {
438 return ::llvm::StringLiteral("RedundantOperationEliminationPass");
439 }
440 ::llvm::StringRef getName() const override { return "RedundantOperationEliminationPass"; }
441
443 static bool classof(const ::mlir::Pass *pass) {
444 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
445 }
446
448 std::unique_ptr<::mlir::Pass> clonePass() const override {
449 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
450 }
451
453 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
454 registry.insert<llzk::LLZKDialect>();
455 registry.insert<llzk::boolean::BoolDialect>();
456 registry.insert<llzk::array::ArrayDialect>();
457 registry.insert<llzk::component::StructDialect>();
458 registry.insert<llzk::constrain::ConstrainDialect>();
459 registry.insert<llzk::felt::FeltDialect>();
460 registry.insert<llzk::global::GlobalDialect>();
461 registry.insert<llzk::include::IncludeDialect>();
462 registry.insert<llzk::function::FunctionDialect>();
463 registry.insert<llzk::string::StringDialect>();
464 registry.insert<llzk::polymorphic::PolymorphicDialect>();
465 registry.insert<mlir::arith::ArithDialect>();
466 registry.insert<mlir::scf::SCFDialect>();
467 }
468
472 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RedundantOperationEliminationPassBase<DerivedT>)
473
474protected:
475private:
476};
477} // namespace impl
478#undef GEN_PASS_DEF_REDUNDANTOPERATIONELIMINATIONPASS
479#endif // GEN_PASS_DEF_REDUNDANTOPERATIONELIMINATIONPASS
480
481//===----------------------------------------------------------------------===//
482// RedundantReadAndWriteEliminationPass
483//===----------------------------------------------------------------------===//
484#ifdef GEN_PASS_DECL_REDUNDANTREADANDWRITEELIMINATIONPASS
485#undef GEN_PASS_DECL_REDUNDANTREADANDWRITEELIMINATIONPASS
486#endif // GEN_PASS_DECL_REDUNDANTREADANDWRITEELIMINATIONPASS
487#ifdef GEN_PASS_DEF_REDUNDANTREADANDWRITEELIMINATIONPASS
488namespace impl {
489
490template <typename DerivedT>
491class RedundantReadAndWriteEliminationPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
492public:
493 using Base = RedundantReadAndWriteEliminationPassBase;
494
495 RedundantReadAndWriteEliminationPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
496 RedundantReadAndWriteEliminationPassBase(const RedundantReadAndWriteEliminationPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
497 RedundantReadAndWriteEliminationPassBase& operator=(const RedundantReadAndWriteEliminationPassBase &) = delete;
498 RedundantReadAndWriteEliminationPassBase(RedundantReadAndWriteEliminationPassBase &&) = delete;
499 RedundantReadAndWriteEliminationPassBase& operator=(RedundantReadAndWriteEliminationPassBase &&) = delete;
500 ~RedundantReadAndWriteEliminationPassBase() = default;
501
503 static constexpr ::llvm::StringLiteral getArgumentName() {
504 return ::llvm::StringLiteral("llzk-duplicate-read-write-elim");
505 }
506 ::llvm::StringRef getArgument() const override { return "llzk-duplicate-read-write-elim"; }
507
508 ::llvm::StringRef getDescription() const override { return "Remove redundant reads and writes"; }
509
511 static constexpr ::llvm::StringLiteral getPassName() {
512 return ::llvm::StringLiteral("RedundantReadAndWriteEliminationPass");
513 }
514 ::llvm::StringRef getName() const override { return "RedundantReadAndWriteEliminationPass"; }
515
517 static bool classof(const ::mlir::Pass *pass) {
518 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
519 }
520
522 std::unique_ptr<::mlir::Pass> clonePass() const override {
523 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
524 }
525
527 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
528 registry.insert<llzk::LLZKDialect>();
529 registry.insert<llzk::boolean::BoolDialect>();
530 registry.insert<llzk::array::ArrayDialect>();
531 registry.insert<llzk::component::StructDialect>();
532 registry.insert<llzk::constrain::ConstrainDialect>();
533 registry.insert<llzk::felt::FeltDialect>();
534 registry.insert<llzk::global::GlobalDialect>();
535 registry.insert<llzk::include::IncludeDialect>();
536 registry.insert<llzk::function::FunctionDialect>();
537 registry.insert<llzk::string::StringDialect>();
538 registry.insert<llzk::polymorphic::PolymorphicDialect>();
539 registry.insert<mlir::arith::ArithDialect>();
540 registry.insert<mlir::scf::SCFDialect>();
541 }
542
546 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RedundantReadAndWriteEliminationPassBase<DerivedT>)
547
548protected:
549private:
550};
551} // namespace impl
552#undef GEN_PASS_DEF_REDUNDANTREADANDWRITEELIMINATIONPASS
553#endif // GEN_PASS_DEF_REDUNDANTREADANDWRITEELIMINATIONPASS
554
555//===----------------------------------------------------------------------===//
556// UnusedDeclarationEliminationPass
557//===----------------------------------------------------------------------===//
558#ifdef GEN_PASS_DECL_UNUSEDDECLARATIONELIMINATIONPASS
559struct UnusedDeclarationEliminationPassOptions {
560 bool removeStructs = false;
561};
562#undef GEN_PASS_DECL_UNUSEDDECLARATIONELIMINATIONPASS
563#endif // GEN_PASS_DECL_UNUSEDDECLARATIONELIMINATIONPASS
564#ifdef GEN_PASS_DEF_UNUSEDDECLARATIONELIMINATIONPASS
565namespace impl {
566
567template <typename DerivedT>
568class UnusedDeclarationEliminationPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
569public:
570 using Base = UnusedDeclarationEliminationPassBase;
571
572 UnusedDeclarationEliminationPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
573 UnusedDeclarationEliminationPassBase(const UnusedDeclarationEliminationPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
574 UnusedDeclarationEliminationPassBase& operator=(const UnusedDeclarationEliminationPassBase &) = delete;
575 UnusedDeclarationEliminationPassBase(UnusedDeclarationEliminationPassBase &&) = delete;
576 UnusedDeclarationEliminationPassBase& operator=(UnusedDeclarationEliminationPassBase &&) = delete;
577 ~UnusedDeclarationEliminationPassBase() = default;
578
580 static constexpr ::llvm::StringLiteral getArgumentName() {
581 return ::llvm::StringLiteral("llzk-unused-declaration-elim");
582 }
583 ::llvm::StringRef getArgument() const override { return "llzk-unused-declaration-elim"; }
584
585 ::llvm::StringRef getDescription() const override { return "Remove unused member and struct declarations"; }
586
588 static constexpr ::llvm::StringLiteral getPassName() {
589 return ::llvm::StringLiteral("UnusedDeclarationEliminationPass");
590 }
591 ::llvm::StringRef getName() const override { return "UnusedDeclarationEliminationPass"; }
592
594 static bool classof(const ::mlir::Pass *pass) {
595 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
596 }
597
599 std::unique_ptr<::mlir::Pass> clonePass() const override {
600 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
601 }
602
604 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
605 registry.insert<llzk::LLZKDialect>();
606 registry.insert<llzk::boolean::BoolDialect>();
607 registry.insert<llzk::array::ArrayDialect>();
608 registry.insert<llzk::component::StructDialect>();
609 registry.insert<llzk::constrain::ConstrainDialect>();
610 registry.insert<llzk::felt::FeltDialect>();
611 registry.insert<llzk::global::GlobalDialect>();
612 registry.insert<llzk::include::IncludeDialect>();
613 registry.insert<llzk::function::FunctionDialect>();
614 registry.insert<llzk::string::StringDialect>();
615 registry.insert<llzk::polymorphic::PolymorphicDialect>();
616 registry.insert<mlir::arith::ArithDialect>();
617 registry.insert<mlir::scf::SCFDialect>();
618 }
619
623 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(UnusedDeclarationEliminationPassBase<DerivedT>)
624
625 UnusedDeclarationEliminationPassBase(UnusedDeclarationEliminationPassOptions options) : UnusedDeclarationEliminationPassBase() {
626 removeStructs = std::move(options.removeStructs);
627 }
628protected:
629 ::mlir::Pass::Option<bool> removeStructs{*this, "remove-structs", ::llvm::cl::desc("Whether to remove unused struct definitions as well. Requires module to declare a Main component, otherwise all components will appear unused."), ::llvm::cl::init(false)};
630private:
631};
632} // namespace impl
633#undef GEN_PASS_DEF_UNUSEDDECLARATIONELIMINATIONPASS
634#endif // GEN_PASS_DEF_UNUSEDDECLARATIONELIMINATIONPASS
635#ifdef GEN_PASS_REGISTRATION
636
637//===----------------------------------------------------------------------===//
638// ComputeConstrainToProductPass Registration
639//===----------------------------------------------------------------------===//
640
642 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
644 });
645}
646
647// Old registration code, kept for temporary backwards compatibility.
649 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
651 });
652}
653
654//===----------------------------------------------------------------------===//
655// EnforceNoMemberOverwritePass Registration
656//===----------------------------------------------------------------------===//
657
659 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
661 });
662}
663
664// Old registration code, kept for temporary backwards compatibility.
666 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
668 });
669}
670
671//===----------------------------------------------------------------------===//
672// FuseProductLoopsPass Registration
673//===----------------------------------------------------------------------===//
674
675inline void registerFuseProductLoopsPass() {
676 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
678 });
679}
680
681// Old registration code, kept for temporary backwards compatibility.
683 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
685 });
686}
687
688//===----------------------------------------------------------------------===//
689// InlineStructsPass Registration
690//===----------------------------------------------------------------------===//
691
692inline void registerInlineStructsPass() {
693 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
695 });
696}
697
698// Old registration code, kept for temporary backwards compatibility.
699inline void registerInlineStructsPassPass() {
700 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
702 });
703}
704
705//===----------------------------------------------------------------------===//
706// PolyLoweringPass Registration
707//===----------------------------------------------------------------------===//
708
709inline void registerPolyLoweringPass() {
710 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
712 });
713}
714
715// Old registration code, kept for temporary backwards compatibility.
716inline void registerPolyLoweringPassPass() {
717 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
719 });
720}
721
722//===----------------------------------------------------------------------===//
723// RedundantOperationEliminationPass Registration
724//===----------------------------------------------------------------------===//
725
727 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
729 });
730}
731
732// Old registration code, kept for temporary backwards compatibility.
734 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
736 });
737}
738
739//===----------------------------------------------------------------------===//
740// RedundantReadAndWriteEliminationPass Registration
741//===----------------------------------------------------------------------===//
742
744 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
746 });
747}
748
749// Old registration code, kept for temporary backwards compatibility.
751 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
753 });
754}
755
756//===----------------------------------------------------------------------===//
757// UnusedDeclarationEliminationPass Registration
758//===----------------------------------------------------------------------===//
759
761 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
763 });
764}
765
766// Old registration code, kept for temporary backwards compatibility.
768 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
770 });
771}
772
773//===----------------------------------------------------------------------===//
774// Transformation Registration
775//===----------------------------------------------------------------------===//
776
777inline void registerTransformationPasses() {
786}
787#undef GEN_PASS_REGISTRATION
788#endif // GEN_PASS_REGISTRATION
789// Deprecated. Please use the new per-pass macros.
790#ifdef GEN_PASS_CLASSES
791
792template <typename DerivedT>
793class ComputeConstrainToProductPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
794public:
795 using Base = ComputeConstrainToProductPassBase;
796
797 ComputeConstrainToProductPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
798 ComputeConstrainToProductPassBase(const ComputeConstrainToProductPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
799 ComputeConstrainToProductPassBase& operator=(const ComputeConstrainToProductPassBase &) = delete;
800 ComputeConstrainToProductPassBase(ComputeConstrainToProductPassBase &&) = delete;
801 ComputeConstrainToProductPassBase& operator=(ComputeConstrainToProductPassBase &&) = delete;
802 ~ComputeConstrainToProductPassBase() = default;
803
805 static constexpr ::llvm::StringLiteral getArgumentName() {
806 return ::llvm::StringLiteral("llzk-compute-constrain-to-product");
807 }
808 ::llvm::StringRef getArgument() const override { return "llzk-compute-constrain-to-product"; }
809
810 ::llvm::StringRef getDescription() const override { return "Replace separate @compute and @constrain functions in a struct with a single @product function"; }
811
813 static constexpr ::llvm::StringLiteral getPassName() {
814 return ::llvm::StringLiteral("ComputeConstrainToProductPass");
815 }
816 ::llvm::StringRef getName() const override { return "ComputeConstrainToProductPass"; }
817
819 static bool classof(const ::mlir::Pass *pass) {
820 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
821 }
822
824 std::unique_ptr<::mlir::Pass> clonePass() const override {
825 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
826 }
827
829 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
830 registry.insert<llzk::LLZKDialect>();
831 registry.insert<llzk::boolean::BoolDialect>();
832 registry.insert<llzk::array::ArrayDialect>();
833 registry.insert<llzk::component::StructDialect>();
834 registry.insert<llzk::constrain::ConstrainDialect>();
835 registry.insert<llzk::felt::FeltDialect>();
836 registry.insert<llzk::global::GlobalDialect>();
837 registry.insert<llzk::include::IncludeDialect>();
838 registry.insert<llzk::function::FunctionDialect>();
839 registry.insert<llzk::string::StringDialect>();
840 registry.insert<llzk::polymorphic::PolymorphicDialect>();
841 registry.insert<mlir::arith::ArithDialect>();
842 registry.insert<mlir::scf::SCFDialect>();
843 }
844
848 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ComputeConstrainToProductPassBase<DerivedT>)
849
850protected:
851 ::mlir::Pass::Option<std::string> rootStruct{*this, "root-struct", ::llvm::cl::desc("Root struct at which to start alignment (default to `@Main`)"), ::llvm::cl::init("@Main")};
852};
853
854template <typename DerivedT>
855class EnforceNoMemberOverwritePassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
856public:
857 using Base = EnforceNoMemberOverwritePassBase;
858
859 EnforceNoMemberOverwritePassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
860 EnforceNoMemberOverwritePassBase(const EnforceNoMemberOverwritePassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
861 EnforceNoMemberOverwritePassBase& operator=(const EnforceNoMemberOverwritePassBase &) = delete;
862 EnforceNoMemberOverwritePassBase(EnforceNoMemberOverwritePassBase &&) = delete;
863 EnforceNoMemberOverwritePassBase& operator=(EnforceNoMemberOverwritePassBase &&) = delete;
864 ~EnforceNoMemberOverwritePassBase() = default;
865
867 static constexpr ::llvm::StringLiteral getArgumentName() {
868 return ::llvm::StringLiteral("llzk-enforce-no-overwrite");
869 }
870 ::llvm::StringRef getArgument() const override { return "llzk-enforce-no-overwrite"; }
871
872 ::llvm::StringRef getDescription() const override { return "Checks that every struct member is written exactly once"; }
873
875 static constexpr ::llvm::StringLiteral getPassName() {
876 return ::llvm::StringLiteral("EnforceNoMemberOverwritePass");
877 }
878 ::llvm::StringRef getName() const override { return "EnforceNoMemberOverwritePass"; }
879
881 static bool classof(const ::mlir::Pass *pass) {
882 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
883 }
884
886 std::unique_ptr<::mlir::Pass> clonePass() const override {
887 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
888 }
889
891 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
892 registry.insert<llzk::LLZKDialect>();
893 registry.insert<llzk::boolean::BoolDialect>();
894 registry.insert<llzk::array::ArrayDialect>();
895 registry.insert<llzk::component::StructDialect>();
896 registry.insert<llzk::constrain::ConstrainDialect>();
897 registry.insert<llzk::felt::FeltDialect>();
898 registry.insert<llzk::global::GlobalDialect>();
899 registry.insert<llzk::include::IncludeDialect>();
900 registry.insert<llzk::function::FunctionDialect>();
901 registry.insert<llzk::string::StringDialect>();
902 registry.insert<llzk::polymorphic::PolymorphicDialect>();
903 registry.insert<mlir::arith::ArithDialect>();
904 registry.insert<mlir::scf::SCFDialect>();
905 }
906
910 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(EnforceNoMemberOverwritePassBase<DerivedT>)
911
912protected:
913};
914
915template <typename DerivedT>
916class FuseProductLoopsPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
917public:
918 using Base = FuseProductLoopsPassBase;
919
920 FuseProductLoopsPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
921 FuseProductLoopsPassBase(const FuseProductLoopsPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
922 FuseProductLoopsPassBase& operator=(const FuseProductLoopsPassBase &) = delete;
923 FuseProductLoopsPassBase(FuseProductLoopsPassBase &&) = delete;
924 FuseProductLoopsPassBase& operator=(FuseProductLoopsPassBase &&) = delete;
925 ~FuseProductLoopsPassBase() = default;
926
928 static constexpr ::llvm::StringLiteral getArgumentName() {
929 return ::llvm::StringLiteral("llzk-fuse-product-loops");
930 }
931 ::llvm::StringRef getArgument() const override { return "llzk-fuse-product-loops"; }
932
933 ::llvm::StringRef getDescription() const override { return "Fuse matching witness/constraint loops in a @product function"; }
934
936 static constexpr ::llvm::StringLiteral getPassName() {
937 return ::llvm::StringLiteral("FuseProductLoopsPass");
938 }
939 ::llvm::StringRef getName() const override { return "FuseProductLoopsPass"; }
940
942 static bool classof(const ::mlir::Pass *pass) {
943 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
944 }
945
947 std::unique_ptr<::mlir::Pass> clonePass() const override {
948 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
949 }
950
952 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
953 registry.insert<llzk::LLZKDialect>();
954 registry.insert<llzk::boolean::BoolDialect>();
955 registry.insert<llzk::array::ArrayDialect>();
956 registry.insert<llzk::component::StructDialect>();
957 registry.insert<llzk::constrain::ConstrainDialect>();
958 registry.insert<llzk::felt::FeltDialect>();
959 registry.insert<llzk::global::GlobalDialect>();
960 registry.insert<llzk::include::IncludeDialect>();
961 registry.insert<llzk::function::FunctionDialect>();
962 registry.insert<llzk::string::StringDialect>();
963 registry.insert<llzk::polymorphic::PolymorphicDialect>();
964 registry.insert<mlir::arith::ArithDialect>();
965 registry.insert<mlir::scf::SCFDialect>();
966 }
967
971 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FuseProductLoopsPassBase<DerivedT>)
972
973protected:
974};
975
976template <typename DerivedT>
977class InlineStructsPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
978public:
979 using Base = InlineStructsPassBase;
980
981 InlineStructsPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
982 InlineStructsPassBase(const InlineStructsPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
983 InlineStructsPassBase& operator=(const InlineStructsPassBase &) = delete;
984 InlineStructsPassBase(InlineStructsPassBase &&) = delete;
985 InlineStructsPassBase& operator=(InlineStructsPassBase &&) = delete;
986 ~InlineStructsPassBase() = default;
987
989 static constexpr ::llvm::StringLiteral getArgumentName() {
990 return ::llvm::StringLiteral("llzk-inline-structs");
991 }
992 ::llvm::StringRef getArgument() const override { return "llzk-inline-structs"; }
993
994 ::llvm::StringRef getDescription() const override { return "Inlines nested structs (i.e., subcomponents)."; }
995
997 static constexpr ::llvm::StringLiteral getPassName() {
998 return ::llvm::StringLiteral("InlineStructsPass");
999 }
1000 ::llvm::StringRef getName() const override { return "InlineStructsPass"; }
1001
1003 static bool classof(const ::mlir::Pass *pass) {
1004 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1005 }
1006
1008 std::unique_ptr<::mlir::Pass> clonePass() const override {
1009 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1010 }
1011
1013 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1014 registry.insert<llzk::LLZKDialect>();
1015 registry.insert<llzk::boolean::BoolDialect>();
1016 registry.insert<llzk::array::ArrayDialect>();
1017 registry.insert<llzk::component::StructDialect>();
1018 registry.insert<llzk::constrain::ConstrainDialect>();
1019 registry.insert<llzk::felt::FeltDialect>();
1020 registry.insert<llzk::global::GlobalDialect>();
1021 registry.insert<llzk::include::IncludeDialect>();
1022 registry.insert<llzk::function::FunctionDialect>();
1023 registry.insert<llzk::string::StringDialect>();
1024 registry.insert<llzk::polymorphic::PolymorphicDialect>();
1025 registry.insert<mlir::arith::ArithDialect>();
1026 registry.insert<mlir::scf::SCFDialect>();
1027 }
1028
1032 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(InlineStructsPassBase<DerivedT>)
1033
1034protected:
1035 ::mlir::Pass::Option<uint64_t> maxComplexity{*this, "max-merge-complexity", ::llvm::cl::desc("Maximum allowed constraint+multiplications in merged @constrain functions"), ::llvm::cl::init(0)};
1036};
1037
1038template <typename DerivedT>
1039class PolyLoweringPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
1040public:
1041 using Base = PolyLoweringPassBase;
1042
1043 PolyLoweringPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1044 PolyLoweringPassBase(const PolyLoweringPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
1045 PolyLoweringPassBase& operator=(const PolyLoweringPassBase &) = delete;
1046 PolyLoweringPassBase(PolyLoweringPassBase &&) = delete;
1047 PolyLoweringPassBase& operator=(PolyLoweringPassBase &&) = delete;
1048 ~PolyLoweringPassBase() = default;
1049
1051 static constexpr ::llvm::StringLiteral getArgumentName() {
1052 return ::llvm::StringLiteral("llzk-poly-lowering-pass");
1053 }
1054 ::llvm::StringRef getArgument() const override { return "llzk-poly-lowering-pass"; }
1055
1056 ::llvm::StringRef getDescription() const override { return "Lower the degree of all polynomial equations to a specified maximum"; }
1057
1059 static constexpr ::llvm::StringLiteral getPassName() {
1060 return ::llvm::StringLiteral("PolyLoweringPass");
1061 }
1062 ::llvm::StringRef getName() const override { return "PolyLoweringPass"; }
1063
1065 static bool classof(const ::mlir::Pass *pass) {
1066 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1067 }
1068
1070 std::unique_ptr<::mlir::Pass> clonePass() const override {
1071 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1072 }
1073
1075 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1076 registry.insert<llzk::LLZKDialect>();
1077 registry.insert<llzk::boolean::BoolDialect>();
1078 registry.insert<llzk::array::ArrayDialect>();
1079 registry.insert<llzk::component::StructDialect>();
1080 registry.insert<llzk::constrain::ConstrainDialect>();
1081 registry.insert<llzk::felt::FeltDialect>();
1082 registry.insert<llzk::global::GlobalDialect>();
1083 registry.insert<llzk::include::IncludeDialect>();
1084 registry.insert<llzk::function::FunctionDialect>();
1085 registry.insert<llzk::string::StringDialect>();
1086 registry.insert<llzk::polymorphic::PolymorphicDialect>();
1087 registry.insert<mlir::arith::ArithDialect>();
1088 registry.insert<mlir::scf::SCFDialect>();
1089 }
1090
1094 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PolyLoweringPassBase<DerivedT>)
1095
1096protected:
1097 ::mlir::Pass::Option<unsigned> maxDegree{*this, "max-degree", ::llvm::cl::desc("Maximum degree of constraint polynomials (default 2, minimum 2)"), ::llvm::cl::init(2)};
1098};
1099
1100template <typename DerivedT>
1101class RedundantOperationEliminationPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
1102public:
1103 using Base = RedundantOperationEliminationPassBase;
1104
1105 RedundantOperationEliminationPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1106 RedundantOperationEliminationPassBase(const RedundantOperationEliminationPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
1107 RedundantOperationEliminationPassBase& operator=(const RedundantOperationEliminationPassBase &) = delete;
1108 RedundantOperationEliminationPassBase(RedundantOperationEliminationPassBase &&) = delete;
1109 RedundantOperationEliminationPassBase& operator=(RedundantOperationEliminationPassBase &&) = delete;
1110 ~RedundantOperationEliminationPassBase() = default;
1111
1113 static constexpr ::llvm::StringLiteral getArgumentName() {
1114 return ::llvm::StringLiteral("llzk-duplicate-op-elim");
1115 }
1116 ::llvm::StringRef getArgument() const override { return "llzk-duplicate-op-elim"; }
1117
1118 ::llvm::StringRef getDescription() const override { return "Remove redundant operations"; }
1119
1121 static constexpr ::llvm::StringLiteral getPassName() {
1122 return ::llvm::StringLiteral("RedundantOperationEliminationPass");
1123 }
1124 ::llvm::StringRef getName() const override { return "RedundantOperationEliminationPass"; }
1125
1127 static bool classof(const ::mlir::Pass *pass) {
1128 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1129 }
1130
1132 std::unique_ptr<::mlir::Pass> clonePass() const override {
1133 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1134 }
1135
1137 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1138 registry.insert<llzk::LLZKDialect>();
1139 registry.insert<llzk::boolean::BoolDialect>();
1140 registry.insert<llzk::array::ArrayDialect>();
1141 registry.insert<llzk::component::StructDialect>();
1142 registry.insert<llzk::constrain::ConstrainDialect>();
1143 registry.insert<llzk::felt::FeltDialect>();
1144 registry.insert<llzk::global::GlobalDialect>();
1145 registry.insert<llzk::include::IncludeDialect>();
1146 registry.insert<llzk::function::FunctionDialect>();
1147 registry.insert<llzk::string::StringDialect>();
1148 registry.insert<llzk::polymorphic::PolymorphicDialect>();
1149 registry.insert<mlir::arith::ArithDialect>();
1150 registry.insert<mlir::scf::SCFDialect>();
1151 }
1152
1156 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RedundantOperationEliminationPassBase<DerivedT>)
1157
1158protected:
1159};
1160
1161template <typename DerivedT>
1162class RedundantReadAndWriteEliminationPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
1163public:
1164 using Base = RedundantReadAndWriteEliminationPassBase;
1165
1166 RedundantReadAndWriteEliminationPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1167 RedundantReadAndWriteEliminationPassBase(const RedundantReadAndWriteEliminationPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
1168 RedundantReadAndWriteEliminationPassBase& operator=(const RedundantReadAndWriteEliminationPassBase &) = delete;
1169 RedundantReadAndWriteEliminationPassBase(RedundantReadAndWriteEliminationPassBase &&) = delete;
1170 RedundantReadAndWriteEliminationPassBase& operator=(RedundantReadAndWriteEliminationPassBase &&) = delete;
1171 ~RedundantReadAndWriteEliminationPassBase() = default;
1172
1174 static constexpr ::llvm::StringLiteral getArgumentName() {
1175 return ::llvm::StringLiteral("llzk-duplicate-read-write-elim");
1176 }
1177 ::llvm::StringRef getArgument() const override { return "llzk-duplicate-read-write-elim"; }
1178
1179 ::llvm::StringRef getDescription() const override { return "Remove redundant reads and writes"; }
1180
1182 static constexpr ::llvm::StringLiteral getPassName() {
1183 return ::llvm::StringLiteral("RedundantReadAndWriteEliminationPass");
1184 }
1185 ::llvm::StringRef getName() const override { return "RedundantReadAndWriteEliminationPass"; }
1186
1188 static bool classof(const ::mlir::Pass *pass) {
1189 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1190 }
1191
1193 std::unique_ptr<::mlir::Pass> clonePass() const override {
1194 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1195 }
1196
1198 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1199 registry.insert<llzk::LLZKDialect>();
1200 registry.insert<llzk::boolean::BoolDialect>();
1201 registry.insert<llzk::array::ArrayDialect>();
1202 registry.insert<llzk::component::StructDialect>();
1203 registry.insert<llzk::constrain::ConstrainDialect>();
1204 registry.insert<llzk::felt::FeltDialect>();
1205 registry.insert<llzk::global::GlobalDialect>();
1206 registry.insert<llzk::include::IncludeDialect>();
1207 registry.insert<llzk::function::FunctionDialect>();
1208 registry.insert<llzk::string::StringDialect>();
1209 registry.insert<llzk::polymorphic::PolymorphicDialect>();
1210 registry.insert<mlir::arith::ArithDialect>();
1211 registry.insert<mlir::scf::SCFDialect>();
1212 }
1213
1217 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RedundantReadAndWriteEliminationPassBase<DerivedT>)
1218
1219protected:
1220};
1221
1222template <typename DerivedT>
1223class UnusedDeclarationEliminationPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
1224public:
1225 using Base = UnusedDeclarationEliminationPassBase;
1226
1227 UnusedDeclarationEliminationPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1228 UnusedDeclarationEliminationPassBase(const UnusedDeclarationEliminationPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
1229 UnusedDeclarationEliminationPassBase& operator=(const UnusedDeclarationEliminationPassBase &) = delete;
1230 UnusedDeclarationEliminationPassBase(UnusedDeclarationEliminationPassBase &&) = delete;
1231 UnusedDeclarationEliminationPassBase& operator=(UnusedDeclarationEliminationPassBase &&) = delete;
1232 ~UnusedDeclarationEliminationPassBase() = default;
1233
1235 static constexpr ::llvm::StringLiteral getArgumentName() {
1236 return ::llvm::StringLiteral("llzk-unused-declaration-elim");
1237 }
1238 ::llvm::StringRef getArgument() const override { return "llzk-unused-declaration-elim"; }
1239
1240 ::llvm::StringRef getDescription() const override { return "Remove unused member and struct declarations"; }
1241
1243 static constexpr ::llvm::StringLiteral getPassName() {
1244 return ::llvm::StringLiteral("UnusedDeclarationEliminationPass");
1245 }
1246 ::llvm::StringRef getName() const override { return "UnusedDeclarationEliminationPass"; }
1247
1249 static bool classof(const ::mlir::Pass *pass) {
1250 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1251 }
1252
1254 std::unique_ptr<::mlir::Pass> clonePass() const override {
1255 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1256 }
1257
1259 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1260 registry.insert<llzk::LLZKDialect>();
1261 registry.insert<llzk::boolean::BoolDialect>();
1262 registry.insert<llzk::array::ArrayDialect>();
1263 registry.insert<llzk::component::StructDialect>();
1264 registry.insert<llzk::constrain::ConstrainDialect>();
1265 registry.insert<llzk::felt::FeltDialect>();
1266 registry.insert<llzk::global::GlobalDialect>();
1267 registry.insert<llzk::include::IncludeDialect>();
1268 registry.insert<llzk::function::FunctionDialect>();
1269 registry.insert<llzk::string::StringDialect>();
1270 registry.insert<llzk::polymorphic::PolymorphicDialect>();
1271 registry.insert<mlir::arith::ArithDialect>();
1272 registry.insert<mlir::scf::SCFDialect>();
1273 }
1274
1278 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(UnusedDeclarationEliminationPassBase<DerivedT>)
1279
1280protected:
1281 ::mlir::Pass::Option<bool> removeStructs{*this, "remove-structs", ::llvm::cl::desc("Whether to remove unused struct definitions as well. Requires module to declare a Main component, otherwise all components will appear unused."), ::llvm::cl::init(false)};
1282};
1283#undef GEN_PASS_CLASSES
1284#endif // GEN_PASS_CLASSES
void registerTransformationPasses()
void registerUnusedDeclarationEliminationPassPass()
std::unique_ptr< mlir::Pass > createRedundantOperationEliminationPass()
void registerFuseProductLoopsPassPass()
void registerRedundantOperationEliminationPass()
void registerEnforceNoMemberOverwritePassPass()
std::unique_ptr< Pass > createComputeConstrainToProductPass()
void registerPolyLoweringPassPass()
void registerUnusedDeclarationEliminationPass()
void registerComputeConstrainToProductPassPass()
void registerRedundantOperationEliminationPassPass()
std::unique_ptr< mlir::Pass > createRedundantReadAndWriteEliminationPass()
void registerInlineStructsPassPass()
std::unique_ptr< mlir::Pass > createUnusedDeclarationEliminationPass()
void registerComputeConstrainToProductPass()
std::unique_ptr< mlir::Pass > createPolyLoweringPass()
void registerRedundantReadAndWriteEliminationPass()
void registerPolyLoweringPass()
void registerRedundantReadAndWriteEliminationPassPass()
std::unique_ptr< mlir::Pass > createInlineStructsPass()
void registerEnforceNoMemberOverwritePass()
std::unique_ptr< mlir::Pass > createNoOverwritesPass()
std::unique_ptr< mlir::Pass > createFuseProductLoopsPass()
void registerInlineStructsPass()
void registerFuseProductLoopsPass()