Skip to content

Conversation

@mehnadnerd
Copy link
Contributor

@mehnadnerd mehnadnerd commented Dec 24, 2024

When Zalasr is enabled, it will emit the A7 atomic ABI tag. Zalasr is the load-acquire and store-release extension, and the reason A7 (and A6S) exists is to support it.
The A7 atomic ABI is compatible with A6S (which is what is currently emitted as the tag), but A7 is not compatible with A6C, while A6C and A6S are compatible.

https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-atomic.adoc#risc-v-atomics-mappings

https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#tag_riscv_atomic_abi-14-uleb128version

@llvmbot
Copy link
Member

llvmbot commented Dec 24, 2024

@llvm/pr-subscribers-backend-risc-v

Author: Brendan Sweeney (mehnadnerd)

Changes

When Zalasr is enabled, it will emit the A7 atomic ABI tag.


Full diff: https://github.com/llvm/llvm-project/pull/121017.diff

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp (+5-3)
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
index 99f57f47835abd..6035dffaa8ac8e 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -86,9 +86,11 @@ void RISCVTargetStreamer::emitTargetAttributes(const MCSubtargetInfo &STI,
 
   if (RiscvAbiAttr && STI.hasFeature(RISCV::FeatureStdExtA)) {
     unsigned AtomicABITag = static_cast<unsigned>(
-        STI.hasFeature(RISCV::FeatureNoTrailingSeqCstFence)
-            ? RISCVAttrs::RISCVAtomicAbiTag::A6C
-            : RISCVAttrs::RISCVAtomicAbiTag::A6S);
+        STI.hasFeature(RISCV::FeatureStdExtZalasr)
+            ? RISCVAttrs::RISCVAtomicAbiTag::A7
+            : STI.hasFeature(RISCV::FeatureNoTrailingSeqCstFence)
+              ? RISCVAttrs::RISCVAtomicAbiTag::A6C
+              : RISCVAttrs::RISCVAtomicAbiTag::A6S);
     emitAttribute(RISCVAttrs::ATOMIC_ABI, AtomicABITag);
   }
 }

@github-actions
Copy link

github-actions bot commented Dec 24, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@mehnadnerd
Copy link
Contributor Author

Still upgrading tests

@mehnadnerd mehnadnerd force-pushed the dev/brs/zalasrlower branch 2 times, most recently from 2077859 to a96abb9 Compare December 24, 2024 22:36
@mehnadnerd mehnadnerd force-pushed the dev/brs/zalasrlower branch from a96abb9 to ff3ea14 Compare January 4, 2025 23:21
@mehnadnerd mehnadnerd requested a review from lenary January 4, 2025 23:31
@mehnadnerd
Copy link
Contributor Author

Everything should be ready now. I don't have write access so please land it once you are done reviewing it.

When Zalasr is enabled, it will emit the A7 atomic ABI tag.
Copy link
Collaborator

@preames preames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@preames
Copy link
Collaborator

preames commented Mar 1, 2025

FYI, I have spoken with @mehnadnerd offline. He does not have commit access, and has asked me to land this on his behalf after approval. I'm going to give it until Monday in case any other reviewers have comments, and then land.

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@preames preames merged commit 4fd5d93 into llvm:main Mar 3, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants