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"
20#include "llvm/TargetParser/AtomicScope.h"
66 return "system_scope";
68 return "device_scope";
70 return "workgroup_scope";
72 return "cluster_scope";
74 return "wavefront_scope";
76 return "single_scope";
78 return "hip_singlethread";
80 return "hip_wavefront";
82 return "hip_workgroup";
90 return "opencl_workgroup";
92 return "opencl_device";
94 return "opencl_allsvmdevices";
96 return "opencl_subgroup";
98 llvm_unreachable(
"Invalid sync scope");
147 switch (
static_cast<ID>(S)) {
157 llvm_unreachable(
"Invalid language sync scope value");
161 return S >=
static_cast<unsigned>(
WorkGroup) &&
162 S <=
static_cast<unsigned>(
Last);
166 static_assert(
Last ==
SubGroup,
"Does not include all sync scopes");
167 static const unsigned Scopes[] = {
201 switch (
static_cast<ID>(S)) {
217 llvm_unreachable(
"Invalid language sync scope value");
222 S <=
static_cast<unsigned>(
Last);
226 static const unsigned Scopes[] = {
229 static_cast<unsigned>(
System),
static_cast<unsigned>(
Agent)};
230 static_assert(
sizeof(Scopes) /
sizeof(Scopes[0]) ==
Count,
231 "Does not include all sync scopes");
236 return static_cast<unsigned>(
System);
247 System =
static_cast<unsigned>(llvm::AtomicScope::System),
248 Device =
static_cast<unsigned>(llvm::AtomicScope::Device),
249 Workgroup =
static_cast<unsigned>(llvm::AtomicScope::Workgroup),
250 Wavefront =
static_cast<unsigned>(llvm::AtomicScope::Wavefront),
251 Single =
static_cast<unsigned>(llvm::AtomicScope::Single),
252 Cluster =
static_cast<unsigned>(llvm::AtomicScope::Cluster),
260 switch (
static_cast<ID>(S)) {
276 llvm_unreachable(
"Invalid language sync scope value");
280 return S <= static_cast<unsigned>(
Last);
284 static const unsigned Scopes[] = {
285 static_cast<unsigned>(
System),
static_cast<unsigned>(
Device),
288 static_assert(
sizeof(Scopes) /
sizeof(Scopes[0]) ==
Count,
289 "Does not include all sync scopes");
294 return static_cast<unsigned>(
System);
298inline std::unique_ptr<AtomicScopeModel>
302 return std::unique_ptr<AtomicScopeModel>{};
304 return std::make_unique<AtomicScopeOpenCLModel>();
306 return std::make_unique<AtomicScopeHIPModel>();
308 return std::make_unique<AtomicScopeGenericModel>();
310 llvm_unreachable(
"Invalid atomic scope model kind");
Defines the clang::LangOptions interface.
bool isValid(unsigned S) const override
Check if the compile-time constant sync scope value is valid.
AtomicScopeGenericModel()=default
unsigned getFallBackValue() const override
If atomic builtin function is called with invalid sync scope value at runtime, it will fall back to a...
ID
The enum values match predefined built-in macros __MEMORY_SCOPE_*.
ArrayRef< unsigned > getRuntimeValues() const override
Get all possible sync scope values that might be encountered at runtime for the current language.
SyncScope map(unsigned S) const override
Maps language specific sync scope values to internal SyncScope enum.
bool isValid(unsigned S) const override
Check if the compile-time constant sync 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 sync scope values that might be encountered at runtime for the current language.
unsigned getFallBackValue() const override
If atomic builtin function is called with invalid sync scope value at runtime, it will fall back to a...
SyncScope map(unsigned S) const override
Maps language specific sync scope values to internal SyncScope enum.
Defines the interface for sync 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 sync scope values that might be encountered at runtime for the current language.
virtual SyncScope map(unsigned S) const =0
Maps language specific sync scope values to internal SyncScope enum.
virtual unsigned getFallBackValue() const =0
If atomic builtin function is called with invalid sync scope value at runtime, it will fall back to a...
virtual ~AtomicScopeModel()
virtual bool isValid(unsigned S) const =0
Check if the compile-time constant sync scope value is valid.
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 sync scope values that might be encountered at runtime for the current language.
bool isValid(unsigned S) const override
Check if the compile-time constant sync scope value is valid.
unsigned getFallBackValue() const override
If atomic builtin function is called with invalid sync scope value at runtime, it will fall back to a...
SyncScope map(unsigned S) const override
Maps language specific sync 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 sync 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.