[llvm] [NVPTX] Load/Store/Fence syncscope support (PR #106101)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 11 15:46:58 PDT 2024


================
@@ -915,6 +920,42 @@ getOperationOrderings(MemSDNode *N, const NVPTXSubtarget *Subtarget) {
 
 } // namespace
 
+NVPTX::Scope NVPTXDAGToDAGISel::getOperationScope(MemSDNode *N,
+                                                  NVPTX::Ordering Ord) const {
+  switch (Ord) {
+  case NVPTX::Ordering::NotAtomic:
+  case NVPTX::Ordering::Volatile: // Non-atomic volatile operations
+    // NVPTX uses Thread scope as the scope of non-atomic operations.
+    return NVPTX::Scope::Thread;
+  case NVPTX::Ordering::RelaxedMMIO:
+    // RelaxedMMIO operations are always system scope.
+    // If a RelaxedMMIO order was generated from an atomic volatile operation
+    // with a smaller thread scope, we bump it here to system scope.
+    return NVPTX::Scope::System;
+  case NVPTX::Ordering::Relaxed:
+  case NVPTX::Ordering::Acquire:
+  case NVPTX::Ordering::Release:
+  case NVPTX::Ordering::AcquireRelease:
+  case NVPTX::Ordering::SequentiallyConsistent:
+    auto S = Scopes[N->getSyncScopeID()];
+
+    // Atomic operations must have a scope greater than thread.
----------------
Artem-B wrote:

That's where ordered scope values would be helpful and we could write `S <= Thread` so it matches what the comment says. Exact comparison will silently misbehave if we there would happen to be other scopes we disallow.

Alternatively, rephrase the comment so that it says that "atomics are not allowed within thread scope".

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


More information about the llvm-commits mailing list