LLVM 22.0.0git
AMDGPUMachineModuleInfo.h
Go to the documentation of this file.
1//===--- AMDGPUMachineModuleInfo.h ------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// AMDGPU Machine Module Info.
11///
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEMODULEINFO_H
16#define LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEMODULEINFO_H
17
19#include "llvm/IR/LLVMContext.h"
20
21namespace llvm {
22
24private:
25
26 // All supported memory/synchronization scopes can be found here:
27 // http://llvm.org/docs/AMDGPUUsage.html#memory-scopes
28
29 /// Agent synchronization scope ID (cross address space).
30 SyncScope::ID AgentSSID;
31 /// Workgroup synchronization scope ID (cross address space).
32 SyncScope::ID WorkgroupSSID;
33 /// Wavefront synchronization scope ID (cross address space).
34 SyncScope::ID WavefrontSSID;
35 /// Cluster synchronization scope ID (cross address space).
36 SyncScope::ID ClusterSSID;
37 /// System synchronization scope ID (single address space).
38 SyncScope::ID SystemOneAddressSpaceSSID;
39 /// Agent synchronization scope ID (single address space).
40 SyncScope::ID AgentOneAddressSpaceSSID;
41 /// Workgroup synchronization scope ID (single address space).
42 SyncScope::ID WorkgroupOneAddressSpaceSSID;
43 /// Wavefront synchronization scope ID (single address space).
44 SyncScope::ID WavefrontOneAddressSpaceSSID;
45 /// Single thread synchronization scope ID (single address space).
46 SyncScope::ID SingleThreadOneAddressSpaceSSID;
47 /// Cluster synchronization scope ID (single address space).
48 SyncScope::ID ClusterOneAddressSpaceSSID;
49
50 /// In AMDGPU target synchronization scopes are inclusive, meaning a
51 /// larger synchronization scope is inclusive of a smaller synchronization
52 /// scope.
53 ///
54 /// \returns \p SSID's inclusion ordering, or "std::nullopt" if \p SSID is not
55 /// supported by the AMDGPU target.
56 std::optional<uint8_t>
57 getSyncScopeInclusionOrdering(SyncScope::ID SSID) const {
58 if (SSID == SyncScope::SingleThread ||
60 return 0;
61 else if (SSID == getWavefrontSSID() ||
63 return 1;
64 else if (SSID == getWorkgroupSSID() ||
66 return 2;
67 else if (SSID == getClusterSSID() ||
69 return 3;
70 else if (SSID == getAgentSSID() ||
72 return 4;
73 else if (SSID == SyncScope::System ||
75 return 5;
76
77 return std::nullopt;
78 }
79
80 /// \returns True if \p SSID is restricted to single address space, false
81 /// otherwise
82 bool isOneAddressSpace(SyncScope::ID SSID) const {
83 return SSID == getClusterOneAddressSpaceSSID() ||
89 }
90
91public:
93
94 /// \returns Agent synchronization scope ID (cross address space).
96 return AgentSSID;
97 }
98 /// \returns Workgroup synchronization scope ID (cross address space).
100 return WorkgroupSSID;
101 }
102 /// \returns Wavefront synchronization scope ID (cross address space).
104 return WavefrontSSID;
105 }
106 /// \returns Cluster synchronization scope ID (cross address space).
107 SyncScope::ID getClusterSSID() const { return ClusterSSID; }
108 /// \returns System synchronization scope ID (single address space).
110 return SystemOneAddressSpaceSSID;
111 }
112 /// \returns Agent synchronization scope ID (single address space).
114 return AgentOneAddressSpaceSSID;
115 }
116 /// \returns Workgroup synchronization scope ID (single address space).
118 return WorkgroupOneAddressSpaceSSID;
119 }
120 /// \returns Wavefront synchronization scope ID (single address space).
122 return WavefrontOneAddressSpaceSSID;
123 }
124 /// \returns Single thread synchronization scope ID (single address space).
126 return SingleThreadOneAddressSpaceSSID;
127 }
128 /// \returns Single thread synchronization scope ID (single address space).
130 return ClusterOneAddressSpaceSSID;
131 }
132
133 /// In AMDGPU target synchronization scopes are inclusive, meaning a
134 /// larger synchronization scope is inclusive of a smaller synchronization
135 /// scope.
136 ///
137 /// \returns True if synchronization scope \p A is larger than or equal to
138 /// synchronization scope \p B, false if synchronization scope \p A is smaller
139 /// than synchronization scope \p B, or "std::nullopt" if either
140 /// synchronization scope \p A or \p B is not supported by the AMDGPU target.
142 SyncScope::ID B) const {
143 const auto &AIO = getSyncScopeInclusionOrdering(A);
144 const auto &BIO = getSyncScopeInclusionOrdering(B);
145 if (!AIO || !BIO)
146 return std::nullopt;
147
148 bool IsAOneAddressSpace = isOneAddressSpace(A);
149 bool IsBOneAddressSpace = isOneAddressSpace(B);
150
151 return *AIO >= *BIO &&
152 (IsAOneAddressSpace == IsBOneAddressSpace || !IsAOneAddressSpace);
153 }
154};
155
156} // end namespace llvm
157
158#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEMODULEINFO_H
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
AMDGPUMachineModuleInfo(const MachineModuleInfo &MMI)
SyncScope::ID getClusterOneAddressSpaceSSID() const
std::optional< bool > isSyncScopeInclusion(SyncScope::ID A, SyncScope::ID B) const
In AMDGPU target synchronization scopes are inclusive, meaning a larger synchronization scope is incl...
SyncScope::ID getAgentOneAddressSpaceSSID() const
SyncScope::ID getSingleThreadOneAddressSpaceSSID() const
SyncScope::ID getWavefrontOneAddressSpaceSSID() const
SyncScope::ID getSystemOneAddressSpaceSSID() const
SyncScope::ID getWorkgroupOneAddressSpaceSSID() const
MachineModuleInfoELF(const MachineModuleInfo &)
This class contains meta information specific to a module.
@ SingleThread
Synchronized with respect to signal handlers executing in the same thread.
Definition LLVMContext.h:55
@ System
Synchronized with respect to all concurrently executing threads.
Definition LLVMContext.h:58
This is an optimization pass for GlobalISel generic memory operations.