[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v5 (PR #108636)

Peilin Ye via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 2 18:34:10 PDT 2024


================
@@ -522,6 +526,28 @@ let Predicates = [BPFNoALU32] in {
 }
 def STD : STOREi64<BPF_DW, "u64", store>;
 
+class relaxed_store<PatFrag base>
+  : PatFrag<(ops node:$val, node:$ptr), (base node:$val, node:$ptr)> {
+  let IsAtomic = 1;
+  let IsAtomicOrderingReleaseOrStronger = 0;
+}
+
+class releasing_store<PatFrag base>
+  : PatFrag<(ops node:$val, node:$ptr), (base node:$val, node:$ptr)> {
+  let IsAtomic = 1;
+  let IsAtomicOrderingRelease = 1;
+}
----------------
peilin-ye wrote:

Eduard [suggested earlier](https://github.com/llvm/llvm-project/pull/108636#discussion_r1765597286) (referencing [Andrii's suggestion](https://github.com/llvm/llvm-project/pull/107343#issuecomment-2334664935) in #107343) that, for now, we "fall back" to `ACQUIRE` or `RELEASE` if user requested `RELAXED`, until we actually support `RELAXED` in the future.

> Is my interpretation correct or __atomic_load_n(ptr, __ATOMIC_RELAXED) could have semantics beyond '*ptr'?

`__ATOMIC_RELAXED` still guarantees atomicity but `*ptr` does not, if i'm understanding correctly?

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


More information about the cfe-commits mailing list