15 #ifndef LLVM_CLANG_BASIC_SYNCSCOPE_H 16 #define LLVM_CLANG_BASIC_SYNCSCOPE_H 19 #include "llvm/ADT/ArrayRef.h" 20 #include "llvm/ADT/StringRef.h" 54 return "opencl_workgroup";
56 return "opencl_device";
58 return "opencl_allsvmdevices";
60 return "opencl_subgroup";
62 llvm_unreachable(
"Invalid synch scope");
74 virtual SyncScope map(
unsigned S)
const = 0;
78 virtual bool isValid(
unsigned S)
const = 0;
87 virtual unsigned getFallBackValue()
const = 0;
111 switch (static_cast<ID>(S)) {
121 llvm_unreachable(
"Invalid language synch scope value");
125 return S >=
static_cast<unsigned>(WorkGroup) &&
126 S <= static_cast<unsigned>(
Last);
130 static_assert(
Last == SubGroup,
"Does not include all synch scopes");
131 static const unsigned Scopes[] = {
132 static_cast<unsigned>(WorkGroup), static_cast<unsigned>(Device),
133 static_cast<unsigned>(AllSVMDevices), static_cast<unsigned>(SubGroup)};
134 return llvm::makeArrayRef(Scopes);
138 return static_cast<unsigned>(AllSVMDevices);
142 inline std::unique_ptr<AtomicScopeModel>
146 return std::unique_ptr<AtomicScopeModel>{};
148 return llvm::make_unique<AtomicScopeOpenCLModel>();
150 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.