From ff3ea1413bb04178db7b3b08e9cc7dc1535e38e6 Mon Sep 17 00:00:00 2001 From: Brendan Sweeney Date: Mon, 23 Dec 2024 16:28:53 -0800 Subject: [PATCH] [RISCV] Emitting proper atomic ABI tag when Zalasr is enabled When Zalasr is enabled, it will emit the A7 atomic ABI tag. --- .../Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp | 11 +++++++---- llvm/test/CodeGen/RISCV/attributes.ll | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp index 99f57f47835abd..a853181fc7962b 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp @@ -85,10 +85,13 @@ void RISCVTargetStreamer::emitTargetAttributes(const MCSubtargetInfo &STI, } if (RiscvAbiAttr && STI.hasFeature(RISCV::FeatureStdExtA)) { - unsigned AtomicABITag = static_cast( - STI.hasFeature(RISCV::FeatureNoTrailingSeqCstFence) - ? RISCVAttrs::RISCVAtomicAbiTag::A6C - : RISCVAttrs::RISCVAtomicAbiTag::A6S); + unsigned AtomicABITag; + if (STI.hasFeature(RISCV::FeatureStdExtZalasr)) + AtomicABITag = static_cast(RISCVAttrs::RISCVAtomicAbiTag::A7); + else if (STI.hasFeature(RISCV::FeatureNoTrailingSeqCstFence)) + AtomicABITag = static_cast(RISCVAttrs::RISCVAtomicAbiTag::A6C); + else + AtomicABITag = static_cast(RISCVAttrs::RISCVAtomicAbiTag::A6S); emitAttribute(RISCVAttrs::ATOMIC_ABI, AtomicABITag); } } diff --git a/llvm/test/CodeGen/RISCV/attributes.ll b/llvm/test/CodeGen/RISCV/attributes.ll index 7e55e0590ec598..b1b18fcfd5b007 100644 --- a/llvm/test/CodeGen/RISCV/attributes.ll +++ b/llvm/test/CodeGen/RISCV/attributes.ll @@ -155,6 +155,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 @@ -596,6 +597,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" @@ -632,4 +634,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 }