Skip to content

Commit 956361c

Browse files
authored
[RISCV] Zabha/Zacas implies Zaamo (#115694)
The Zabha/Zacas extension depends upon the Zaamo extension. Ref: https://github.com/riscv/riscv-isa-manual/blob/main/src/zacas.adoc https://github.com/riscv/riscv-isa-manual/blob/main/src/zabha.adoc.
1 parent 6a857fe commit 956361c

File tree

5 files changed

+9
-22
lines changed

5 files changed

+9
-22
lines changed

llvm/lib/Target/RISCV/RISCVFeatures.td

+4-2
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,16 @@ def HasStdExtAOrZaamo
237237

238238
def FeatureStdExtZabha
239239
: RISCVExtension<"zabha", 1, 0,
240-
"'Zabha' (Byte and Halfword Atomic Memory Operations)">;
240+
"'Zabha' (Byte and Halfword Atomic Memory Operations)",
241+
[FeatureStdExtZaamo]>;
241242
def HasStdExtZabha : Predicate<"Subtarget->hasStdExtZabha()">,
242243
AssemblerPredicate<(all_of FeatureStdExtZabha),
243244
"'Zabha' (Byte and Halfword Atomic Memory Operations)">;
244245

245246
def FeatureStdExtZacas
246247
: RISCVExtension<"zacas", 1, 0,
247-
"'Zacas' (Atomic Compare-And-Swap Instructions)">,
248+
"'Zacas' (Atomic Compare-And-Swap Instructions)",
249+
[FeatureStdExtZaamo]>,
248250
RISCVExtensionBitmask<0, 26>;
249251
def HasStdExtZacas : Predicate<"Subtarget->hasStdExtZacas()">,
250252
AssemblerPredicate<(all_of FeatureStdExtZacas),

llvm/lib/TargetParser/RISCVISAInfo.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,6 @@ Error RISCVISAInfo::checkDependency() {
760760
if (XLen != 32 && Exts.count("zcf"))
761761
return getError("'zcf' is only supported for 'rv32'");
762762

763-
if (!(Exts.count("a") || Exts.count("zaamo")))
764-
for (auto Ext : {"zacas", "zabha"})
765-
if (Exts.count(Ext))
766-
return getExtensionRequiresError(Ext, "a' or 'zaamo");
767-
768763
if (Exts.count("xwchc") != 0) {
769764
if (XLen != 32)
770765
return getError("'xwchc' is only supported for 'rv32'");

llvm/test/CodeGen/RISCV/attributes.ll

+4-4
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,11 @@
428428
; RV32ZFBFMIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0"
429429
; RV32ZVFBFMIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvl32b1p0"
430430
; RV32ZVFBFWMA: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
431-
; RV32ZACAS: .attribute 5, "rv32i2p1_a2p1_zacas1p0"
431+
; RV32ZACAS: .attribute 5, "rv32i2p1_a2p1_zaamo1p0_zacas1p0"
432432
; RV32ZALASR: .attribute 5, "rv32i2p1_zalasr0p1"
433433
; RV32ZAMA16B: .attribute 5, "rv32i2p1_zama16b1p0"
434434
; RV32ZICFILP: .attribute 5, "rv32i2p1_zicfilp1p0_zicsr2p0"
435-
; RV32ZABHA: .attribute 5, "rv32i2p1_a2p1_zabha1p0"
435+
; RV32ZABHA: .attribute 5, "rv32i2p1_a2p1_zaamo1p0_zabha1p0"
436436
; RV32ZVBC32E: .attribute 5, "rv32i2p1_zicsr2p0_zvbc32e0p7_zve32x1p0_zvl32b1p0"
437437
; RV32ZVKGS: .attribute 5, "rv32i2p1_zicsr2p0_zve32x1p0_zvkg1p0_zvkgs0p7_zvl32b1p0"
438438
; RV32SSNPM: .attribute 5, "rv32i2p1_ssnpm1p0"
@@ -574,10 +574,10 @@
574574
; RV64ZFBFMIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0"
575575
; RV64ZVFBFMIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvl32b1p0"
576576
; RV64ZVFBFWMA: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
577-
; RV64ZACAS: .attribute 5, "rv64i2p1_a2p1_zacas1p0"
577+
; RV64ZACAS: .attribute 5, "rv64i2p1_a2p1_zaamo1p0_zacas1p0"
578578
; RV64ZALASR: .attribute 5, "rv64i2p1_zalasr0p1"
579579
; RV64ZICFILP: .attribute 5, "rv64i2p1_zicfilp1p0_zicsr2p0"
580-
; RV64ZABHA: .attribute 5, "rv64i2p1_a2p1_zabha1p0"
580+
; RV64ZABHA: .attribute 5, "rv64i2p1_a2p1_zaamo1p0_zabha1p0"
581581
; RV64ZVBC32E: .attribute 5, "rv64i2p1_zicsr2p0_zvbc32e0p7_zve32x1p0_zvl32b1p0"
582582
; RV64ZVKGS: .attribute 5, "rv64i2p1_zicsr2p0_zve32x1p0_zvkg1p0_zvkgs0p7_zvl32b1p0"
583583
; RV64SSNPM: .attribute 5, "rv64i2p1_ssnpm1p0"

llvm/test/MC/RISCV/attribute-arch.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@
394394
# CHECK: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
395395

396396
.attribute arch, "rv32ia_zacas1p0"
397-
# CHECK: attribute 5, "rv32i2p1_a2p1_zacas1p0"
397+
# CHECK: attribute 5, "rv32i2p1_a2p1_zaamo1p0_zacas1p0"
398398

399399
.attribute arch, "rv32izalasr0p1"
400400
# CHECK: attribute 5, "rv32i2p1_zalasr0p1"

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -660,16 +660,6 @@ TEST(ParseArchString, MissingDepency) {
660660
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
661661
"");
662662
}
663-
664-
for (StringRef Input : {"rv32i_zacas1p0"}) {
665-
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
666-
"'zacas' requires 'a' or 'zaamo' extension to also be specified");
667-
}
668-
669-
for (StringRef Input : {"rv32i_zabha"}) {
670-
EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
671-
"'zabha' requires 'a' or 'zaamo' extension to also be specified");
672-
}
673663
}
674664

675665
TEST(ParseArchString, RejectsUnrecognizedProfileNames) {

0 commit comments

Comments
 (0)