Skip to content

Commit 6ee708b

Browse files
committed
[RISCV] Add an error that Xqciac and Xqcicm are not compatible with C+D or Zcd.
I was reviewing encodings to put the disassembling of vendor instructions after after standard instructions and found that these overlap with c.fldsp and c.fsdsp.
1 parent 4f60f45 commit 6ee708b

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,16 @@ Error RISCVISAInfo::checkDependency() {
740740
bool HasZfinx = Exts.count("zfinx") != 0;
741741
bool HasVector = Exts.count("zve32x") != 0;
742742
bool HasZvl = MinVLen != 0;
743-
bool HasZcmt = Exts.count("zcmt") != 0;
743+
bool HasZcmp = Exts.count("zcmp") != 0;
744+
bool HasXqccmp = Exts.count("xqccmp") != 0;
745+
744746
static constexpr StringLiteral XqciExts[] = {
745747
{"xqcia"}, {"xqciac"}, {"xqcibm"}, {"xqcicli"},
746748
{"xqcicm"}, {"xqcics"}, {"xqcicsr"}, {"xqciint"},
747749
{"xqcilia"}, {"xqcilo"}, {"xqcilsm"}, {"xqcisls"}};
748-
bool HasZcmp = Exts.count("zcmp") != 0;
749-
bool HasXqccmp = Exts.count("xqccmp") != 0;
750+
static constexpr StringLiteral ZcdOverlaps[] = {
751+
{"zcmt"}, {"zcmp"}, {"xqciac"}, {"xqcicm"}
752+
};
750753

751754
if (HasI && HasE)
752755
return getIncompatibleError("i", "e");
@@ -757,11 +760,13 @@ Error RISCVISAInfo::checkDependency() {
757760
if (HasZvl && !HasVector)
758761
return getExtensionRequiresError("zvl*b", "v' or 'zve*");
759762

760-
if ((HasZcmt || Exts.count("zcmp")) && HasD && (HasC || Exts.count("zcd")))
761-
return getError(Twine("'") + (HasZcmt ? "zcmt" : "zcmp") +
762-
"' extension is incompatible with '" +
763-
(HasC ? "c" : "zcd") +
764-
"' extension when 'd' extension is enabled");
763+
if (HasD && (HasC || Exts.count("zcd")))
764+
for (auto Ext : ZcdOverlaps)
765+
if (Exts.count(Ext.str()))
766+
return getError(Twine("'") + Ext +
767+
"' extension is incompatible with '" +
768+
(HasC ? "c" : "zcd") +
769+
"' extension when 'd' extension is enabled");
765770

766771
if (XLen != 32 && Exts.count("zcf"))
767772
return getError("'zcf' is only supported for 'rv32'");

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,30 @@ TEST(ParseArchString, RejectsConflictingExtensions) {
663663
::testing::EndsWith(" is only supported for 'rv32'"));
664664
}
665665

666+
for (StringRef Input : {"rv32idc_xqciac0p3"}) {
667+
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
668+
"'xqciac' extension is incompatible with 'c' extension when 'd' "
669+
"extension is enabled");
670+
}
671+
672+
for (StringRef Input : {"rv32i_zcd_xqciac0p3"}) {
673+
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
674+
"'xqciac' extension is incompatible with 'zcd' extension when 'd' "
675+
"extension is enabled");
676+
}
677+
678+
for (StringRef Input : {"rv32idc_xqcicm0p2"}) {
679+
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
680+
"'xqcicm' extension is incompatible with 'c' extension when 'd' "
681+
"extension is enabled");
682+
}
683+
684+
for (StringRef Input : {"rv32i_zcd_xqcicm0p2"}) {
685+
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
686+
"'xqcicm' extension is incompatible with 'zcd' extension when 'd' "
687+
"extension is enabled");
688+
}
689+
666690
for (StringRef Input : {"rv32i_zcmp_xqccmp0p1", "rv64i_zcmp_xqccmp0p1"}) {
667691
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
668692
"'zcmp' and 'xqccmp' extensions are incompatible");

0 commit comments

Comments
 (0)