diff --git a/compiler/src/main.cpp b/compiler/src/main.cpp index 2d29f5ec0..5eef41b0f 100644 --- a/compiler/src/main.cpp +++ b/compiler/src/main.cpp @@ -1,7 +1,8 @@ #include -#include +#include +#include #include #include @@ -10,50 +11,30 @@ #include "zamalang/Dialect/MidLFHE/IR/MidLFHEDialect.h" #include "zamalang/Dialect/MidLFHE/IR/MidLFHETypes.h" -struct CommandLineArgs { - std::vector inputs; - std::string output; -}; +namespace cmdline { +llvm::cl::list inputs(llvm::cl::Positional, + llvm::cl::desc(""), + llvm::cl::OneOrMore); -void parseCommandLine(int argc, char **argv, CommandLineArgs *args) { - try { - TCLAP::CmdLine cmd("zamacompiler", ' ', "0.0.1"); - // Input file names - TCLAP::UnlabeledMultiArg fileNames("file", "The input files", - false, "file"); - cmd.add(fileNames); - - // Output - TCLAP::ValueArg output( - "o", "out", "Place the output into the ", false, "", "string"); - cmd.add(output); - - cmd.parse(argc, argv); - args->output = output.getValue(); - args->inputs = fileNames.getValue(); - - } catch (TCLAP::ArgException &e) // catch exceptions - { - std::cerr << "error: " << e.error() << " for arg " << e.argId() - << std::endl; - std::exit(1); - } -} +llvm::cl::opt output("o", + llvm::cl::desc("Specify output filename"), + llvm::cl::value_desc("filename")); +}; // namespace cmdline int main(int argc, char **argv) { // Parse command line arguments - CommandLineArgs cmdLineArgs; - parseCommandLine(argc, argv, &cmdLineArgs); + llvm::cl::ParseCommandLineOptions(argc, argv); // Initialize the MLIR context mlir::MLIRContext context; + // Load our Dialect in this MLIR Context. context.getOrLoadDialect(); context.getOrLoadDialect(); context.getOrLoadDialect(); // For all input file, parse and dump - for (const auto &fileName : cmdLineArgs.inputs) { + for (const auto &fileName : cmdline::inputs) { auto module = mlir::parseSourceFile(fileName, &context); if (!module) { exit(1);