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

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 21 05:23:57 PDT 2026


================
@@ -4608,6 +4614,38 @@ bool AArch64DAGToDAGISel::SelectCMP_SWAP(SDNode *N) {
   return true;
 }
 
+AArch64AtomicStoreHint
+AArch64DAGToDAGISel::decodeAtomicHintFlags(MachineMemOperand *MMO) const {
+  int AtomicHint = -1;
+  const MDNode *MemCacheHint = MMO->getMemCacheHint();
+  if (!MemCacheHint)
+    return AArch64AtomicStoreHint::HINT_NONE;
+
+  for (unsigned I = 0; I + 1 < MemCacheHint->getNumOperands(); I += 2) {
+    const auto *Key = cast<MDString>(MemCacheHint->getOperand(I));
+    StringRef KeyStr = Key->getString();
+    const Metadata *Val = MemCacheHint->getOperand(I + 1).get();
+
+    if (KeyStr != "aarch64.atomic_hint")
+      continue;
+
+    AtomicHint = cast<ConstantInt>(cast<ConstantAsMetadata>(Val)->getValue())
+                     ->getZExtValue();
----------------
Lukacma wrote:

```suggestion
    if ((MemCacheHint->getOperand(I)).equalsStr("aarch64.atomic_hint")){
      const Metadata *Val = MemCacheHint->getOperand(I + 1).get();
      AtomicHint = cast<ConstantInt>(cast<ConstantAsMetadata>(Val)->getValue())
                      ->getZExtValue();
    }
```

Maybe rewriting it like this will be neater.

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


More information about the cfe-commits mailing list