Skip to content

Commit ff3ea14

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 a738d81 commit ff3ea14

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ void RISCVTargetStreamer::emitTargetAttributes(const MCSubtargetInfo &STI,
8585
}
8686

8787
if (RiscvAbiAttr && STI.hasFeature(RISCV::FeatureStdExtA)) {
88-
unsigned AtomicABITag = static_cast<unsigned>(
89-
STI.hasFeature(RISCV::FeatureNoTrailingSeqCstFence)
90-
? RISCVAttrs::RISCVAtomicAbiTag::A6C
91-
: RISCVAttrs::RISCVAtomicAbiTag::A6S);
88+
unsigned AtomicABITag;
89+
if (STI.hasFeature(RISCV::FeatureStdExtZalasr))
90+
AtomicABITag = static_cast<unsigned>(RISCVAttrs::RISCVAtomicAbiTag::A7);
91+
else if (STI.hasFeature(RISCV::FeatureNoTrailingSeqCstFence))
92+
AtomicABITag = static_cast<unsigned>(RISCVAttrs::RISCVAtomicAbiTag::A6C);
93+
else
94+
AtomicABITag = static_cast<unsigned>(RISCVAttrs::RISCVAtomicAbiTag::A6S);
9295
emitAttribute(RISCVAttrs::ATOMIC_ABI, AtomicABITag);
9396
}
9497
}

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
; RUN: llc -mtriple=riscv64 -mattr=+m,+zmmul %s -o - | FileCheck --check-prefixes=CHECK,RV64MZMMUL %s
156156
; RUN: llc -mtriple=riscv64 -mattr=+a,no-trailing-seq-cst-fence --riscv-abi-attributes %s -o - | FileCheck --check-prefixes=CHECK,RV64A,A6C %s
157157
; RUN: llc -mtriple=riscv64 -mattr=+a --riscv-abi-attributes %s -o - | FileCheck --check-prefixes=CHECK,RV64A,A6S %s
158+
; RUN: llc -mtriple=riscv64 -mattr=+a,experimental-zalasr --riscv-abi-attributes %s -o - | FileCheck --check-prefixes=CHECK,RV64ZALASRA,A7 %s
158159
; RUN: llc -mtriple=riscv64 -mattr=+b %s -o - | FileCheck --check-prefixes=CHECK,RV64B %s
159160
; RUN: llc -mtriple=riscv64 -mattr=+f %s -o - | FileCheck --check-prefixes=CHECK,RV64F %s
160161
; RUN: llc -mtriple=riscv64 -mattr=+d %s -o - | FileCheck --check-prefixes=CHECK,RV64D %s
@@ -596,6 +597,7 @@
596597
; RV64ZVFBFWMA: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
597598
; RV64ZACAS: .attribute 5, "rv64i2p1_zaamo1p0_zacas1p0"
598599
; RV64ZALASR: .attribute 5, "rv64i2p1_zalasr0p1"
600+
; RV64ZALASRA: .attribute 5, "rv64i2p1_a2p1_zaamo1p0_zalasr0p1_zalrsc1p0"
599601
; RV64ZICFILP: .attribute 5, "rv64i2p1_zicfilp1p0_zicsr2p0"
600602
; RV64ZABHA: .attribute 5, "rv64i2p1_zaamo1p0_zabha1p0"
601603
; RV64ZVBC32E: .attribute 5, "rv64i2p1_zicsr2p0_zvbc32e0p7_zve32x1p0_zvl32b1p0"
@@ -632,4 +634,5 @@ define i8 @atomic_load_i8_seq_cst(ptr %a) nounwind {
632634
ret i8 %1
633635
; A6S: .attribute 14, 2
634636
; A6C: .attribute 14, 1
637+
; A7: .attribute 14, 3
635638
}

0 commit comments

Comments
 (0)