clang 21.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.
25enum class OpenACCDirectiveKind : uint8_t {
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
159}
160
161// Tests 'K' to see if it is 'data', 'host_data', 'enter data', or 'exit data'.
163 return K == OpenACCDirectiveKind::Data ||
167}
168
169enum class OpenACCAtomicKind : uint8_t {
170 Read,
171 Write,
172 Update,
173 Capture,
174 None,
175};
176
177template <typename StreamTy>
178inline StreamTy &printOpenACCAtomicKind(StreamTy &Out, OpenACCAtomicKind AK) {
179 switch (AK) {
181 return Out << "read";
183 return Out << "write";
185 return Out << "update";
187 return Out << "capture";
189 return Out << "<none>";
190 }
191}
194 return printOpenACCAtomicKind(Out, AK);
195}
196inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
198 return printOpenACCAtomicKind(Out, AK);
199}
200
201/// Represents the kind of an OpenACC clause.
202enum class OpenACCClauseKind : uint8_t {
203 /// 'finalize' clause, allowed on 'exit data' directive.
204 Finalize,
205 /// 'if_present' clause, allowed on 'host_data' and 'update' directives.
206 IfPresent,
207 /// 'seq' clause, allowed on 'loop' and 'routine' directives.
208 Seq,
209 /// 'independent' clause, allowed on 'loop' directives.
211 /// 'auto' clause, allowed on 'loop' directives.
212 Auto,
213 /// 'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
214 Worker,
215 /// 'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
216 Vector,
217 /// 'nohost' clause, allowed on 'routine' directives.
218 NoHost,
219 /// 'default' clause, allowed on parallel, serial, kernel (and compound)
220 /// constructs.
221 Default,
222 /// 'if' clause, allowed on all the Compute Constructs, Data Constructs,
223 /// Executable Constructs, and Combined Constructs.
224 If,
225 /// 'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
226 Self,
227 /// 'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and
228 /// 'declare'.
229 Copy,
230 /// 'copy' clause alias 'pcopy'. Preserved for diagnostic purposes.
231 PCopy,
232 /// 'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
234 /// 'use_device' clause, allowed on 'host_data' construct.
235 UseDevice,
236 /// 'attach' clause, allowed on Compute and Combined constructs, plus 'data'
237 /// and 'enter data'.
238 Attach,
239 /// 'delete' clause, allowed on the 'exit data' construct.
240 Delete,
241 /// 'detach' clause, allowed on the 'exit data' construct.
242 Detach,
243 /// 'device' clause, allowed on the 'update' construct.
244 Device,
245 /// 'deviceptr' clause, allowed on Compute and Combined Constructs, plus
246 /// 'data' and 'declare'.
247 DevicePtr,
248 /// 'device_resident' clause, allowed on the 'declare' construct.
250 /// 'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop',
251 /// and 'serial loop' constructs.
253 /// 'host' clause, allowed on 'update' construct.
254 Host,
255 /// 'link' clause, allowed on 'declare' construct.
256 Link,
257 /// 'no_create' clause, allowed on allowed on Compute and Combined constructs,
258 /// plus 'data'.
259 NoCreate,
260 /// 'present' clause, allowed on Compute and Combined constructs, plus 'data'
261 /// and 'declare'.
262 Present,
263 /// 'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel
264 /// loop', and 'serial loop' constructs.
265 Private,
266 /// 'copyout' clause, allowed on Compute and Combined constructs, plus 'data',
267 /// 'exit data', and 'declare'.
268 CopyOut,
269 /// 'copyout' clause alias 'pcopyout'. Preserved for diagnostic purposes.
270 PCopyOut,
271 /// 'copyout' clause alias 'present_or_copyout'. Preserved for diagnostic
272 /// purposes.
274 /// 'copyin' clause, allowed on Compute and Combined constructs, plus 'data',
275 /// 'enter data', and 'declare'.
276 CopyIn,
277 /// 'copyin' clause alias 'pcopyin'. Preserved for diagnostic purposes.
278 PCopyIn,
279 /// 'copyin' clause alias 'present_or_copyin'. Preserved for diagnostic
280 /// purposes.
282 /// 'create' clause, allowed on Compute and Combined constructs, plus 'data',
283 /// 'enter data', and 'declare'.
284 Create,
285 /// 'create' clause alias 'pcreate'. Preserved for diagnostic purposes.
286 PCreate,
287 /// 'create' clause alias 'present_or_create'. Preserved for diagnostic
288 /// purposes.
290 /// 'reduction' clause, allowed on Parallel, Serial, Loop, and the combined
291 /// constructs.
292 Reduction,
293 /// 'collapse' clause, allowed on 'loop' and Combined constructs.
294 Collapse,
295 /// 'bind' clause, allowed on routine constructs.
296 Bind,
297 /// 'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop',
298 /// and 'kernels loop' constructs.
300 /// 'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and
301 /// 'kernels loop' constructs.
302 NumGangs,
303 /// 'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop',
304 /// and 'kernels loop' constructs.
306 /// 'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
307 DeviceNum,
308 /// 'default_async' clause, allowed on 'set' construct.
310 /// 'device_type' clause, allowed on Compute, 'data', 'init', 'shutdown',
311 /// 'set', update', 'loop', 'routine', and Combined constructs.
313 /// 'dtype' clause, an alias for 'device_type', stored separately for
314 /// diagnostic purposes.
315 DType,
316 /// 'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined
317 /// constructs.
318 Async,
319 /// 'tile' clause, allowed on 'loop' and Combined constructs.
320 Tile,
321 /// 'gang' clause, allowed on 'loop' and Combined constructs.
322 Gang,
323 /// 'wait' clause, allowed on Compute, Data, 'update', and Combined
324 /// constructs.
325 Wait,
326
327 /// Represents an invalid clause, for the purposes of parsing.
328 Invalid,
329};
330
331template <typename StreamTy>
332inline StreamTy &printOpenACCClauseKind(StreamTy &Out, OpenACCClauseKind K) {
333 switch (K) {
335 return Out << "finalize";
336
338 return Out << "if_present";
339
341 return Out << "seq";
342
344 return Out << "independent";
345
347 return Out << "auto";
348
350 return Out << "worker";
351
353 return Out << "vector";
354
356 return Out << "nohost";
357
359 return Out << "default";
360
362 return Out << "if";
363
365 return Out << "self";
366
368 return Out << "copy";
369
371 return Out << "pcopy";
372
374 return Out << "present_or_copy";
375
377 return Out << "use_device";
378
380 return Out << "attach";
381
383 return Out << "delete";
384
386 return Out << "detach";
387
389 return Out << "device";
390
392 return Out << "deviceptr";
393
395 return Out << "device_resident";
396
398 return Out << "firstprivate";
399
401 return Out << "host";
402
404 return Out << "link";
405
407 return Out << "no_create";
408
410 return Out << "present";
411
413 return Out << "private";
414
416 return Out << "copyout";
417
419 return Out << "pcopyout";
420
422 return Out << "present_or_copyout";
423
425 return Out << "copyin";
426
428 return Out << "pcopyin";
429
431 return Out << "present_or_copyin";
432
434 return Out << "create";
435
437 return Out << "pcreate";
438
440 return Out << "present_or_create";
441
443 return Out << "reduction";
444
446 return Out << "collapse";
447
449 return Out << "bind";
450
452 return Out << "vector_length";
453
455 return Out << "num_gangs";
456
458 return Out << "num_workers";
459
461 return Out << "device_num";
462
464 return Out << "default_async";
465
467 return Out << "device_type";
468
470 return Out << "dtype";
471
473 return Out << "async";
474
476 return Out << "tile";
477
479 return Out << "gang";
480
482 return Out << "wait";
483
485 return Out << "<invalid>";
486 }
487 llvm_unreachable("Uncovered clause kind");
488}
489
492 return printOpenACCClauseKind(Out, K);
493}
494
495inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
497 return printOpenACCClauseKind(Out, K);
498}
499
500enum class OpenACCDefaultClauseKind : uint8_t {
501 /// 'none' option.
502 None,
503 /// 'present' option.
504 Present,
505 /// Not a valid option.
506 Invalid,
507};
508
509template <typename StreamTy>
510inline StreamTy &printOpenACCDefaultClauseKind(StreamTy &Out,
512 switch (K) {
514 return Out << "none";
516 return Out << "present";
518 return Out << "<invalid>";
519 }
520 llvm_unreachable("Unknown OpenACCDefaultClauseKind enum");
521}
522
525 return printOpenACCDefaultClauseKind(Out, K);
526}
527
528inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
530 return printOpenACCDefaultClauseKind(Out, K);
531}
532
533enum class OpenACCReductionOperator : uint8_t {
534 /// '+'.
535 Addition,
536 /// '*'.
538 /// 'max'.
539 Max,
540 /// 'min'.
541 Min,
542 /// '&'.
544 /// '|'.
545 BitwiseOr,
546 /// '^'.
548 /// '&&'.
549 And,
550 /// '||'.
551 Or,
552 /// Invalid Reduction Clause Kind.
553 Invalid,
554};
555
556template <typename StreamTy>
557inline StreamTy &printOpenACCReductionOperator(StreamTy &Out,
559 switch (Op) {
561 return Out << "+";
563 return Out << "*";
565 return Out << "max";
567 return Out << "min";
569 return Out << "&";
571 return Out << "|";
573 return Out << "^";
575 return Out << "&&";
577 return Out << "||";
579 return Out << "<invalid>";
580 }
581 llvm_unreachable("Unknown reduction operator kind");
582}
585 return printOpenACCReductionOperator(Out, Op);
586}
587inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
589 return printOpenACCReductionOperator(Out, Op);
590}
591
592enum class OpenACCGangKind : uint8_t {
593 /// num:
594 Num,
595 /// dim:
596 Dim,
597 /// static:
598 Static
599};
600
601template <typename StreamTy>
602inline StreamTy &printOpenACCGangKind(StreamTy &Out, OpenACCGangKind GK) {
603 switch (GK) {
605 return Out << "num";
607 return Out << "dim";
609 return Out << "static";
610 }
611 llvm_unreachable("unknown gang kind");
612}
614 OpenACCGangKind Op) {
615 return printOpenACCGangKind(Out, Op);
616}
617inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
618 OpenACCGangKind Op) {
619 return printOpenACCGangKind(Out, Op);
620}
621} // namespace clang
622
623#endif // LLVM_CLANG_BASIC_OPENACCKINDS_H
Defines the Diagnostic-related interfaces.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
Definition: Diagnostic.h:1106
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCDirectiveKind
Definition: OpenACCKinds.h:25
OpenACCReductionOperator
Definition: OpenACCKinds.h:533
@ Invalid
Invalid Reduction Clause Kind.
bool isOpenACCComputeDirectiveKind(OpenACCDirectiveKind K)
Definition: OpenACCKinds.h:149
OpenACCAtomicKind
Definition: OpenACCKinds.h:169
bool isOpenACCCombinedDirectiveKind(OpenACCDirectiveKind K)
Definition: OpenACCKinds.h:155
bool isOpenACCDataDirectiveKind(OpenACCDirectiveKind K)
Definition: OpenACCKinds.h:162
OpenACCClauseKind
Represents the kind of an OpenACC clause.
Definition: OpenACCKinds.h:202
@ 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.
StreamTy & printOpenACCDefaultClauseKind(StreamTy &Out, OpenACCDefaultClauseKind K)
Definition: OpenACCKinds.h:510
OpenACCDefaultClauseKind
Definition: OpenACCKinds.h:500
@ Invalid
Not a valid option.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
StreamTy & printOpenACCGangKind(StreamTy &Out, OpenACCGangKind GK)
Definition: OpenACCKinds.h:602
StreamTy & printOpenACCClauseKind(StreamTy &Out, OpenACCClauseKind K)
Definition: OpenACCKinds.h:332
StreamTy & printOpenACCDirectiveKind(StreamTy &Out, OpenACCDirectiveKind K)
Definition: OpenACCKinds.h:70
StreamTy & printOpenACCAtomicKind(StreamTy &Out, OpenACCAtomicKind AK)
Definition: OpenACCKinds.h:178
OpenACCGangKind
Definition: OpenACCKinds.h:592
@ None
The alignment was not explicit in code.
StreamTy & printOpenACCReductionOperator(StreamTy &Out, OpenACCReductionOperator Op)
Definition: OpenACCKinds.h:557