Skip to content

Commit 90a8322

Browse files
authored
[RISCV] Add an error that Xqccmp, Xqciac, and Xqcicm are not compatible with C+D or Zcd. (#130816)
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 d71b3de commit 90a8322

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,15 @@ 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"}, {"xqccmp"}, {"xqciac"}, {"xqcicm"}};
750752

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

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");
762+
if (HasD && (HasC || Exts.count("zcd")))
763+
for (auto Ext : ZcdOverlaps)
764+
if (Exts.count(Ext.str()))
765+
return getError(
766+
Twine("'") + Ext + "' extension is incompatible with '" +
767+
(HasC ? "c" : "zcd") + "' extension when 'd' extension is enabled");
765768

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

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

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

666+
for (StringRef Input :
667+
{"rv32idc_xqciac0p3", "rv32i_zcd_xqciac0p3", "rv32idc_xqcicm0p2",
668+
"rv32i_zcd_xqcicm0p2", "rv32idc_xqccmp0p1", "rv32i_zcd_xqccmp0p1"}) {
669+
EXPECT_THAT(
670+
toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
671+
::testing::EndsWith("extension when 'd' extension is enabled"));
672+
}
673+
666674
for (StringRef Input : {"rv32i_zcmp_xqccmp0p1", "rv64i_zcmp_xqccmp0p1"}) {
667675
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
668676
"'zcmp' and 'xqccmp' extensions are incompatible");

0 commit comments

Comments
 (0)