[llvm] [llvm] Refactor llc to use OptTable (PR #187901)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 25 01:16:20 PDT 2026
================
@@ -399,19 +497,79 @@ int main(int argc, char **argv) {
initializeScavengerTestPass(*Registry);
SmallVector<PassPlugin, 1> PluginList;
- PassPlugins.setCallback([&](const std::string &PluginPath) {
- auto Plugin = PassPlugin::Load(PluginPath);
- if (!Plugin)
- reportFatalUsageError(Plugin.takeError());
- PluginList.emplace_back(Plugin.get());
- });
- // Register the Target and CPU printer for --version.
- cl::AddExtraVersionPrinter(sys::printDefaultTargetAndDetectedCPU);
- // Register the target printer for --version.
- cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
+ LlcOptTable Tbl;
+ unsigned MissingArgIndex, MissingArgCount;
+ ArrayRef<const char *> ArgsArr = ArrayRef(argv + 1, argc - 1);
+ opt::InputArgList Args =
+ Tbl.ParseArgs(ArgsArr, MissingArgIndex, MissingArgCount);
- cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
+ if (MissingArgCount) {
+ reportError("missing argument to option: " +
+ Twine(Args.getArgString(MissingArgIndex)));
+ }
+
+ if (Args.hasArg(OPT_help)) {
+ Tbl.printHelp(outs(), "llc [options] <input bitcode>",
+ "llvm system compiler");
----------------
aengelke wrote:
Shouldn't we print cl:: help here as well?
https://github.com/llvm/llvm-project/pull/187901
More information about the llvm-commits
mailing list