LLVM  9.0.0svn
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 
18 #include "llvm/ADT/None.h"
19 #include "llvm/ADT/Optional.h"
22 #include "llvm/IR/LLVMContext.h"
23 
24 namespace llvm {
25 
27 private:
28 
29  // All supported memory/synchronization scopes can be found here:
30  // http://llvm.org/docs/AMDGPUUsage.html#memory-scopes
31 
32  /// Agent synchronization scope ID.
33  SyncScope::ID AgentSSID;
34  /// Workgroup synchronization scope ID.
35  SyncScope::ID WorkgroupSSID;
36  /// Wavefront synchronization scope ID.
37  SyncScope::ID WavefrontSSID;
38 
39  /// In AMDGPU target synchronization scopes are inclusive, meaning a
40  /// larger synchronization scope is inclusive of a smaller synchronization
41  /// scope.
42  ///
43  /// \returns \p SSID's inclusion ordering, or "None" if \p SSID is not
44  /// supported by the AMDGPU target.
45  Optional<uint8_t> getSyncScopeInclusionOrdering(SyncScope::ID SSID) const {
46  if (SSID == SyncScope::SingleThread)
47  return 0;
48  else if (SSID == getWavefrontSSID())
49  return 1;
50  else if (SSID == getWorkgroupSSID())
51  return 2;
52  else if (SSID == getAgentSSID())
53  return 3;
54  else if (SSID == SyncScope::System)
55  return 4;
56 
57  return None;
58  }
59 
60 public:
62 
63  /// \returns Agent synchronization scope ID.
65  return AgentSSID;
66  }
67  /// \returns Workgroup synchronization scope ID.
69  return WorkgroupSSID;
70  }
71  /// \returns Wavefront synchronization scope ID.
73  return WavefrontSSID;
74  }
75 
76  /// In AMDGPU target synchronization scopes are inclusive, meaning a
77  /// larger synchronization scope is inclusive of a smaller synchronization
78  /// scope.
79  ///
80  /// \returns True if synchronization scope \p A is larger than or equal to
81  /// synchronization scope \p B, false if synchronization scope \p A is smaller
82  /// than synchronization scope \p B, or "None" if either synchronization scope
83  /// \p A or \p B is not supported by the AMDGPU target.
85  const auto &AIO = getSyncScopeInclusionOrdering(A);
86  const auto &BIO = getSyncScopeInclusionOrdering(B);
87  if (!AIO || !BIO)
88  return None;
89 
90  return AIO.getValue() > BIO.getValue();
91  }
92 };
93 
94 } // end namespace llvm
95 
96 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEMODULEINFO_H
Optional< bool > isSyncScopeInclusion(SyncScope::ID A, SyncScope::ID B) const
In AMDGPU target synchronization scopes are inclusive, meaning a larger synchronization scope is incl...
This class represents lattice values for constants.
Definition: AllocatorList.h:23
SyncScope::ID getWavefrontSSID() const
SyncScope::ID getWorkgroupSSID() const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation for ELF targets.
Synchronized with respect to signal handlers executing in the same thread.
Definition: LLVMContext.h:55
AMDGPUMachineModuleInfo(const MachineModuleInfo &MMI)
Synchronized with respect to all concurrently executing threads.
Definition: LLVMContext.h:58
This class contains meta information specific to a module.