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" 53 return "opencl_workgroup";
55 return "opencl_device";
57 return "opencl_allsvmdevices";
59 return "opencl_subgroup";
61 llvm_unreachable(
"Invalid synch scope");
73 virtual SyncScope map(
unsigned S)
const = 0;
77 virtual bool isValid(
unsigned S)
const = 0;
86 virtual unsigned getFallBackValue()
const = 0;
110 switch (static_cast<ID>(S)) {
120 llvm_unreachable(
"Invalid language synch scope value");
124 return S >=
static_cast<unsigned>(WorkGroup) &&
125 S <= static_cast<unsigned>(
Last);
129 static_assert(
Last == SubGroup,
"Does not include all synch scopes");
130 static const unsigned Scopes[] = {
131 static_cast<unsigned>(WorkGroup), static_cast<unsigned>(Device),
132 static_cast<unsigned>(AllSVMDevices), static_cast<unsigned>(SubGroup)};
133 return llvm::makeArrayRef(Scopes);
137 return static_cast<unsigned>(AllSVMDevices);
141 inline std::unique_ptr<AtomicScopeModel>
145 return std::unique_ptr<AtomicScopeModel>{};
147 return std::make_unique<AtomicScopeOpenCLModel>();
149 llvm_unreachable(
"Invalid atomic scope model kind");
SyncScope map(unsigned S) const override
Maps language specific synch scope values to internal SyncScope enum.
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.
Defines the interface for synch scope model.
ArrayRef< unsigned > getRuntimeValues() const override
Get all possible synch scope values that might be encountered at runtime for the current language...
Defines the clang::LangOptions interface.
bool isValid(unsigned S) const override
Check if the compile-time constant synch scope value is valid.
llvm::StringRef getAsString(SyncScope S)
ID
The enum values match the pre-defined macros __OPENCL_MEMORY_SCOPE_*, which are used to define memory...
Defines the synch scope model for OpenCL.
SyncScope
Defines synch scope values used internally by clang.
virtual ~AtomicScopeModel()
Dataflow Directional Tag Classes.
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
AtomicScopeModelKind
Defines the kind of atomic scope models.