LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
TransformationPassPipelines.cpp
Go to the documentation of this file.
1//===-- TransformationPassPipeline.cpp --------------------------*- C++ -*-===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2025 Veridise Inc.
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
14//===----------------------------------------------------------------------===//
15
17
18#include <mlir/Pass/PassManager.h>
19#include <mlir/Pass/PassRegistry.h>
20#include <mlir/Transforms/Passes.h>
21
22using namespace mlir;
23
24namespace llzk {
25
26struct FullPolyLoweringOptions : public PassPipelineOptions<FullPolyLoweringOptions> {
27 Option<unsigned> maxDegree {
28 *this, "max-degree", llvm::cl::desc("Maximum polynomial degree (must be ≥ 2)"),
29 llvm::cl::init(2)
30 };
31};
32
38
40 PassPipelineRegistration<>(
41 "llzk-remove-unnecessary-ops",
42 "Remove unnecessary operations, such as redundant reads or repeated constraints",
43 [](OpPassManager &pm) {
46 }
47 );
48
49 PassPipelineRegistration<>(
50 "llzk-remove-unnecessary-ops-and-defs",
51 "Remove unnecessary operations, field definitions, and struct definitions",
52 [](OpPassManager &pm) { addRemoveUnnecessaryOpsAndDefsPipeline(pm); }
53 );
54
55 PassPipelineRegistration<FullPolyLoweringOptions>(
56 "llzk-full-poly-lowering",
57 "Lower all polynomial constraints to a given max degree, then remove unnecessary operations "
58 "and definitions.",
59 [](OpPassManager &pm, const FullPolyLoweringOptions &opts) {
60 // 1. Degree lowering
62
63 // 2. Cleanup
65 }
66 );
67
68 PassPipelineRegistration<>(
69 "llzk-full-r1cs-lowering", "Lower all polynomial constraints to r1cs",
70 [](OpPassManager &pm) {
71 // 1. Degree lowering
72 pm.addPass(llzk::createPolyLoweringPass(2));
73
74 // 2. Cleanup
76
77 // 3. Convert to R1CS
78 pm.addPass(llzk::createR1CSLoweringPass());
79
80 // 4. Run CSE to eliminate to_linear ops
81 pm.addPass(mlir::createCSEPass());
82 }
83 );
84}
85
86} // namespace llzk
std::unique_ptr< mlir::Pass > createRedundantOperationEliminationPass()
void registerTransformationPassPipelines()
std::unique_ptr< mlir::Pass > createRedundantReadAndWriteEliminationPass()
std::unique_ptr< mlir::Pass > createUnusedDeclarationEliminationPass()
std::unique_ptr< mlir::Pass > createPolyLoweringPass()
void addRemoveUnnecessaryOpsAndDefsPipeline(OpPassManager &pm)
std::unique_ptr< mlir::Pass > createR1CSLoweringPass()