[llvm] 10a4f1e - [RISCV] Add helper functions to exploit similarity of some RISCVISAInfo::checkDependency() error strings. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 00:22:41 PDT 2024
Author: Craig Topper
Date: 2024-08-19T00:22:28-07:00
New Revision: 10a4f1ef9e1f30729920d2dd22d75d1002e66d0d
URL: https://github.com/llvm/llvm-project/commit/10a4f1ef9e1f30729920d2dd22d75d1002e66d0d
DIFF: https://github.com/llvm/llvm-project/commit/10a4f1ef9e1f30729920d2dd22d75d1002e66d0d.diff
LOG: [RISCV] Add helper functions to exploit similarity of some RISCVISAInfo::checkDependency() error strings. NFC
Added:
Modified:
llvm/lib/TargetParser/RISCVISAInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index e8d912486efc6..ac0bf8c5cec9d 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -721,6 +721,16 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
return RISCVISAInfo::postProcessAndChecking(std::move(ISAInfo));
}
+static Error getIncompatibleError(StringRef Ext1, StringRef Ext2) {
+ return getError("'" + Ext1 + "' and '" + Ext2 +
+ "' extensions are incompatible");
+}
+
+static Error getExtensionRequiresError(StringRef Ext, StringRef ReqExt) {
+ return getError("'" + Ext + "' requires '" + ReqExt +
+ "' extension to also be specified");
+}
+
Error RISCVISAInfo::checkDependency() {
bool HasE = Exts.count("e") != 0;
bool HasI = Exts.count("i") != 0;
@@ -733,29 +743,24 @@ Error RISCVISAInfo::checkDependency() {
bool HasZcmt = Exts.count("zcmt") != 0;
if (HasI && HasE)
- return getError("'I' and 'E' extensions are incompatible");
+ return getIncompatibleError("I", "E");
if (HasF && HasZfinx)
- return getError("'f' and 'zfinx' extensions are incompatible");
+ return getIncompatibleError("f", "zfinx");
if (HasZvl && !HasVector)
- return getError(Twine("'") + "zvl*b" +
- "' requires 'v' or 'zve*' extension to also be specified");
+ return getExtensionRequiresError("zvl*b", "v' or 'zve*");
if (!HasVector)
for (auto Ext :
{"zvbb", "zvbc32e", "zvkb", "zvkg", "zvkgs", "zvkned", "zvknha", "zvksed", "zvksh"})
if (Exts.count(Ext))
- return getError(
- Twine("'") + Ext +
- "' requires 'v' or 'zve*' extension to also be specified");
+ return getExtensionRequiresError(Ext, "v' or 'zve*");
if (!Exts.count("zve64x"))
for (auto Ext : {"zvknhb", "zvbc"})
if (Exts.count(Ext))
- return getError(
- Twine("'") + Ext +
- "' requires 'v' or 'zve64*' extension to also be specified");
+ return getExtensionRequiresError(Ext, "v' or 'zve64*");
if ((HasZcmt || Exts.count("zcmp")) && HasD && (HasC || Exts.count("zcd")))
return getError(Twine("'") + (HasZcmt ? "zcmt" : "zcmp") +
@@ -769,19 +774,17 @@ Error RISCVISAInfo::checkDependency() {
if (!(Exts.count("a") || Exts.count("zaamo")))
for (auto Ext : {"zacas", "zabha"})
if (Exts.count(Ext))
- return getError(
- Twine("'") + Ext +
- "' requires 'a' or 'zaamo' extension to also be specified");
+ return getExtensionRequiresError(Ext, "a' or 'zaamo");
if (Exts.count("xwchc") != 0) {
if (XLen != 32)
return getError("'Xwchc' is only supported for 'rv32'");
if (HasD)
- return getError("'D' and 'Xwchc' extensions are incompatible");
+ return getIncompatibleError("D", "Xwchc");
if (Exts.count("zcb") != 0)
- return getError("'Xwchc' and 'Zcb' extensions are incompatible");
+ return getIncompatibleError("Xwchc", "Zcb");
}
return Error::success();
More information about the llvm-commits
mailing list