Skip to content

Commit

Permalink
[RISCV] Emitting proper atomic ABI tag when Zalasr is enabled
Browse files Browse the repository at this point in the history
When Zalasr is enabled, it will emit the A7 atomic ABI tag.
  • Loading branch information
Brendan Sweeney committed Dec 24, 2024
1 parent cd66c9b commit a96abb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ void RISCVTargetStreamer::emitTargetAttributes(const MCSubtargetInfo &STI,

if (RiscvAbiAttr && STI.hasFeature(RISCV::FeatureStdExtA)) {
unsigned AtomicABITag = static_cast<unsigned>(
STI.hasFeature(RISCV::FeatureNoTrailingSeqCstFence)
STI.hasFeature(RISCV::FeatureStdExtZalasr)
? RISCVAttrs::RISCVAtomicAbiTag::A7
: STI.hasFeature(RISCV::FeatureNoTrailingSeqCstFence)
? RISCVAttrs::RISCVAtomicAbiTag::A6C
: RISCVAttrs::RISCVAtomicAbiTag::A6S);
emitAttribute(RISCVAttrs::ATOMIC_ABI, AtomicABITag);
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/CodeGen/RISCV/attributes.ll
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
; RUN: llc -mtriple=riscv64 -mattr=+m,+zmmul %s -o - | FileCheck --check-prefixes=CHECK,RV64MZMMUL %s
; RUN: llc -mtriple=riscv64 -mattr=+a,no-trailing-seq-cst-fence --riscv-abi-attributes %s -o - | FileCheck --check-prefixes=CHECK,RV64A,A6C %s
; RUN: llc -mtriple=riscv64 -mattr=+a --riscv-abi-attributes %s -o - | FileCheck --check-prefixes=CHECK,RV64A,A6S %s
; RUN: llc -mtriple=riscv64 -mattr=+a,experimental-zalasr --riscv-abi-attributes %s -o - | FileCheck --check-prefixes=CHECK,RV64ZALASRA,A7 %s
; RUN: llc -mtriple=riscv64 -mattr=+b %s -o - | FileCheck --check-prefixes=CHECK,RV64B %s
; RUN: llc -mtriple=riscv64 -mattr=+f %s -o - | FileCheck --check-prefixes=CHECK,RV64F %s
; RUN: llc -mtriple=riscv64 -mattr=+d %s -o - | FileCheck --check-prefixes=CHECK,RV64D %s
Expand Down Expand Up @@ -590,6 +591,7 @@
; RV64ZVFBFWMA: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
; RV64ZACAS: .attribute 5, "rv64i2p1_zaamo1p0_zacas1p0"
; RV64ZALASR: .attribute 5, "rv64i2p1_zalasr0p1"
; RV64ZALASRA: .attribute 5, "rv64i2p1_a2p1_zaamo1p0_zalasr0p1_zalrsc1p0"
; RV64ZICFILP: .attribute 5, "rv64i2p1_zicfilp1p0_zicsr2p0"
; RV64ZABHA: .attribute 5, "rv64i2p1_zaamo1p0_zabha1p0"
; RV64ZVBC32E: .attribute 5, "rv64i2p1_zicsr2p0_zvbc32e0p7_zve32x1p0_zvl32b1p0"
Expand Down Expand Up @@ -624,4 +626,5 @@ define i8 @atomic_load_i8_seq_cst(ptr %a) nounwind {
ret i8 %1
; A6S: .attribute 14, 2
; A6C: .attribute 14, 1
; A7: .attribute 14, 3
}

0 comments on commit a96abb9

Please sign in to comment.