LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
LLZKTransformationPassPipelines.h
Go to the documentation of this file.
1//===-- LLZKTransformationPassPipelines.h -----------------------*- C++ -*-===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2026 Project LLZK
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
9
10#pragma once
11
16
17#include <mlir/Pass/PassManager.h>
18#include <mlir/Pass/PassOptions.h>
19
20namespace llzk {
21
25 : public mlir::PassPipelineOptions<StructInliningFlatteningOptions> {
26 // Implementation note: these options should be kept in sync with the `FlatteningPass` ODS.
27
28 Option<unsigned> iterationLimit {
29 *this, "max-iter", llvm::cl::desc("maximum number of flattening iterations before giving up"),
30 llvm::cl::init(1000)
31 };
32
33 Option<polymorphic::FlatteningCleanupMode> cleanupMode {
34 *this, "cleanup",
35 llvm::cl::desc(
36 "cleanup mode for flattening in this pipeline. When left as `unspecified`, these "
37 "pipelines use `main-as-root`. Overriding this is not recommended because the later "
38 "`llzk-inline-structs` pass may crash if parameterized templates survive flattening."
39 ),
41 };
42
45 .iterationLimit = iterationLimit, .cleanupMode = cleanupMode
46 };
47 }
48};
49
57
59struct FullStructInliningOptions : public mlir::PassPipelineOptions<FullStructInliningOptions> {
60
62
64 static_cast<std::unique_ptr<mlir::Pass> (*)()>(&llzk::component::createInlineStructsPass)>;
65
66 Option<FlatteningOptions> flattening {
67 *this, "flattening",
68 llvm::cl::desc(
69 "options for the flattening pass used in this pipeline; this pipeline defaults "
70 "flattening pass cleanup to `main-as-root`"
71 ),
72 llvm::cl::init(FlatteningOptions {})
73 };
74 Option<bool> arrayToScalar {
75 *this, "array-to-scalar",
76 llvm::cl::desc("whether to run the array-to-scalar pass in this pipeline"),
77 llvm::cl::init(true)
78 };
79 Option<bool> podToScalar {
80 *this, "pod-to-scalar",
81 llvm::cl::desc("whether to run the pod-to-scalar pass in this pipeline"), llvm::cl::init(true)
82 };
83 Option<InliningOptions> inlining {
84 *this, "inlining", llvm::cl::desc("options for the inlining pass used in this pipeline"),
85 llvm::cl::init(InliningOptions {})
86 };
87};
88
94
96struct FullPolyLoweringOptions : public mlir::PassPipelineOptions<FullPolyLoweringOptions> {
97
99
101 static_cast<std::unique_ptr<mlir::Pass> (*)()>(&llzk::createPolyLoweringPass)>;
102
103 Option<StructInliningOptions> structInlining {
104 *this, "flatten-inline",
105 llvm::cl::desc(
106 "options for the struct flattening and inlining pipeline used before polynomial "
107 "lowering; this pipeline defaults flattening cleanup to `main-as-root`"
108 ),
109 llvm::cl::init(StructInliningOptions {})
110 };
111 Option<PolyLoweringOptions> polyLowering {
112 *this, "lowering",
113 llvm::cl::desc("options for the polynomial lowering pass used in this pipeline"),
114 llvm::cl::init(PolyLoweringOptions {})
115 };
116};
117
118void buildRemoveUnnecessaryOpsPipeline(mlir::OpPassManager &);
119
120void buildRemoveUnnecessaryOpsAndDefsPipeline(mlir::OpPassManager &);
121
122void buildFullPolyLoweringPipeline(mlir::OpPassManager &, const FullPolyLoweringConfig &);
123
124void buildProductProgramPipeline(mlir::OpPassManager &);
125
127
128void buildFullInliningPipeline(mlir::OpPassManager &, const FullStructInliningConfig &);
129
131
132} // namespace llzk
std::unique_ptr<::mlir::Pass > createInlineStructsPass()
void buildRemoveUnnecessaryOpsAndDefsPipeline(mlir::OpPassManager &pm)
std::unique_ptr<::mlir::Pass > createPolyLoweringPass()
void buildProductProgramPipeline(OpPassManager &pm)
void buildFullStructInliningPipeline(OpPassManager &pm, const FullStructInliningConfig &cfg)
void buildFullPolyLoweringPipeline(OpPassManager &pm, const FullPolyLoweringConfig &cfg)
void buildFullInliningPipeline(OpPassManager &pm, const FullStructInliningConfig &cfg)
void buildRemoveUnnecessaryOpsPipeline(mlir::OpPassManager &pm)
Pure C++ configuration for the full polynomial lowering pipeline.
CLI Option configuration for the full polynomial lowering pipeline.
NestedPassOptions< static_cast< std::unique_ptr< mlir::Pass >(*)()>(&llzk::createPolyLoweringPass)> PolyLoweringOptions
Option< StructInliningOptions > structInlining
NestedPipelineOptions< FullStructInliningOptions > StructInliningOptions
Pure C++ configuration for the full struct inlining pipeline.
polymorphic::FlatteningPassOptions flattening
component::InlineStructsPassOptions inlining
CLI Option configuration for the full struct inlining pipeline.
NestedPipelineOptions< StructInliningFlatteningOptions > FlatteningOptions
NestedPassOptions< static_cast< std::unique_ptr< mlir::Pass >(*)()>(&llzk::component::createInlineStructsPass)> InliningOptions
Stores textual options for a constituent pass after validating them against that pass' native MLIR op...
Definition Parsers.h:65
Stores textual options for a constituent pipeline after validating them against that pipeline's nativ...
Definition Parsers.h:82
Typed nested options for the flattening pass when used inside the full struct-inlining and full poly-...
polymorphic::FlatteningPassOptions createPassOptions() const
Option< polymorphic::FlatteningCleanupMode > cleanupMode