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[] = {
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)};
204 return static_cast<unsigned>(
System);
208inline 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 clang::LangOptions interface.
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.
AtomicScopeModelKind
Defines the kind of atomic scope models.
SyncScope
Defines synch scope values used internally by clang.
llvm::StringRef getAsString(SyncScope S)
@ None
The alignment was not explicit in code.