[clang] [clang] Enable descriptions for --print-supported-extensions (PR #66715)

Balint Cristian via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 20 03:17:24 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());
+  }
----------------
cbalint13 wrote:

Not sure, does it worth ?

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


More information about the cfe-commits mailing list