20#include <mlir/Pass/PassManager.h>
21#include <mlir/Pass/PassRegistry.h>
22#include <mlir/Transforms/Passes.h>
36template <
typename NestedPassOptionT>
37inline std::unique_ptr<Pass> createConfiguredPass(
const NestedPassOptionT &options) {
38 return options.getValue().createPass();
41void buildFullStructInliningPipelineImpl(
43 bool podToScalar, std::unique_ptr<Pass> inliningPass
55 pm.addPass(mlir::createCanonicalizerPass());
60 pm.addPass(mlir::createCanonicalizerPass());
72 pm.addPass(mlir::createCanonicalizerPass());
73 pm.addPass(std::move(inliningPass));
81void buildFullPolyLoweringPipelineImpl(
83 bool podToScalar, std::unique_ptr<Pass> inliningPass, std::unique_ptr<Pass> polyLoweringPass
86 buildFullStructInliningPipelineImpl(
87 pm, flattening, arrayToScalar, podToScalar, std::move(inliningPass)
90 pm.addPass(std::move(polyLoweringPass));
113 buildFullStructInliningPipelineImpl(
123 buildFullStructInliningPipelineImpl(
130 buildFullPolyLoweringPipelineImpl(
144 pm.addPass(mlir::createCanonicalizerPass());
148 pm.addPass(mlir::createCanonicalizerPass());
153 PassPipelineRegistration<>(
154 "llzk-constraint-flattening",
155 "Monomorphize templates, expose child members, and expand main constrain",
159 PassPipelineRegistration<>(
160 "llzk-remove-unnecessary-ops",
161 "Remove unnecessary operations, such as redundant reads or repeated constraints",
165 PassPipelineRegistration<>(
166 "llzk-remove-unnecessary-ops-and-defs",
167 "Remove unnecessary operations, member definitions, and struct definitions",
171 PassPipelineRegistration<>(
172 "llzk-product-program",
173 "Convert @compute/@constrain functions to @product function and perform alignment",
177 PassPipelineRegistration<FullStructInliningOptions>(
178 "llzk-full-struct-inlining",
179 "Run flattening and inlining of all struct definitions into the `main` struct. This "
180 "pipeline uses the `main-as-root` cleanup mode in the flattening pass by default. It "
181 "is not recommended to override this cleanup mode because other cleanup modes may "
182 "leave behind parameterized templates that later cause `llzk-inline-structs` to crash.",
184 auto flattening = opts.
flattening.getValue().createOptions();
185 buildFullStructInliningPipelineImpl(
192 PassPipelineRegistration<FullStructInliningOptions>(
193 "llzk-full-inlining",
194 "Run free function inlining, flattening, and struct inlining. This is the "
195 "recommended pipeline before any downstream pass that does not understand `function.call`.",
197 auto flattening = opts.
flattening.getValue().createOptions();
201 buildFullStructInliningPipelineImpl(
208 PassPipelineRegistration<FullPolyLoweringOptions>(
209 "llzk-full-poly-lowering",
210 "Run flattening and inlining of all struct definitions into the `main` struct, then lower "
211 "polynomial constraints to a given max degree, and finally remove unnecessary operations and "
212 "definitions. This pipeline uses the `main-as-root` cleanup mode in the flattening pass by "
213 "default. It is not recommended to override this cleanup mode because other cleanup modes "
214 "may leave behind parameterized templates that later cause `llzk-inline-structs` to crash.",
216 auto structInlining = opts.structInlining.getValue().createOptions();
217 auto flattening = structInlining->
flattening.getValue().createOptions();
218 buildFullPolyLoweringPipelineImpl(
219 pm, flattening->createPassOptions(), structInlining->arrayToScalar,
220 structInlining->podToScalar, createConfiguredPass(structInlining->inlining),
221 createConfiguredPass(opts.polyLowering)
std::unique_ptr<::mlir::Pass > createArrayToScalarPass()
std::unique_ptr<::mlir::Pass > createExposeChildMembersPass()
std::unique_ptr<::mlir::Pass > createInlineStructsPass()
std::unique_ptr<::mlir::Pass > createPodToScalarPass()
std::unique_ptr<::mlir::Pass > createConstraintFlatteningPass()
std::unique_ptr<::mlir::Pass > createTemplateMonomorphizationPass()
std::unique_ptr<::mlir::Pass > createFlatteningPass()
void buildRemoveUnnecessaryOpsAndDefsPipeline(mlir::OpPassManager &pm)
void registerTransformationPassPipelines()
std::unique_ptr<::mlir::Pass > createInlineFreeFunctionsPass()
std::unique_ptr<::mlir::Pass > createFuseProductControlFlowPass()
std::unique_ptr<::mlir::Pass > createPolyLoweringPass()
std::unique_ptr<::mlir::Pass > createWhileToForPass()
std::unique_ptr<::mlir::Pass > createUnusedDeclarationEliminationPass()
void buildProductProgramPipeline(OpPassManager &pm)
void buildFullStructInliningPipeline(OpPassManager &pm, const FullStructInliningConfig &cfg)
void buildFullPolyLoweringPipeline(OpPassManager &pm, const FullPolyLoweringConfig &cfg)
void buildConstraintFlatteningPipeline(OpPassManager &pm)
std::unique_ptr<::mlir::Pass > createComputeConstrainToProductPass()
std::unique_ptr<::mlir::Pass > createRedundantOperationEliminationPass()
void buildFullInliningPipeline(OpPassManager &pm, const FullStructInliningConfig &cfg)
std::unique_ptr<::mlir::Pass > createRedundantReadAndWriteEliminationPass()
void buildRemoveUnnecessaryOpsPipeline(mlir::OpPassManager &pm)
Pure C++ configuration for the full polynomial lowering pipeline.
PolyLoweringPassOptions polyLowering
FullStructInliningConfig structInlining
CLI Option configuration for the full polynomial lowering pipeline.
Pure C++ configuration for the full struct inlining pipeline.
polymorphic::FlatteningPassOptions flattening
component::InlineStructsPassOptions inlining
CLI Option configuration for the full struct inlining pipeline.
Option< FlatteningOptions > flattening
Option< bool > arrayToScalar
Option< InliningOptions > inlining
Option< bool > podToScalar