Skip to content

Commit a96abb9

Browse files
author
Brendan Sweeney
committed
[RISCV] Emitting proper atomic ABI tag when Zalasr is enabled
When Zalasr is enabled, it will emit the A7 atomic ABI tag.
1 parent cd66c9b commit a96abb9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ void RISCVTargetStreamer::emitTargetAttributes(const MCSubtargetInfo &STI,
8686

8787
if (RiscvAbiAttr && STI.hasFeature(RISCV::FeatureStdExtA)) {
8888
unsigned AtomicABITag = static_cast<unsigned>(
89-
STI.hasFeature(RISCV::FeatureNoTrailingSeqCstFence)
89+
STI.hasFeature(RISCV::FeatureStdExtZalasr)
90+
? RISCVAttrs::RISCVAtomicAbiTag::A7
91+
: STI.hasFeature(RISCV::FeatureNoTrailingSeqCstFence)
9092
? RISCVAttrs::RISCVAtomicAbiTag::A6C
9193
: RISCVAttrs::RISCVAtomicAbiTag::A6S);
9294
emitAttribute(RISCVAttrs::ATOMIC_ABI, AtomicABITag);

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
; RUN: llc -mtriple=riscv64 -mattr=+m,+zmmul %s -o - | FileCheck --check-prefixes=CHECK,RV64MZMMUL %s
154154
; RUN: llc -mtriple=riscv64 -mattr=+a,no-trailing-seq-cst-fence --riscv-abi-attributes %s -o - | FileCheck --check-prefixes=CHECK,RV64A,A6C %s
155155
; RUN: llc -mtriple=riscv64 -mattr=+a --riscv-abi-attributes %s -o - | FileCheck --check-prefixes=CHECK,RV64A,A6S %s
156+
; RUN: llc -mtriple=riscv64 -mattr=+a,experimental-zalasr --riscv-abi-attributes %s -o - | FileCheck --check-prefixes=CHECK,RV64ZALASRA,A7 %s
156157
; RUN: llc -mtriple=riscv64 -mattr=+b %s -o - | FileCheck --check-prefixes=CHECK,RV64B %s
157158
; RUN: llc -mtriple=riscv64 -mattr=+f %s -o - | FileCheck --check-prefixes=CHECK,RV64F %s
158159
; RUN: llc -mtriple=riscv64 -mattr=+d %s -o - | FileCheck --check-prefixes=CHECK,RV64D %s
@@ -590,6 +591,7 @@
590591
; RV64ZVFBFWMA: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
591592
; RV64ZACAS: .attribute 5, "rv64i2p1_zaamo1p0_zacas1p0"
592593
; RV64ZALASR: .attribute 5, "rv64i2p1_zalasr0p1"
594+
; RV64ZALASRA: .attribute 5, "rv64i2p1_a2p1_zaamo1p0_zalasr0p1_zalrsc1p0"
593595
; RV64ZICFILP: .attribute 5, "rv64i2p1_zicfilp1p0_zicsr2p0"
594596
; RV64ZABHA: .attribute 5, "rv64i2p1_zaamo1p0_zabha1p0"
595597
; RV64ZVBC32E: .attribute 5, "rv64i2p1_zicsr2p0_zvbc32e0p7_zve32x1p0_zvl32b1p0"
@@ -624,4 +626,5 @@ define i8 @atomic_load_i8_seq_cst(ptr %a) nounwind {
624626
ret i8 %1
625627
; A6S: .attribute 14, 2
626628
; A6C: .attribute 14, 1
629+
; A7: .attribute 14, 3
627630
}

0 commit comments

Comments
 (0)