[clang] [llvm] [RISCV] Add ability to list extensions enabled for a target (PR #98207)

Michael Maitland via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 10 06:09:49 PDT 2024


================
@@ -116,6 +115,44 @@ void llvm::riscvExtensionsHelp(StringMap<StringRef> DescMap) {
             "For example, clang -march=rv32i_v1p0\n";
 }
 
+void RISCVISAInfo::printEnabledExtensions(
+    bool IsRV64, std::set<StringRef> &EnabledFeatureNames,
+    StringMap<StringRef> &DescMap) {
+  outs() << "Extensions enabled for the given RISC-V target\n\n";
+  PrintExtension("Name", "Version", (DescMap.empty() ? "" : "Description"));
+
+  RISCVISAUtils::OrderedExtensionMap FullExtMap;
+  RISCVISAUtils::OrderedExtensionMap ExtMap;
+  for (const auto &E : SupportedExtensions)
+    if (EnabledFeatureNames.count(E.Name) != 0) {
+      FullExtMap[E.Name] = {E.Version.Major, E.Version.Minor};
+      ExtMap[E.Name] = {E.Version.Major, E.Version.Minor};
+    }
+  for (const auto &E : ExtMap) {
+    std::string Version =
+        std::to_string(E.second.Major) + "." + std::to_string(E.second.Minor);
+    PrintExtension(E.first, Version, DescMap[E.first]);
+  }
----------------
michaelmaitland wrote:

I propose that we print with the current order proposed in this patch (canonical). If we decide that we'd like to change printing order, then we should have a follow up PR that changes print order for both `printSupportedExtensions` and `printEnabledExtensions`.

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


More information about the cfe-commits mailing list