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

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 13:11:43 PDT 2024


================
@@ -116,6 +115,45 @@ 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.find(E.Name) != EnabledFeatureNames.end()) {
----------------
topperc wrote:

You can use `std::set::count`

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


More information about the llvm-commits mailing list