16#include "r1cs/DialectRegistration.h"
18#include "zklean/DialectRegistration.h"
24#include <mlir/IR/DialectRegistry.h>
25#include <mlir/IR/MLIRContext.h>
26#include <mlir/IR/OperationSupport.h>
27#include <mlir/Support/LogicalResult.h>
28#include <mlir/Tools/mlir-opt/MlirOptMain.h>
30#include <llvm/ADT/ArrayRef.h>
31#include <llvm/ADT/StringRef.h>
32#include <llvm/Support/CommandLine.h>
33#include <llvm/Support/PrettyStackTrace.h>
34#include <llvm/Support/Signals.h>
35#include <llvm/Support/raw_ostream.h>
43#include "pcl/DialectRegistration.h"
47static int runMain(
int argc,
char **argv) {
48 llvm::cl::list<std::string> IncludeDirs(
49 "I", llvm::cl::desc(
"Directory of include files"), llvm::cl::value_desc(
"directory"),
53 llvm::cl::opt<bool> PrintAllOps(
54 "print-llzk-ops", llvm::cl::desc(
"Print a list of all ops registered in LLZK")
57 llvm::sys::PrintStackTraceOnErrorSignal(llvm::StringRef());
58 llvm::setBugReportMsg(
60 " and include the crash backtrace, relevant LLZK files,"
61 " and associated run script(s).\n"
63 llvm::cl::AddExtraVersionPrinter([](llvm::raw_ostream &os) {
68 mlir::DialectRegistry registry;
70 r1cs::registerDialects(registry);
71 zklean::registerDialects(registry);
73 pcl::registerDialects(registry);
77 r1cs::registerPasses(registry);
78 zklean::registerPasses(registry);
80 pcl::registerPasses(registry);
84 std::string inputFilename, outputFilename;
85 std::tie(inputFilename, outputFilename) =
86 registerAndParseCLIOptions(argc, argv,
"llzk-opt", registry);
89 mlir::MLIRContext context;
90 context.appendDialectRegistry(registry);
91 context.loadAllAvailableDialects();
92 llvm::outs() <<
"All ops registered in LLZK IR: {\n";
93 for (
const auto &opName : context.getRegisteredOperations()) {
94 llvm::outs().indent(2) << opName.getStringRef() <<
'\n';
96 llvm::outs() <<
"}\n";
106 auto result = mlir::MlirOptMain(argc, argv, inputFilename, outputFilename, registry);
107 return mlir::asMainReturnCode(result);
110int main(
int argc,
char **argv)
noexcept {
112 return runMain(argc, argv);
113 }
catch (
const std::exception &ex) {
114 llvm::errs() <<
"llzk-opt: unhandled exception: " << ex.what() <<
'\n';
116 llvm::errs() <<
"llzk-opt: unhandled non-standard exception\n";
#define LLZK_VERSION_STRING
LLZK version string configured by CMake for this build.
#define LLZK_URL
Project homepage URL configured by CMake.
static GlobalSourceMgr & get()
int main(int argc, char **argv) noexcept
Declares dialect and pass registration functions for core LLZK dialects.
void registerDialects(mlir::DialectRegistry ®istry)
Register core LLZK dialects, the MLIR arith, scf, and smt dialects, and verification extensions in re...
void registerPasses(mlir::DialectRegistry ®istry)
Register LLZK analysis, validation, and transformation passes and pipelines, SMT conversion passes,...