5#define GEN_PASS_DECL_COMPUTECONSTRAINTOPRODUCTPASS
6#define GEN_PASS_DECL_ENFORCENOMEMBEROVERWRITEPASS
7#define GEN_PASS_DECL_FUSEPRODUCTCONTROLFLOWPASS
8#define GEN_PASS_DECL_INLINEFREEFUNCTIONSPASS
9#define GEN_PASS_DECL_POLYLOWERINGPASS
10#define GEN_PASS_DECL_REDUNDANTOPERATIONELIMINATIONPASS
11#define GEN_PASS_DECL_REDUNDANTREADANDWRITEELIMINATIONPASS
12#define GEN_PASS_DECL_REMOVEUNUSEDDISCARDABLEALLOCATIONSPASS
13#define GEN_PASS_DECL_UNUSEDDECLARATIONELIMINATIONPASS
14#define GEN_PASS_DECL_WHILETOFORPASS
21#ifdef GEN_PASS_DECL_COMPUTECONSTRAINTOPRODUCTPASS
22struct ComputeConstrainToProductPassOptions {
23 std::string rootStruct =
"Main";
27#undef GEN_PASS_DECL_COMPUTECONSTRAINTOPRODUCTPASS
29#ifdef GEN_PASS_DEF_COMPUTECONSTRAINTOPRODUCTPASS
40template <
typename DerivedT>
41class ComputeConstrainToProductPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
43 using Base = ComputeConstrainToProductPassBase;
45 ComputeConstrainToProductPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
46 ComputeConstrainToProductPassBase(
const ComputeConstrainToProductPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
47 ComputeConstrainToProductPassBase& operator=(
const ComputeConstrainToProductPassBase &) =
delete;
48 ComputeConstrainToProductPassBase(ComputeConstrainToProductPassBase &&) =
delete;
49 ComputeConstrainToProductPassBase& operator=(ComputeConstrainToProductPassBase &&) =
delete;
50 ~ComputeConstrainToProductPassBase() =
default;
53 static constexpr ::llvm::StringLiteral getArgumentName() {
54 return ::llvm::StringLiteral(
"llzk-compute-constrain-to-product");
56 ::llvm::StringRef getArgument()
const override {
return "llzk-compute-constrain-to-product"; }
58 ::llvm::StringRef getDescription()
const override {
return R
"PD(Replace separate `@compute` and `@constrain` functions in a struct with a single `@product` function)PD"; }
61 static constexpr ::llvm::StringLiteral getPassName() {
62 return ::llvm::StringLiteral(
"ComputeConstrainToProductPass");
64 ::llvm::StringRef getName()
const override {
return "ComputeConstrainToProductPass"; }
67 static bool classof(const ::mlir::Pass *pass) {
68 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
72 std::unique_ptr<::mlir::Pass> clonePass()
const override {
73 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
77 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
78 registry.insert<llzk::LLZKDialect>();
79 registry.insert<llzk::boolean::BoolDialect>();
80 registry.insert<llzk::array::ArrayDialect>();
81 registry.insert<llzk::component::StructDialect>();
82 registry.insert<llzk::constrain::ConstrainDialect>();
83 registry.insert<llzk::felt::FeltDialect>();
84 registry.insert<llzk::global::GlobalDialect>();
85 registry.insert<llzk::include::IncludeDialect>();
86 registry.insert<llzk::function::FunctionDialect>();
87 registry.insert<llzk::string::StringDialect>();
88 registry.insert<llzk::polymorphic::PolymorphicDialect>();
89 registry.insert<mlir::arith::ArithDialect>();
90 registry.insert<mlir::scf::SCFDialect>();
96 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ComputeConstrainToProductPassBase<DerivedT>)
98 ComputeConstrainToProductPassBase(ComputeConstrainToProductPassOptions options) : ComputeConstrainToProductPassBase() {
99 rootStruct = std::move(options.rootStruct);
102 ::mlir::Pass::Option<std::string> rootStruct{*
this,
"root-struct", ::llvm::cl::desc(R
"PO(Root struct at which to start alignment (default to `@Main`))PO"), ::llvm::cl::init("Main")};
106 return std::make_unique<DerivedT>();
110 return std::make_unique<DerivedT>(std::move(options));
116 return impl::createComputeConstrainToProductPass();
120 return impl::createComputeConstrainToProductPass(std::move(options));
122#undef GEN_PASS_DEF_COMPUTECONSTRAINTOPRODUCTPASS
128#ifdef GEN_PASS_DECL_ENFORCENOMEMBEROVERWRITEPASS
130#undef GEN_PASS_DECL_ENFORCENOMEMBEROVERWRITEPASS
132#ifdef GEN_PASS_DEF_ENFORCENOMEMBEROVERWRITEPASS
139template <
typename DerivedT>
140class EnforceNoMemberOverwritePassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
142 using Base = EnforceNoMemberOverwritePassBase;
144 EnforceNoMemberOverwritePassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
145 EnforceNoMemberOverwritePassBase(
const EnforceNoMemberOverwritePassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
146 EnforceNoMemberOverwritePassBase& operator=(
const EnforceNoMemberOverwritePassBase &) =
delete;
147 EnforceNoMemberOverwritePassBase(EnforceNoMemberOverwritePassBase &&) =
delete;
148 EnforceNoMemberOverwritePassBase& operator=(EnforceNoMemberOverwritePassBase &&) =
delete;
149 ~EnforceNoMemberOverwritePassBase() =
default;
152 static constexpr ::llvm::StringLiteral getArgumentName() {
153 return ::llvm::StringLiteral(
"llzk-enforce-no-overwrite");
155 ::llvm::StringRef getArgument()
const override {
return "llzk-enforce-no-overwrite"; }
157 ::llvm::StringRef getDescription()
const override {
return R
"PD(Checks that every struct member is written exactly once)PD"; }
160 static constexpr ::llvm::StringLiteral getPassName() {
161 return ::llvm::StringLiteral(
"EnforceNoMemberOverwritePass");
163 ::llvm::StringRef getName()
const override {
return "EnforceNoMemberOverwritePass"; }
166 static bool classof(const ::mlir::Pass *pass) {
167 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
171 std::unique_ptr<::mlir::Pass> clonePass()
const override {
172 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
176 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
177 registry.insert<llzk::LLZKDialect>();
178 registry.insert<llzk::boolean::BoolDialect>();
179 registry.insert<llzk::array::ArrayDialect>();
180 registry.insert<llzk::component::StructDialect>();
181 registry.insert<llzk::constrain::ConstrainDialect>();
182 registry.insert<llzk::felt::FeltDialect>();
183 registry.insert<llzk::global::GlobalDialect>();
184 registry.insert<llzk::include::IncludeDialect>();
185 registry.insert<llzk::function::FunctionDialect>();
186 registry.insert<llzk::string::StringDialect>();
187 registry.insert<llzk::polymorphic::PolymorphicDialect>();
188 registry.insert<mlir::arith::ArithDialect>();
189 registry.insert<mlir::scf::SCFDialect>();
195 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(EnforceNoMemberOverwritePassBase<DerivedT>)
201 return std::make_unique<DerivedT>();
207 return impl::createEnforceNoMemberOverwritePass();
209#undef GEN_PASS_DEF_ENFORCENOMEMBEROVERWRITEPASS
215#ifdef GEN_PASS_DECL_FUSEPRODUCTCONTROLFLOWPASS
217#undef GEN_PASS_DECL_FUSEPRODUCTCONTROLFLOWPASS
219#ifdef GEN_PASS_DEF_FUSEPRODUCTCONTROLFLOWPASS
226template <
typename DerivedT>
227class FuseProductControlFlowPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
229 using Base = FuseProductControlFlowPassBase;
231 FuseProductControlFlowPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
232 FuseProductControlFlowPassBase(
const FuseProductControlFlowPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
233 FuseProductControlFlowPassBase& operator=(
const FuseProductControlFlowPassBase &) =
delete;
234 FuseProductControlFlowPassBase(FuseProductControlFlowPassBase &&) =
delete;
235 FuseProductControlFlowPassBase& operator=(FuseProductControlFlowPassBase &&) =
delete;
236 ~FuseProductControlFlowPassBase() =
default;
239 static constexpr ::llvm::StringLiteral getArgumentName() {
240 return ::llvm::StringLiteral(
"llzk-fuse-product-control-flow");
242 ::llvm::StringRef getArgument()
const override {
return "llzk-fuse-product-control-flow"; }
244 ::llvm::StringRef getDescription()
const override {
return R
"PD(Fuse matching compute/constrain control flow in a `@product` function)PD"; }
247 static constexpr ::llvm::StringLiteral getPassName() {
248 return ::llvm::StringLiteral(
"FuseProductControlFlowPass");
250 ::llvm::StringRef getName()
const override {
return "FuseProductControlFlowPass"; }
253 static bool classof(const ::mlir::Pass *pass) {
254 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
258 std::unique_ptr<::mlir::Pass> clonePass()
const override {
259 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
263 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
264 registry.insert<llzk::LLZKDialect>();
265 registry.insert<llzk::boolean::BoolDialect>();
266 registry.insert<llzk::array::ArrayDialect>();
267 registry.insert<llzk::component::StructDialect>();
268 registry.insert<llzk::constrain::ConstrainDialect>();
269 registry.insert<llzk::felt::FeltDialect>();
270 registry.insert<llzk::global::GlobalDialect>();
271 registry.insert<llzk::include::IncludeDialect>();
272 registry.insert<llzk::function::FunctionDialect>();
273 registry.insert<llzk::string::StringDialect>();
274 registry.insert<llzk::polymorphic::PolymorphicDialect>();
275 registry.insert<mlir::arith::ArithDialect>();
276 registry.insert<mlir::scf::SCFDialect>();
282 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FuseProductControlFlowPassBase<DerivedT>)
288 return std::make_unique<DerivedT>();
294 return impl::createFuseProductControlFlowPass();
296#undef GEN_PASS_DEF_FUSEPRODUCTCONTROLFLOWPASS
302#ifdef GEN_PASS_DECL_INLINEFREEFUNCTIONSPASS
304#undef GEN_PASS_DECL_INLINEFREEFUNCTIONSPASS
306#ifdef GEN_PASS_DEF_INLINEFREEFUNCTIONSPASS
313template <
typename DerivedT>
314class InlineFreeFunctionsPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
316 using Base = InlineFreeFunctionsPassBase;
318 InlineFreeFunctionsPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
319 InlineFreeFunctionsPassBase(
const InlineFreeFunctionsPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
320 InlineFreeFunctionsPassBase& operator=(
const InlineFreeFunctionsPassBase &) =
delete;
321 InlineFreeFunctionsPassBase(InlineFreeFunctionsPassBase &&) =
delete;
322 InlineFreeFunctionsPassBase& operator=(InlineFreeFunctionsPassBase &&) =
delete;
323 ~InlineFreeFunctionsPassBase() =
default;
326 static constexpr ::llvm::StringLiteral getArgumentName() {
327 return ::llvm::StringLiteral(
"llzk-inline-free-functions");
329 ::llvm::StringRef getArgument()
const override {
return "llzk-inline-free-functions"; }
331 ::llvm::StringRef getDescription()
const override {
return R
"PD(Inline calls to free functions)PD"; }
334 static constexpr ::llvm::StringLiteral getPassName() {
335 return ::llvm::StringLiteral(
"InlineFreeFunctionsPass");
337 ::llvm::StringRef getName()
const override {
return "InlineFreeFunctionsPass"; }
340 static bool classof(const ::mlir::Pass *pass) {
341 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
345 std::unique_ptr<::mlir::Pass> clonePass()
const override {
346 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
350 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
351 registry.insert<llzk::LLZKDialect>();
352 registry.insert<llzk::boolean::BoolDialect>();
353 registry.insert<llzk::array::ArrayDialect>();
354 registry.insert<llzk::component::StructDialect>();
355 registry.insert<llzk::constrain::ConstrainDialect>();
356 registry.insert<llzk::felt::FeltDialect>();
357 registry.insert<llzk::global::GlobalDialect>();
358 registry.insert<llzk::include::IncludeDialect>();
359 registry.insert<llzk::function::FunctionDialect>();
360 registry.insert<llzk::string::StringDialect>();
361 registry.insert<llzk::polymorphic::PolymorphicDialect>();
362 registry.insert<mlir::arith::ArithDialect>();
363 registry.insert<mlir::scf::SCFDialect>();
369 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(InlineFreeFunctionsPassBase<DerivedT>)
375 return std::make_unique<DerivedT>();
381 return impl::createInlineFreeFunctionsPass();
383#undef GEN_PASS_DEF_INLINEFREEFUNCTIONSPASS
389#ifdef GEN_PASS_DECL_POLYLOWERINGPASS
390struct PolyLoweringPassOptions {
391 unsigned maxDegree = 2;
395#undef GEN_PASS_DECL_POLYLOWERINGPASS
397#ifdef GEN_PASS_DEF_POLYLOWERINGPASS
408template <
typename DerivedT>
409class PolyLoweringPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
411 using Base = PolyLoweringPassBase;
413 PolyLoweringPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
414 PolyLoweringPassBase(
const PolyLoweringPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
415 PolyLoweringPassBase& operator=(
const PolyLoweringPassBase &) =
delete;
416 PolyLoweringPassBase(PolyLoweringPassBase &&) =
delete;
417 PolyLoweringPassBase& operator=(PolyLoweringPassBase &&) =
delete;
418 ~PolyLoweringPassBase() =
default;
421 static constexpr ::llvm::StringLiteral getArgumentName() {
422 return ::llvm::StringLiteral(
"llzk-poly-lowering-pass");
424 ::llvm::StringRef getArgument()
const override {
return "llzk-poly-lowering-pass"; }
426 ::llvm::StringRef getDescription()
const override {
return R
"PD(Lower the degree of all polynomial equations to a specified maximum)PD"; }
429 static constexpr ::llvm::StringLiteral getPassName() {
430 return ::llvm::StringLiteral(
"PolyLoweringPass");
432 ::llvm::StringRef getName()
const override {
return "PolyLoweringPass"; }
435 static bool classof(const ::mlir::Pass *pass) {
436 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
440 std::unique_ptr<::mlir::Pass> clonePass()
const override {
441 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
445 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
446 registry.insert<llzk::LLZKDialect>();
447 registry.insert<llzk::boolean::BoolDialect>();
448 registry.insert<llzk::array::ArrayDialect>();
449 registry.insert<llzk::component::StructDialect>();
450 registry.insert<llzk::constrain::ConstrainDialect>();
451 registry.insert<llzk::felt::FeltDialect>();
452 registry.insert<llzk::global::GlobalDialect>();
453 registry.insert<llzk::include::IncludeDialect>();
454 registry.insert<llzk::function::FunctionDialect>();
455 registry.insert<llzk::string::StringDialect>();
456 registry.insert<llzk::polymorphic::PolymorphicDialect>();
457 registry.insert<mlir::arith::ArithDialect>();
458 registry.insert<mlir::scf::SCFDialect>();
464 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PolyLoweringPassBase<DerivedT>)
466 PolyLoweringPassBase(PolyLoweringPassOptions options) : PolyLoweringPassBase() {
467 maxDegree = std::move(options.maxDegree);
470 ::mlir::Pass::Option<unsigned> maxDegree{*
this,
"max-degree", ::llvm::cl::desc(R
"PO(Maximum degree of constraint polynomials (default 2, minimum 2))PO"), ::llvm::cl::init(2)};
474 return std::make_unique<DerivedT>();
478 return std::make_unique<DerivedT>(std::move(options));
484 return impl::createPolyLoweringPass();
488 return impl::createPolyLoweringPass(std::move(options));
490#undef GEN_PASS_DEF_POLYLOWERINGPASS
496#ifdef GEN_PASS_DECL_REDUNDANTOPERATIONELIMINATIONPASS
498#undef GEN_PASS_DECL_REDUNDANTOPERATIONELIMINATIONPASS
500#ifdef GEN_PASS_DEF_REDUNDANTOPERATIONELIMINATIONPASS
507template <
typename DerivedT>
508class RedundantOperationEliminationPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
510 using Base = RedundantOperationEliminationPassBase;
512 RedundantOperationEliminationPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
513 RedundantOperationEliminationPassBase(
const RedundantOperationEliminationPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
514 RedundantOperationEliminationPassBase& operator=(
const RedundantOperationEliminationPassBase &) =
delete;
515 RedundantOperationEliminationPassBase(RedundantOperationEliminationPassBase &&) =
delete;
516 RedundantOperationEliminationPassBase& operator=(RedundantOperationEliminationPassBase &&) =
delete;
517 ~RedundantOperationEliminationPassBase() =
default;
520 static constexpr ::llvm::StringLiteral getArgumentName() {
521 return ::llvm::StringLiteral(
"llzk-duplicate-op-elim");
523 ::llvm::StringRef getArgument()
const override {
return "llzk-duplicate-op-elim"; }
525 ::llvm::StringRef getDescription()
const override {
return R
"PD(Remove redundant operations)PD"; }
528 static constexpr ::llvm::StringLiteral getPassName() {
529 return ::llvm::StringLiteral(
"RedundantOperationEliminationPass");
531 ::llvm::StringRef getName()
const override {
return "RedundantOperationEliminationPass"; }
534 static bool classof(const ::mlir::Pass *pass) {
535 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
539 std::unique_ptr<::mlir::Pass> clonePass()
const override {
540 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
544 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
545 registry.insert<llzk::LLZKDialect>();
546 registry.insert<llzk::boolean::BoolDialect>();
547 registry.insert<llzk::array::ArrayDialect>();
548 registry.insert<llzk::component::StructDialect>();
549 registry.insert<llzk::constrain::ConstrainDialect>();
550 registry.insert<llzk::felt::FeltDialect>();
551 registry.insert<llzk::global::GlobalDialect>();
552 registry.insert<llzk::include::IncludeDialect>();
553 registry.insert<llzk::function::FunctionDialect>();
554 registry.insert<llzk::string::StringDialect>();
555 registry.insert<llzk::polymorphic::PolymorphicDialect>();
556 registry.insert<mlir::arith::ArithDialect>();
557 registry.insert<mlir::scf::SCFDialect>();
563 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RedundantOperationEliminationPassBase<DerivedT>)
569 return std::make_unique<DerivedT>();
575 return impl::createRedundantOperationEliminationPass();
577#undef GEN_PASS_DEF_REDUNDANTOPERATIONELIMINATIONPASS
583#ifdef GEN_PASS_DECL_REDUNDANTREADANDWRITEELIMINATIONPASS
585#undef GEN_PASS_DECL_REDUNDANTREADANDWRITEELIMINATIONPASS
587#ifdef GEN_PASS_DEF_REDUNDANTREADANDWRITEELIMINATIONPASS
594template <
typename DerivedT>
595class RedundantReadAndWriteEliminationPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
597 using Base = RedundantReadAndWriteEliminationPassBase;
599 RedundantReadAndWriteEliminationPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
600 RedundantReadAndWriteEliminationPassBase(
const RedundantReadAndWriteEliminationPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
601 RedundantReadAndWriteEliminationPassBase& operator=(
const RedundantReadAndWriteEliminationPassBase &) =
delete;
602 RedundantReadAndWriteEliminationPassBase(RedundantReadAndWriteEliminationPassBase &&) =
delete;
603 RedundantReadAndWriteEliminationPassBase& operator=(RedundantReadAndWriteEliminationPassBase &&) =
delete;
604 ~RedundantReadAndWriteEliminationPassBase() =
default;
607 static constexpr ::llvm::StringLiteral getArgumentName() {
608 return ::llvm::StringLiteral(
"llzk-duplicate-read-write-elim");
610 ::llvm::StringRef getArgument()
const override {
return "llzk-duplicate-read-write-elim"; }
612 ::llvm::StringRef getDescription()
const override {
return R
"PD(Remove redundant reads and writes)PD"; }
615 static constexpr ::llvm::StringLiteral getPassName() {
616 return ::llvm::StringLiteral(
"RedundantReadAndWriteEliminationPass");
618 ::llvm::StringRef getName()
const override {
return "RedundantReadAndWriteEliminationPass"; }
621 static bool classof(const ::mlir::Pass *pass) {
622 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
626 std::unique_ptr<::mlir::Pass> clonePass()
const override {
627 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
631 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
632 registry.insert<llzk::LLZKDialect>();
633 registry.insert<llzk::boolean::BoolDialect>();
634 registry.insert<llzk::array::ArrayDialect>();
635 registry.insert<llzk::component::StructDialect>();
636 registry.insert<llzk::constrain::ConstrainDialect>();
637 registry.insert<llzk::felt::FeltDialect>();
638 registry.insert<llzk::global::GlobalDialect>();
639 registry.insert<llzk::include::IncludeDialect>();
640 registry.insert<llzk::function::FunctionDialect>();
641 registry.insert<llzk::string::StringDialect>();
642 registry.insert<llzk::polymorphic::PolymorphicDialect>();
643 registry.insert<mlir::arith::ArithDialect>();
644 registry.insert<mlir::scf::SCFDialect>();
650 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RedundantReadAndWriteEliminationPassBase<DerivedT>)
656 return std::make_unique<DerivedT>();
662 return impl::createRedundantReadAndWriteEliminationPass();
664#undef GEN_PASS_DEF_REDUNDANTREADANDWRITEELIMINATIONPASS
670#ifdef GEN_PASS_DECL_REMOVEUNUSEDDISCARDABLEALLOCATIONSPASS
671struct RemoveUnusedDiscardableAllocationsPassOptions {
672 std::string allocatorOpName =
"";
676#undef GEN_PASS_DECL_REMOVEUNUSEDDISCARDABLEALLOCATIONSPASS
678#ifdef GEN_PASS_DEF_REMOVEUNUSEDDISCARDABLEALLOCATIONSPASS
689template <
typename DerivedT>
690class RemoveUnusedDiscardableAllocationsPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
692 using Base = RemoveUnusedDiscardableAllocationsPassBase;
694 RemoveUnusedDiscardableAllocationsPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
695 RemoveUnusedDiscardableAllocationsPassBase(
const RemoveUnusedDiscardableAllocationsPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
696 RemoveUnusedDiscardableAllocationsPassBase& operator=(
const RemoveUnusedDiscardableAllocationsPassBase &) =
delete;
697 RemoveUnusedDiscardableAllocationsPassBase(RemoveUnusedDiscardableAllocationsPassBase &&) =
delete;
698 RemoveUnusedDiscardableAllocationsPassBase& operator=(RemoveUnusedDiscardableAllocationsPassBase &&) =
delete;
699 ~RemoveUnusedDiscardableAllocationsPassBase() =
default;
702 static constexpr ::llvm::StringLiteral getArgumentName() {
703 return ::llvm::StringLiteral(
"llzk-remove-unused-discardable-allocations");
705 ::llvm::StringRef getArgument()
const override {
return "llzk-remove-unused-discardable-allocations"; }
707 ::llvm::StringRef getDescription()
const override {
return R
"PD(Remove unread discardable allocations and their dead stores)PD"; }
710 static constexpr ::llvm::StringLiteral getPassName() {
711 return ::llvm::StringLiteral(
"RemoveUnusedDiscardableAllocationsPass");
713 ::llvm::StringRef getName()
const override {
return "RemoveUnusedDiscardableAllocationsPass"; }
716 static bool classof(const ::mlir::Pass *pass) {
717 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
721 std::unique_ptr<::mlir::Pass> clonePass()
const override {
722 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
726 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
727 registry.insert<llzk::LLZKDialect>();
728 registry.insert<llzk::boolean::BoolDialect>();
729 registry.insert<llzk::array::ArrayDialect>();
730 registry.insert<llzk::component::StructDialect>();
731 registry.insert<llzk::constrain::ConstrainDialect>();
732 registry.insert<llzk::felt::FeltDialect>();
733 registry.insert<llzk::global::GlobalDialect>();
734 registry.insert<llzk::include::IncludeDialect>();
735 registry.insert<llzk::function::FunctionDialect>();
736 registry.insert<llzk::string::StringDialect>();
737 registry.insert<llzk::polymorphic::PolymorphicDialect>();
738 registry.insert<mlir::arith::ArithDialect>();
739 registry.insert<mlir::scf::SCFDialect>();
745 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RemoveUnusedDiscardableAllocationsPassBase<DerivedT>)
747 RemoveUnusedDiscardableAllocationsPassBase(RemoveUnusedDiscardableAllocationsPassOptions options) : RemoveUnusedDiscardableAllocationsPassBase() {
748 allocatorOpName = std::move(options.allocatorOpName);
751 ::mlir::Pass::Option<std::string> allocatorOpName{*
this,
"allocator-op", ::llvm::cl::desc(R
"PO(Operation name of the discardable allocator to remove)PO"), ::llvm::cl::init("")};
755 return std::make_unique<DerivedT>();
759 return std::make_unique<DerivedT>(std::move(options));
765 return impl::createRemoveUnusedDiscardableAllocationsPass();
769 return impl::createRemoveUnusedDiscardableAllocationsPass(std::move(options));
771#undef GEN_PASS_DEF_REMOVEUNUSEDDISCARDABLEALLOCATIONSPASS
777#ifdef GEN_PASS_DECL_UNUSEDDECLARATIONELIMINATIONPASS
778struct UnusedDeclarationEliminationPassOptions {
779 bool removeStructs =
false;
783#undef GEN_PASS_DECL_UNUSEDDECLARATIONELIMINATIONPASS
785#ifdef GEN_PASS_DEF_UNUSEDDECLARATIONELIMINATIONPASS
796template <
typename DerivedT>
797class UnusedDeclarationEliminationPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
799 using Base = UnusedDeclarationEliminationPassBase;
801 UnusedDeclarationEliminationPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
802 UnusedDeclarationEliminationPassBase(
const UnusedDeclarationEliminationPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
803 UnusedDeclarationEliminationPassBase& operator=(
const UnusedDeclarationEliminationPassBase &) =
delete;
804 UnusedDeclarationEliminationPassBase(UnusedDeclarationEliminationPassBase &&) =
delete;
805 UnusedDeclarationEliminationPassBase& operator=(UnusedDeclarationEliminationPassBase &&) =
delete;
806 ~UnusedDeclarationEliminationPassBase() =
default;
809 static constexpr ::llvm::StringLiteral getArgumentName() {
810 return ::llvm::StringLiteral(
"llzk-unused-declaration-elim");
812 ::llvm::StringRef getArgument()
const override {
return "llzk-unused-declaration-elim"; }
814 ::llvm::StringRef getDescription()
const override {
return R
"PD(Remove unused member and struct declarations)PD"; }
817 static constexpr ::llvm::StringLiteral getPassName() {
818 return ::llvm::StringLiteral(
"UnusedDeclarationEliminationPass");
820 ::llvm::StringRef getName()
const override {
return "UnusedDeclarationEliminationPass"; }
823 static bool classof(const ::mlir::Pass *pass) {
824 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
828 std::unique_ptr<::mlir::Pass> clonePass()
const override {
829 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
833 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
834 registry.insert<llzk::LLZKDialect>();
835 registry.insert<llzk::boolean::BoolDialect>();
836 registry.insert<llzk::array::ArrayDialect>();
837 registry.insert<llzk::component::StructDialect>();
838 registry.insert<llzk::constrain::ConstrainDialect>();
839 registry.insert<llzk::felt::FeltDialect>();
840 registry.insert<llzk::global::GlobalDialect>();
841 registry.insert<llzk::include::IncludeDialect>();
842 registry.insert<llzk::function::FunctionDialect>();
843 registry.insert<llzk::string::StringDialect>();
844 registry.insert<llzk::polymorphic::PolymorphicDialect>();
845 registry.insert<mlir::arith::ArithDialect>();
846 registry.insert<mlir::scf::SCFDialect>();
852 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(UnusedDeclarationEliminationPassBase<DerivedT>)
854 UnusedDeclarationEliminationPassBase(UnusedDeclarationEliminationPassOptions options) : UnusedDeclarationEliminationPassBase() {
855 removeStructs = std::move(options.removeStructs);
858 ::mlir::Pass::Option<bool> removeStructs{*
this,
"remove-structs", ::llvm::cl::desc(R
"PO(Whether to remove unused struct definitions as well. Requires module to declare a Main component, otherwise all components will appear unused.)PO"), ::llvm::cl::init(false)};
862 return std::make_unique<DerivedT>();
866 return std::make_unique<DerivedT>(std::move(options));
872 return impl::createUnusedDeclarationEliminationPass();
876 return impl::createUnusedDeclarationEliminationPass(std::move(options));
878#undef GEN_PASS_DEF_UNUSEDDECLARATIONELIMINATIONPASS
884#ifdef GEN_PASS_DECL_WHILETOFORPASS
886#undef GEN_PASS_DECL_WHILETOFORPASS
888#ifdef GEN_PASS_DEF_WHILETOFORPASS
895template <
typename DerivedT>
896class WhileToForPassBase :
public ::mlir::OperationPass<::mlir::ModuleOp> {
898 using Base = WhileToForPassBase;
900 WhileToForPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
901 WhileToForPassBase(
const WhileToForPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
902 WhileToForPassBase& operator=(
const WhileToForPassBase &) =
delete;
903 WhileToForPassBase(WhileToForPassBase &&) =
delete;
904 WhileToForPassBase& operator=(WhileToForPassBase &&) =
delete;
905 ~WhileToForPassBase() =
default;
908 static constexpr ::llvm::StringLiteral getArgumentName() {
909 return ::llvm::StringLiteral(
"llzk-while-to-for");
911 ::llvm::StringRef getArgument()
const override {
return "llzk-while-to-for"; }
913 ::llvm::StringRef getDescription()
const override {
return R
"PD(Converts scf.while loops to equivalent scf.for loops when possible)PD"; }
916 static constexpr ::llvm::StringLiteral getPassName() {
917 return ::llvm::StringLiteral(
"WhileToForPass");
919 ::llvm::StringRef getName()
const override {
return "WhileToForPass"; }
922 static bool classof(const ::mlir::Pass *pass) {
923 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
927 std::unique_ptr<::mlir::Pass> clonePass()
const override {
928 return std::make_unique<DerivedT>(*
static_cast<const DerivedT *
>(
this));
932 void getDependentDialects(::mlir::DialectRegistry ®istry)
const override {
933 registry.insert<llzk::LLZKDialect>();
934 registry.insert<llzk::boolean::BoolDialect>();
935 registry.insert<llzk::array::ArrayDialect>();
936 registry.insert<llzk::component::StructDialect>();
937 registry.insert<llzk::constrain::ConstrainDialect>();
938 registry.insert<llzk::felt::FeltDialect>();
939 registry.insert<llzk::global::GlobalDialect>();
940 registry.insert<llzk::include::IncludeDialect>();
941 registry.insert<llzk::function::FunctionDialect>();
942 registry.insert<llzk::string::StringDialect>();
943 registry.insert<llzk::polymorphic::PolymorphicDialect>();
944 registry.insert<mlir::arith::ArithDialect>();
945 registry.insert<mlir::scf::SCFDialect>();
951 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(WhileToForPassBase<DerivedT>)
957 return std::make_unique<DerivedT>();
963 return impl::createWhileToForPass();
965#undef GEN_PASS_DEF_WHILETOFORPASS
967#ifdef GEN_PASS_REGISTRATION
969#define GEN_PASS_REGISTRATION_COMPUTECONSTRAINTOPRODUCTPASS
970#define GEN_PASS_REGISTRATION_ENFORCENOMEMBEROVERWRITEPASS
971#define GEN_PASS_REGISTRATION_FUSEPRODUCTCONTROLFLOWPASS
972#define GEN_PASS_REGISTRATION_INLINEFREEFUNCTIONSPASS
973#define GEN_PASS_REGISTRATION_POLYLOWERINGPASS
974#define GEN_PASS_REGISTRATION_REDUNDANTOPERATIONELIMINATIONPASS
975#define GEN_PASS_REGISTRATION_REDUNDANTREADANDWRITEELIMINATIONPASS
976#define GEN_PASS_REGISTRATION_REMOVEUNUSEDDISCARDABLEALLOCATIONSPASS
977#define GEN_PASS_REGISTRATION_UNUSEDDECLARATIONELIMINATIONPASS
978#define GEN_PASS_REGISTRATION_WHILETOFORPASS
984#ifdef GEN_PASS_REGISTRATION_COMPUTECONSTRAINTOPRODUCTPASS
987 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
994 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
999#undef GEN_PASS_REGISTRATION_COMPUTECONSTRAINTOPRODUCTPASS
1005#ifdef GEN_PASS_REGISTRATION_ENFORCENOMEMBEROVERWRITEPASS
1008 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1015 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1020#undef GEN_PASS_REGISTRATION_ENFORCENOMEMBEROVERWRITEPASS
1026#ifdef GEN_PASS_REGISTRATION_FUSEPRODUCTCONTROLFLOWPASS
1029 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1036 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1041#undef GEN_PASS_REGISTRATION_FUSEPRODUCTCONTROLFLOWPASS
1047#ifdef GEN_PASS_REGISTRATION_INLINEFREEFUNCTIONSPASS
1050 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1057 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1062#undef GEN_PASS_REGISTRATION_INLINEFREEFUNCTIONSPASS
1068#ifdef GEN_PASS_REGISTRATION_POLYLOWERINGPASS
1071 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1078 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1083#undef GEN_PASS_REGISTRATION_POLYLOWERINGPASS
1089#ifdef GEN_PASS_REGISTRATION_REDUNDANTOPERATIONELIMINATIONPASS
1092 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1099 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1104#undef GEN_PASS_REGISTRATION_REDUNDANTOPERATIONELIMINATIONPASS
1110#ifdef GEN_PASS_REGISTRATION_REDUNDANTREADANDWRITEELIMINATIONPASS
1113 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1120 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1125#undef GEN_PASS_REGISTRATION_REDUNDANTREADANDWRITEELIMINATIONPASS
1131#ifdef GEN_PASS_REGISTRATION_REMOVEUNUSEDDISCARDABLEALLOCATIONSPASS
1134 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1141 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1146#undef GEN_PASS_REGISTRATION_REMOVEUNUSEDDISCARDABLEALLOCATIONSPASS
1152#ifdef GEN_PASS_REGISTRATION_UNUSEDDECLARATIONELIMINATIONPASS
1155 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1162 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1167#undef GEN_PASS_REGISTRATION_UNUSEDDECLARATIONELIMINATIONPASS
1173#ifdef GEN_PASS_REGISTRATION_WHILETOFORPASS
1176 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1183 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1188#undef GEN_PASS_REGISTRATION_WHILETOFORPASS
1190#ifdef GEN_PASS_REGISTRATION
1208#undef GEN_PASS_REGISTRATION
1210#ifdef GEN_PASS_CLASSES
1211#error "GEN_PASS_CLASSES is deprecated; use per-pass macros"
1212#undef GEN_PASS_CLASSES
void registerTransformationPasses()
std::unique_ptr<::mlir::Pass > createFuseProductControlFlowPass()
std::unique_ptr<::mlir::Pass > createUnusedDeclarationEliminationPass()
std::unique_ptr<::mlir::Pass > createPolyLoweringPass()
std::unique_ptr<::mlir::Pass > createRemoveUnusedDiscardableAllocationsPass()
std::unique_ptr<::mlir::Pass > createInlineFreeFunctionsPass()
std::unique_ptr<::mlir::Pass > createRedundantReadAndWriteEliminationPass()
std::unique_ptr<::mlir::Pass > createRedundantOperationEliminationPass()
std::unique_ptr<::mlir::Pass > createWhileToForPass()
std::unique_ptr<::mlir::Pass > createComputeConstrainToProductPass()
std::unique_ptr<::mlir::Pass > createEnforceNoMemberOverwritePass()
void registerUnusedDeclarationEliminationPassPass()
void registerWhileToForPassPass()
void registerWhileToForPass()
void registerInlineFreeFunctionsPass()
void registerRedundantOperationEliminationPass()
void registerEnforceNoMemberOverwritePassPass()
void registerPolyLoweringPassPass()
void registerUnusedDeclarationEliminationPass()
void registerComputeConstrainToProductPassPass()
void registerFuseProductControlFlowPass()
void registerRedundantOperationEliminationPassPass()
void registerFuseProductControlFlowPassPass()
void registerRemoveUnusedDiscardableAllocationsPass()
void registerComputeConstrainToProductPass()
void registerRedundantReadAndWriteEliminationPass()
void registerPolyLoweringPass()
void registerInlineFreeFunctionsPassPass()
void registerRedundantReadAndWriteEliminationPassPass()
void registerRemoveUnusedDiscardableAllocationsPassPass()
void registerEnforceNoMemberOverwritePass()