/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.h
Line | Count | Source |
1 | | //===--- AMDGPUMachineModuleInfo.h ------------------------------*- C++ -*-===// |
2 | | // |
3 | | // The LLVM Compiler Infrastructure |
4 | | // |
5 | | // This file is distributed under the University of Illinois Open Source |
6 | | // License. See LICENSE.TXT for details. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | // |
10 | | /// \file |
11 | | /// \brief AMDGPU Machine Module Info. |
12 | | /// |
13 | | // |
14 | | //===----------------------------------------------------------------------===// |
15 | | |
16 | | #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEMODULEINFO_H |
17 | | #define LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEMODULEINFO_H |
18 | | |
19 | | #include "llvm/ADT/None.h" |
20 | | #include "llvm/ADT/Optional.h" |
21 | | #include "llvm/CodeGen/MachineModuleInfo.h" |
22 | | #include "llvm/CodeGen/MachineModuleInfoImpls.h" |
23 | | #include "llvm/IR/LLVMContext.h" |
24 | | |
25 | | namespace llvm { |
26 | | |
27 | | class AMDGPUMachineModuleInfo final : public MachineModuleInfoELF { |
28 | | private: |
29 | | |
30 | | // All supported memory/synchronization scopes can be found here: |
31 | | // http://llvm.org/docs/AMDGPUUsage.html#memory-scopes |
32 | | |
33 | | /// \brief Agent synchronization scope ID. |
34 | | SyncScope::ID AgentSSID; |
35 | | /// \brief Workgroup synchronization scope ID. |
36 | | SyncScope::ID WorkgroupSSID; |
37 | | /// \brief Wavefront synchronization scope ID. |
38 | | SyncScope::ID WavefrontSSID; |
39 | | |
40 | | /// \brief In AMDGPU target synchronization scopes are inclusive, meaning a |
41 | | /// larger synchronization scope is inclusive of a smaller synchronization |
42 | | /// scope. |
43 | | /// |
44 | | /// \returns \p SSID's inclusion ordering, or "None" if \p SSID is not |
45 | | /// supported by the AMDGPU target. |
46 | 87.9k | Optional<uint8_t> getSyncScopeInclusionOrdering(SyncScope::ID SSID) const { |
47 | 87.9k | if (SSID == SyncScope::SingleThread) |
48 | 44.0k | return 0; |
49 | 43.9k | else if (43.9k SSID == getWavefrontSSID()43.9k ) |
50 | 47 | return 1; |
51 | 43.9k | else if (43.9k SSID == getWorkgroupSSID()43.9k ) |
52 | 48 | return 2; |
53 | 43.8k | else if (43.8k SSID == getAgentSSID()43.8k ) |
54 | 49 | return 3; |
55 | 43.8k | else if (43.8k SSID == SyncScope::System43.8k ) |
56 | 43.8k | return 4; |
57 | 87.9k | |
58 | 12 | return None; |
59 | 87.9k | } |
60 | | |
61 | | public: |
62 | | AMDGPUMachineModuleInfo(const MachineModuleInfo &MMI); |
63 | | |
64 | | /// \returns Agent synchronization scope ID. |
65 | 44.1k | SyncScope::ID getAgentSSID() const { |
66 | 44.1k | return AgentSSID; |
67 | 44.1k | } |
68 | | /// \returns Workgroup synchronization scope ID. |
69 | 44.0k | SyncScope::ID getWorkgroupSSID() const { |
70 | 44.0k | return WorkgroupSSID; |
71 | 44.0k | } |
72 | | /// \returns Wavefront synchronization scope ID. |
73 | 44.0k | SyncScope::ID getWavefrontSSID() const { |
74 | 44.0k | return WavefrontSSID; |
75 | 44.0k | } |
76 | | |
77 | | /// \brief In AMDGPU target synchronization scopes are inclusive, meaning a |
78 | | /// larger synchronization scope is inclusive of a smaller synchronization |
79 | | /// scope. |
80 | | /// |
81 | | /// \returns True if synchronization scope \p A is larger than or equal to |
82 | | /// synchronization scope \p B, false if synchronization scope \p A is smaller |
83 | | /// than synchronization scope \p B, or "None" if either synchronization scope |
84 | | /// \p A or \p B is not supported by the AMDGPU target. |
85 | 43.9k | Optional<bool> isSyncScopeInclusion(SyncScope::ID A, SyncScope::ID B) const { |
86 | 43.9k | const auto &AIO = getSyncScopeInclusionOrdering(A); |
87 | 43.9k | const auto &BIO = getSyncScopeInclusionOrdering(B); |
88 | 43.9k | if (!AIO || 43.9k !BIO43.9k ) |
89 | 12 | return None; |
90 | 43.9k | |
91 | 43.9k | return AIO.getValue() > BIO.getValue(); |
92 | 43.9k | } |
93 | | }; |
94 | | |
95 | | } // end namespace llvm |
96 | | |
97 | | #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEMODULEINFO_H |