[llvm] [NVPTX] Load/Store/Fence syncscope support (PR #106101)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 10:56:58 PDT 2024
================
@@ -915,6 +926,39 @@ getOperationOrderings(MemSDNode *N, const NVPTXSubtarget *Subtarget) {
} // namespace
+NVPTX::Scope NVPTXDAGToDAGISel::getOperationScope(MemSDNode *N,
+ NVPTX::Ordering O) const {
+ switch (O) {
+ 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.
+ if (S == NVPTX::Scope::Thread)
+ report_fatal_error(
+ formatv("Atomics need scope > \"{}\".", ScopeToString(S)));
+
+ // If scope is cluster, clusters must be supported.
+ if (S == NVPTX::Scope::Cluster)
+ Subtarget->failIfClustersUnsupported("cluster scope");
+
+ // If operation is volatile, then its scope is system.
+ return N->isVolatile() ? NVPTX::Scope::System : S;
+ }
----------------
Artem-B wrote:
I'd add `llvm_unreachable()` here.
https://github.com/llvm/llvm-project/pull/106101
More information about the llvm-commits
mailing list