[clang] [llvm] [RISCV] Support RISC-V Profiles in -march option (PR #76357)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 10:56:34 PDT 2024


================
@@ -854,6 +895,30 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
                              "string must be lowercase");
   }
 
+  bool IsProfile = Arch.starts_with("rvi") || Arch.starts_with("rva") ||
+                   Arch.starts_with("rvb") || Arch.starts_with("rvm");
+  std::string NewArch;
+  if (IsProfile) {
+    const auto *FoundProfile =
+        llvm::find_if(SupportedProfiles, [&](const RISCVProfile &Profile) {
+          return Arch.starts_with(Profile.Name);
+        });
+
+    if (FoundProfile == std::end(SupportedProfiles))
+      return createStringError(errc::invalid_argument, "unsupported profile");
+
+    NewArch = FoundProfile->MArch;
----------------
michaelmaitland wrote:

Do you need to declare `std::string NewArch;` above or can you introduce it here since it is not used above?

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


More information about the llvm-commits mailing list