-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[mlir][NFC] Split registerAndParseCLIOptions() in mlir-opt #166538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -681,17 +681,8 @@ processBuffer(raw_ostream &os, std::unique_ptr<MemoryBuffer> ownedBuffer, | |
| return success(); | ||
| } | ||
|
|
||
| std::pair<std::string, std::string> | ||
| mlir::registerAndParseCLIOptions(int argc, char **argv, | ||
| llvm::StringRef toolName, | ||
| DialectRegistry ®istry) { | ||
| 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("-")); | ||
| // Register any command line options. | ||
| std::string mlir::registerCLIOptions(llvm::StringRef toolName, | ||
| DialectRegistry ®istry) { | ||
| MlirOptMainConfig::registerCLOptions(registry); | ||
| registerAsmPrinterCLOptions(); | ||
| registerMLIRContextCLOptions(); | ||
|
|
@@ -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()); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @weiweichen 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gentle ping. if this is fine, i'd merge it "as is". worst case I can make a follow-up.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, this looks fine then. |
||
| } | ||
|
|
||
| std::pair<std::string, std::string> | ||
| mlir::registerAndParseCLIOptions(int argc, char **argv, | ||
| llvm::StringRef toolName, | ||
| DialectRegistry ®istry) { | ||
| auto helpHeader = registerCLIOptions(toolName, registry); | ||
| return parseCLIOptions(argc, argv, helpHeader); | ||
| } | ||
|
|
||
| static LogicalResult printRegisteredDialects(DialectRegistry ®istry) { | ||
| llvm::outs() << "Available Dialects: "; | ||
| interleave(registry.getDialectNames(), llvm::outs(), ","); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these two stay in
mlir::registerCLIOptionssince they are both registering the options rather than parsing?