[clang] [llvm] [AArch64][clang][llvm] Add ACLE `stshh` atomic store builtin (PR #181386)

Kerry McLaughlin via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 26 03:54:04 PST 2026


================
@@ -17741,6 +17741,53 @@ void AArch64TargetLowering::getTgtMemIntrinsic(
     Infos.push_back(Info);
     return;
   }
+  case Intrinsic::aarch64_stshh_atomic_store: {
+    const auto *OrderC = dyn_cast<ConstantInt>(I.getArgOperand(2));
+    const auto *SizeC = dyn_cast<ConstantInt>(I.getArgOperand(4));
+    if (!OrderC || !SizeC)
+      return;
+
+    unsigned SizeBits = SizeC->getZExtValue();
+    switch (SizeBits) {
+    case 8:
+    case 16:
+    case 32:
+    case 64:
+      break;
+    default:
+      return;
+    }
+
+    AtomicOrdering Ordering;
+    switch (OrderC->getZExtValue()) {
+    case 0: // __ATOMIC_RELAXED
+      Ordering = AtomicOrdering::Monotonic;
+      break;
+    case 3: // __ATOMIC_RELEASE
+      Ordering = AtomicOrdering::Release;
+      break;
+    case 5: // __ATOMIC_SEQ_CST
+      Ordering = AtomicOrdering::SequentiallyConsistent;
+      break;
+    default:
+      return;
+    }
----------------
kmclaughlin-arm wrote:

It makes sense to check that the `OrderC` value is valid, but then I think you could just cast `OrderC` to `AtomicOrdering` rather than using a new variable?

https://github.com/llvm/llvm-project/pull/181386


More information about the cfe-commits mailing list