@@ -630,41 +630,13 @@ LogicalResult mlir::MlirOptMain(llvm::raw_ostream &outputStream,
630630 config.outputSplitMarker ());
631631}
632632
633- LogicalResult mlir::MlirOptMain (int argc, char **argv, llvm::StringRef toolName,
634- DialectRegistry ®istry,
635- const AdditionalRegistrationFn &additionalRegistration) {
636- static cl::opt<std::string> inputFilename (
637- cl::Positional, cl::desc (" <input file>" ), cl::init (" -" ));
638-
639- static cl::opt<std::string> outputFilename (" o" , cl::desc (" Output filename" ),
640- cl::value_desc (" filename" ),
641- cl::init (" -" ));
633+ LogicalResult mlir::MlirOptMain (int argc, char **argv,
634+ llvm::StringRef inputFilename,
635+ llvm::StringRef outputFilename,
636+ DialectRegistry ®istry) {
642637
643638 InitLLVM y (argc, argv);
644639
645- // Register any command line options.
646- registerAsmPrinterCLOptions ();
647- registerMLIRContextCLOptions ();
648- registerPassManagerCLOptions ();
649- registerDefaultTimingManagerCLOptions ();
650- tracing::DebugCounter::registerCLOptions ();
651-
652- // Build the list of dialects as a header for the --help message.
653- std::string helpHeader = (toolName + " \n Available Dialects: " ).str ();
654- {
655- llvm::raw_string_ostream os (helpHeader);
656- interleaveComma (registry.getDialectNames (), os,
657- [&](auto name) { os << name; });
658- }
659-
660- // It is not possible to place a call after command line parser
661- // since not all options are registered at the moment
662- additionalRegistration (helpHeader);
663-
664- MlirOptMainConfig::registerCLOptions (registry);
665-
666- // Parse pass names in main to ensure static initialization completed.
667- cl::ParseCommandLineOptions (argc, argv, helpHeader);
668640 MlirOptMainConfig config = MlirOptMainConfig::createFromCLOptions ();
669641
670642 if (config.shouldShowDialects ())
@@ -701,3 +673,14 @@ LogicalResult mlir::MlirOptMain(int argc, char **argv, llvm::StringRef toolName,
701673 output->keep ();
702674 return success ();
703675}
676+
677+ LogicalResult mlir::MlirOptMain (int argc, char **argv, llvm::StringRef toolName,
678+ DialectRegistry ®istry) {
679+
680+ // Register and parse command line options.
681+ std::string inputFilename, outputFilename;
682+ std::tie (inputFilename, outputFilename) =
683+ registerAndParseCLIOptions (argc, argv, toolName, registry);
684+
685+ return MlirOptMain (argc, argv, inputFilename, outputFilename, registry);
686+ }
0 commit comments