LLVM 19.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
20namespace llvm {
21
23private:
24
25 // All supported memory/synchronization scopes can be found here:
26 // http://llvm.org/docs/AMDGPUUsage.html#memory-scopes
27
28 /// Agent synchronization scope ID (cross address space).
29 SyncScope::ID AgentSSID;
30 /// Workgroup synchronization scope ID (cross address space).
31 SyncScope::ID WorkgroupSSID;
32 /// Wavefront synchronization scope ID (cross address space).
33 SyncScope::ID WavefrontSSID;
34 /// System synchronization scope ID (single address space).
35 SyncScope::ID SystemOneAddressSpaceSSID;
36 /// Agent synchronization scope ID (single address space).
37 SyncScope::ID AgentOneAddressSpaceSSID;
38 /// Workgroup synchronization scope ID (single address space).
39 SyncScope::ID WorkgroupOneAddressSpaceSSID;
40 /// Wavefront synchronization scope ID (single address space).
41 SyncScope::ID WavefrontOneAddressSpaceSSID;
42 /// Single thread synchronization scope ID (single address space).
43 SyncScope::ID SingleThreadOneAddressSpaceSSID;
44
45 /// In AMDGPU target synchronization scopes are inclusive, meaning a
46 /// larger synchronization scope is inclusive of a smaller synchronization
47 /// scope.
48 ///
49 /// \returns \p SSID's inclusion ordering, or "std::nullopt" if \p SSID is not
50 /// supported by the AMDGPU target.
51 std::optional<uint8_t>
52 getSyncScopeInclusionOrdering(SyncScope::ID SSID) const {
53 if (SSID == SyncScope::SingleThread ||
55 return 0;
56 else if (SSID == getWavefrontSSID() ||
58 return 1;
59 else if (SSID == getWorkgroupSSID() ||
61 return 2;
62 else if (SSID == getAgentSSID() ||
64 return 3;
65 else if (SSID == SyncScope::System ||
67 return 4;
68
69 return std::nullopt;
70 }
71
72 /// \returns True if \p SSID is restricted to single address space, false
73 /// otherwise
74 bool isOneAddressSpace(SyncScope::ID SSID) const {
75 return SSID == getSingleThreadOneAddressSpaceSSID() ||
80 }
81
82public:
84
85 /// \returns Agent synchronization scope ID (cross address space).
87 return AgentSSID;
88 }
89 /// \returns Workgroup synchronization scope ID (cross address space).
91 return WorkgroupSSID;
92 }
93 /// \returns Wavefront synchronization scope ID (cross address space).
95 return WavefrontSSID;
96 }
97 /// \returns System synchronization scope ID (single address space).
99 return SystemOneAddressSpaceSSID;
100 }
101 /// \returns Agent synchronization scope ID (single address space).
103 return AgentOneAddressSpaceSSID;
104 }
105 /// \returns Workgroup synchronization scope ID (single address space).
107 return WorkgroupOneAddressSpaceSSID;
108 }
109 /// \returns Wavefront synchronization scope ID (single address space).
111 return WavefrontOneAddressSpaceSSID;
112 }
113 /// \returns Single thread synchronization scope ID (single address space).
115 return SingleThreadOneAddressSpaceSSID;
116 }
117
118 /// In AMDGPU target synchronization scopes are inclusive, meaning a
119 /// larger synchronization scope is inclusive of a smaller synchronization
120 /// scope.
121 ///
122 /// \returns True if synchronization scope \p A is larger than or equal to
123 /// synchronization scope \p B, false if synchronization scope \p A is smaller
124 /// than synchronization scope \p B, or "std::nullopt" if either
125 /// synchronization scope \p A or \p B is not supported by the AMDGPU target.
127 SyncScope::ID B) const {
128 const auto &AIO = getSyncScopeInclusionOrdering(A);
129 const auto &BIO = getSyncScopeInclusionOrdering(B);
130 if (!AIO || !BIO)
131 return std::nullopt;
132
133 bool IsAOneAddressSpace = isOneAddressSpace(A);
134 bool IsBOneAddressSpace = isOneAddressSpace(B);
135
136 return *AIO >= *BIO &&
137 (IsAOneAddressSpace == IsBOneAddressSpace || !IsAOneAddressSpace);
138 }
139};
140
141} // end namespace llvm
142
143#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEMODULEINFO_H
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
SyncScope::ID getWorkgroupSSID() const
SyncScope::ID getWavefrontSSID() 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 - This is a MachineModuleInfoImpl implementation for ELF targets.
This class contains meta information specific to a module.
@ SingleThread
Synchronized with respect to signal handlers executing in the same thread.
Definition: LLVMContext.h:54
@ System
Synchronized with respect to all concurrently executing threads.
Definition: LLVMContext.h:57
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18