1//===-- AnalysisPasses.td - LLZK Analysis Passes -----------*- tablegen -*-===//
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
8//===----------------------------------------------------------------------===//
10#ifndef LLZK_ANALYSIS_TD
11#define LLZK_ANALYSIS_TD
13include "llzk/Pass/PassBase.td"
14include "mlir/IR/EnumAttr.td"
16def OutputStreamDescription {
17 string r = "Specifies the stream to which the pass prints.";
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">,
26 let cppNamespace = "::llzk";
27 let genSpecializedAttr = 0;
30/// Reusable pass Option for allowing a pass user to specify the output stream.
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()'")
43/// Reusable pass Option allowing pass user to specify whether or not to dump
44/// the DOT graph to file.
46 : Option<"saveDotGraph", "saveDot", "bool",
47 /* default */ "false", "Whether to dump the graph to DOT format.">;
49//===----------------------------------------------------------------------===//
50// Analysis Pass definitions
51//===----------------------------------------------------------------------===//
53def CallGraphPrinterPass : LLZKPass<"llzk-print-call-graph"> {
54 let summary = "Print the LLZK module's call graph.";
55 let constructor = "llzk::createCallGraphPrinterPass(llvm::errs())";
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())";
63def ConstraintDependencyGraphPrinterPass
64 : LLZKPass<"llzk-print-constraint-dependency-graphs"> {
65 let summary = "Print constraint dependency graph for all LLZK structs.";
67 "llzk::createConstraintDependencyGraphPrinterPass(llvm::errs())";
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())";
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.">,
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];
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];
95#endif // LLZK_ANALYSIS_TD