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
62 pm.addPass(mlir::createCanonicalizerPass());
63 pm.addPass(std::move(inliningPass));
71void buildFullPolyLoweringPipelineImpl(
73 bool podToScalar, std::unique_ptr<Pass> inliningPass, std::unique_ptr<Pass> polyLoweringPass
76 buildFullStructInliningPipelineImpl(
77 pm, flattening, arrayToScalar, podToScalar, std::move(inliningPass)
80 pm.addPass(std::move(polyLoweringPass));
103 buildFullStructInliningPipelineImpl(
113 buildFullStructInliningPipelineImpl(
120 buildFullPolyLoweringPipelineImpl(
133 PassPipelineRegistration<>(
134 "llzk-remove-unnecessary-ops",
135 "Remove unnecessary operations, such as redundant reads or repeated constraints",
139 PassPipelineRegistration<>(
140 "llzk-remove-unnecessary-ops-and-defs",
141 "Remove unnecessary operations, member definitions, and struct definitions",
145 PassPipelineRegistration<>(
146 "llzk-product-program",
147 "Convert @compute/@constrain functions to @product function and perform alignment",
151 PassPipelineRegistration<FullStructInliningOptions>(
152 "llzk-full-struct-inlining",
153 "Run flattening and inlining of all struct definitions into the `main` struct. This "
154 "pipeline uses the `main-as-root` cleanup mode in the flattening pass by default. It "
155 "is not recommended to override this cleanup mode because other cleanup modes may "
156 "leave behind parameterized templates that later cause `llzk-inline-structs` to crash.",
158 auto flattening = opts.
flattening.getValue().createOptions();
159 buildFullStructInliningPipelineImpl(
166 PassPipelineRegistration<FullStructInliningOptions>(
167 "llzk-full-inlining",
168 "Run free function inlining, flattening, and struct inlining. This is the "
169 "recommended pipeline before any downstream pass that does not understand `function.call`.",
171 auto flattening = opts.
flattening.getValue().createOptions();
175 buildFullStructInliningPipelineImpl(
182 PassPipelineRegistration<FullPolyLoweringOptions>(
183 "llzk-full-poly-lowering",
184 "Run flattening and inlining of all struct definitions into the `main` struct, then lower "
185 "polynomial constraints to a given max degree, and finally remove unnecessary operations and "
186 "definitions. This pipeline uses the `main-as-root` cleanup mode in the flattening pass by "
187 "default. It is not recommended to override this cleanup mode because other cleanup modes "
188 "may leave behind parameterized templates that later cause `llzk-inline-structs` to crash.",
190 auto structInlining = opts.structInlining.getValue().createOptions();
191 auto flattening = structInlining->
flattening.getValue().createOptions();
192 buildFullPolyLoweringPipelineImpl(
193 pm, flattening->createPassOptions(), structInlining->arrayToScalar,
194 structInlining->podToScalar, createConfiguredPass(structInlining->inlining),
195 createConfiguredPass(opts.polyLowering)
std::unique_ptr<::mlir::Pass > createArrayToScalarPass()
std::unique_ptr<::mlir::Pass > createInlineStructsPass()
std::unique_ptr<::mlir::Pass > createPodToScalarPass()
std::unique_ptr<::mlir::Pass > createFlatteningPass()
void buildRemoveUnnecessaryOpsAndDefsPipeline(mlir::OpPassManager &pm)
void registerTransformationPassPipelines()
std::unique_ptr<::mlir::Pass > createInlineFreeFunctionsPass()
std::unique_ptr<::mlir::Pass > createPolyLoweringPass()
std::unique_ptr<::mlir::Pass > createUnusedDeclarationEliminationPass()
void buildProductProgramPipeline(OpPassManager &pm)
std::unique_ptr<::mlir::Pass > createFuseProductLoopsPass()
void buildFullStructInliningPipeline(OpPassManager &pm, const FullStructInliningConfig &cfg)
void buildFullPolyLoweringPipeline(OpPassManager &pm, const FullPolyLoweringConfig &cfg)
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