================ @@ -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; + StringRef ArchWithoutProfile = Arch.substr(strlen(FoundProfile->Name)); + if (!ArchWithoutProfile.empty()) { + if (!ArchWithoutProfile.starts_with("_")) + return createStringError( + errc::invalid_argument, + "additional extensions must be after separator '_'"); + NewArch = NewArch + ArchWithoutProfile.str(); ---------------- 4vtomat wrote:
Maybe `NewArch += ArchWithoutProfile.str()` to reduce 1 redundant copy? https://github.com/llvm/llvm-project/pull/76357 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits