LLZK 2.1.1
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
TransformationPasses.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_EMPTYTEMPLATEREMOVALPASS
6#define GEN_PASS_DECL_FLATTENINGPASS
7#undef GEN_PASS_DECL
8#endif // GEN_PASS_DECL
9
10//===----------------------------------------------------------------------===//
11// EmptyTemplateRemovalPass
12//===----------------------------------------------------------------------===//
13#ifdef GEN_PASS_DECL_EMPTYTEMPLATEREMOVALPASS
14std::unique_ptr<::mlir::Pass> createEmptyTemplateRemovalPass();
15#undef GEN_PASS_DECL_EMPTYTEMPLATEREMOVALPASS
16#endif // GEN_PASS_DECL_EMPTYTEMPLATEREMOVALPASS
17#ifdef GEN_PASS_DEF_EMPTYTEMPLATEREMOVALPASS
18
19namespace impl {
20 std::unique_ptr<::mlir::Pass> createEmptyTemplateRemovalPass();
21} // namespace impl
22namespace impl {
23
24template <typename DerivedT>
25class EmptyTemplateRemovalPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
26public:
27 using Base = EmptyTemplateRemovalPassBase;
28
29 EmptyTemplateRemovalPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
30 EmptyTemplateRemovalPassBase(const EmptyTemplateRemovalPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
31 EmptyTemplateRemovalPassBase& operator=(const EmptyTemplateRemovalPassBase &) = delete;
32 EmptyTemplateRemovalPassBase(EmptyTemplateRemovalPassBase &&) = delete;
33 EmptyTemplateRemovalPassBase& operator=(EmptyTemplateRemovalPassBase &&) = delete;
34 ~EmptyTemplateRemovalPassBase() = default;
35
37 static constexpr ::llvm::StringLiteral getArgumentName() {
38 return ::llvm::StringLiteral("llzk-drop-empty-templates");
39 }
40 ::llvm::StringRef getArgument() const override { return "llzk-drop-empty-templates"; }
41
42 ::llvm::StringRef getDescription() const override { return "Remove empty templates"; }
43
45 static constexpr ::llvm::StringLiteral getPassName() {
46 return ::llvm::StringLiteral("EmptyTemplateRemovalPass");
47 }
48 ::llvm::StringRef getName() const override { return "EmptyTemplateRemovalPass"; }
49
51 static bool classof(const ::mlir::Pass *pass) {
52 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
53 }
54
56 std::unique_ptr<::mlir::Pass> clonePass() const override {
57 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
58 }
59
61 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
62 registry.insert<llzk::LLZKDialect>();
63 registry.insert<llzk::boolean::BoolDialect>();
64 registry.insert<llzk::array::ArrayDialect>();
65 registry.insert<llzk::component::StructDialect>();
66 registry.insert<llzk::constrain::ConstrainDialect>();
67 registry.insert<llzk::felt::FeltDialect>();
68 registry.insert<llzk::global::GlobalDialect>();
69 registry.insert<llzk::include::IncludeDialect>();
70 registry.insert<llzk::function::FunctionDialect>();
71 registry.insert<llzk::string::StringDialect>();
72 registry.insert<llzk::polymorphic::PolymorphicDialect>();
73 registry.insert<mlir::arith::ArithDialect>();
74 registry.insert<mlir::scf::SCFDialect>();
75 }
76
80 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(EmptyTemplateRemovalPassBase<DerivedT>)
81
82protected:
83private:
84
85 friend std::unique_ptr<::mlir::Pass> createEmptyTemplateRemovalPass() {
86 return std::make_unique<DerivedT>();
87 }
88};
89} // namespace impl
90
91std::unique_ptr<::mlir::Pass> createEmptyTemplateRemovalPass() {
92 return impl::createEmptyTemplateRemovalPass();
93}
94#undef GEN_PASS_DEF_EMPTYTEMPLATEREMOVALPASS
95#endif // GEN_PASS_DEF_EMPTYTEMPLATEREMOVALPASS
96
97//===----------------------------------------------------------------------===//
98// FlatteningPass
99//===----------------------------------------------------------------------===//
100#ifdef GEN_PASS_DECL_FLATTENINGPASS
101struct FlatteningPassOptions {
102 unsigned iterationLimit = 1000;
104};
105std::unique_ptr<::mlir::Pass> createFlatteningPass();
106std::unique_ptr<::mlir::Pass> createFlatteningPass(FlatteningPassOptions options);
107#undef GEN_PASS_DECL_FLATTENINGPASS
108#endif // GEN_PASS_DECL_FLATTENINGPASS
109#ifdef GEN_PASS_DEF_FLATTENINGPASS
110
111namespace impl {
112 std::unique_ptr<::mlir::Pass> createFlatteningPass();
113} // namespace impl
114
115namespace impl {
116 std::unique_ptr<::mlir::Pass> createFlatteningPass(FlatteningPassOptions options);
117} // namespace impl
118namespace impl {
119
120template <typename DerivedT>
121class FlatteningPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
122public:
123 using Base = FlatteningPassBase;
124
125 FlatteningPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
126 FlatteningPassBase(const FlatteningPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
127 FlatteningPassBase& operator=(const FlatteningPassBase &) = delete;
128 FlatteningPassBase(FlatteningPassBase &&) = delete;
129 FlatteningPassBase& operator=(FlatteningPassBase &&) = delete;
130 ~FlatteningPassBase() = default;
131
133 static constexpr ::llvm::StringLiteral getArgumentName() {
134 return ::llvm::StringLiteral("llzk-flatten");
135 }
136 ::llvm::StringRef getArgument() const override { return "llzk-flatten"; }
137
138 ::llvm::StringRef getDescription() const override { return "Flatten structs and unroll loops"; }
139
141 static constexpr ::llvm::StringLiteral getPassName() {
142 return ::llvm::StringLiteral("FlatteningPass");
143 }
144 ::llvm::StringRef getName() const override { return "FlatteningPass"; }
145
147 static bool classof(const ::mlir::Pass *pass) {
148 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
149 }
150
152 std::unique_ptr<::mlir::Pass> clonePass() const override {
153 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
154 }
155
157 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
158 registry.insert<llzk::LLZKDialect>();
159 registry.insert<llzk::boolean::BoolDialect>();
160 registry.insert<llzk::array::ArrayDialect>();
161 registry.insert<llzk::component::StructDialect>();
162 registry.insert<llzk::constrain::ConstrainDialect>();
163 registry.insert<llzk::felt::FeltDialect>();
164 registry.insert<llzk::global::GlobalDialect>();
165 registry.insert<llzk::include::IncludeDialect>();
166 registry.insert<llzk::function::FunctionDialect>();
167 registry.insert<llzk::string::StringDialect>();
168 registry.insert<llzk::polymorphic::PolymorphicDialect>();
169 registry.insert<mlir::arith::ArithDialect>();
170 registry.insert<mlir::scf::SCFDialect>();
171 }
172
176 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FlatteningPassBase<DerivedT>)
177
178 FlatteningPassBase(FlatteningPassOptions options) : FlatteningPassBase() {
179 iterationLimit = std::move(options.iterationLimit);
180 cleanupMode = std::move(options.cleanupMode);
181 }
182protected:
183 ::mlir::Pass::Option<unsigned> iterationLimit{*this, "max-iter", ::llvm::cl::desc("Maximum number of times the pass will run if a fixpoint is not reached earlier. Unrolling loops can provide more opportunities for instantiating structs but the converse is true as well. Thus, the pass will run multiple times until no further changes can be made or the upper limit provided in this option is reached."), ::llvm::cl::init(1000)};
184 ::mlir::Pass::Option<::llzk::polymorphic::FlatteningCleanupMode> cleanupMode{*this, "cleanup", ::llvm::cl::desc("Specifies the extent to which unused parameterized definitions (i.e. structs or free functions within a `poly.template`) are removed during the flattening pass."), ::llvm::cl::init(::llzk::polymorphic::FlatteningCleanupMode::Preimage), ::llvm::cl::values(
189 "Only definitions that were replaced with concrete instantiations are deleted."),
192 "All definitions that cannot be reached by a use-def chain from some concrete definition are deleted."),
195 "All definitions that cannot be reached by a use-def chain from the \"Main\" struct are deleted.")
196 )};
197private:
198
199 friend std::unique_ptr<::mlir::Pass> createFlatteningPass() {
200 return std::make_unique<DerivedT>();
201 }
202
203 friend std::unique_ptr<::mlir::Pass> createFlatteningPass(FlatteningPassOptions options) {
204 return std::make_unique<DerivedT>(std::move(options));
205 }
206};
207} // namespace impl
208
209std::unique_ptr<::mlir::Pass> createFlatteningPass() {
210 return impl::createFlatteningPass();
211}
212
213std::unique_ptr<::mlir::Pass> createFlatteningPass(FlatteningPassOptions options) {
214 return impl::createFlatteningPass(std::move(options));
215}
216#undef GEN_PASS_DEF_FLATTENINGPASS
217#endif // GEN_PASS_DEF_FLATTENINGPASS
218#ifdef GEN_PASS_REGISTRATION
219
220//===----------------------------------------------------------------------===//
221// EmptyTemplateRemovalPass Registration
222//===----------------------------------------------------------------------===//
223
225 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
227 });
228}
229
230// Old registration code, kept for temporary backwards compatibility.
232 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
234 });
235}
236
237//===----------------------------------------------------------------------===//
238// FlatteningPass Registration
239//===----------------------------------------------------------------------===//
240
241inline void registerFlatteningPass() {
242 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
243 return createFlatteningPass();
244 });
245}
246
247// Old registration code, kept for temporary backwards compatibility.
248inline void registerFlatteningPassPass() {
249 ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
250 return createFlatteningPass();
251 });
252}
253
254//===----------------------------------------------------------------------===//
255// Transformation Registration
256//===----------------------------------------------------------------------===//
257
258inline void registerTransformationPasses() {
261}
262#undef GEN_PASS_REGISTRATION
263#endif // GEN_PASS_REGISTRATION
264// Deprecated. Please use the new per-pass macros.
265#ifdef GEN_PASS_CLASSES
266
267template <typename DerivedT>
268class EmptyTemplateRemovalPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
269public:
270 using Base = EmptyTemplateRemovalPassBase;
271
272 EmptyTemplateRemovalPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
273 EmptyTemplateRemovalPassBase(const EmptyTemplateRemovalPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
274 EmptyTemplateRemovalPassBase& operator=(const EmptyTemplateRemovalPassBase &) = delete;
275 EmptyTemplateRemovalPassBase(EmptyTemplateRemovalPassBase &&) = delete;
276 EmptyTemplateRemovalPassBase& operator=(EmptyTemplateRemovalPassBase &&) = delete;
277 ~EmptyTemplateRemovalPassBase() = default;
278
280 static constexpr ::llvm::StringLiteral getArgumentName() {
281 return ::llvm::StringLiteral("llzk-drop-empty-templates");
282 }
283 ::llvm::StringRef getArgument() const override { return "llzk-drop-empty-templates"; }
284
285 ::llvm::StringRef getDescription() const override { return "Remove empty templates"; }
286
288 static constexpr ::llvm::StringLiteral getPassName() {
289 return ::llvm::StringLiteral("EmptyTemplateRemovalPass");
290 }
291 ::llvm::StringRef getName() const override { return "EmptyTemplateRemovalPass"; }
292
294 static bool classof(const ::mlir::Pass *pass) {
295 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
296 }
297
299 std::unique_ptr<::mlir::Pass> clonePass() const override {
300 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
301 }
302
304 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
305 registry.insert<llzk::LLZKDialect>();
306 registry.insert<llzk::boolean::BoolDialect>();
307 registry.insert<llzk::array::ArrayDialect>();
308 registry.insert<llzk::component::StructDialect>();
309 registry.insert<llzk::constrain::ConstrainDialect>();
310 registry.insert<llzk::felt::FeltDialect>();
311 registry.insert<llzk::global::GlobalDialect>();
312 registry.insert<llzk::include::IncludeDialect>();
313 registry.insert<llzk::function::FunctionDialect>();
314 registry.insert<llzk::string::StringDialect>();
315 registry.insert<llzk::polymorphic::PolymorphicDialect>();
316 registry.insert<mlir::arith::ArithDialect>();
317 registry.insert<mlir::scf::SCFDialect>();
318 }
319
323 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(EmptyTemplateRemovalPassBase<DerivedT>)
324
325protected:
326};
327
328template <typename DerivedT>
329class FlatteningPassBase : public ::mlir::OperationPass<::mlir::ModuleOp> {
330public:
331 using Base = FlatteningPassBase;
332
333 FlatteningPassBase() : ::mlir::OperationPass<::mlir::ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
334 FlatteningPassBase(const FlatteningPassBase &other) : ::mlir::OperationPass<::mlir::ModuleOp>(other) {}
335 FlatteningPassBase& operator=(const FlatteningPassBase &) = delete;
336 FlatteningPassBase(FlatteningPassBase &&) = delete;
337 FlatteningPassBase& operator=(FlatteningPassBase &&) = delete;
338 ~FlatteningPassBase() = default;
339
341 static constexpr ::llvm::StringLiteral getArgumentName() {
342 return ::llvm::StringLiteral("llzk-flatten");
343 }
344 ::llvm::StringRef getArgument() const override { return "llzk-flatten"; }
345
346 ::llvm::StringRef getDescription() const override { return "Flatten structs and unroll loops"; }
347
349 static constexpr ::llvm::StringLiteral getPassName() {
350 return ::llvm::StringLiteral("FlatteningPass");
351 }
352 ::llvm::StringRef getName() const override { return "FlatteningPass"; }
353
355 static bool classof(const ::mlir::Pass *pass) {
356 return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
357 }
358
360 std::unique_ptr<::mlir::Pass> clonePass() const override {
361 return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
362 }
363
365 void getDependentDialects(::mlir::DialectRegistry &registry) const override {
366 registry.insert<llzk::LLZKDialect>();
367 registry.insert<llzk::boolean::BoolDialect>();
368 registry.insert<llzk::array::ArrayDialect>();
369 registry.insert<llzk::component::StructDialect>();
370 registry.insert<llzk::constrain::ConstrainDialect>();
371 registry.insert<llzk::felt::FeltDialect>();
372 registry.insert<llzk::global::GlobalDialect>();
373 registry.insert<llzk::include::IncludeDialect>();
374 registry.insert<llzk::function::FunctionDialect>();
375 registry.insert<llzk::string::StringDialect>();
376 registry.insert<llzk::polymorphic::PolymorphicDialect>();
377 registry.insert<mlir::arith::ArithDialect>();
378 registry.insert<mlir::scf::SCFDialect>();
379 }
380
384 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FlatteningPassBase<DerivedT>)
385
386protected:
387 ::mlir::Pass::Option<unsigned> iterationLimit{*this, "max-iter", ::llvm::cl::desc("Maximum number of times the pass will run if a fixpoint is not reached earlier. Unrolling loops can provide more opportunities for instantiating structs but the converse is true as well. Thus, the pass will run multiple times until no further changes can be made or the upper limit provided in this option is reached."), ::llvm::cl::init(1000)};
388 ::mlir::Pass::Option<::llzk::polymorphic::FlatteningCleanupMode> cleanupMode{*this, "cleanup", ::llvm::cl::desc("Specifies the extent to which unused parameterized definitions (i.e. structs or free functions within a `poly.template`) are removed during the flattening pass."), ::llvm::cl::init(::llzk::polymorphic::FlatteningCleanupMode::Preimage), ::llvm::cl::values(
393 "Only definitions that were replaced with concrete instantiations are deleted."),
396 "All definitions that cannot be reached by a use-def chain from some concrete definition are deleted."),
399 "All definitions that cannot be reached by a use-def chain from the \"Main\" struct are deleted.")
400 )};
401};
402#undef GEN_PASS_CLASSES
403#endif // GEN_PASS_CLASSES
void registerTransformationPasses()
std::unique_ptr<::mlir::Pass > createEmptyTemplateRemovalPass()
std::unique_ptr<::mlir::Pass > createFlatteningPass()
::llvm::StringRef stringifyFlatteningCleanupMode(FlatteningCleanupMode val)
void registerEmptyTemplateRemovalPassPass()