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"
63 return "system_scope";
65 return "device_scope";
67 return "workgroup_scope";
69 return "wavefront_scope";
71 return "single_scope";
73 return "hip_singlethread";
75 return "hip_wavefront";
77 return "hip_workgroup";
83 return "opencl_workgroup";
85 return "opencl_device";
87 return "opencl_allsvmdevices";
89 return "opencl_subgroup";
91 llvm_unreachable(
"Invalid synch scope");
140 switch (
static_cast<ID>(S)) {
150 llvm_unreachable(
"Invalid language synch scope value");
154 return S >=
static_cast<unsigned>(
WorkGroup) &&
155 S <=
static_cast<unsigned>(
Last);
159 static_assert(
Last ==
SubGroup,
"Does not include all synch scopes");
160 static const unsigned Scopes[] = {
189 switch (
static_cast<ID>(S)) {
201 llvm_unreachable(
"Invalid language synch scope value");
206 S <=
static_cast<unsigned>(
Last);
210 static_assert(
Last ==
System,
"Does not include all synch scopes");
211 static const unsigned Scopes[] = {
214 static_cast<unsigned>(
System)};
219 return static_cast<unsigned>(
System);
239 switch (
static_cast<ID>(S)) {
251 llvm_unreachable(
"Invalid language sync scope value");
255 return S <= static_cast<unsigned>(
Last);
259 static_assert(
Last ==
Single,
"Does not include all sync scopes");
260 static const unsigned Scopes[] = {
261 static_cast<unsigned>(
Device),
static_cast<unsigned>(
System),
263 static_cast<unsigned>(
Single)};
268 return static_cast<unsigned>(
System);
272inline std::unique_ptr<AtomicScopeModel>
276 return std::unique_ptr<AtomicScopeModel>{};
278 return std::make_unique<AtomicScopeOpenCLModel>();
280 return std::make_unique<AtomicScopeHIPModel>();
282 return std::make_unique<AtomicScopeGenericModel>();
284 llvm_unreachable(
"Invalid atomic scope model kind");
Defines the clang::LangOptions interface.
Defines the generic atomic scope model.
bool isValid(unsigned S) const override
Check if the compile-time constant synch scope value is valid.
AtomicScopeGenericModel()=default
unsigned getFallBackValue() const override
If atomic builtin function is called with invalid synch scope value at runtime, it will fall back to ...
ID
The enum values match predefined built-in macros __ATOMIC_SCOPE_*.
ArrayRef< unsigned > getRuntimeValues() const override
Get all possible synch scope values that might be encountered at runtime for the current language.
SyncScope map(unsigned S) const override
Maps language specific synch scope values to internal SyncScope enum.
Defines the synch scope model for HIP.
bool isValid(unsigned S) const override
Check if the compile-time constant synch scope value is valid.
ID
The enum values match the pre-defined macros __HIP_MEMORY_SCOPE_*, which are used to define memory_sc...
ArrayRef< unsigned > getRuntimeValues() const override
Get all possible synch scope values that might be encountered at runtime for the current language.
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.
Defines the interface for synch scope model.
static std::unique_ptr< AtomicScopeModel > create(AtomicScopeModelKind K)
Create an atomic scope model by AtomicScopeModelKind.
virtual ArrayRef< unsigned > getRuntimeValues() const =0
Get all possible synch scope values that might be encountered at runtime for the current language.
virtual SyncScope map(unsigned S) const =0
Maps language specific synch scope values to internal SyncScope enum.
virtual unsigned getFallBackValue() const =0
If atomic builtin function is called with invalid synch scope value at runtime, it will fall back to ...
virtual ~AtomicScopeModel()
virtual bool isValid(unsigned S) const =0
Check if the compile-time constant synch scope value is valid.
Defines the synch scope model for OpenCL.
ID
The enum values match the pre-defined macros __OPENCL_MEMORY_SCOPE_*, which are used to define memory...
ArrayRef< unsigned > getRuntimeValues() const override
Get all possible synch scope values that might be encountered at runtime for the current language.
bool isValid(unsigned S) const override
Check if the compile-time constant synch scope value is valid.
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.
The JSON file list parser is used to communicate input to InstallAPI.
AtomicScopeModelKind
Defines the kind of atomic scope models.
SyncScope
Defines synch scope values used internally by clang.
llvm::StringRef getAsString(SyncScope S)
@ Generic
not a target-specific vector type
@ None
The alignment was not explicit in code.