[llvm] [clang] [RISCV] Relax march string order constraint (PR #78120)
Piyou Chen via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 23 17:53:34 PST 2024
================
@@ -695,6 +696,106 @@ RISCVISAInfo::parseNormalizedArchString(StringRef Arch) {
return std::move(ISAInfo);
}
+static Error splitExtsByUnderscore(StringRef Exts,
+ std::vector<std::string> &SplitExts) {
+ SmallVector<StringRef, 8> Split;
+ if (Exts.empty())
+ return Error::success();
+
+ Exts.split(Split, "_");
+
+ for (auto Ext : Split) {
+ if (Ext.empty())
+ return createStringError(errc::invalid_argument,
+ "extension name missing after separator '_'");
+
+ SplitExts.push_back(Ext.str());
+ }
+ return Error::success();
+}
+
+static Error processMultiLetterExtension(
+ StringRef RawExt,
+ MapVector<std::string, RISCVISAInfo::ExtensionVersion,
+ std::map<std::string, unsigned>> &SeenExtMap,
+ bool IgnoreUnknown, bool EnableExperimentalExtension,
+ bool ExperimentalExtensionVersionCheck) {
+ StringRef Type = getExtensionType(RawExt);
+ StringRef Desc = getExtensionTypeDesc(RawExt);
+ auto Pos = findLastNonVersionCharacter(RawExt) + 1;
+ StringRef Name(RawExt.substr(0, Pos));
+ StringRef Vers(RawExt.substr(Pos));
+
+ if (Type.empty()) {
+ if (IgnoreUnknown)
+ return Error::success();
+ return createStringError(errc::invalid_argument,
+ "invalid extension prefix '" + RawExt + "'");
+ }
+
+ if (!IgnoreUnknown && Name.size() == Type.size())
+ return createStringError(errc::invalid_argument,
+ "%s name missing after '%s'", Desc.str().c_str(),
+ Type.str().c_str());
+
+ unsigned Major, Minor, ConsumeLength;
+ if (auto E = getExtensionVersion(Name, Vers, Major, Minor, ConsumeLength,
+ EnableExperimentalExtension,
+ ExperimentalExtensionVersionCheck)) {
+ if (IgnoreUnknown) {
+ consumeError(std::move(E));
+ return Error::success();
+ }
+ return E;
+ }
+
+ // Check if duplicated extension.
+ if (!IgnoreUnknown && (SeenExtMap.find(Name.str()) != SeenExtMap.end()))
----------------
BeMg wrote:
Done
https://github.com/llvm/llvm-project/pull/78120
More information about the cfe-commits
mailing list