Go to the documentation of this file.
14 #ifndef LLVM_CLANG_BASIC_SYNCSCOPE_H
15 #define LLVM_CLANG_BASIC_SYNCSCOPE_H
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/StringRef.h"
58 return "hip_singlethread";
60 return "hip_wavefront";
62 return "hip_workgroup";
68 return "opencl_workgroup";
70 return "opencl_device";
72 return "opencl_allsvmdevices";
74 return "opencl_subgroup";
76 llvm_unreachable(
"Invalid synch scope");
92 virtual bool isValid(
unsigned S)
const = 0;
125 switch (
static_cast<ID>(S)) {
135 llvm_unreachable(
"Invalid language synch scope value");
139 return S >=
static_cast<unsigned>(
WorkGroup) &&
140 S <=
static_cast<unsigned>(
Last);
144 static_assert(
Last ==
SubGroup,
"Does not include all synch scopes");
145 static const unsigned Scopes[] = {
148 return llvm::makeArrayRef(Scopes);
174 switch (
static_cast<ID>(S)) {
186 llvm_unreachable(
"Invalid language synch scope value");
191 S <=
static_cast<unsigned>(
Last);
195 static_assert(
Last ==
System,
"Does not include all synch scopes");
196 static const unsigned Scopes[] = {
199 static_cast<unsigned>(
System)};
200 return llvm::makeArrayRef(Scopes);
204 return static_cast<unsigned>(
System);
208 inline std::unique_ptr<AtomicScopeModel>
212 return std::unique_ptr<AtomicScopeModel>{};
214 return std::make_unique<AtomicScopeOpenCLModel>();
216 return std::make_unique<AtomicScopeHIPModel>();
218 llvm_unreachable(
"Invalid atomic scope model kind");
Defines the synch scope model for OpenCL.
unsigned getFallBackValue() const override
If atomic builtin function is called with invalid synch scope value at runtime, it will fall back to ...
static std::unique_ptr< AtomicScopeModel > create(AtomicScopeModelKind K)
Create an atomic scope model by AtomicScopeModelKind.
ArrayRef< unsigned > getRuntimeValues() const override
Get all possible synch scope values that might be encountered at runtime for the current language.
llvm::StringRef getAsString(SyncScope S)
virtual unsigned getFallBackValue() const =0
If atomic builtin function is called with invalid synch scope value at runtime, it will fall back to ...
Defines the interface for synch scope model.
SyncScope
Defines synch scope values used internally by clang.
bool isValid(unsigned S) const override
Check if the compile-time constant synch scope value is valid.
virtual ~AtomicScopeModel()
ID
The enum values match the pre-defined macros __OPENCL_MEMORY_SCOPE_*, which are used to define memory...
bool isValid(unsigned S) const override
Check if the compile-time constant synch scope value is valid.
virtual bool isValid(unsigned S) const =0
Check if the compile-time constant synch scope value is valid.
virtual ArrayRef< unsigned > getRuntimeValues() const =0
Get all possible synch scope values that might be encountered at runtime for the current language.
Defines the synch scope model for HIP.
ArrayRef< unsigned > getRuntimeValues() const override
Get all possible synch scope values that might be encountered at runtime for the current language.
ID
The enum values match the pre-defined macros __HIP_MEMORY_SCOPE_*, which are used to define memory_sc...
virtual SyncScope map(unsigned S) const =0
Maps language specific synch scope values to internal SyncScope enum.
SyncScope map(unsigned S) const override
Maps language specific synch scope values to internal SyncScope enum.
AtomicScopeModelKind
Defines the kind of atomic scope models.
unsigned getFallBackValue() const override
If atomic builtin function is called with invalid synch scope value at runtime, it will fall back to ...
SyncScope map(unsigned S) const override
Maps language specific synch scope values to internal SyncScope enum.