1 //===--- OpenMPKinds.cpp - Token Kinds Support ----------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 /// This file implements the OpenMP enum and support functions.
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"
20 using namespace clang
;
21 using namespace llvm::omp
;
23 unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind
, StringRef Str
,
24 const LangOptions
&LangOpts
) {
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
));
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
));
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
);
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
;
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
);
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
;
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
;
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
);
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
);
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
);
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
);
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
);
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
);
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
);
143 case OMPC_threadprivate
:
146 case OMPC_num_threads
:
154 case OMPC_firstprivate
:
156 case OMPC_task_reduction
:
157 case OMPC_in_reduction
:
160 case OMPC_copyprivate
:
179 case OMPC_thread_limit
:
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
:
195 case OMPC_nontemporal
:
197 case OMPC_novariants
:
202 case OMPC_uses_allocators
:
205 case OMPC_append_args
:
210 llvm_unreachable("Invalid OpenMP simple clause kind");
213 const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind
,
217 switch (llvm::omp::DefaultKind(Type
)) {
218 #define OMP_DEFAULT_KIND(Enum, Name) \
221 #include "llvm/Frontend/OpenMP/OMPKinds.def"
223 llvm_unreachable("Invalid OpenMP 'default' clause type");
226 #define OMP_PROC_BIND_KIND(Enum, Name, Value) \
229 #include "llvm/Frontend/OpenMP/OMPKinds.def"
231 llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
234 case OMPC_SCHEDULE_unknown
:
235 case OMPC_SCHEDULE_MODIFIER_last
:
237 #define OPENMP_SCHEDULE_KIND(Name) \
238 case OMPC_SCHEDULE_##Name: \
240 #define OPENMP_SCHEDULE_MODIFIER(Name) \
241 case OMPC_SCHEDULE_MODIFIER_##Name: \
243 #include "clang/Basic/OpenMPKinds.def"
245 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
248 case OMPC_DEPEND_unknown
:
250 #define OPENMP_DEPEND_KIND(Name) \
251 case OMPC_DEPEND_##Name: \
253 #include "clang/Basic/OpenMPKinds.def"
255 llvm_unreachable("Invalid OpenMP 'depend' clause type");
258 case OMPC_LINEAR_unknown
:
260 #define OPENMP_LINEAR_KIND(Name) \
261 case OMPC_LINEAR_##Name: \
263 #include "clang/Basic/OpenMPKinds.def"
265 llvm_unreachable("Invalid OpenMP 'linear' clause type");
268 case OMPC_MAP_unknown
:
269 case OMPC_MAP_MODIFIER_last
:
271 #define OPENMP_MAP_KIND(Name) \
272 case OMPC_MAP_##Name: \
274 #define OPENMP_MAP_MODIFIER_KIND(Name) \
275 case OMPC_MAP_MODIFIER_##Name: \
277 #include "clang/Basic/OpenMPKinds.def"
281 llvm_unreachable("Invalid OpenMP 'map' clause type");
285 case OMPC_MOTION_MODIFIER_unknown
:
287 #define OPENMP_MOTION_MODIFIER_KIND(Name) \
288 case OMPC_MOTION_MODIFIER_##Name: \
290 #include "clang/Basic/OpenMPKinds.def"
294 llvm_unreachable("Invalid OpenMP 'to' or 'from' clause type");
295 case OMPC_dist_schedule
:
297 case OMPC_DIST_SCHEDULE_unknown
:
299 #define OPENMP_DIST_SCHEDULE_KIND(Name) \
300 case OMPC_DIST_SCHEDULE_##Name: \
302 #include "clang/Basic/OpenMPKinds.def"
304 llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
305 case OMPC_defaultmap
:
307 case OMPC_DEFAULTMAP_unknown
:
308 case OMPC_DEFAULTMAP_MODIFIER_last
:
310 #define OPENMP_DEFAULTMAP_KIND(Name) \
311 case OMPC_DEFAULTMAP_##Name: \
313 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
314 case OMPC_DEFAULTMAP_MODIFIER_##Name: \
316 #include "clang/Basic/OpenMPKinds.def"
318 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
319 case OMPC_atomic_default_mem_order
:
321 case OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
:
323 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
324 case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name: \
326 #include "clang/Basic/OpenMPKinds.def"
328 llvm_unreachable("Invalid OpenMP 'atomic_default_mem_order' clause type");
329 case OMPC_device_type
:
331 case OMPC_DEVICE_TYPE_unknown
:
333 #define OPENMP_DEVICE_TYPE_KIND(Name) \
334 case OMPC_DEVICE_TYPE_##Name: \
336 #include "clang/Basic/OpenMPKinds.def"
338 llvm_unreachable("Invalid OpenMP 'device_type' clause type");
339 case OMPC_lastprivate
:
341 case OMPC_LASTPRIVATE_unknown
:
343 #define OPENMP_LASTPRIVATE_KIND(Name) \
344 case OMPC_LASTPRIVATE_##Name: \
346 #include "clang/Basic/OpenMPKinds.def"
348 llvm_unreachable("Invalid OpenMP 'lastprivate' clause type");
351 case OMPC_ORDER_unknown
:
353 #define OPENMP_ORDER_KIND(Name) \
354 case OMPC_ORDER_##Name: \
356 #include "clang/Basic/OpenMPKinds.def"
358 llvm_unreachable("Invalid OpenMP 'order' clause type");
361 case OMPC_DEPEND_unknown
:
363 #define OPENMP_DEPEND_KIND(Name) \
364 case OMPC_DEPEND_##Name: \
366 #include "clang/Basic/OpenMPKinds.def"
368 llvm_unreachable("Invalid OpenMP 'depend' clause type");
371 case OMPC_DEVICE_unknown
:
373 #define OPENMP_DEVICE_MODIFIER(Name) \
374 case OMPC_DEVICE_##Name: \
376 #include "clang/Basic/OpenMPKinds.def"
378 llvm_unreachable("Invalid OpenMP 'device' clause modifier");
381 case OMPC_REDUCTION_unknown
:
383 #define OPENMP_REDUCTION_MODIFIER(Name) \
384 case OMPC_REDUCTION_##Name: \
386 #include "clang/Basic/OpenMPKinds.def"
388 llvm_unreachable("Invalid OpenMP 'reduction' clause modifier");
389 case OMPC_adjust_args
:
391 case OMPC_ADJUST_ARGS_unknown
:
393 #define OPENMP_ADJUST_ARGS_KIND(Name) \
394 case OMPC_ADJUST_ARGS_##Name: \
396 #include "clang/Basic/OpenMPKinds.def"
398 llvm_unreachable("Invalid OpenMP 'adjust_args' clause kind");
401 case OMPC_BIND_unknown
:
403 #define OPENMP_BIND_KIND(Name) \
404 case OMPC_BIND_##Name: \
406 #include "clang/Basic/OpenMPKinds.def"
408 llvm_unreachable("Invalid OpenMP 'bind' clause type");
410 case OMPC_threadprivate
:
413 case OMPC_num_threads
:
421 case OMPC_firstprivate
:
423 case OMPC_task_reduction
:
424 case OMPC_in_reduction
:
427 case OMPC_copyprivate
:
446 case OMPC_thread_limit
:
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
:
462 case OMPC_nontemporal
:
465 case OMPC_novariants
:
469 case OMPC_uses_allocators
:
472 case OMPC_append_args
:
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
);
658 case OMPD_metadirective
:
659 CaptureRegions
.push_back(OMPD_metadirective
);
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
);
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
);
681 case OMPD_teams_distribute
:
682 case OMPD_teams_distribute_simd
:
683 CaptureRegions
.push_back(OMPD_teams
);
686 case OMPD_target_simd
:
687 CaptureRegions
.push_back(OMPD_task
);
688 CaptureRegions
.push_back(OMPD_target
);
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
);
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
);
704 case OMPD_target_enter_data
:
705 case OMPD_target_exit_data
:
706 case OMPD_target_update
:
707 CaptureRegions
.push_back(OMPD_task
);
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
);
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
);
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
);
731 case OMPD_teams_loop
:
732 CaptureRegions
.push_back(OMPD_teams
);
735 CaptureRegions
.push_back(OMPD_nothing
);
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.
750 case OMPD_distribute
:
753 case OMPD_target_data
:
754 case OMPD_distribute_simd
:
756 CaptureRegions
.push_back(OMPD_unknown
);
760 // loop transformations do not introduce captures.
762 case OMPD_threadprivate
:
767 case OMPD_cancellation_point
:
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
:
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");
784 llvm_unreachable("Unknown OpenMP directive");