1#ifndef LLVM_OpenACC_INC
2#define LLVM_OpenACC_INC
3
4#include "llvm/ADT/ArrayRef.h"
5#include "llvm/ADT/BitmaskEnum.h"
6#include "llvm/ADT/StringRef.h"
7#include "llvm/Frontend/Directive/Spelling.h"
8#include "llvm/Support/Compiler.h"
9#include <cstddef>
10#include <utility>
11
12namespace llvm {
13namespace acc {
14
15LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
16
17enum class Association {
18 Block,
19 Declaration,
20 Delimited,
21 Loop,
22 None,
23 Separating,
24};
25
26static constexpr std::size_t Association_enumSize = 6;
27
28enum class Category {
29 Declarative,
30 Executable,
31 Informational,
32 Meta,
33 Subsidiary,
34 Utility,
35};
36
37static constexpr std::size_t Category_enumSize = 6;
38
39enum class SourceLanguage : uint32_t {
40 C = 1U,
41 Fortran = 2U,
42 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Fortran)
43};
44
45static constexpr std::size_t SourceLanguage_enumSize = 2;
46
47enum class Directive {
48 ACCD_atomic,
49 ACCD_cache,
50 ACCD_data,
51 ACCD_declare,
52 ACCD_enter_data,
53 ACCD_exit_data,
54 ACCD_host_data,
55 ACCD_init,
56 ACCD_kernels,
57 ACCD_kernels_loop,
58 ACCD_loop,
59 ACCD_parallel,
60 ACCD_parallel_loop,
61 ACCD_routine,
62 ACCD_serial,
63 ACCD_serial_loop,
64 ACCD_set,
65 ACCD_shutdown,
66 ACCD_unknown,
67 ACCD_update,
68 ACCD_wait,
69};
70
71static constexpr std::size_t Directive_enumSize = 21;
72
73constexpr auto ACCD_atomic = Directive::ACCD_atomic;
74constexpr auto ACCD_cache = Directive::ACCD_cache;
75constexpr auto ACCD_data = Directive::ACCD_data;
76constexpr auto ACCD_declare = Directive::ACCD_declare;
77constexpr auto ACCD_enter_data = Directive::ACCD_enter_data;
78constexpr auto ACCD_exit_data = Directive::ACCD_exit_data;
79constexpr auto ACCD_host_data = Directive::ACCD_host_data;
80constexpr auto ACCD_init = Directive::ACCD_init;
81constexpr auto ACCD_kernels = Directive::ACCD_kernels;
82constexpr auto ACCD_kernels_loop = Directive::ACCD_kernels_loop;
83constexpr auto ACCD_loop = Directive::ACCD_loop;
84constexpr auto ACCD_parallel = Directive::ACCD_parallel;
85constexpr auto ACCD_parallel_loop = Directive::ACCD_parallel_loop;
86constexpr auto ACCD_routine = Directive::ACCD_routine;
87constexpr auto ACCD_serial = Directive::ACCD_serial;
88constexpr auto ACCD_serial_loop = Directive::ACCD_serial_loop;
89constexpr auto ACCD_set = Directive::ACCD_set;
90constexpr auto ACCD_shutdown = Directive::ACCD_shutdown;
91constexpr auto ACCD_unknown = Directive::ACCD_unknown;
92constexpr auto ACCD_update = Directive::ACCD_update;
93constexpr auto ACCD_wait = Directive::ACCD_wait;
94
95enum class Clause {
96 ACCC_async,
97 ACCC_attach,
98 ACCC_auto,
99 ACCC_bind,
100 ACCC_capture,
101 ACCC_collapse,
102 ACCC_copy,
103 ACCC_copyin,
104 ACCC_copyout,
105 ACCC_create,
106 ACCC_default,
107 ACCC_default_async,
108 ACCC_delete,
109 ACCC_detach,
110 ACCC_device,
111 ACCC_device_num,
112 ACCC_deviceptr,
113 ACCC_device_resident,
114 ACCC_device_type,
115 ACCC_finalize,
116 ACCC_firstprivate,
117 ACCC_gang,
118 ACCC_host,
119 ACCC_if,
120 ACCC_if_present,
121 ACCC_independent,
122 ACCC_link,
123 ACCC_no_create,
124 ACCC_nohost,
125 ACCC_num_gangs,
126 ACCC_num_workers,
127 ACCC_present,
128 ACCC_private,
129 ACCC_read,
130 ACCC_reduction,
131 ACCC_self,
132 ACCC_seq,
133 ACCC_shortloop,
134 ACCC_tile,
135 ACCC_unknown,
136 ACCC_use_device,
137 ACCC_vector,
138 ACCC_vector_length,
139 ACCC_wait,
140 ACCC_worker,
141 ACCC_write,
142};
143
144static constexpr std::size_t Clause_enumSize = 46;
145
146constexpr auto ACCC_async = Clause::ACCC_async;
147constexpr auto ACCC_attach = Clause::ACCC_attach;
148constexpr auto ACCC_auto = Clause::ACCC_auto;
149constexpr auto ACCC_bind = Clause::ACCC_bind;
150constexpr auto ACCC_capture = Clause::ACCC_capture;
151constexpr auto ACCC_collapse = Clause::ACCC_collapse;
152constexpr auto ACCC_copy = Clause::ACCC_copy;
153constexpr auto ACCC_copyin = Clause::ACCC_copyin;
154constexpr auto ACCC_copyout = Clause::ACCC_copyout;
155constexpr auto ACCC_create = Clause::ACCC_create;
156constexpr auto ACCC_default = Clause::ACCC_default;
157constexpr auto ACCC_default_async = Clause::ACCC_default_async;
158constexpr auto ACCC_delete = Clause::ACCC_delete;
159constexpr auto ACCC_detach = Clause::ACCC_detach;
160constexpr auto ACCC_device = Clause::ACCC_device;
161constexpr auto ACCC_device_num = Clause::ACCC_device_num;
162constexpr auto ACCC_deviceptr = Clause::ACCC_deviceptr;
163constexpr auto ACCC_device_resident = Clause::ACCC_device_resident;
164constexpr auto ACCC_device_type = Clause::ACCC_device_type;
165constexpr auto ACCC_finalize = Clause::ACCC_finalize;
166constexpr auto ACCC_firstprivate = Clause::ACCC_firstprivate;
167constexpr auto ACCC_gang = Clause::ACCC_gang;
168constexpr auto ACCC_host = Clause::ACCC_host;
169constexpr auto ACCC_if = Clause::ACCC_if;
170constexpr auto ACCC_if_present = Clause::ACCC_if_present;
171constexpr auto ACCC_independent = Clause::ACCC_independent;
172constexpr auto ACCC_link = Clause::ACCC_link;
173constexpr auto ACCC_no_create = Clause::ACCC_no_create;
174constexpr auto ACCC_nohost = Clause::ACCC_nohost;
175constexpr auto ACCC_num_gangs = Clause::ACCC_num_gangs;
176constexpr auto ACCC_num_workers = Clause::ACCC_num_workers;
177constexpr auto ACCC_present = Clause::ACCC_present;
178constexpr auto ACCC_private = Clause::ACCC_private;
179constexpr auto ACCC_read = Clause::ACCC_read;
180constexpr auto ACCC_reduction = Clause::ACCC_reduction;
181constexpr auto ACCC_self = Clause::ACCC_self;
182constexpr auto ACCC_seq = Clause::ACCC_seq;
183constexpr auto ACCC_shortloop = Clause::ACCC_shortloop;
184constexpr auto ACCC_tile = Clause::ACCC_tile;
185constexpr auto ACCC_unknown = Clause::ACCC_unknown;
186constexpr auto ACCC_use_device = Clause::ACCC_use_device;
187constexpr auto ACCC_vector = Clause::ACCC_vector;
188constexpr auto ACCC_vector_length = Clause::ACCC_vector_length;
189constexpr auto ACCC_wait = Clause::ACCC_wait;
190constexpr auto ACCC_worker = Clause::ACCC_worker;
191constexpr auto ACCC_write = Clause::ACCC_write;
192
193enum class DefaultValue {
194 ACC_Default_present=0,
195 ACC_Default_none=1,
196};
197
198constexpr auto ACC_Default_present = DefaultValue::ACC_Default_present;
199constexpr auto ACC_Default_none = DefaultValue::ACC_Default_none;
200
201// Enumeration helper functions
202LLVM_ABI std::pair<Directive, directive::VersionRange> getOpenACCDirectiveKindAndVersions(StringRef Str);
203inline Directive getOpenACCDirectiveKind(StringRef Str) {
204 return getOpenACCDirectiveKindAndVersions(Str).first;
205}
206
207LLVM_ABI StringRef getOpenACCDirectiveName(Directive D, unsigned Ver = 0);
208
209LLVM_ABI std::pair<Clause, directive::VersionRange> getOpenACCClauseKindAndVersions(StringRef Str);
210
211inline Clause getOpenACCClauseKind(StringRef Str) {
212 return getOpenACCClauseKindAndVersions(Str).first;
213}
214
215LLVM_ABI StringRef getOpenACCClauseName(Clause C, unsigned Ver = 0);
216
217/// Return true if \p C is a valid clause for \p D in version \p Version.
218LLVM_ABI bool isAllowedClauseForDirective(Directive D, Clause C, unsigned Version);
219
220constexpr std::size_t getMaxLeafCount() { return 2; }
221LLVM_ABI Association getDirectiveAssociation(Directive D);
222LLVM_ABI Category getDirectiveCategory(Directive D);
223LLVM_ABI SourceLanguage getDirectiveLanguages(Directive D);
224LLVM_ABI DefaultValue getDefaultValue(StringRef Str);
225LLVM_ABI StringRef getOpenACCDefaultValueName(DefaultValue x);
226
227} // namespace acc
228} // namespace llvm
229#endif // LLVM_OpenACC_INC
230