LLZK 2.1.1
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
AnalysisPasses.td
Go to the documentation of this file.
1//===-- AnalysisPasses.td - LLZK Analysis Passes -----------*- tablegen -*-===//
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//===----------------------------------------------------------------------===//
9
10#ifndef LLZK_ANALYSIS_TD
11#define LLZK_ANALYSIS_TD
12
13include "llzk/Pass/PassBase.td"
14include "mlir/IR/EnumAttr.td"
15
16def OutputStreamDescription {
17 string r = "Specifies the stream to which the pass prints.";
18}
19
20/// Enumeration of the output stream options in LLVM.
21def OutputStream : I32EnumAttr<"OutputStream", OutputStreamDescription.r,
22 [I32EnumAttrCase<"Outs", 1, "outs">,
23 I32EnumAttrCase<"Errs", 2, "errs">,
24 I32EnumAttrCase<"Dbgs", 3, "dbgs">,
25]> {
26 let cppNamespace = "::llzk";
27 let genSpecializedAttr = 0;
28}
29
30/// Reusable pass Option for allowing a pass user to specify the output stream.
31def OutputStreamOption
32 : Option<"outputStream", "stream", "::llzk::OutputStream",
33 /* default */ "::llzk::OutputStream::Errs",
34 OutputStreamDescription.r, [{::llvm::cl::values(
35 clEnumValN(::llzk::OutputStream::Outs, stringifyOutputStream(::llzk::OutputStream::Outs),
36 "Print pass output to 'llvm::outs()'"),
37 clEnumValN(::llzk::OutputStream::Errs, stringifyOutputStream(::llzk::OutputStream::Errs),
38 "Print pass output to 'llvm::errs()'"),
39 clEnumValN(::llzk::OutputStream::Dbgs, stringifyOutputStream(::llzk::OutputStream::Dbgs),
40 "Print pass output to 'llvm::dbgs()'")
41 )}]>;
42
43/// Reusable pass Option allowing pass user to specify whether or not to dump
44/// the DOT graph to file.
45def SaveDotGraphOption
46 : Option<"saveDotGraph", "saveDot", "bool",
47 /* default */ "false", "Whether to dump the graph to DOT format.">;
48
49//===----------------------------------------------------------------------===//
50// Analysis Pass definitions
51//===----------------------------------------------------------------------===//
52
53def CallGraphPrinterPass : LLZKPass<"llzk-print-call-graph"> {
54 let summary = "Print the LLZK module's call graph.";
55 let options = [OutputStreamOption];
56}
57
58def CallGraphSCCsPrinterPass : LLZKPass<"llzk-print-call-graph-sccs"> {
59 let summary = "Print the SCCs from the LLZK module's call graph.";
60 let options = [OutputStreamOption];
61}
62
63def ConstraintDependencyGraphPrinterPass
64 : LLZKPass<"llzk-print-constraint-dependency-graphs"> {
65 let summary = "Print constraint dependency graph for all LLZK structs.";
66 let options = [OutputStreamOption,
67 Option<"runIntraprocedural", "intraprocedural", "bool",
68 /* default */ "false",
69 "Whether to run the analysis intra-procedurally only "
70 "(default is false).">];
71}
72
73def IntervalAnalysisPrinterPass : LLZKPass<"llzk-print-interval-analysis"> {
74 let summary = "Print interval analysis results for all LLZK structs.";
75 let options =
76 [OutputStreamOption,
77 Option<"fieldName", "field", "std::string", /* default */ "\"\"",
78 "The field to use for interval analysis. If supplied, this "
79 "always overrides the module's detected field. If omitted, the "
80 "pass first tries to detect a single field from the enclosing "
81 "module's felt usage "
82 "and otherwise falls back to bn128. Supported fields: "
83 "bn128/bn254, babybear, goldilocks, grumpkin, koalabear, "
84 "mersenne31">,
85 Option<"propagateInputConstraints", "propagate-input-constraints",
86 "bool", /* default */ "false",
87 "Whether to propagate constraints on inputs from @constrain to "
88 "@compute functions. "
89 "This allows for tighter intervals to possibly be found for "
90 "computed values, "
91 "assuming that the witness generator would include constraints "
92 "as assertions during the computation.">,
93 Option<"printSolverConstraints", "print-solver-constraints", "bool",
94 /* default */ "false",
95 "Whether to output SMT solver constraints along with intervals.">,
96 Option<"printComputeIntervals", "print-compute-intervals", "bool",
97 /* default */ "false",
98 "Whether to print compute function intervals (default only "
99 "prints constrain function intervals).">,
100 Option<"printUnreducedIntervals", "print-unreduced-intervals", "bool",
101 /* default */ "false",
102 "Whether to print tracked unreduced intervals alongside reduced "
103 "interval summaries.">,
104 Option<"printSSAIntervals", "print-ssa-intervals", "bool",
105 /* default */ "false",
106 "Whether to print per-SSA intervals for function arguments and "
107 "scalar op results.">,
108 ];
109}
110
111def SymbolDefTreePrinterPass : LLZKPass<"llzk-print-symbol-def-tree"> {
112 let summary = "Print symbol definition tree.";
113 let options = [OutputStreamOption, SaveDotGraphOption];
114}
115
116def SymbolUseGraphPrinterPass : LLZKPass<"llzk-print-symbol-use-graph"> {
117 let summary = "Print symbol use graph.";
118 let options = [OutputStreamOption, SaveDotGraphOption];
119}
120
121def PredecessorPrinterPass : LLZKPass<"llzk-print-predecessors"> {
122 let summary = "Print the predecessors of all operations.";
123 let options = [OutputStreamOption,
124 Option<"preRunRequiredAnalyses", "prerun", "bool",
125 /* default */ "false",
126 "Whether to pre-run the required dataflow analyses "
127 "(e.g., liveness analysis).">];
128}
129
130#endif // LLZK_ANALYSIS_TD