[Mlir-commits] [mlir] [mlir][NFC] Split registerAndParseCLIOptions() in mlir-opt (PR #166538)

Andrei Golubev llvmlistbot at llvm.org
Thu Nov 6 00:19:13 PST 2025


================
@@ -706,11 +697,29 @@ mlir::registerAndParseCLIOptions(int argc, char **argv,
     interleaveComma(registry.getDialectNames(), os,
                     [&](auto name) { os << name; });
   }
-  // Parse pass names in main to ensure static initialization completed.
+  return helpHeader;
+}
+
+std::pair<std::string, std::string>
+mlir::parseCLIOptions(int argc, char **argv, llvm::StringRef helpHeader) {
+  static cl::opt<std::string> inputFilename(
+      cl::Positional, cl::desc("<input file>"), cl::init("-"));
+
+  static cl::opt<std::string> outputFilename("o", cl::desc("Output filename"),
+                                             cl::value_desc("filename"),
+                                             cl::init("-"));
   cl::ParseCommandLineOptions(argc, argv, helpHeader);
   return std::make_pair(inputFilename.getValue(), outputFilename.getValue());
----------------
andrey-golubev wrote:

i need the values here when returning from the "parse" method. if I move them into registration "as is", i'll lose the local variable access.

potentially, these could be moved to `MlirOptMainConfigCLOptions` though?

https://github.com/llvm/llvm-project/pull/166538


More information about the Mlir-commits mailing list