clang 22.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/ADT/BitmaskEnum.h"
19#include "llvm/Support/ErrorHandling.h"
20#include "llvm/Support/raw_ostream.h"
21
22namespace clang {
24
25/ Represents the Construct/Directive kind of a pragma directive. Note the
26/ OpenACC standard is inconsistent between calling these Construct vs
27/ Directive, but we're calling it a Directive to be consistent with OpenMP.
28enum class OpenACCDirectiveKind : uint8_t {
29 / Compute Constructs.
33
34 / Data Environment. "enter data" and "exit data" are also referred to in the
35 / Executable Directives section, but just as a back reference to the Data
36 / Environment.
41
42 / Misc.
45
46 / Combined Constructs.
50
51 / Atomic Construct.
53
54 / Declare Directive.
56
57 / Executable Directives. "wait" is first referred to here, but ends up being
58 / in its own section after "routine".
64
65 / Procedure Calls in Compute Regions.
67
68 / Invalid.
70};
71
72template <typename StreamTy>
73inline StreamTy &printOpenACCDirectiveKind(StreamTy &Out,
75 switch (K) {
77 return Out << "parallel";
78
80 return Out << "serial";
81
83 return Out << "kernels";
84
86 return Out << "data";
87
89 return Out << "enter data";
90
92 return Out << "exit data";
93
95 return Out << "host_data";
96
98 return Out << "loop";
99
101 return Out << "cache";
102
104 return Out << "parallel loop";
105
107 return Out << "serial loop";
108
110 return Out << "kernels loop";
111
113 return Out << "atomic";
114
116 return Out << "declare";
117
119 return Out << "init";
120
122 return Out << "shutdown";
123
125 return Out << "set";
126
128 return Out << "update";
129
131 return Out << "wait";
132
134 return Out << "routine";
135
137 return Out << "<invalid>";
138 }
139 llvm_unreachable("Uncovered directive kind");
140}
141
144 return printOpenACCDirectiveKind(Out, K);
145}
146
147inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
149 return printOpenACCDirectiveKind(Out, K);
150}
151
157
163
164/ Tests 'K' to see if it is 'data', 'host_data', 'enter data', or 'exit data'.
171
179
180template <typename StreamTy>
181inline StreamTy &printOpenACCAtomicKind(StreamTy &Out, OpenACCAtomicKind AK) {
182 switch (AK) {
184 return Out << "read";
186 return Out << "write";
188 return Out << "update";
190 return Out << "capture";
192 return Out << "<none>";
193 }
194 llvm_unreachable("unknown atomic kind");
195}
198 return printOpenACCAtomicKind(Out, AK);
199}
200inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
202 return printOpenACCAtomicKind(Out, AK);
203}
204
205/ Represents the kind of an OpenACC clause. Sorted alphabetically, since this
206/ order ends up influencing the sorting of the list diagnostic.
207enum class OpenACCClauseKind : uint8_t {
208 / 'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined
209 / constructs.
211 / 'attach' clause, allowed on Compute and Combined constructs, plus 'data'
212 / and 'enter data'.
214 / 'auto' clause, allowed on 'loop' directives.
216 / 'bind' clause, allowed on routine constructs.
218 / 'collapse' clause, allowed on 'loop' and Combined constructs.
220 / 'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and
221 / 'declare'.
223 / 'copy' clause alias 'pcopy'. Preserved for diagnostic purposes.
225 / 'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
227 / 'copyin' clause, allowed on Compute and Combined constructs, plus 'data',
228 / 'enter data', and 'declare'.
230 / 'copyin' clause alias 'pcopyin'. Preserved for diagnostic purposes.
232 / 'copyin' clause alias 'present_or_copyin'. Preserved for diagnostic
233 / purposes.
235 / 'copyout' clause, allowed on Compute and Combined constructs, plus 'data',
236 / 'exit data', and 'declare'.
238 / 'copyout' clause alias 'pcopyout'. Preserved for diagnostic purposes.
240 / 'copyout' clause alias 'present_or_copyout'. Preserved for diagnostic
241 / purposes.
243 / 'create' clause, allowed on Compute and Combined constructs, plus 'data',
244 / 'enter data', and 'declare'.
246 / 'create' clause alias 'pcreate'. Preserved for diagnostic purposes.
248 / 'create' clause alias 'present_or_create'. Preserved for diagnostic
249 / purposes.
251 / 'default' clause, allowed on parallel, serial, kernel (and compound)
252 / constructs.
254 / 'default_async' clause, allowed on 'set' construct.
256 / 'delete' clause, allowed on the 'exit data' construct.
258 / 'detach' clause, allowed on the 'exit data' construct.
260 / 'device' clause, allowed on the 'update' construct.
262 / 'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
264 / 'deviceptr' clause, allowed on Compute and Combined Constructs, plus
265 / 'data' and 'declare'.
267 / 'device_resident' clause, allowed on the 'declare' construct.
269 / 'device_type' clause, allowed on Compute, 'data', 'init', 'shutdown',
270 / 'set', update', 'loop', 'routine', and Combined constructs.
272 / 'dtype' clause, an alias for 'device_type', stored separately for
273 / diagnostic purposes.
275 / 'finalize' clause, allowed on 'exit data' directive.
277 / 'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop',
278 / and 'serial loop' constructs.
280 / 'gang' clause, allowed on 'loop' and Combined constructs.
282 / 'host' clause, allowed on 'update' construct.
284 / 'if' clause, allowed on all the Compute Constructs, Data Constructs,
285 / Executable Constructs, and Combined Constructs.
287 / 'if_present' clause, allowed on 'host_data' and 'update' directives.
289 / 'independent' clause, allowed on 'loop' directives.
291 / 'link' clause, allowed on 'declare' construct.
293 / 'no_create' clause, allowed on allowed on Compute and Combined constructs,
294 / plus 'data'.
296 / 'nohost' clause, allowed on 'routine' directives.
298 / 'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and
299 / 'kernels loop' constructs.
301 / 'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop',
302 / and 'kernels loop' constructs.
304 / 'present' clause, allowed on Compute and Combined constructs, plus 'data'
305 / and 'declare'.
307 / 'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel
308 / loop', and 'serial loop' constructs.
310 / 'reduction' clause, allowed on Parallel, Serial, Loop, and the combined
311 / constructs.
313 / 'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
315 / 'seq' clause, allowed on 'loop' and 'routine' directives.
317 / 'tile' clause, allowed on 'loop' and Combined constructs.
319 / 'use_device' clause, allowed on 'host_data' construct.
321 / 'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
323 / 'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop',
324 / and 'kernels loop' constructs.
326 / 'wait' clause, allowed on Compute, Data, 'update', and Combined
327 / constructs.
329 / 'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
331
332 / 'shortloop' is represented in the ACC.td file, but isn't present in the
333 / standard. This appears to be an old extension for the nvidia fortran
334 / compiler, but seemingly not elsewhere. Put it here as a placeholder, but it
335 / is never expected to be generated.
337 / Represents an invalid clause, for the purposes of parsing. Should be
338 / 'last'.
340};
341
342template <typename StreamTy>
343inline StreamTy &printOpenACCClauseKind(StreamTy &Out, OpenACCClauseKind K) {
344 switch (K) {
346 return Out << "finalize";
347
349 return Out << "if_present";
350
352 return Out << "seq";
353
355 return Out << "independent";
356
358 return Out << "auto";
359
361 return Out << "worker";
362
364 return Out << "vector";
365
367 return Out << "nohost";
368
370 return Out << "default";
371
373 return Out << "if";
374
376 return Out << "self";
377
379 return Out << "copy";
380
382 return Out << "pcopy";
383
385 return Out << "present_or_copy";
386
388 return Out << "use_device";
389
391 return Out << "attach";
392
394 return Out << "delete";
395
397 return Out << "detach";
398
400 return Out << "device";
401
403 return Out << "deviceptr";
404
406 return Out << "device_resident";
407
409 return Out << "firstprivate";
410
412 return Out << "host";
413
415 return Out << "link";
416
418 return Out << "no_create";
419
421 return Out << "present";
422
424 return Out << "private";
425
427 return Out << "copyout";
428
430 return Out << "pcopyout";
431
433 return Out << "present_or_copyout";
434
436 return Out << "copyin";
437
439 return Out << "pcopyin";
440
442 return Out << "present_or_copyin";
443
445 return Out << "create";
446
448 return Out << "pcreate";
449
451 return Out << "present_or_create";
452
454 return Out << "reduction";
455
457 return Out << "collapse";
458
460 return Out << "bind";
461
463 return Out << "vector_length";
464
466 return Out << "num_gangs";
467
469 return Out << "num_workers";
470
472 return Out << "device_num";
473
475 return Out << "default_async";
476
478 return Out << "device_type";
479
481 return Out << "dtype";
482
484 return Out << "async";
485
487 return Out << "tile";
488
490 return Out << "gang";
491
493 return Out << "wait";
494
496 llvm_unreachable("Shortloop shouldn't be generated in clang");
497 [[fallthrough]];
499 return Out << "<invalid>";
500 }
501 llvm_unreachable("Uncovered clause kind");
502}
503
506 return printOpenACCClauseKind(Out, K);
507}
508
509inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
511 return printOpenACCClauseKind(Out, K);
512}
513
514enum class OpenACCDefaultClauseKind : uint8_t {
515 / 'none' option.
517 / 'present' option.
519 / Not a valid option.
521};
522
523template <typename StreamTy>
524inline StreamTy &printOpenACCDefaultClauseKind(StreamTy &Out,
526 switch (K) {
528 return Out << "none";
530 return Out << "present";
532 return Out << "<invalid>";
533 }
534 llvm_unreachable("Unknown OpenACCDefaultClauseKind enum");
535}
536
541
542inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
544 return printOpenACCDefaultClauseKind(Out, K);
545}
546
547enum class OpenACCReductionOperator : uint8_t {
548 / '+'.
550 / '*'.
552 / 'max'.
554 / 'min'.
556 / '&'.
558 / '|'.
560 / '^'.
562 / '&&'.
564 / '||'.
566 / Invalid Reduction Clause Kind.
568};
569
570template <typename StreamTy>
571inline StreamTy &printOpenACCReductionOperator(StreamTy &Out,
573 switch (Op) {
575 return Out << "+";
577 return Out << "*";
579 return Out << "max";
581 return Out << "min";
583 return Out << "&";
585 return Out << "|";
587 return Out << "^";
589 return Out << "&&";
591 return Out << "||";
593 return Out << "<invalid>";
594 }
595 llvm_unreachable("Unknown reduction operator kind");
596}
601inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
603 return printOpenACCReductionOperator(Out, Op);
604}
605
606enum class OpenACCGangKind : uint8_t {
607 / num:
609 / dim:
611 / static:
613};
614
615template <typename StreamTy>
616inline StreamTy &printOpenACCGangKind(StreamTy &Out, OpenACCGangKind GK) {
617 switch (GK) {
619 return Out << "num";
621 return Out << "dim";
623 return Out << "static";
624 }
625 llvm_unreachable("unknown gang kind");
626}
628 OpenACCGangKind Op) {
629 return printOpenACCGangKind(Out, Op);
630}
631inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
632 OpenACCGangKind Op) {
633 return printOpenACCGangKind(Out, Op);
634}
635
636/ Represents the 'modifier' of a 'modifier-list', as applied to copy, copyin,
637/ copyout, and create. Implemented as a 'bitmask'.
638/ Note: This attempts to synchronize with mlir::acc::DataClauseModifier,
639/ however has to store `Always` separately(whereas MLIR has it as AlwaysIn &
640/ AlwaysOut). However, we keep them in sync so that we can cast between them.
641enum class OpenACCModifierKind : uint8_t {
643 Zero = 1 << 0,
644 Readonly = 1 << 1,
645 AlwaysIn = 1 << 2,
646 AlwaysOut = 1 << 3,
647 Capture = 1 << 4,
648 Always = 1 << 5,
650};
651
654 return (List & Bit) != OpenACCModifierKind::Invalid;
655}
656
657template <typename StreamTy>
658inline StreamTy &printOpenACCModifierKind(StreamTy &Out,
659 OpenACCModifierKind Mods) {
661 return Out << "<invalid>";
662
663 bool First = true;
664
666 Out << "always";
667 First = false;
668 }
669
671 if (!First)
672 Out << ", ";
673 Out << "alwaysin";
674 First = false;
675 }
676
678 if (!First)
679 Out << ", ";
680 Out << "alwaysout";
681 First = false;
682 }
683
685 if (!First)
686 Out << ", ";
687 Out << "readonly";
688 First = false;
689 }
690
692 if (!First)
693 Out << ", ";
694 Out << "zero";
695 First = false;
696 }
697
699 if (!First)
700 Out << ", ";
701 Out << "capture";
702 First = false;
703 }
704 return Out;
705}
708 return printOpenACCModifierKind(Out, Op);
709}
710inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
712 return printOpenACCModifierKind(Out, Op);
713}
714} / namespace clang
715
716#endif / LLVM_CLANG_BASIC_OPENACCKINDS_H
Defines the Diagnostic-related interfaces.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCDirectiveKind
OpenACCReductionOperator
@ Invalid
Invalid Reduction Clause Kind.
bool isOpenACCComputeDirectiveKind(OpenACCDirectiveKind K)
OpenACCAtomicKind
bool isOpenACCCombinedDirectiveKind(OpenACCDirectiveKind K)
OpenACCModifierKind
bool isOpenACCDataDirectiveKind(OpenACCDirectiveKind K)
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ 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'.
@ Shortloop
'shortloop' is represented in the ACC.td file, but isn't present in the standard.
@ 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)
OpenACCDefaultClauseKind
@ Invalid
Not a valid option.
StreamTy & printOpenACCGangKind(StreamTy &Out, OpenACCGangKind GK)
StreamTy & printOpenACCClauseKind(StreamTy &Out, OpenACCClauseKind K)
StreamTy & printOpenACCModifierKind(StreamTy &Out, OpenACCModifierKind Mods)
static OpenACCComputeConstruct * Create(const ASTContext &C, OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation DirectiveLoc, SourceLocation EndLoc, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
StreamTy & printOpenACCDirectiveKind(StreamTy &Out, OpenACCDirectiveKind K)
StreamTy & printOpenACCAtomicKind(StreamTy &Out, OpenACCAtomicKind AK)
bool isOpenACCModifierBitSet(OpenACCModifierKind List, OpenACCModifierKind Bit)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
@ None
The alignment was not explicit in code.
Definition ASTContext.h:178
StreamTy & printOpenACCReductionOperator(StreamTy &Out, OpenACCReductionOperator Op)

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant