LLZK 0.1.0
Veridise's ZK Language IR
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 constructor = "llzk::createCallGraphPrinterPass(llvm::errs())";
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 constructor = "llzk::createCallGraphSCCsPrinterPass(llvm::errs())";
61}
62
63def ConstraintDependencyGraphPrinterPass
64 : LLZKPass<"llzk-print-constraint-dependency-graphs"> {
65 let summary = "Print constraint dependency graph for all LLZK structs.";
66 let constructor =
67 "llzk::createConstraintDependencyGraphPrinterPass(llvm::errs())";
68}
69
70def IntervalAnalysisPrinterPass : LLZKPass<"llzk-print-interval-analysis"> {
71 let summary = "Print interval analysis results for all LLZK structs.";
72 let constructor = "llzk::createIntervalAnalysisPrinterPass(llvm::errs())";
73 let options =
74 [Option<"fieldName", "field", "std::string", /* default */ "\"bn128\"",
75 "The field to use for interval analysis. Supported fields: "
76 "bn128/bn254, babybear, goldilocks, mersenne31">,
77 Option<"printSolverConstraints", "print-solver-constraints", "bool",
78 /* default */ "false",
79 "Whether to output SMT solver constraints along with intervals.">,
80 ];
81}
82
83def SymbolDefTreePrinterPass : LLZKPass<"llzk-print-symbol-def-tree"> {
84 let summary = "Print symbol definition tree.";
85 let constructor = "llzk::createSymbolDefTreePrinterPass()";
86 let options = [OutputStreamOption, SaveDotGraphOption];
87}
88
89def SymbolUseGraphPrinterPass : LLZKPass<"llzk-print-symbol-use-graph"> {
90 let summary = "Print symbol use graph.";
91 let constructor = "llzk::createSymbolUseGraphPrinterPass()";
92 let options = [OutputStreamOption, SaveDotGraphOption];
93}
94
95#endif // LLZK_ANALYSIS_TD