[clang] [llvm] [AArch64][clang][llvm] Add ACLE `stshh` atomic store builtin (PR #181386)
Kerry McLaughlin via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 3 03:04:30 PST 2026
================
@@ -1001,6 +1004,72 @@ bool AArch64ExpandPseudo::expandStoreSwiftAsyncContext(
return true;
}
+bool AArch64ExpandPseudo::expandSTSHHAtomicStore(
+ MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) {
+ MachineInstr &MI = *MBBI;
+ DebugLoc DL(MI.getDebugLoc());
+
+ unsigned Order = MI.getOperand(2).getImm();
+ unsigned Policy = MI.getOperand(3).getImm();
+ unsigned Size = MI.getOperand(4).getImm();
+
+ bool IsRelaxed = Order == 0;
+ unsigned StoreOpc = 0;
+
+ // __ATOMIC_RELAXED uses STR. __ATOMIC_{RELEASE/SEQ_CST} use STLR.
+ switch (Size) {
+ case 8:
+ StoreOpc = IsRelaxed ? AArch64::STRBBui : AArch64::STLRB;
+ break;
+ case 16:
+ StoreOpc = IsRelaxed ? AArch64::STRHHui : AArch64::STLRH;
+ break;
+ case 32:
+ StoreOpc = IsRelaxed ? AArch64::STRWui : AArch64::STLRW;
+ break;
+ case 64:
+ StoreOpc = IsRelaxed ? AArch64::STRXui : AArch64::STLRX;
+ break;
+ default:
+ llvm_unreachable("Unexpected STSHH atomic store size");
+ }
+
+ // Emit the hint with the retention policy immediate.
+ MachineInstr *Hint = BuildMI(MBB, MBBI, DL, TII->get(AArch64::STSHH))
+ .addImm(Policy)
+ .getInstr();
+
+ // Emit the associated store instruction.
+ Register ValReg = MI.getOperand(0).getReg();
+ Register StoreValReg = ValReg;
----------------
kmclaughlin-arm wrote:
nit: `StoreValReg` is not necessary, we can just use `ValReg` instead
https://github.com/llvm/llvm-project/pull/181386
More information about the cfe-commits
mailing list