[docs] Fix build-docs.sh
[llvm-project.git] / clang / lib / Basic / OpenMPKinds.cpp
blob2f2e6537ebd3ee45eebf395e227c30c0afb04a40
1 //===--- OpenMPKinds.cpp - Token Kinds Support ----------------------------===//
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 /// \file
9 /// This file implements the OpenMP enum and support functions.
10 ///
11 //===----------------------------------------------------------------------===//
13 #include "clang/Basic/OpenMPKinds.h"
14 #include "clang/Basic/IdentifierTable.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/ADT/StringSwitch.h"
17 #include "llvm/Support/ErrorHandling.h"
18 #include <cassert>
20 using namespace clang;
21 using namespace llvm::omp;
23 unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
24 const LangOptions &LangOpts) {
25 switch (Kind) {
26 case OMPC_default:
27 return llvm::StringSwitch<unsigned>(Str)
28 #define OMP_DEFAULT_KIND(Enum, Name) .Case(Name, unsigned(Enum))
29 #include "llvm/Frontend/OpenMP/OMPKinds.def"
30 .Default(unsigned(llvm::omp::OMP_DEFAULT_unknown));
31 case OMPC_proc_bind:
32 return llvm::StringSwitch<unsigned>(Str)
33 #define OMP_PROC_BIND_KIND(Enum, Name, Value) .Case(Name, Value)
34 #include "llvm/Frontend/OpenMP/OMPKinds.def"
35 .Default(unsigned(llvm::omp::OMP_PROC_BIND_unknown));
36 case OMPC_schedule:
37 return llvm::StringSwitch<unsigned>(Str)
38 #define OPENMP_SCHEDULE_KIND(Name) \
39 .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_##Name))
40 #define OPENMP_SCHEDULE_MODIFIER(Name) \
41 .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_MODIFIER_##Name))
42 #include "clang/Basic/OpenMPKinds.def"
43 .Default(OMPC_SCHEDULE_unknown);
44 case OMPC_depend: {
45 unsigned Type = llvm::StringSwitch<unsigned>(Str)
46 #define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
47 #include "clang/Basic/OpenMPKinds.def"
48 .Default(OMPC_DEPEND_unknown);
49 if (LangOpts.OpenMP < 51 && Type == OMPC_DEPEND_inoutset)
50 return OMPC_DEPEND_unknown;
51 return Type;
53 case OMPC_linear:
54 return llvm::StringSwitch<OpenMPLinearClauseKind>(Str)
55 #define OPENMP_LINEAR_KIND(Name) .Case(#Name, OMPC_LINEAR_##Name)
56 #include "clang/Basic/OpenMPKinds.def"
57 .Default(OMPC_LINEAR_unknown);
58 case OMPC_map: {
59 unsigned Type = llvm::StringSwitch<unsigned>(Str)
60 #define OPENMP_MAP_KIND(Name) \
61 .Case(#Name, static_cast<unsigned>(OMPC_MAP_##Name))
62 #define OPENMP_MAP_MODIFIER_KIND(Name) \
63 .Case(#Name, static_cast<unsigned>(OMPC_MAP_MODIFIER_##Name))
64 #include "clang/Basic/OpenMPKinds.def"
65 .Default(OMPC_MAP_unknown);
66 if (LangOpts.OpenMP < 51 && Type == OMPC_MAP_MODIFIER_present)
67 return OMPC_MAP_MODIFIER_unknown;
68 if (!LangOpts.OpenMPExtensions && Type == OMPC_MAP_MODIFIER_ompx_hold)
69 return OMPC_MAP_MODIFIER_unknown;
70 return Type;
72 case OMPC_to:
73 case OMPC_from: {
74 unsigned Type = llvm::StringSwitch<unsigned>(Str)
75 #define OPENMP_MOTION_MODIFIER_KIND(Name) \
76 .Case(#Name, static_cast<unsigned>(OMPC_MOTION_MODIFIER_##Name))
77 #include "clang/Basic/OpenMPKinds.def"
78 .Default(OMPC_MOTION_MODIFIER_unknown);
79 if (LangOpts.OpenMP < 51 && Type == OMPC_MOTION_MODIFIER_present)
80 return OMPC_MOTION_MODIFIER_unknown;
81 return Type;
83 case OMPC_dist_schedule:
84 return llvm::StringSwitch<OpenMPDistScheduleClauseKind>(Str)
85 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
86 #include "clang/Basic/OpenMPKinds.def"
87 .Default(OMPC_DIST_SCHEDULE_unknown);
88 case OMPC_defaultmap:
89 return llvm::StringSwitch<unsigned>(Str)
90 #define OPENMP_DEFAULTMAP_KIND(Name) \
91 .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_##Name))
92 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
93 .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_MODIFIER_##Name))
94 #include "clang/Basic/OpenMPKinds.def"
95 .Default(OMPC_DEFAULTMAP_unknown);
96 case OMPC_atomic_default_mem_order:
97 return llvm::StringSwitch<OpenMPAtomicDefaultMemOrderClauseKind>(Str)
98 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
99 .Case(#Name, OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name)
100 #include "clang/Basic/OpenMPKinds.def"
101 .Default(OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown);
102 case OMPC_device_type:
103 return llvm::StringSwitch<OpenMPDeviceType>(Str)
104 #define OPENMP_DEVICE_TYPE_KIND(Name) .Case(#Name, OMPC_DEVICE_TYPE_##Name)
105 #include "clang/Basic/OpenMPKinds.def"
106 .Default(OMPC_DEVICE_TYPE_unknown);
107 case OMPC_lastprivate:
108 return llvm::StringSwitch<OpenMPLastprivateModifier>(Str)
109 #define OPENMP_LASTPRIVATE_KIND(Name) .Case(#Name, OMPC_LASTPRIVATE_##Name)
110 #include "clang/Basic/OpenMPKinds.def"
111 .Default(OMPC_LASTPRIVATE_unknown);
112 case OMPC_order:
113 return llvm::StringSwitch<OpenMPOrderClauseKind>(Str)
114 #define OPENMP_ORDER_KIND(Name) .Case(#Name, OMPC_ORDER_##Name)
115 #include "clang/Basic/OpenMPKinds.def"
116 .Default(OMPC_ORDER_unknown);
117 case OMPC_update:
118 return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
119 #define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
120 #include "clang/Basic/OpenMPKinds.def"
121 .Default(OMPC_DEPEND_unknown);
122 case OMPC_device:
123 return llvm::StringSwitch<OpenMPDeviceClauseModifier>(Str)
124 #define OPENMP_DEVICE_MODIFIER(Name) .Case(#Name, OMPC_DEVICE_##Name)
125 #include "clang/Basic/OpenMPKinds.def"
126 .Default(OMPC_DEVICE_unknown);
127 case OMPC_reduction:
128 return llvm::StringSwitch<OpenMPReductionClauseModifier>(Str)
129 #define OPENMP_REDUCTION_MODIFIER(Name) .Case(#Name, OMPC_REDUCTION_##Name)
130 #include "clang/Basic/OpenMPKinds.def"
131 .Default(OMPC_REDUCTION_unknown);
132 case OMPC_adjust_args:
133 return llvm::StringSwitch<OpenMPAdjustArgsOpKind>(Str)
134 #define OPENMP_ADJUST_ARGS_KIND(Name) .Case(#Name, OMPC_ADJUST_ARGS_##Name)
135 #include "clang/Basic/OpenMPKinds.def"
136 .Default(OMPC_ADJUST_ARGS_unknown);
137 case OMPC_bind:
138 return llvm::StringSwitch<unsigned>(Str)
139 #define OPENMP_BIND_KIND(Name) .Case(#Name, OMPC_BIND_##Name)
140 #include "clang/Basic/OpenMPKinds.def"
141 .Default(OMPC_BIND_unknown);
142 case OMPC_unknown:
143 case OMPC_threadprivate:
144 case OMPC_if:
145 case OMPC_final:
146 case OMPC_num_threads:
147 case OMPC_safelen:
148 case OMPC_simdlen:
149 case OMPC_sizes:
150 case OMPC_allocator:
151 case OMPC_allocate:
152 case OMPC_collapse:
153 case OMPC_private:
154 case OMPC_firstprivate:
155 case OMPC_shared:
156 case OMPC_task_reduction:
157 case OMPC_in_reduction:
158 case OMPC_aligned:
159 case OMPC_copyin:
160 case OMPC_copyprivate:
161 case OMPC_ordered:
162 case OMPC_nowait:
163 case OMPC_untied:
164 case OMPC_mergeable:
165 case OMPC_flush:
166 case OMPC_depobj:
167 case OMPC_read:
168 case OMPC_write:
169 case OMPC_capture:
170 case OMPC_compare:
171 case OMPC_seq_cst:
172 case OMPC_acq_rel:
173 case OMPC_acquire:
174 case OMPC_release:
175 case OMPC_relaxed:
176 case OMPC_threads:
177 case OMPC_simd:
178 case OMPC_num_teams:
179 case OMPC_thread_limit:
180 case OMPC_priority:
181 case OMPC_grainsize:
182 case OMPC_nogroup:
183 case OMPC_num_tasks:
184 case OMPC_hint:
185 case OMPC_uniform:
186 case OMPC_use_device_ptr:
187 case OMPC_use_device_addr:
188 case OMPC_is_device_ptr:
189 case OMPC_has_device_addr:
190 case OMPC_unified_address:
191 case OMPC_unified_shared_memory:
192 case OMPC_reverse_offload:
193 case OMPC_dynamic_allocators:
194 case OMPC_match:
195 case OMPC_nontemporal:
196 case OMPC_destroy:
197 case OMPC_novariants:
198 case OMPC_nocontext:
199 case OMPC_detach:
200 case OMPC_inclusive:
201 case OMPC_exclusive:
202 case OMPC_uses_allocators:
203 case OMPC_affinity:
204 case OMPC_when:
205 case OMPC_append_args:
206 break;
207 default:
208 break;
210 llvm_unreachable("Invalid OpenMP simple clause kind");
213 const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
214 unsigned Type) {
215 switch (Kind) {
216 case OMPC_default:
217 switch (llvm::omp::DefaultKind(Type)) {
218 #define OMP_DEFAULT_KIND(Enum, Name) \
219 case Enum: \
220 return Name;
221 #include "llvm/Frontend/OpenMP/OMPKinds.def"
223 llvm_unreachable("Invalid OpenMP 'default' clause type");
224 case OMPC_proc_bind:
225 switch (Type) {
226 #define OMP_PROC_BIND_KIND(Enum, Name, Value) \
227 case Value: \
228 return Name;
229 #include "llvm/Frontend/OpenMP/OMPKinds.def"
231 llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
232 case OMPC_schedule:
233 switch (Type) {
234 case OMPC_SCHEDULE_unknown:
235 case OMPC_SCHEDULE_MODIFIER_last:
236 return "unknown";
237 #define OPENMP_SCHEDULE_KIND(Name) \
238 case OMPC_SCHEDULE_##Name: \
239 return #Name;
240 #define OPENMP_SCHEDULE_MODIFIER(Name) \
241 case OMPC_SCHEDULE_MODIFIER_##Name: \
242 return #Name;
243 #include "clang/Basic/OpenMPKinds.def"
245 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
246 case OMPC_depend:
247 switch (Type) {
248 case OMPC_DEPEND_unknown:
249 return "unknown";
250 #define OPENMP_DEPEND_KIND(Name) \
251 case OMPC_DEPEND_##Name: \
252 return #Name;
253 #include "clang/Basic/OpenMPKinds.def"
255 llvm_unreachable("Invalid OpenMP 'depend' clause type");
256 case OMPC_linear:
257 switch (Type) {
258 case OMPC_LINEAR_unknown:
259 return "unknown";
260 #define OPENMP_LINEAR_KIND(Name) \
261 case OMPC_LINEAR_##Name: \
262 return #Name;
263 #include "clang/Basic/OpenMPKinds.def"
265 llvm_unreachable("Invalid OpenMP 'linear' clause type");
266 case OMPC_map:
267 switch (Type) {
268 case OMPC_MAP_unknown:
269 case OMPC_MAP_MODIFIER_last:
270 return "unknown";
271 #define OPENMP_MAP_KIND(Name) \
272 case OMPC_MAP_##Name: \
273 return #Name;
274 #define OPENMP_MAP_MODIFIER_KIND(Name) \
275 case OMPC_MAP_MODIFIER_##Name: \
276 return #Name;
277 #include "clang/Basic/OpenMPKinds.def"
278 default:
279 break;
281 llvm_unreachable("Invalid OpenMP 'map' clause type");
282 case OMPC_to:
283 case OMPC_from:
284 switch (Type) {
285 case OMPC_MOTION_MODIFIER_unknown:
286 return "unknown";
287 #define OPENMP_MOTION_MODIFIER_KIND(Name) \
288 case OMPC_MOTION_MODIFIER_##Name: \
289 return #Name;
290 #include "clang/Basic/OpenMPKinds.def"
291 default:
292 break;
294 llvm_unreachable("Invalid OpenMP 'to' or 'from' clause type");
295 case OMPC_dist_schedule:
296 switch (Type) {
297 case OMPC_DIST_SCHEDULE_unknown:
298 return "unknown";
299 #define OPENMP_DIST_SCHEDULE_KIND(Name) \
300 case OMPC_DIST_SCHEDULE_##Name: \
301 return #Name;
302 #include "clang/Basic/OpenMPKinds.def"
304 llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
305 case OMPC_defaultmap:
306 switch (Type) {
307 case OMPC_DEFAULTMAP_unknown:
308 case OMPC_DEFAULTMAP_MODIFIER_last:
309 return "unknown";
310 #define OPENMP_DEFAULTMAP_KIND(Name) \
311 case OMPC_DEFAULTMAP_##Name: \
312 return #Name;
313 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
314 case OMPC_DEFAULTMAP_MODIFIER_##Name: \
315 return #Name;
316 #include "clang/Basic/OpenMPKinds.def"
318 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
319 case OMPC_atomic_default_mem_order:
320 switch (Type) {
321 case OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown:
322 return "unknown";
323 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
324 case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name: \
325 return #Name;
326 #include "clang/Basic/OpenMPKinds.def"
328 llvm_unreachable("Invalid OpenMP 'atomic_default_mem_order' clause type");
329 case OMPC_device_type:
330 switch (Type) {
331 case OMPC_DEVICE_TYPE_unknown:
332 return "unknown";
333 #define OPENMP_DEVICE_TYPE_KIND(Name) \
334 case OMPC_DEVICE_TYPE_##Name: \
335 return #Name;
336 #include "clang/Basic/OpenMPKinds.def"
338 llvm_unreachable("Invalid OpenMP 'device_type' clause type");
339 case OMPC_lastprivate:
340 switch (Type) {
341 case OMPC_LASTPRIVATE_unknown:
342 return "unknown";
343 #define OPENMP_LASTPRIVATE_KIND(Name) \
344 case OMPC_LASTPRIVATE_##Name: \
345 return #Name;
346 #include "clang/Basic/OpenMPKinds.def"
348 llvm_unreachable("Invalid OpenMP 'lastprivate' clause type");
349 case OMPC_order:
350 switch (Type) {
351 case OMPC_ORDER_unknown:
352 return "unknown";
353 #define OPENMP_ORDER_KIND(Name) \
354 case OMPC_ORDER_##Name: \
355 return #Name;
356 #include "clang/Basic/OpenMPKinds.def"
358 llvm_unreachable("Invalid OpenMP 'order' clause type");
359 case OMPC_update:
360 switch (Type) {
361 case OMPC_DEPEND_unknown:
362 return "unknown";
363 #define OPENMP_DEPEND_KIND(Name) \
364 case OMPC_DEPEND_##Name: \
365 return #Name;
366 #include "clang/Basic/OpenMPKinds.def"
368 llvm_unreachable("Invalid OpenMP 'depend' clause type");
369 case OMPC_device:
370 switch (Type) {
371 case OMPC_DEVICE_unknown:
372 return "unknown";
373 #define OPENMP_DEVICE_MODIFIER(Name) \
374 case OMPC_DEVICE_##Name: \
375 return #Name;
376 #include "clang/Basic/OpenMPKinds.def"
378 llvm_unreachable("Invalid OpenMP 'device' clause modifier");
379 case OMPC_reduction:
380 switch (Type) {
381 case OMPC_REDUCTION_unknown:
382 return "unknown";
383 #define OPENMP_REDUCTION_MODIFIER(Name) \
384 case OMPC_REDUCTION_##Name: \
385 return #Name;
386 #include "clang/Basic/OpenMPKinds.def"
388 llvm_unreachable("Invalid OpenMP 'reduction' clause modifier");
389 case OMPC_adjust_args:
390 switch (Type) {
391 case OMPC_ADJUST_ARGS_unknown:
392 return "unknown";
393 #define OPENMP_ADJUST_ARGS_KIND(Name) \
394 case OMPC_ADJUST_ARGS_##Name: \
395 return #Name;
396 #include "clang/Basic/OpenMPKinds.def"
398 llvm_unreachable("Invalid OpenMP 'adjust_args' clause kind");
399 case OMPC_bind:
400 switch (Type) {
401 case OMPC_BIND_unknown:
402 return "unknown";
403 #define OPENMP_BIND_KIND(Name) \
404 case OMPC_BIND_##Name: \
405 return #Name;
406 #include "clang/Basic/OpenMPKinds.def"
408 llvm_unreachable("Invalid OpenMP 'bind' clause type");
409 case OMPC_unknown:
410 case OMPC_threadprivate:
411 case OMPC_if:
412 case OMPC_final:
413 case OMPC_num_threads:
414 case OMPC_safelen:
415 case OMPC_simdlen:
416 case OMPC_sizes:
417 case OMPC_allocator:
418 case OMPC_allocate:
419 case OMPC_collapse:
420 case OMPC_private:
421 case OMPC_firstprivate:
422 case OMPC_shared:
423 case OMPC_task_reduction:
424 case OMPC_in_reduction:
425 case OMPC_aligned:
426 case OMPC_copyin:
427 case OMPC_copyprivate:
428 case OMPC_ordered:
429 case OMPC_nowait:
430 case OMPC_untied:
431 case OMPC_mergeable:
432 case OMPC_flush:
433 case OMPC_depobj:
434 case OMPC_read:
435 case OMPC_write:
436 case OMPC_capture:
437 case OMPC_compare:
438 case OMPC_seq_cst:
439 case OMPC_acq_rel:
440 case OMPC_acquire:
441 case OMPC_release:
442 case OMPC_relaxed:
443 case OMPC_threads:
444 case OMPC_simd:
445 case OMPC_num_teams:
446 case OMPC_thread_limit:
447 case OMPC_priority:
448 case OMPC_grainsize:
449 case OMPC_nogroup:
450 case OMPC_num_tasks:
451 case OMPC_hint:
452 case OMPC_uniform:
453 case OMPC_use_device_ptr:
454 case OMPC_use_device_addr:
455 case OMPC_is_device_ptr:
456 case OMPC_has_device_addr:
457 case OMPC_unified_address:
458 case OMPC_unified_shared_memory:
459 case OMPC_reverse_offload:
460 case OMPC_dynamic_allocators:
461 case OMPC_match:
462 case OMPC_nontemporal:
463 case OMPC_destroy:
464 case OMPC_detach:
465 case OMPC_novariants:
466 case OMPC_nocontext:
467 case OMPC_inclusive:
468 case OMPC_exclusive:
469 case OMPC_uses_allocators:
470 case OMPC_affinity:
471 case OMPC_when:
472 case OMPC_append_args:
473 break;
474 default:
475 break;
477 llvm_unreachable("Invalid OpenMP simple clause kind");
480 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
481 return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
482 DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
483 DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
484 DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
485 DKind == OMPD_parallel_master_taskloop ||
486 DKind == OMPD_parallel_master_taskloop_simd ||
487 DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
488 DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
489 DKind == OMPD_parallel_masked_taskloop_simd ||
490 DKind == OMPD_target_parallel_for ||
491 DKind == OMPD_distribute_parallel_for ||
492 DKind == OMPD_distribute_parallel_for_simd ||
493 DKind == OMPD_distribute_simd ||
494 DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
495 DKind == OMPD_teams_distribute ||
496 DKind == OMPD_teams_distribute_simd ||
497 DKind == OMPD_teams_distribute_parallel_for_simd ||
498 DKind == OMPD_teams_distribute_parallel_for ||
499 DKind == OMPD_target_teams_distribute ||
500 DKind == OMPD_target_teams_distribute_parallel_for ||
501 DKind == OMPD_target_teams_distribute_parallel_for_simd ||
502 DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
503 DKind == OMPD_unroll || DKind == OMPD_loop ||
504 DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
505 DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
508 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
509 return DKind == OMPD_for || DKind == OMPD_for_simd ||
510 DKind == OMPD_sections || DKind == OMPD_section ||
511 DKind == OMPD_single || DKind == OMPD_parallel_for ||
512 DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
513 DKind == OMPD_target_parallel_for ||
514 DKind == OMPD_distribute_parallel_for ||
515 DKind == OMPD_distribute_parallel_for_simd ||
516 DKind == OMPD_target_parallel_for_simd ||
517 DKind == OMPD_teams_distribute_parallel_for_simd ||
518 DKind == OMPD_teams_distribute_parallel_for ||
519 DKind == OMPD_target_teams_distribute_parallel_for ||
520 DKind == OMPD_target_teams_distribute_parallel_for_simd;
523 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
524 return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
525 DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
526 DKind == OMPD_parallel_master_taskloop ||
527 DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
528 DKind == OMPD_parallel_masked_taskloop ||
529 DKind == OMPD_parallel_masked_taskloop_simd ||
530 DKind == OMPD_parallel_master_taskloop_simd;
533 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
534 return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
535 DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
536 DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
537 DKind == OMPD_distribute_parallel_for ||
538 DKind == OMPD_distribute_parallel_for_simd ||
539 DKind == OMPD_target_parallel_for_simd ||
540 DKind == OMPD_teams_distribute_parallel_for ||
541 DKind == OMPD_teams_distribute_parallel_for_simd ||
542 DKind == OMPD_target_teams_distribute_parallel_for ||
543 DKind == OMPD_target_teams_distribute_parallel_for_simd ||
544 DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
545 DKind == OMPD_parallel_master_taskloop ||
546 DKind == OMPD_parallel_master_taskloop_simd ||
547 DKind == OMPD_parallel_masked_taskloop ||
548 DKind == OMPD_parallel_masked_taskloop_simd ||
549 DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
552 bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
553 return DKind == OMPD_target || DKind == OMPD_target_parallel ||
554 DKind == OMPD_target_parallel_for ||
555 DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
556 DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
557 DKind == OMPD_target_teams_distribute_parallel_for ||
558 DKind == OMPD_target_teams_distribute_parallel_for_simd ||
559 DKind == OMPD_target_teams_distribute_simd ||
560 DKind == OMPD_target_teams_loop || DKind == OMPD_target_parallel_loop;
563 bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
564 return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
565 DKind == OMPD_target_exit_data || DKind == OMPD_target_update;
568 bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind) {
569 return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
570 DKind == OMPD_teams_distribute_simd ||
571 DKind == OMPD_teams_distribute_parallel_for_simd ||
572 DKind == OMPD_teams_distribute_parallel_for ||
573 DKind == OMPD_teams_loop;
576 bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {
577 return isOpenMPNestingTeamsDirective(DKind) || DKind == OMPD_target_teams ||
578 DKind == OMPD_target_teams_distribute ||
579 DKind == OMPD_target_teams_distribute_parallel_for ||
580 DKind == OMPD_target_teams_distribute_parallel_for_simd ||
581 DKind == OMPD_target_teams_distribute_simd ||
582 DKind == OMPD_target_teams_loop;
585 bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
586 return DKind == OMPD_simd || DKind == OMPD_for_simd ||
587 DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
588 DKind == OMPD_master_taskloop_simd ||
589 DKind == OMPD_masked_taskloop_simd ||
590 DKind == OMPD_parallel_master_taskloop_simd ||
591 DKind == OMPD_parallel_masked_taskloop_simd ||
592 DKind == OMPD_distribute_parallel_for_simd ||
593 DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
594 DKind == OMPD_teams_distribute_simd ||
595 DKind == OMPD_teams_distribute_parallel_for_simd ||
596 DKind == OMPD_target_teams_distribute_parallel_for_simd ||
597 DKind == OMPD_target_teams_distribute_simd ||
598 DKind == OMPD_target_parallel_for_simd;
601 bool clang::isOpenMPNestingDistributeDirective(OpenMPDirectiveKind Kind) {
602 return Kind == OMPD_distribute || Kind == OMPD_distribute_parallel_for ||
603 Kind == OMPD_distribute_parallel_for_simd ||
604 Kind == OMPD_distribute_simd;
605 // TODO add next directives.
608 bool clang::isOpenMPDistributeDirective(OpenMPDirectiveKind Kind) {
609 return isOpenMPNestingDistributeDirective(Kind) ||
610 Kind == OMPD_teams_distribute || Kind == OMPD_teams_distribute_simd ||
611 Kind == OMPD_teams_distribute_parallel_for_simd ||
612 Kind == OMPD_teams_distribute_parallel_for ||
613 Kind == OMPD_target_teams_distribute ||
614 Kind == OMPD_target_teams_distribute_parallel_for ||
615 Kind == OMPD_target_teams_distribute_parallel_for_simd ||
616 Kind == OMPD_target_teams_distribute_simd;
619 bool clang::isOpenMPGenericLoopDirective(OpenMPDirectiveKind Kind) {
620 return Kind == OMPD_loop || Kind == OMPD_teams_loop ||
621 Kind == OMPD_target_teams_loop || Kind == OMPD_parallel_loop ||
622 Kind == OMPD_target_parallel_loop;
625 bool clang::isOpenMPPrivate(OpenMPClauseKind Kind) {
626 return Kind == OMPC_private || Kind == OMPC_firstprivate ||
627 Kind == OMPC_lastprivate || Kind == OMPC_linear ||
628 Kind == OMPC_reduction || Kind == OMPC_task_reduction ||
629 Kind == OMPC_in_reduction; // TODO add next clauses like 'reduction'.
632 bool clang::isOpenMPThreadPrivate(OpenMPClauseKind Kind) {
633 return Kind == OMPC_threadprivate || Kind == OMPC_copyin;
636 bool clang::isOpenMPTaskingDirective(OpenMPDirectiveKind Kind) {
637 return Kind == OMPD_task || isOpenMPTaskLoopDirective(Kind);
640 bool clang::isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind) {
641 return Kind == OMPD_distribute_parallel_for ||
642 Kind == OMPD_distribute_parallel_for_simd ||
643 Kind == OMPD_teams_distribute_parallel_for_simd ||
644 Kind == OMPD_teams_distribute_parallel_for ||
645 Kind == OMPD_target_teams_distribute_parallel_for ||
646 Kind == OMPD_target_teams_distribute_parallel_for_simd;
649 bool clang::isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind) {
650 return DKind == OMPD_tile || DKind == OMPD_unroll;
653 void clang::getOpenMPCaptureRegions(
654 SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
655 OpenMPDirectiveKind DKind) {
656 assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
657 switch (DKind) {
658 case OMPD_metadirective:
659 CaptureRegions.push_back(OMPD_metadirective);
660 break;
661 case OMPD_parallel:
662 case OMPD_parallel_for:
663 case OMPD_parallel_for_simd:
664 case OMPD_parallel_master:
665 case OMPD_parallel_masked:
666 case OMPD_parallel_sections:
667 case OMPD_distribute_parallel_for:
668 case OMPD_distribute_parallel_for_simd:
669 case OMPD_parallel_loop:
670 CaptureRegions.push_back(OMPD_parallel);
671 break;
672 case OMPD_target_teams:
673 case OMPD_target_teams_distribute:
674 case OMPD_target_teams_distribute_simd:
675 case OMPD_target_teams_loop:
676 CaptureRegions.push_back(OMPD_task);
677 CaptureRegions.push_back(OMPD_target);
678 CaptureRegions.push_back(OMPD_teams);
679 break;
680 case OMPD_teams:
681 case OMPD_teams_distribute:
682 case OMPD_teams_distribute_simd:
683 CaptureRegions.push_back(OMPD_teams);
684 break;
685 case OMPD_target:
686 case OMPD_target_simd:
687 CaptureRegions.push_back(OMPD_task);
688 CaptureRegions.push_back(OMPD_target);
689 break;
690 case OMPD_teams_distribute_parallel_for:
691 case OMPD_teams_distribute_parallel_for_simd:
692 CaptureRegions.push_back(OMPD_teams);
693 CaptureRegions.push_back(OMPD_parallel);
694 break;
695 case OMPD_target_parallel:
696 case OMPD_target_parallel_for:
697 case OMPD_target_parallel_for_simd:
698 case OMPD_target_parallel_loop:
699 CaptureRegions.push_back(OMPD_task);
700 CaptureRegions.push_back(OMPD_target);
701 CaptureRegions.push_back(OMPD_parallel);
702 break;
703 case OMPD_task:
704 case OMPD_target_enter_data:
705 case OMPD_target_exit_data:
706 case OMPD_target_update:
707 CaptureRegions.push_back(OMPD_task);
708 break;
709 case OMPD_taskloop:
710 case OMPD_taskloop_simd:
711 case OMPD_master_taskloop:
712 case OMPD_master_taskloop_simd:
713 case OMPD_masked_taskloop:
714 case OMPD_masked_taskloop_simd:
715 CaptureRegions.push_back(OMPD_taskloop);
716 break;
717 case OMPD_parallel_masked_taskloop:
718 case OMPD_parallel_masked_taskloop_simd:
719 case OMPD_parallel_master_taskloop:
720 case OMPD_parallel_master_taskloop_simd:
721 CaptureRegions.push_back(OMPD_parallel);
722 CaptureRegions.push_back(OMPD_taskloop);
723 break;
724 case OMPD_target_teams_distribute_parallel_for:
725 case OMPD_target_teams_distribute_parallel_for_simd:
726 CaptureRegions.push_back(OMPD_task);
727 CaptureRegions.push_back(OMPD_target);
728 CaptureRegions.push_back(OMPD_teams);
729 CaptureRegions.push_back(OMPD_parallel);
730 break;
731 case OMPD_teams_loop:
732 CaptureRegions.push_back(OMPD_teams);
733 break;
734 case OMPD_nothing:
735 CaptureRegions.push_back(OMPD_nothing);
736 break;
737 case OMPD_loop:
738 // TODO: 'loop' may require different capture regions depending on the bind
739 // clause or the parent directive when there is no bind clause. Use
740 // OMPD_unknown for now.
741 case OMPD_simd:
742 case OMPD_for:
743 case OMPD_for_simd:
744 case OMPD_sections:
745 case OMPD_section:
746 case OMPD_single:
747 case OMPD_master:
748 case OMPD_critical:
749 case OMPD_taskgroup:
750 case OMPD_distribute:
751 case OMPD_ordered:
752 case OMPD_atomic:
753 case OMPD_target_data:
754 case OMPD_distribute_simd:
755 case OMPD_dispatch:
756 CaptureRegions.push_back(OMPD_unknown);
757 break;
758 case OMPD_tile:
759 case OMPD_unroll:
760 // loop transformations do not introduce captures.
761 break;
762 case OMPD_threadprivate:
763 case OMPD_allocate:
764 case OMPD_taskyield:
765 case OMPD_barrier:
766 case OMPD_taskwait:
767 case OMPD_cancellation_point:
768 case OMPD_cancel:
769 case OMPD_flush:
770 case OMPD_depobj:
771 case OMPD_scan:
772 case OMPD_declare_reduction:
773 case OMPD_declare_mapper:
774 case OMPD_declare_simd:
775 case OMPD_declare_target:
776 case OMPD_end_declare_target:
777 case OMPD_requires:
778 case OMPD_declare_variant:
779 case OMPD_begin_declare_variant:
780 case OMPD_end_declare_variant:
781 llvm_unreachable("OpenMP Directive is not allowed");
782 case OMPD_unknown:
783 default:
784 llvm_unreachable("Unknown OpenMP directive");