diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp index dd74f79f04b92..578ba1bcd3eb0 100644 --- a/llvm/lib/TargetParser/RISCVISAInfo.cpp +++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp @@ -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"); @@ -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'"); diff --git a/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp b/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp index e24b2d47f6bc4..a04725c6c5211 100644 --- a/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp +++ b/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp @@ -663,6 +663,14 @@ TEST(ParseArchString, RejectsConflictingExtensions) { ::testing::EndsWith(" is only supported for 'rv32'")); } + for (StringRef Input : + {"rv32idc_xqciac0p3", "rv32i_zcd_xqciac0p3", "rv32idc_xqcicm0p2", + "rv32i_zcd_xqcicm0p2", "rv32idc_xqccmp0p1", "rv32i_zcd_xqccmp0p1"}) { + 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");