[clang] [llvm] [AArch64] Implement the atomic store with hint intrinsic (PR #198316)

Kerry McLaughlin via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 16 03:00:06 PDT 2026


================
@@ -18521,7 +18522,25 @@ AArch64TargetLowering::getTargetMMOFlags(const Instruction &I) const {
   if (Subtarget->getProcFamily() == AArch64Subtarget::Falkor &&
       I.hasMetadata(FALKOR_STRIDED_ACCESS_MD))
     return MOStridedAccess;
-  return MachineMemOperand::MONone;
+
+  auto Flags = MachineMemOperand::MONone;
+  const MDNode *AtomicStHint = I.getMetadata(AARCH64_ATOMIC_STORE_HINT_MD);
+  if (AtomicStHint) {
+    unsigned HintVal =
+        cast<ConstantInt>(
+            cast<ConstantAsMetadata>(AtomicStHint->getOperand(0))->getValue())
+            ->getZExtValue();
+    AArch64AtomicStoreHint Hint = getAtomicStoreHintFromMD(HintVal);
+    assert(Hint != AArch64AtomicStoreHint::HINT_NONE &&
+           "Unrecognised atomic hint value requested.");
----------------
kmclaughlin-arm wrote:

Unfortunately I can't just use `HintVal` here, because the immediate values from the metadata don't exactly match the values represented in `AArch64AtomicStoreHint`.

i.e. the docs specify that the hint values allowed are 0 (`HINT_STSHH_KEEP`) and 1 (`HINT_STSHH_STRM`). However, the value of `AArch64AtomicStoreHint` represented by 0 is `HINT_NONE`, meaning that neither `MOAtomicHintBit0` or `MOAtomicHintBit1` were set. I can try to change the LLVM intrinsic to use different immediate values to the builtin, but I'm not sure that makes sense.

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


More information about the cfe-commits mailing list