[clang] [clang] Enable descriptions for --print-supported-extensions (PR #66715)
David Spickett via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 20 01:59:33 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:
Given that this loop is almost the same for normal and experimental extensions, you could move this out into a static function `static void PrintExtensions` that takes a prefix that's either `""` or `"experimental-"`.
This would make it clear that both format in the same way, same padding etc.
https://github.com/llvm/llvm-project/pull/66715
More information about the cfe-commits
mailing list