Warning: This file is not a C or C++ file. It does not have highlighting.
1 | //===-- include/flang/Semantics/openmp-directive-sets.h ---------*- 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 | #ifndef FORTRAN_SEMANTICS_OPENMP_DIRECTIVE_SETS_H_ |
10 | #define FORTRAN_SEMANTICS_OPENMP_DIRECTIVE_SETS_H_ |
11 | |
12 | #include "flang/Common/enum-set.h" |
13 | #include "llvm/Frontend/OpenMP/OMPConstants.h" |
14 | |
15 | using OmpDirectiveSet = Fortran::common::EnumSet<llvm::omp::Directive, |
16 | llvm::omp::Directive_enumSize>; |
17 | |
18 | namespace llvm::omp { |
19 | //===----------------------------------------------------------------------===// |
20 | // Directive sets for single directives |
21 | //===----------------------------------------------------------------------===// |
22 | // - top<Directive>Set: The directive appears alone or as the first in a |
23 | // compound construct. |
24 | // - all<Directive>Set: All standalone or compound uses of the directive. |
25 | |
26 | static const OmpDirectiveSet topDistributeSet{ |
27 | Directive::OMPD_distribute, |
28 | Directive::OMPD_distribute_parallel_do, |
29 | Directive::OMPD_distribute_parallel_do_simd, |
30 | Directive::OMPD_distribute_simd, |
31 | }; |
32 | |
33 | static const OmpDirectiveSet allDistributeSet{ |
34 | OmpDirectiveSet{ |
35 | Directive::OMPD_target_teams_distribute, |
36 | Directive::OMPD_target_teams_distribute_parallel_do, |
37 | Directive::OMPD_target_teams_distribute_parallel_do_simd, |
38 | Directive::OMPD_target_teams_distribute_simd, |
39 | Directive::OMPD_teams_distribute, |
40 | Directive::OMPD_teams_distribute_parallel_do, |
41 | Directive::OMPD_teams_distribute_parallel_do_simd, |
42 | Directive::OMPD_teams_distribute_simd, |
43 | } | topDistributeSet, |
44 | }; |
45 | |
46 | static const OmpDirectiveSet topDoSet{ |
47 | Directive::OMPD_do, |
48 | Directive::OMPD_do_simd, |
49 | }; |
50 | |
51 | static const OmpDirectiveSet allDoSet{ |
52 | OmpDirectiveSet{ |
53 | Directive::OMPD_distribute_parallel_do, |
54 | Directive::OMPD_distribute_parallel_do_simd, |
55 | Directive::OMPD_parallel_do, |
56 | Directive::OMPD_parallel_do_simd, |
57 | Directive::OMPD_target_parallel_do, |
58 | Directive::OMPD_target_parallel_do_simd, |
59 | Directive::OMPD_target_teams_distribute_parallel_do, |
60 | Directive::OMPD_target_teams_distribute_parallel_do_simd, |
61 | Directive::OMPD_teams_distribute_parallel_do, |
62 | Directive::OMPD_teams_distribute_parallel_do_simd, |
63 | } | topDoSet, |
64 | }; |
65 | |
66 | static const OmpDirectiveSet topLoopSet{ |
67 | Directive::OMPD_loop, |
68 | }; |
69 | |
70 | static const OmpDirectiveSet allLoopSet{ |
71 | OmpDirectiveSet{ |
72 | Directive::OMPD_parallel_loop, |
73 | Directive::OMPD_target_parallel_loop, |
74 | Directive::OMPD_target_teams_loop, |
75 | Directive::OMPD_teams_loop, |
76 | } | topLoopSet, |
77 | }; |
78 | |
79 | static const OmpDirectiveSet topParallelSet{ |
80 | Directive::OMPD_parallel, |
81 | Directive::OMPD_parallel_do, |
82 | Directive::OMPD_parallel_do_simd, |
83 | Directive::OMPD_parallel_loop, |
84 | Directive::OMPD_parallel_masked_taskloop, |
85 | Directive::OMPD_parallel_masked_taskloop_simd, |
86 | Directive::OMPD_parallel_master_taskloop, |
87 | Directive::OMPD_parallel_master_taskloop_simd, |
88 | Directive::OMPD_parallel_sections, |
89 | Directive::OMPD_parallel_workshare, |
90 | }; |
91 | |
92 | static const OmpDirectiveSet allParallelSet{ |
93 | OmpDirectiveSet{ |
94 | Directive::OMPD_distribute_parallel_do, |
95 | Directive::OMPD_distribute_parallel_do_simd, |
96 | Directive::OMPD_target_parallel, |
97 | Directive::OMPD_target_parallel_do, |
98 | Directive::OMPD_target_parallel_do_simd, |
99 | Directive::OMPD_target_parallel_loop, |
100 | Directive::OMPD_target_teams_distribute_parallel_do, |
101 | Directive::OMPD_target_teams_distribute_parallel_do_simd, |
102 | Directive::OMPD_teams_distribute_parallel_do, |
103 | Directive::OMPD_teams_distribute_parallel_do_simd, |
104 | } | topParallelSet, |
105 | }; |
106 | |
107 | static const OmpDirectiveSet topSimdSet{ |
108 | Directive::OMPD_simd, |
109 | }; |
110 | |
111 | static const OmpDirectiveSet allSimdSet{ |
112 | OmpDirectiveSet{ |
113 | Directive::OMPD_distribute_parallel_do_simd, |
114 | Directive::OMPD_distribute_simd, |
115 | Directive::OMPD_do_simd, |
116 | Directive::OMPD_masked_taskloop_simd, |
117 | Directive::OMPD_master_taskloop_simd, |
118 | Directive::OMPD_parallel_do_simd, |
119 | Directive::OMPD_parallel_masked_taskloop_simd, |
120 | Directive::OMPD_parallel_master_taskloop_simd, |
121 | Directive::OMPD_target_parallel_do_simd, |
122 | Directive::OMPD_target_simd, |
123 | Directive::OMPD_target_teams_distribute_parallel_do_simd, |
124 | Directive::OMPD_target_teams_distribute_simd, |
125 | Directive::OMPD_taskloop_simd, |
126 | Directive::OMPD_teams_distribute_parallel_do_simd, |
127 | Directive::OMPD_teams_distribute_simd, |
128 | } | topSimdSet, |
129 | }; |
130 | |
131 | static const OmpDirectiveSet topTargetSet{ |
132 | Directive::OMPD_target, |
133 | Directive::OMPD_target_parallel, |
134 | Directive::OMPD_target_parallel_do, |
135 | Directive::OMPD_target_parallel_do_simd, |
136 | Directive::OMPD_target_parallel_loop, |
137 | Directive::OMPD_target_simd, |
138 | Directive::OMPD_target_teams, |
139 | Directive::OMPD_target_teams_distribute, |
140 | Directive::OMPD_target_teams_distribute_parallel_do, |
141 | Directive::OMPD_target_teams_distribute_parallel_do_simd, |
142 | Directive::OMPD_target_teams_distribute_simd, |
143 | Directive::OMPD_target_teams_loop, |
144 | }; |
145 | |
146 | static const OmpDirectiveSet allTargetSet{topTargetSet}; |
147 | |
148 | static const OmpDirectiveSet topTaskloopSet{ |
149 | Directive::OMPD_taskloop, |
150 | Directive::OMPD_taskloop_simd, |
151 | }; |
152 | |
153 | static const OmpDirectiveSet allTaskloopSet{ |
154 | OmpDirectiveSet{ |
155 | Directive::OMPD_masked_taskloop, |
156 | Directive::OMPD_masked_taskloop_simd, |
157 | Directive::OMPD_master_taskloop, |
158 | Directive::OMPD_master_taskloop_simd, |
159 | Directive::OMPD_parallel_masked_taskloop, |
160 | Directive::OMPD_parallel_masked_taskloop_simd, |
161 | Directive::OMPD_parallel_master_taskloop, |
162 | Directive::OMPD_parallel_master_taskloop_simd, |
163 | } | topTaskloopSet, |
164 | }; |
165 | |
166 | static const OmpDirectiveSet topTeamsSet{ |
167 | Directive::OMPD_teams, |
168 | Directive::OMPD_teams_distribute, |
169 | Directive::OMPD_teams_distribute_parallel_do, |
170 | Directive::OMPD_teams_distribute_parallel_do_simd, |
171 | Directive::OMPD_teams_distribute_simd, |
172 | }; |
173 | |
174 | static const OmpDirectiveSet allTeamsSet{ |
175 | OmpDirectiveSet{ |
176 | Directive::OMPD_target_teams, |
177 | Directive::OMPD_target_teams_distribute, |
178 | Directive::OMPD_target_teams_distribute_parallel_do, |
179 | Directive::OMPD_target_teams_distribute_parallel_do_simd, |
180 | Directive::OMPD_target_teams_distribute_simd, |
181 | Directive::OMPD_target_teams_loop, |
182 | } | topTeamsSet, |
183 | }; |
184 | |
185 | //===----------------------------------------------------------------------===// |
186 | // Directive sets for groups of multiple directives |
187 | //===----------------------------------------------------------------------===// |
188 | |
189 | // Composite constructs |
190 | static const OmpDirectiveSet allDistributeParallelDoSet{ |
191 | allDistributeSet & allParallelSet & allDoSet}; |
192 | static const OmpDirectiveSet allDistributeParallelDoSimdSet{ |
193 | allDistributeSet & allParallelSet & allDoSet & allSimdSet}; |
194 | static const OmpDirectiveSet allDistributeSimdSet{ |
195 | allDistributeSet & allSimdSet}; |
196 | static const OmpDirectiveSet allDoSimdSet{allDoSet & allSimdSet}; |
197 | static const OmpDirectiveSet allTaskloopSimdSet{allTaskloopSet & allSimdSet}; |
198 | |
199 | static const OmpDirectiveSet compositeConstructSet{ |
200 | Directive::OMPD_distribute_parallel_do, |
201 | Directive::OMPD_distribute_parallel_do_simd, |
202 | Directive::OMPD_distribute_simd, |
203 | Directive::OMPD_do_simd, |
204 | Directive::OMPD_taskloop_simd, |
205 | }; |
206 | |
207 | static const OmpDirectiveSet blockConstructSet{ |
208 | Directive::OMPD_master, |
209 | Directive::OMPD_ordered, |
210 | Directive::OMPD_parallel, |
211 | Directive::OMPD_parallel_workshare, |
212 | Directive::OMPD_single, |
213 | Directive::OMPD_target, |
214 | Directive::OMPD_target_data, |
215 | Directive::OMPD_target_parallel, |
216 | Directive::OMPD_target_teams, |
217 | Directive::OMPD_task, |
218 | Directive::OMPD_taskgroup, |
219 | Directive::OMPD_teams, |
220 | Directive::OMPD_workshare, |
221 | }; |
222 | |
223 | static const OmpDirectiveSet loopConstructSet{ |
224 | Directive::OMPD_distribute, |
225 | Directive::OMPD_distribute_parallel_do, |
226 | Directive::OMPD_distribute_parallel_do_simd, |
227 | Directive::OMPD_distribute_simd, |
228 | Directive::OMPD_do, |
229 | Directive::OMPD_do_simd, |
230 | Directive::OMPD_loop, |
231 | Directive::OMPD_masked_taskloop, |
232 | Directive::OMPD_masked_taskloop_simd, |
233 | Directive::OMPD_master_taskloop, |
234 | Directive::OMPD_master_taskloop_simd, |
235 | Directive::OMPD_parallel_do, |
236 | Directive::OMPD_parallel_do_simd, |
237 | Directive::OMPD_parallel_loop, |
238 | Directive::OMPD_parallel_masked_taskloop, |
239 | Directive::OMPD_parallel_masked_taskloop_simd, |
240 | Directive::OMPD_parallel_master_taskloop, |
241 | Directive::OMPD_parallel_master_taskloop_simd, |
242 | Directive::OMPD_simd, |
243 | Directive::OMPD_target_parallel_do, |
244 | Directive::OMPD_target_parallel_do_simd, |
245 | Directive::OMPD_target_parallel_loop, |
246 | Directive::OMPD_target_simd, |
247 | Directive::OMPD_target_teams_distribute, |
248 | Directive::OMPD_target_teams_distribute_parallel_do, |
249 | Directive::OMPD_target_teams_distribute_parallel_do_simd, |
250 | Directive::OMPD_target_teams_distribute_simd, |
251 | Directive::OMPD_target_teams_loop, |
252 | Directive::OMPD_taskloop, |
253 | Directive::OMPD_taskloop_simd, |
254 | Directive::OMPD_teams_distribute, |
255 | Directive::OMPD_teams_distribute_parallel_do, |
256 | Directive::OMPD_teams_distribute_parallel_do_simd, |
257 | Directive::OMPD_teams_distribute_simd, |
258 | Directive::OMPD_teams_loop, |
259 | Directive::OMPD_tile, |
260 | Directive::OMPD_unroll, |
261 | }; |
262 | |
263 | static const OmpDirectiveSet nonPartialVarSet{ |
264 | Directive::OMPD_allocate, |
265 | Directive::OMPD_allocators, |
266 | Directive::OMPD_threadprivate, |
267 | Directive::OMPD_declare_target, |
268 | }; |
269 | |
270 | static const OmpDirectiveSet taskGeneratingSet{ |
271 | OmpDirectiveSet{ |
272 | Directive::OMPD_task, |
273 | } | allTaskloopSet, |
274 | }; |
275 | |
276 | static const OmpDirectiveSet workShareSet{ |
277 | OmpDirectiveSet{ |
278 | Directive::OMPD_workshare, |
279 | Directive::OMPD_parallel_workshare, |
280 | Directive::OMPD_parallel_sections, |
281 | Directive::OMPD_sections, |
282 | Directive::OMPD_single, |
283 | } | allDoSet, |
284 | }; |
285 | |
286 | //===----------------------------------------------------------------------===// |
287 | // Directive sets for allowed/not allowed nested directives |
288 | //===----------------------------------------------------------------------===// |
289 | |
290 | static const OmpDirectiveSet nestedBarrierErrSet{ |
291 | OmpDirectiveSet{ |
292 | Directive::OMPD_atomic, |
293 | Directive::OMPD_critical, |
294 | Directive::OMPD_master, |
295 | Directive::OMPD_ordered, |
296 | } | taskGeneratingSet | |
297 | workShareSet, |
298 | }; |
299 | |
300 | static const OmpDirectiveSet nestedCancelDoAllowedSet{ |
301 | Directive::OMPD_distribute_parallel_do, |
302 | Directive::OMPD_do, |
303 | Directive::OMPD_parallel_do, |
304 | Directive::OMPD_target_parallel_do, |
305 | Directive::OMPD_target_teams_distribute_parallel_do, |
306 | Directive::OMPD_teams_distribute_parallel_do, |
307 | }; |
308 | |
309 | static const OmpDirectiveSet nestedCancelParallelAllowedSet{ |
310 | Directive::OMPD_parallel, |
311 | Directive::OMPD_target_parallel, |
312 | }; |
313 | |
314 | static const OmpDirectiveSet nestedCancelSectionsAllowedSet{ |
315 | Directive::OMPD_parallel_sections, |
316 | Directive::OMPD_sections, |
317 | }; |
318 | |
319 | static const OmpDirectiveSet nestedCancelTaskgroupAllowedSet{ |
320 | Directive::OMPD_task, |
321 | Directive::OMPD_taskloop, |
322 | }; |
323 | |
324 | static const OmpDirectiveSet nestedMasterErrSet{ |
325 | OmpDirectiveSet{ |
326 | Directive::OMPD_atomic, |
327 | } | taskGeneratingSet | |
328 | workShareSet, |
329 | }; |
330 | |
331 | static const OmpDirectiveSet nestedOrderedDoAllowedSet{ |
332 | Directive::OMPD_do, |
333 | Directive::OMPD_parallel_do, |
334 | Directive::OMPD_target_parallel_do, |
335 | }; |
336 | |
337 | static const OmpDirectiveSet nestedOrderedErrSet{ |
338 | Directive::OMPD_atomic, |
339 | Directive::OMPD_critical, |
340 | Directive::OMPD_ordered, |
341 | Directive::OMPD_task, |
342 | Directive::OMPD_taskloop, |
343 | }; |
344 | |
345 | static const OmpDirectiveSet nestedOrderedParallelErrSet{ |
346 | Directive::OMPD_parallel, |
347 | Directive::OMPD_parallel_sections, |
348 | Directive::OMPD_parallel_workshare, |
349 | Directive::OMPD_target_parallel, |
350 | }; |
351 | |
352 | static const OmpDirectiveSet nestedReduceWorkshareAllowedSet{ |
353 | Directive::OMPD_do, |
354 | Directive::OMPD_do_simd, |
355 | Directive::OMPD_sections, |
356 | }; |
357 | |
358 | static const OmpDirectiveSet nestedTeamsAllowedSet{ |
359 | Directive::OMPD_distribute, |
360 | Directive::OMPD_distribute_parallel_do, |
361 | Directive::OMPD_distribute_parallel_do_simd, |
362 | Directive::OMPD_distribute_simd, |
363 | Directive::OMPD_parallel, |
364 | Directive::OMPD_parallel_do, |
365 | Directive::OMPD_parallel_do_simd, |
366 | Directive::OMPD_parallel_master, |
367 | Directive::OMPD_parallel_master_taskloop, |
368 | Directive::OMPD_parallel_master_taskloop_simd, |
369 | Directive::OMPD_parallel_sections, |
370 | Directive::OMPD_parallel_workshare, |
371 | }; |
372 | |
373 | static const OmpDirectiveSet nestedWorkshareErrSet{ |
374 | OmpDirectiveSet{ |
375 | Directive::OMPD_atomic, |
376 | Directive::OMPD_critical, |
377 | Directive::OMPD_master, |
378 | Directive::OMPD_ordered, |
379 | Directive::OMPD_task, |
380 | Directive::OMPD_taskloop, |
381 | } | workShareSet, |
382 | }; |
383 | } // namespace llvm::omp |
384 | |
385 | #endif // FORTRAN_SEMANTICS_OPENMP_DIRECTIVE_SETS_H_ |
386 |
Warning: This file is not a C or C++ file. It does not have highlighting.