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 | |
12 | namespace llvm { |
13 | namespace acc { |
14 | |
15 | LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); |
16 | |
17 | enum class Association { |
18 | Block, |
19 | Declaration, |
20 | Delimited, |
21 | Loop, |
22 | None, |
23 | Separating, |
24 | }; |
25 | |
26 | static constexpr std::size_t Association_enumSize = 6; |
27 | |
28 | enum class Category { |
29 | Declarative, |
30 | Executable, |
31 | Informational, |
32 | Meta, |
33 | Subsidiary, |
34 | Utility, |
35 | }; |
36 | |
37 | static constexpr std::size_t Category_enumSize = 6; |
38 | |
39 | enum class SourceLanguage : uint32_t { |
40 | C = 1U, |
41 | Fortran = 2U, |
42 | LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Fortran) |
43 | }; |
44 | |
45 | static constexpr std::size_t SourceLanguage_enumSize = 2; |
46 | |
47 | enum 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 | |
71 | static constexpr std::size_t Directive_enumSize = 21; |
72 | |
73 | constexpr auto ACCD_atomic = Directive::ACCD_atomic; |
74 | constexpr auto ACCD_cache = Directive::ACCD_cache; |
75 | constexpr auto ACCD_data = Directive::ACCD_data; |
76 | constexpr auto ACCD_declare = Directive::ACCD_declare; |
77 | constexpr auto ACCD_enter_data = Directive::ACCD_enter_data; |
78 | constexpr auto ACCD_exit_data = Directive::ACCD_exit_data; |
79 | constexpr auto ACCD_host_data = Directive::ACCD_host_data; |
80 | constexpr auto ACCD_init = Directive::ACCD_init; |
81 | constexpr auto ACCD_kernels = Directive::ACCD_kernels; |
82 | constexpr auto ACCD_kernels_loop = Directive::ACCD_kernels_loop; |
83 | constexpr auto ACCD_loop = Directive::ACCD_loop; |
84 | constexpr auto ACCD_parallel = Directive::ACCD_parallel; |
85 | constexpr auto ACCD_parallel_loop = Directive::ACCD_parallel_loop; |
86 | constexpr auto ACCD_routine = Directive::ACCD_routine; |
87 | constexpr auto ACCD_serial = Directive::ACCD_serial; |
88 | constexpr auto ACCD_serial_loop = Directive::ACCD_serial_loop; |
89 | constexpr auto ACCD_set = Directive::ACCD_set; |
90 | constexpr auto ACCD_shutdown = Directive::ACCD_shutdown; |
91 | constexpr auto ACCD_unknown = Directive::ACCD_unknown; |
92 | constexpr auto ACCD_update = Directive::ACCD_update; |
93 | constexpr auto ACCD_wait = Directive::ACCD_wait; |
94 | |
95 | enum 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 | |
144 | static constexpr std::size_t Clause_enumSize = 46; |
145 | |
146 | constexpr auto ACCC_async = Clause::ACCC_async; |
147 | constexpr auto ACCC_attach = Clause::ACCC_attach; |
148 | constexpr auto ACCC_auto = Clause::ACCC_auto; |
149 | constexpr auto ACCC_bind = Clause::ACCC_bind; |
150 | constexpr auto ACCC_capture = Clause::ACCC_capture; |
151 | constexpr auto ACCC_collapse = Clause::ACCC_collapse; |
152 | constexpr auto ACCC_copy = Clause::ACCC_copy; |
153 | constexpr auto ACCC_copyin = Clause::ACCC_copyin; |
154 | constexpr auto ACCC_copyout = Clause::ACCC_copyout; |
155 | constexpr auto ACCC_create = Clause::ACCC_create; |
156 | constexpr auto ACCC_default = Clause::ACCC_default; |
157 | constexpr auto ACCC_default_async = Clause::ACCC_default_async; |
158 | constexpr auto ACCC_delete = Clause::ACCC_delete; |
159 | constexpr auto ACCC_detach = Clause::ACCC_detach; |
160 | constexpr auto ACCC_device = Clause::ACCC_device; |
161 | constexpr auto ACCC_device_num = Clause::ACCC_device_num; |
162 | constexpr auto ACCC_deviceptr = Clause::ACCC_deviceptr; |
163 | constexpr auto ACCC_device_resident = Clause::ACCC_device_resident; |
164 | constexpr auto ACCC_device_type = Clause::ACCC_device_type; |
165 | constexpr auto ACCC_finalize = Clause::ACCC_finalize; |
166 | constexpr auto ACCC_firstprivate = Clause::ACCC_firstprivate; |
167 | constexpr auto ACCC_gang = Clause::ACCC_gang; |
168 | constexpr auto ACCC_host = Clause::ACCC_host; |
169 | constexpr auto ACCC_if = Clause::ACCC_if; |
170 | constexpr auto ACCC_if_present = Clause::ACCC_if_present; |
171 | constexpr auto ACCC_independent = Clause::ACCC_independent; |
172 | constexpr auto ACCC_link = Clause::ACCC_link; |
173 | constexpr auto ACCC_no_create = Clause::ACCC_no_create; |
174 | constexpr auto ACCC_nohost = Clause::ACCC_nohost; |
175 | constexpr auto ACCC_num_gangs = Clause::ACCC_num_gangs; |
176 | constexpr auto ACCC_num_workers = Clause::ACCC_num_workers; |
177 | constexpr auto ACCC_present = Clause::ACCC_present; |
178 | constexpr auto ACCC_private = Clause::ACCC_private; |
179 | constexpr auto ACCC_read = Clause::ACCC_read; |
180 | constexpr auto ACCC_reduction = Clause::ACCC_reduction; |
181 | constexpr auto ACCC_self = Clause::ACCC_self; |
182 | constexpr auto ACCC_seq = Clause::ACCC_seq; |
183 | constexpr auto ACCC_shortloop = Clause::ACCC_shortloop; |
184 | constexpr auto ACCC_tile = Clause::ACCC_tile; |
185 | constexpr auto ACCC_unknown = Clause::ACCC_unknown; |
186 | constexpr auto ACCC_use_device = Clause::ACCC_use_device; |
187 | constexpr auto ACCC_vector = Clause::ACCC_vector; |
188 | constexpr auto ACCC_vector_length = Clause::ACCC_vector_length; |
189 | constexpr auto ACCC_wait = Clause::ACCC_wait; |
190 | constexpr auto ACCC_worker = Clause::ACCC_worker; |
191 | constexpr auto ACCC_write = Clause::ACCC_write; |
192 | |
193 | enum class DefaultValue { |
194 | ACC_Default_present=0, |
195 | ACC_Default_none=1, |
196 | }; |
197 | |
198 | constexpr auto ACC_Default_present = DefaultValue::ACC_Default_present; |
199 | constexpr auto ACC_Default_none = DefaultValue::ACC_Default_none; |
200 | |
201 | // Enumeration helper functions |
202 | LLVM_ABI std::pair<Directive, directive::VersionRange> getOpenACCDirectiveKindAndVersions(StringRef Str); |
203 | inline Directive getOpenACCDirectiveKind(StringRef Str) { |
204 | return getOpenACCDirectiveKindAndVersions(Str).first; |
205 | } |
206 | |
207 | LLVM_ABI StringRef getOpenACCDirectiveName(Directive D, unsigned Ver = 0); |
208 | |
209 | LLVM_ABI std::pair<Clause, directive::VersionRange> getOpenACCClauseKindAndVersions(StringRef Str); |
210 | |
211 | inline Clause getOpenACCClauseKind(StringRef Str) { |
212 | return getOpenACCClauseKindAndVersions(Str).first; |
213 | } |
214 | |
215 | LLVM_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. |
218 | LLVM_ABI bool isAllowedClauseForDirective(Directive D, Clause C, unsigned Version); |
219 | |
220 | constexpr std::size_t getMaxLeafCount() { return 2; } |
221 | LLVM_ABI Association getDirectiveAssociation(Directive D); |
222 | LLVM_ABI Category getDirectiveCategory(Directive D); |
223 | LLVM_ABI SourceLanguage getDirectiveLanguages(Directive D); |
224 | LLVM_ABI DefaultValue getDefaultValue(StringRef Str); |
225 | LLVM_ABI StringRef getOpenACCDefaultValueName(DefaultValue x); |
226 | |
227 | } // namespace acc |
228 | } // namespace llvm |
229 | #endif // LLVM_OpenACC_INC |
230 | |