clang 20.0.0git
OpenACCKinds.h
Go to the documentation of this file.
1//===--- OpenACCKinds.h - OpenACC Enums -------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// Defines some OpenACC-specific enums and functions.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_BASIC_OPENACCKINDS_H
15#define LLVM_CLANG_BASIC_OPENACCKINDS_H
16
18#include "llvm/Support/ErrorHandling.h"
19#include "llvm/Support/raw_ostream.h"
20
21namespace clang {
22// Represents the Construct/Directive kind of a pragma directive. Note the
23// OpenACC standard is inconsistent between calling these Construct vs
24// Directive, but we're calling it a Directive to be consistent with OpenMP.
26 // Compute Constructs.
28 Serial,
29 Kernels,
30
31 // Data Environment. "enter data" and "exit data" are also referred to in the
32 // Executable Directives section, but just as a back reference to the Data
33 // Environment.
34 Data,
38
39 // Misc.
40 Loop,
41 Cache,
42
43 // Combined Constructs.
47
48 // Atomic Construct.
49 Atomic,
50
51 // Declare Directive.
52 Declare,
53
54 // Executable Directives. "wait" is first referred to here, but ends up being
55 // in its own section after "routine".
56 Init,
58 Set,
59 Update,
60 Wait,
61
62 // Procedure Calls in Compute Regions.
63 Routine,
64
65 // Invalid.
66 Invalid,
67};
68
69template <typename StreamTy>
70inline StreamTy &printOpenACCDirectiveKind(StreamTy &Out,
72 switch (K) {
74 return Out << "parallel";
75
77 return Out << "serial";
78
80 return Out << "kernels";
81
83 return Out << "data";
84
86 return Out << "enter data";
87
89 return Out << "exit data";
90
92 return Out << "host_data";
93
95 return Out << "loop";
96
98 return Out << "cache";
99
101 return Out << "parallel loop";
102
104 return Out << "serial loop";
105
107 return Out << "kernels loop";
108
110 return Out << "atomic";
111
113 return Out << "declare";
114
116 return Out << "init";
117
119 return Out << "shutdown";
120
122 return Out << "set";
123
125 return Out << "update";
126
128 return Out << "wait";
129
131 return Out << "routine";
132
134 return Out << "<invalid>";
135 }
136 llvm_unreachable("Uncovered directive kind");
137}
138
141 return printOpenACCDirectiveKind(Out, K);
142}
143
144inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
146 return printOpenACCDirectiveKind(Out, K);
147}
148
150 return K == OpenACCDirectiveKind::Parallel ||
153}
154
156 Read,
157 Write,
158 Update,
159 Capture,
160 Invalid,
161};
162
163/// Represents the kind of an OpenACC clause.
165 /// 'finalize' clause, allowed on 'exit data' directive.
166 Finalize,
167 /// 'if_present' clause, allowed on 'host_data' and 'update' directives.
168 IfPresent,
169 /// 'seq' clause, allowed on 'loop' and 'routine' directives.
170 Seq,
171 /// 'independent' clause, allowed on 'loop' directives.
173 /// 'auto' clause, allowed on 'loop' directives.
174 Auto,
175 /// 'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
176 Worker,
177 /// 'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
178 Vector,
179 /// 'nohost' clause, allowed on 'routine' directives.
180 NoHost,
181 /// 'default' clause, allowed on parallel, serial, kernel (and compound)
182 /// constructs.
183 Default,
184 /// 'if' clause, allowed on all the Compute Constructs, Data Constructs,
185 /// Executable Constructs, and Combined Constructs.
186 If,
187 /// 'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
188 Self,
189 /// 'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and
190 /// 'declare'.
191 Copy,
192 /// 'copy' clause alias 'pcopy'. Preserved for diagnostic purposes.
193 PCopy,
194 /// 'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
196 /// 'use_device' clause, allowed on 'host_data' construct.
197 UseDevice,
198 /// 'attach' clause, allowed on Compute and Combined constructs, plus 'data'
199 /// and 'enter data'.
200 Attach,
201 /// 'delete' clause, allowed on the 'exit data' construct.
202 Delete,
203 /// 'detach' clause, allowed on the 'exit data' construct.
204 Detach,
205 /// 'device' clause, allowed on the 'update' construct.
206 Device,
207 /// 'deviceptr' clause, allowed on Compute and Combined Constructs, plus
208 /// 'data' and 'declare'.
209 DevicePtr,
210 /// 'device_resident' clause, allowed on the 'declare' construct.
212 /// 'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop',
213 /// and 'serial loop' constructs.
215 /// 'host' clause, allowed on 'update' construct.
216 Host,
217 /// 'link' clause, allowed on 'declare' construct.
218 Link,
219 /// 'no_create' clause, allowed on allowed on Compute and Combined constructs,
220 /// plus 'data'.
221 NoCreate,
222 /// 'present' clause, allowed on Compute and Combined constructs, plus 'data'
223 /// and 'declare'.
224 Present,
225 /// 'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel
226 /// loop', and 'serial loop' constructs.
227 Private,
228 /// 'copyout' clause, allowed on Compute and Combined constructs, plus 'data',
229 /// 'exit data', and 'declare'.
230 CopyOut,
231 /// 'copyout' clause alias 'pcopyout'. Preserved for diagnostic purposes.
232 PCopyOut,
233 /// 'copyout' clause alias 'present_or_copyout'. Preserved for diagnostic
234 /// purposes.
236 /// 'copyin' clause, allowed on Compute and Combined constructs, plus 'data',
237 /// 'enter data', and 'declare'.
238 CopyIn,
239 /// 'copyin' clause alias 'pcopyin'. Preserved for diagnostic purposes.
240 PCopyIn,
241 /// 'copyin' clause alias 'present_or_copyin'. Preserved for diagnostic
242 /// purposes.
244 /// 'create' clause, allowed on Compute and Combined constructs, plus 'data',
245 /// 'enter data', and 'declare'.
246 Create,
247 /// 'create' clause alias 'pcreate'. Preserved for diagnostic purposes.
248 PCreate,
249 /// 'create' clause alias 'present_or_create'. Preserved for diagnostic
250 /// purposes.
252 /// 'reduction' clause, allowed on Parallel, Serial, Loop, and the combined
253 /// constructs.
254 Reduction,
255 /// 'collapse' clause, allowed on 'loop' and Combined constructs.
256 Collapse,
257 /// 'bind' clause, allowed on routine constructs.
258 Bind,
259 /// 'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop',
260 /// and 'kernels loop' constructs.
262 /// 'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and
263 /// 'kernels loop' constructs.
264 NumGangs,
265 /// 'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop',
266 /// and 'kernels loop' constructs.
268 /// 'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
269 DeviceNum,
270 /// 'default_async' clause, allowed on 'set' construct.
272 /// 'device_type' clause, allowed on Compute, 'data', 'init', 'shutdown',
273 /// 'set', update', 'loop', 'routine', and Combined constructs.
275 /// 'dtype' clause, an alias for 'device_type', stored separately for
276 /// diagnostic purposes.
277 DType,
278 /// 'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined
279 /// constructs.
280 Async,
281 /// 'tile' clause, allowed on 'loop' and Combined constructs.
282 Tile,
283 /// 'gang' clause, allowed on 'loop' and Combined constructs.
284 Gang,
285 /// 'wait' clause, allowed on Compute, Data, 'update', and Combined
286 /// constructs.
287 Wait,
288
289 /// Represents an invalid clause, for the purposes of parsing.
290 Invalid,
291};
292
293template <typename StreamTy>
294inline StreamTy &printOpenACCClauseKind(StreamTy &Out, OpenACCClauseKind K) {
295 switch (K) {
297 return Out << "finalize";
298
300 return Out << "if_present";
301
303 return Out << "seq";
304
306 return Out << "independent";
307
309 return Out << "auto";
310
312 return Out << "worker";
313
315 return Out << "vector";
316
318 return Out << "nohost";
319
321 return Out << "default";
322
324 return Out << "if";
325
327 return Out << "self";
328
330 return Out << "copy";
331
333 return Out << "pcopy";
334
336 return Out << "present_or_copy";
337
339 return Out << "use_device";
340
342 return Out << "attach";
343
345 return Out << "delete";
346
348 return Out << "detach";
349
351 return Out << "device";
352
354 return Out << "deviceptr";
355
357 return Out << "device_resident";
358
360 return Out << "firstprivate";
361
363 return Out << "host";
364
366 return Out << "link";
367
369 return Out << "no_create";
370
372 return Out << "present";
373
375 return Out << "private";
376
378 return Out << "copyout";
379
381 return Out << "pcopyout";
382
384 return Out << "present_or_copyout";
385
387 return Out << "copyin";
388
390 return Out << "pcopyin";
391
393 return Out << "present_or_copyin";
394
396 return Out << "create";
397
399 return Out << "pcreate";
400
402 return Out << "present_or_create";
403
405 return Out << "reduction";
406
408 return Out << "collapse";
409
411 return Out << "bind";
412
414 return Out << "vector_length";
415
417 return Out << "num_gangs";
418
420 return Out << "num_workers";
421
423 return Out << "device_num";
424
426 return Out << "default_async";
427
429 return Out << "device_type";
430
432 return Out << "dtype";
433
435 return Out << "async";
436
438 return Out << "tile";
439
441 return Out << "gang";
442
444 return Out << "wait";
445
447 return Out << "<invalid>";
448 }
449 llvm_unreachable("Uncovered clause kind");
450}
451
454 return printOpenACCClauseKind(Out, K);
455}
456
457inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
459 return printOpenACCClauseKind(Out, K);
460}
461
463 /// 'none' option.
464 None,
465 /// 'present' option.
466 Present,
467 /// Not a valid option.
468 Invalid,
469};
470
471template <typename StreamTy>
472inline StreamTy &printOpenACCDefaultClauseKind(StreamTy &Out,
474 switch (K) {
476 return Out << "none";
478 return Out << "present";
480 return Out << "<invalid>";
481 }
482 llvm_unreachable("Unknown OpenACCDefaultClauseKind enum");
483}
484
487 return printOpenACCDefaultClauseKind(Out, K);
488}
489
490inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
492 return printOpenACCDefaultClauseKind(Out, K);
493}
494
496 /// '+'.
497 Addition,
498 /// '*'.
500 /// 'max'.
501 Max,
502 /// 'min'.
503 Min,
504 /// '&'.
506 /// '|'.
507 BitwiseOr,
508 /// '^'.
510 /// '&&'.
511 And,
512 /// '||'.
513 Or,
514 /// Invalid Reduction Clause Kind.
515 Invalid,
516};
517
518template <typename StreamTy>
519inline StreamTy &printOpenACCReductionOperator(StreamTy &Out,
521 switch (Op) {
523 return Out << "+";
525 return Out << "*";
527 return Out << "max";
529 return Out << "min";
531 return Out << "&";
533 return Out << "|";
535 return Out << "^";
537 return Out << "&&";
539 return Out << "||";
541 return Out << "<invalid>";
542 }
543 llvm_unreachable("Unknown reduction operator kind");
544}
547 return printOpenACCReductionOperator(Out, Op);
548}
549inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
551 return printOpenACCReductionOperator(Out, Op);
552}
553} // namespace clang
554
555#endif // LLVM_CLANG_BASIC_OPENACCKINDS_H
Defines the Diagnostic-related interfaces.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
Definition: Diagnostic.h:1115
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCClauseKind
Represents the kind of an OpenACC clause.
Definition: OpenACCKinds.h:164
@ Auto
'auto' clause, allowed on 'loop' directives.
@ Bind
'bind' clause, allowed on routine constructs.
@ Gang
'gang' clause, allowed on 'loop' and Combined constructs.
@ Wait
'wait' clause, allowed on Compute, Data, 'update', and Combined constructs.
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ PCopyOut
'copyout' clause alias 'pcopyout'. Preserved for diagnostic purposes.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Async
'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined constructs.
@ PresentOrCreate
'create' clause alias 'present_or_create'.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ NoHost
'nohost' clause, allowed on 'routine' directives.
@ PresentOrCopy
'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Copy
'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ Worker
'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ DeviceType
'device_type' clause, allowed on Compute, 'data', 'init', 'shutdown', 'set', update',...
@ DefaultAsync
'default_async' clause, allowed on 'set' construct.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ NumGangs
'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
@ Default
'default' clause, allowed on parallel, serial, kernel (and compound) constructs.
@ UseDevice
'use_device' clause, allowed on 'host_data' construct.
@ NoCreate
'no_create' clause, allowed on allowed on Compute and Combined constructs, plus 'data'.
@ PresentOrCopyOut
'copyout' clause alias 'present_or_copyout'.
@ Link
'link' clause, allowed on 'declare' construct.
@ Reduction
'reduction' clause, allowed on Parallel, Serial, Loop, and the combined constructs.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ CopyOut
'copyout' clause, allowed on Compute and Combined constructs, plus 'data', 'exit data',...
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
@ FirstPrivate
'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop', and 'serial loop' constructs...
@ Host
'host' clause, allowed on 'update' construct.
@ PCopy
'copy' clause alias 'pcopy'. Preserved for diagnostic purposes.
@ Tile
'tile' clause, allowed on 'loop' and Combined constructs.
@ PCopyIn
'copyin' clause alias 'pcopyin'. Preserved for diagnostic purposes.
@ DeviceResident
'device_resident' clause, allowed on the 'declare' construct.
@ PCreate
'create' clause alias 'pcreate'. Preserved for diagnostic purposes.
@ Present
'present' clause, allowed on Compute and Combined constructs, plus 'data' and 'declare'.
@ DType
'dtype' clause, an alias for 'device_type', stored separately for diagnostic purposes.
@ CopyIn
'copyin' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ Device
'device' clause, allowed on the 'update' construct.
@ Independent
'independent' clause, allowed on 'loop' directives.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
@ IfPresent
'if_present' clause, allowed on 'host_data' and 'update' directives.
@ Detach
'detach' clause, allowed on the 'exit data' construct.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ PresentOrCopyIn
'copyin' clause alias 'present_or_copyin'.
@ Finalize
'finalize' clause, allowed on 'exit data' directive.
bool isOpenACCComputeDirectiveKind(OpenACCDirectiveKind K)
Definition: OpenACCKinds.h:149
StreamTy & printOpenACCDefaultClauseKind(StreamTy &Out, OpenACCDefaultClauseKind K)
Definition: OpenACCKinds.h:472
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
OpenACCAtomicKind
Definition: OpenACCKinds.h:155
OpenACCDefaultClauseKind
Definition: OpenACCKinds.h:462
@ Invalid
Not a valid option.
StreamTy & printOpenACCClauseKind(StreamTy &Out, OpenACCClauseKind K)
Definition: OpenACCKinds.h:294
OpenACCDirectiveKind
Definition: OpenACCKinds.h:25
StreamTy & printOpenACCDirectiveKind(StreamTy &Out, OpenACCDirectiveKind K)
Definition: OpenACCKinds.h:70
OpenACCReductionOperator
Definition: OpenACCKinds.h:495
@ Invalid
Invalid Reduction Clause Kind.
@ None
The alignment was not explicit in code.
StreamTy & printOpenACCReductionOperator(StreamTy &Out, OpenACCReductionOperator Op)
Definition: OpenACCKinds.h:519