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"
65 return "system_scope";
67 return "device_scope";
69 return "workgroup_scope";
71 return "cluster_scope";
73 return "wavefront_scope";
75 return "single_scope";
77 return "hip_singlethread";
79 return "hip_wavefront";
81 return "hip_workgroup";
89 return "opencl_workgroup";
91 return "opencl_device";
93 return "opencl_allsvmdevices";
95 return "opencl_subgroup";
97 llvm_unreachable(
"Invalid sync scope");
146 switch (
static_cast<ID>(S)) {
156 llvm_unreachable(
"Invalid language sync scope value");
160 return S >=
static_cast<unsigned>(
WorkGroup) &&
161 S <=
static_cast<unsigned>(
Last);
165 static_assert(
Last ==
SubGroup,
"Does not include all sync scopes");
166 static const unsigned Scopes[] = {
200 switch (
static_cast<ID>(S)) {
216 llvm_unreachable(
"Invalid language sync scope value");
221 S <=
static_cast<unsigned>(
Last);
225 static const unsigned Scopes[] = {
228 static_cast<unsigned>(
System),
static_cast<unsigned>(
Agent)};
229 static_assert(
sizeof(Scopes) /
sizeof(Scopes[0]) ==
Count,
230 "Does not include all sync scopes");
235 return static_cast<unsigned>(
System);
259 switch (
static_cast<ID>(S)) {
275 llvm_unreachable(
"Invalid language sync scope value");
279 return S <= static_cast<unsigned>(
Last);
283 static const unsigned Scopes[] = {
284 static_cast<unsigned>(
System),
static_cast<unsigned>(
Device),
287 static_assert(
sizeof(Scopes) /
sizeof(Scopes[0]) ==
Count,
288 "Does not include all sync scopes");
293 return static_cast<unsigned>(
System);
297inline std::unique_ptr<AtomicScopeModel>
301 return std::unique_ptr<AtomicScopeModel>{};
303 return std::make_unique<AtomicScopeOpenCLModel>();
305 return std::make_unique<AtomicScopeHIPModel>();
307 return std::make_unique<AtomicScopeGenericModel>();
309 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.