mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-01 01:31:26 +00:00
[RISCV] Add errors for mixing Zcmp with C/Zcd and D.
We already had an error for Zcmt though it appears to be untested Add similar one for Zcmp along with tests for both. Factor the code to share the strings as much as possible. Reviewed By: VincentWu Differential Revision: https://reviews.llvm.org/D153159
This commit is contained in:
parent
2268459985
commit
61e91988bc
@ -860,13 +860,11 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
|
||||
|
||||
Error RISCVISAInfo::checkDependency() {
|
||||
bool HasC = Exts.count("c") != 0;
|
||||
bool HasD = Exts.count("d") != 0;
|
||||
bool HasF = Exts.count("f") != 0;
|
||||
bool HasZfinx = Exts.count("zfinx") != 0;
|
||||
bool HasVector = Exts.count("zve32x") != 0;
|
||||
bool HasZvl = MinVLen != 0;
|
||||
bool HasZcmt = Exts.count("zcmt") != 0;
|
||||
bool HasZcd = Exts.count("zcd") != 0;
|
||||
|
||||
if (HasF && HasZfinx)
|
||||
return createStringError(errc::invalid_argument,
|
||||
@ -899,15 +897,13 @@ Error RISCVISAInfo::checkDependency() {
|
||||
errc::invalid_argument,
|
||||
"'zvknhb' requires 'v' or 'zve64*' extension to also be specified");
|
||||
|
||||
if (HasZcmt && HasD && HasC)
|
||||
if ((HasZcmt || Exts.count("zcmp")) && Exts.count("d") &&
|
||||
(HasC || Exts.count("zcd")))
|
||||
return createStringError(
|
||||
errc::invalid_argument,
|
||||
"'zcmt' is incompatible with 'c' extension when 'd' extension is set");
|
||||
|
||||
if (HasZcmt && HasD && HasZcd)
|
||||
return createStringError(errc::invalid_argument,
|
||||
"'zcmt' is incompatible with 'zcd' extension when "
|
||||
"'d' extension is set");
|
||||
Twine("'") + (HasZcmt ? "zcmt" : "zcmp") +
|
||||
"' extension is incompatible with '" + (HasC ? "c" : "zcd") +
|
||||
"' extension when 'd' extension is enabled");
|
||||
|
||||
// Additional dependency checks.
|
||||
// TODO: The 'q' extension requires rv64.
|
||||
|
@ -447,6 +447,30 @@ TEST(ParseArchString, RejectsConflictingExtensions) {
|
||||
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
|
||||
"'f' and 'zfinx' extensions are incompatible");
|
||||
}
|
||||
|
||||
for (StringRef Input : {"rv32idc_zcmp1p0", "rv64idc_zcmp1p0"}) {
|
||||
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
|
||||
"'zcmp' extension is incompatible with 'c' extension when 'd' "
|
||||
"extension is enabled");
|
||||
}
|
||||
|
||||
for (StringRef Input : {"rv32id_zcd1p0_zcmp1p0", "rv64id_zcd1p0_zcmp1p0"}) {
|
||||
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
|
||||
"'zcmp' extension is incompatible with 'zcd' extension when 'd' "
|
||||
"extension is enabled");
|
||||
}
|
||||
|
||||
for (StringRef Input : {"rv32idc_zcmt1p0", "rv64idc_zcmt1p0"}) {
|
||||
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
|
||||
"'zcmt' extension is incompatible with 'c' extension when 'd' "
|
||||
"extension is enabled");
|
||||
}
|
||||
|
||||
for (StringRef Input : {"rv32id_zcd1p0_zcmt1p0", "rv64id_zcd1p0_zcmt1p0"}) {
|
||||
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
|
||||
"'zcmt' extension is incompatible with 'zcd' extension when 'd' "
|
||||
"extension is enabled");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ToFeatureVector, IIsDroppedAndExperimentalExtensionsArePrefixed) {
|
||||
|
Loading…
Reference in New Issue
Block a user