Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions llvm/lib/TargetParser/RISCVISAInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,13 +740,15 @@ Error RISCVISAInfo::checkDependency() {
bool HasZfinx = Exts.count("zfinx") != 0;
bool HasVector = Exts.count("zve32x") != 0;
bool HasZvl = MinVLen != 0;
bool HasZcmt = Exts.count("zcmt") != 0;
bool HasZcmp = Exts.count("zcmp") != 0;
bool HasXqccmp = Exts.count("xqccmp") != 0;

static constexpr StringLiteral XqciExts[] = {
{"xqcia"}, {"xqciac"}, {"xqcibm"}, {"xqcicli"},
{"xqcicm"}, {"xqcics"}, {"xqcicsr"}, {"xqciint"},
{"xqcilia"}, {"xqcilo"}, {"xqcilsm"}, {"xqcisls"}};
bool HasZcmp = Exts.count("zcmp") != 0;
bool HasXqccmp = Exts.count("xqccmp") != 0;
static constexpr StringLiteral ZcdOverlaps[] = {
{"zcmt"}, {"zcmp"}, {"xqccmp"}, {"xqciac"}, {"xqcicm"}};

if (HasI && HasE)
return getIncompatibleError("i", "e");
Expand All @@ -757,11 +759,12 @@ Error RISCVISAInfo::checkDependency() {
if (HasZvl && !HasVector)
return getExtensionRequiresError("zvl*b", "v' or 'zve*");

if ((HasZcmt || Exts.count("zcmp")) && HasD && (HasC || Exts.count("zcd")))
return getError(Twine("'") + (HasZcmt ? "zcmt" : "zcmp") +
"' extension is incompatible with '" +
(HasC ? "c" : "zcd") +
"' extension when 'd' extension is enabled");
if (HasD && (HasC || Exts.count("zcd")))
for (auto Ext : ZcdOverlaps)
if (Exts.count(Ext.str()))
return getError(
Twine("'") + Ext + "' extension is incompatible with '" +
(HasC ? "c" : "zcd") + "' extension when 'd' extension is enabled");

if (XLen != 32 && Exts.count("zcf"))
return getError("'zcf' is only supported for 'rv32'");
Expand Down
7 changes: 7 additions & 0 deletions llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,13 @@ TEST(ParseArchString, RejectsConflictingExtensions) {
::testing::EndsWith(" is only supported for 'rv32'"));
}

for (StringRef Input : {"rv32idc_xqciac0p3", "rv32i_zcd_xqciac0p3", "rv32idc_xqcicm0p2",
"rv32i_zcd_xqcicm0p2"}) {
EXPECT_THAT(
toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
::testing::EndsWith("extension when 'd' extension is enabled"));
}

for (StringRef Input : {"rv32i_zcmp_xqccmp0p1", "rv64i_zcmp_xqccmp0p1"}) {
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
"'zcmp' and 'xqccmp' extensions are incompatible");
Expand Down
Loading