Skip to content

Commit d489b7c

Browse files
committed
[RISCV] Merge some ISA error reporting together and make some errors more precise.
Loop over the extension names that have the same error message. Print the name of Zvk* extensions instead of 'zvk*'.
1 parent 164d123 commit d489b7c

File tree

2 files changed

+30
-39
lines changed

2 files changed

+30
-39
lines changed

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -739,31 +739,23 @@ Error RISCVISAInfo::checkDependency() {
739739
return getError("'f' and 'zfinx' extensions are incompatible");
740740

741741
if (HasZvl && !HasVector)
742-
return getError(
743-
"'zvl*b' requires 'v' or 'zve*' extension to also be specified");
744-
745-
if (Exts.count("zvbb") && !HasVector)
746-
return getError(
747-
"'zvbb' requires 'v' or 'zve*' extension to also be specified");
748-
749-
if (Exts.count("zvbc") && !Exts.count("zve64x"))
750-
return getError(
751-
"'zvbc' requires 'v' or 'zve64*' extension to also be specified");
752-
753-
if (Exts.count("zvbc32e") && !Exts.count("zve32x"))
754-
return getError(
755-
"'zvbc32e' requires 'v' or 'zve*' extension to also be specified");
756-
757-
if ((Exts.count("zvkb") || Exts.count("zvkg") || Exts.count("zvkgs") ||
758-
Exts.count("zvkned") || Exts.count("zvknha") || Exts.count("zvksed") ||
759-
Exts.count("zvksh")) &&
760-
!HasVector)
761-
return getError(
762-
"'zvk*' requires 'v' or 'zve*' extension to also be specified");
763-
764-
if (Exts.count("zvknhb") && !Exts.count("zve64x"))
765-
return getError(
766-
"'zvknhb' requires 'v' or 'zve64*' extension to also be specified");
742+
return getError(Twine("'") + "zvl*b" +
743+
"' requires 'v' or 'zve*' extension to also be specified");
744+
745+
if (!HasVector)
746+
for (auto Ext :
747+
{"zvbb", "zvbc32e", "zvkb", "zvkg", "zvkgs", "zvkned", "zvknha", "zvksed", "zvksh"})
748+
if (Exts.count(Ext))
749+
return getError(
750+
Twine("'") + Ext +
751+
"' requires 'v' or 'zve*' extension to also be specified");
752+
753+
if (!Exts.count("zve64x"))
754+
for (auto Ext : {"zvknhb", "zvbc"})
755+
if (Exts.count(Ext))
756+
return getError(
757+
Twine("'") + Ext +
758+
"' requires 'v' or 'zve64*' extension to also be specified");
767759

768760
if ((HasZcmt || Exts.count("zcmp")) && HasD && (HasC || Exts.count("zcd")))
769761
return getError(Twine("'") + (HasZcmt ? "zcmt" : "zcmp") +
@@ -774,13 +766,12 @@ Error RISCVISAInfo::checkDependency() {
774766
if (XLen != 32 && Exts.count("zcf"))
775767
return getError("'zcf' is only supported for 'rv32'");
776768

777-
if (Exts.count("zacas") && !(Exts.count("a") || Exts.count("zaamo")))
778-
return getError(
779-
"'zacas' requires 'a' or 'zaamo' extension to also be specified");
780-
781-
if (Exts.count("zabha") && !(Exts.count("a") || Exts.count("zaamo")))
782-
return getError(
783-
"'zabha' requires 'a' or 'zaamo' extension to also be specified");
769+
if (!(Exts.count("a") || Exts.count("zaamo")))
770+
for (auto Ext : {"zacas", "zabha"})
771+
if (Exts.count(Ext))
772+
return getError(
773+
Twine("'") + Ext +
774+
"' requires 'a' or 'zaamo' extension to also be specified");
784775

785776
if (Exts.count("xwchc") != 0) {
786777
if (XLen != 32)

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,37 +660,37 @@ TEST(ParseArchString, MissingDepency) {
660660

661661
for (StringRef Input : {"rv32i_zvkb"}) {
662662
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
663-
"'zvk*' requires 'v' or 'zve*' extension to also be specified");
663+
"'zvkb' requires 'v' or 'zve*' extension to also be specified");
664664
}
665665

666666
for (StringRef Input : {"rv32i_zvkg"}) {
667667
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
668-
"'zvk*' requires 'v' or 'zve*' extension to also be specified");
668+
"'zvkg' requires 'v' or 'zve*' extension to also be specified");
669669
}
670670

671671
for (StringRef Input : {"rv32i_zvkgs0p7"}) {
672672
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
673-
"'zvk*' requires 'v' or 'zve*' extension to also be specified");
673+
"'zvkg' requires 'v' or 'zve*' extension to also be specified");
674674
}
675675

676676
for (StringRef Input : {"rv32i_zvkned"}) {
677677
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
678-
"'zvk*' requires 'v' or 'zve*' extension to also be specified");
678+
"'zvkned' requires 'v' or 'zve*' extension to also be specified");
679679
}
680680

681681
for (StringRef Input : {"rv32i_zvknha"}) {
682682
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
683-
"'zvk*' requires 'v' or 'zve*' extension to also be specified");
683+
"'zvknha' requires 'v' or 'zve*' extension to also be specified");
684684
}
685685

686686
for (StringRef Input : {"rv32i_zvksed"}) {
687687
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
688-
"'zvk*' requires 'v' or 'zve*' extension to also be specified");
688+
"'zvksed' requires 'v' or 'zve*' extension to also be specified");
689689
}
690690

691691
for (StringRef Input : {"rv32i_zvksh"}) {
692692
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
693-
"'zvk*' requires 'v' or 'zve*' extension to also be specified");
693+
"'zvksh' requires 'v' or 'zve*' extension to also be specified");
694694
}
695695

696696
for (StringRef Input : {"rv32i_zvknhb"}) {

0 commit comments

Comments
 (0)