clang: include/clang/Basic/SyncScope.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_BASIC_SYNCSCOPE_H

15#define LLVM_CLANG_BASIC_SYNCSCOPE_H

16

18#include "llvm/ADT/ArrayRef.h"

19#include "llvm/ADT/StringRef.h"

20#include

21

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

58};

59

61 switch (S) {

63 return "system_scope";

65 return "device_scope";

67 return "workgroup_scope";

69 return "wavefront_scope";

71 return "single_scope";

73 return "hip_singlethread";

75 return "hip_wavefront";

77 return "hip_workgroup";

79 return "hip_agent";

81 return "hip_system";

83 return "opencl_workgroup";

85 return "opencl_device";

87 return "opencl_allsvmdevices";

89 return "opencl_subgroup";

90 }

91 llvm_unreachable("Invalid synch scope");

92}

93

94

96

97

99public:

101

102

104

105

106

107 virtual bool isValid(unsigned S) const = 0;

108

109

110

112

113

114

115

117

118

119

121};

122

123

125public:

126

127

128

136

138

140 switch (static_cast<ID>(S)) {

149 }

150 llvm_unreachable("Invalid language synch scope value");

151 }

152

153 bool isValid(unsigned S) const override {

154 return S >= static_cast<unsigned>(WorkGroup) &&

155 S <= static_cast<unsigned>(Last);

156 }

157

159 static_assert(Last == SubGroup, "Does not include all synch scopes");

160 static const unsigned Scopes[] = {

161 static_cast<unsigned>(WorkGroup), static_cast<unsigned>(Device),

164 }

165

168 }

169};

170

171

173public:

174

175

176

185

187

189 switch (static_cast<ID>(S)) {

200 }

201 llvm_unreachable("Invalid language synch scope value");

202 }

203

204 bool isValid(unsigned S) const override {

205 return S >= static_cast<unsigned>(SingleThread) &&

206 S <= static_cast<unsigned>(Last);

207 }

208

210 static_assert(Last == System, "Does not include all synch scopes");

211 static const unsigned Scopes[] = {

213 static_cast<unsigned>(Workgroup), static_cast<unsigned>(Agent),

214 static_cast<unsigned>(System)};

216 }

217

219 return static_cast<unsigned>(System);

220 }

221};

222

223

225public:

226

235

237

239 switch (static_cast<ID>(S)) {

250 }

251 llvm_unreachable("Invalid language sync scope value");

252 }

253

254 bool isValid(unsigned S) const override {

255 return S <= static_cast(Last);

256 }

257

259 static_assert(Last == Single, "Does not include all sync scopes");

260 static const unsigned Scopes[] = {

261 static_cast<unsigned>(Device), static_cast<unsigned>(System),

263 static_cast<unsigned>(Single)};

265 }

266

268 return static_cast<unsigned>(System);

269 }

270};

271

272inline std::unique_ptr

274 switch (K) {

276 return std::unique_ptr{};

278 return std::make_unique();

280 return std::make_unique();

282 return std::make_unique();

283 }

284 llvm_unreachable("Invalid atomic scope model kind");

285}

286}

287

288#endif

Defines the clang::LangOptions interface.

Defines the generic atomic scope model.

bool isValid(unsigned S) const override

Check if the compile-time constant synch scope value is valid.

AtomicScopeGenericModel()=default

unsigned getFallBackValue() const override

If atomic builtin function is called with invalid synch scope value at runtime, it will fall back to ...

ID

The enum values match predefined built-in macros __ATOMIC_SCOPE_*.

ArrayRef< unsigned > getRuntimeValues() const override

Get all possible synch scope values that might be encountered at runtime for the current language.

SyncScope map(unsigned S) const override

Maps language specific synch scope values to internal SyncScope enum.

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.

The JSON file list parser is used to communicate input to InstallAPI.

AtomicScopeModelKind

Defines the kind of atomic scope models.

SyncScope

Defines synch 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.