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