[clang] [clang] Enable descriptions for --print-supported-extensions (PR #66715)
David Spickett via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 20 03:31:16 PDT 2023
================
@@ -210,24 +210,42 @@ static void verifyTables() {
#endif
}
-void llvm::riscvExtensionsHelp() {
- outs() << "All available -march extensions for RISC-V\n\n";
- outs() << '\t' << left_justify("Name", 20) << "Version\n";
+void llvm::getAllExtensions(StringMap<RISCVExtensionInfo> &ExtMap) {
+ for (const auto &E : SupportedExtensions)
+ ExtMap[E.Name] = {E.Version.Major, E.Version.Minor};
+ for (const auto &E : SupportedExperimentalExtensions)
+ ExtMap[(StringRef("experimental-") + E.Name).str().c_str()] = {
+ E.Version.Major, E.Version.Minor};
+}
+
+void llvm::riscvExtensionsHelp(StringMap<StringRef> llvmDescMap) {
+
+ outs() << "All available -march extensions for RISC-V\n\n"
+ << " " << left_justify("Name", 20) << left_justify("Version", 10)
+ << (llvmDescMap.empty() ? "\n" : "Description\n");
RISCVISAInfo::OrderedExtensionMap ExtMap;
for (const auto &E : SupportedExtensions)
ExtMap[E.Name] = {E.Version.Major, E.Version.Minor};
- for (const auto &E : ExtMap)
- outs() << format("\t%-20s%d.%d\n", E.first.c_str(), E.second.MajorVersion,
- E.second.MinorVersion);
+ for (const auto &E : ExtMap) {
+ std::string Version = std::to_string(E.second.MajorVersion) + "." +
+ std::to_string(E.second.MinorVersion);
+ outs() << format(" %-20s%-10s", E.first.c_str(), Version.c_str())
+ << format(llvmDescMap.empty() ? "\n" : "%s\n",
+ llvmDescMap[E.first].str().c_str());
+ }
----------------
DavidSpickett wrote:
I would given that a reader has to parse the formatting specifiers, a few ifs and a lookup or two. If they only need to do that once that's nice.
But the two loops are visually identical apart from the "experimental-" so it's a close decision.
Go with what you think is best.
https://github.com/llvm/llvm-project/pull/66715
More information about the cfe-commits
mailing list