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
);
108 return llvm::StringSwitch
<OpenMPAtClauseKind
>(Str
)
109 #define OPENMP_AT_KIND(Name) .Case(#Name, OMPC_AT_##Name)
110 #include "clang/Basic/OpenMPKinds.def"
111 .Default(OMPC_AT_unknown
);
113 return llvm::StringSwitch
<OpenMPSeverityClauseKind
>(Str
)
114 #define OPENMP_SEVERITY_KIND(Name) .Case(#Name, OMPC_SEVERITY_##Name)
115 #include "clang/Basic/OpenMPKinds.def"
116 .Default(OMPC_SEVERITY_unknown
);
117 case OMPC_lastprivate
:
118 return llvm::StringSwitch
<OpenMPLastprivateModifier
>(Str
)
119 #define OPENMP_LASTPRIVATE_KIND(Name) .Case(#Name, OMPC_LASTPRIVATE_##Name)
120 #include "clang/Basic/OpenMPKinds.def"
121 .Default(OMPC_LASTPRIVATE_unknown
);
123 return llvm::StringSwitch
<unsigned>(Str
)
124 #define OPENMP_ORDER_KIND(Name) \
125 .Case(#Name, static_cast<unsigned>(OMPC_ORDER_##Name))
126 #define OPENMP_ORDER_MODIFIER(Name) \
127 .Case(#Name, static_cast<unsigned>(OMPC_ORDER_MODIFIER_##Name))
128 #include "clang/Basic/OpenMPKinds.def"
129 .Default(OMPC_ORDER_unknown
);
131 return llvm::StringSwitch
<OpenMPDependClauseKind
>(Str
)
132 #define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
133 #include "clang/Basic/OpenMPKinds.def"
134 .Default(OMPC_DEPEND_unknown
);
136 return llvm::StringSwitch
<OpenMPDeviceClauseModifier
>(Str
)
137 #define OPENMP_DEVICE_MODIFIER(Name) .Case(#Name, OMPC_DEVICE_##Name)
138 #include "clang/Basic/OpenMPKinds.def"
139 .Default(OMPC_DEVICE_unknown
);
141 return llvm::StringSwitch
<OpenMPReductionClauseModifier
>(Str
)
142 #define OPENMP_REDUCTION_MODIFIER(Name) .Case(#Name, OMPC_REDUCTION_##Name)
143 #include "clang/Basic/OpenMPKinds.def"
144 .Default(OMPC_REDUCTION_unknown
);
145 case OMPC_adjust_args
:
146 return llvm::StringSwitch
<OpenMPAdjustArgsOpKind
>(Str
)
147 #define OPENMP_ADJUST_ARGS_KIND(Name) .Case(#Name, OMPC_ADJUST_ARGS_##Name)
148 #include "clang/Basic/OpenMPKinds.def"
149 .Default(OMPC_ADJUST_ARGS_unknown
);
151 return llvm::StringSwitch
<unsigned>(Str
)
152 #define OPENMP_BIND_KIND(Name) .Case(#Name, OMPC_BIND_##Name)
153 #include "clang/Basic/OpenMPKinds.def"
154 .Default(OMPC_BIND_unknown
);
155 case OMPC_grainsize
: {
156 unsigned Type
= llvm::StringSwitch
<unsigned>(Str
)
157 #define OPENMP_GRAINSIZE_MODIFIER(Name) .Case(#Name, OMPC_GRAINSIZE_##Name)
158 #include "clang/Basic/OpenMPKinds.def"
159 .Default(OMPC_GRAINSIZE_unknown
);
160 if (LangOpts
.OpenMP
< 51)
161 return OMPC_GRAINSIZE_unknown
;
164 case OMPC_num_tasks
: {
165 unsigned Type
= llvm::StringSwitch
<unsigned>(Str
)
166 #define OPENMP_NUMTASKS_MODIFIER(Name) .Case(#Name, OMPC_NUMTASKS_##Name)
167 #include "clang/Basic/OpenMPKinds.def"
168 .Default(OMPC_NUMTASKS_unknown
);
169 if (LangOpts
.OpenMP
< 51)
170 return OMPC_NUMTASKS_unknown
;
174 case OMPC_threadprivate
:
177 case OMPC_num_threads
:
185 case OMPC_firstprivate
:
187 case OMPC_task_reduction
:
188 case OMPC_in_reduction
:
191 case OMPC_copyprivate
:
210 case OMPC_thread_limit
:
215 case OMPC_use_device_ptr
:
216 case OMPC_use_device_addr
:
217 case OMPC_is_device_ptr
:
218 case OMPC_has_device_addr
:
219 case OMPC_unified_address
:
220 case OMPC_unified_shared_memory
:
221 case OMPC_reverse_offload
:
222 case OMPC_dynamic_allocators
:
224 case OMPC_nontemporal
:
226 case OMPC_novariants
:
231 case OMPC_uses_allocators
:
234 case OMPC_append_args
:
239 llvm_unreachable("Invalid OpenMP simple clause kind");
242 const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind
,
246 switch (llvm::omp::DefaultKind(Type
)) {
247 #define OMP_DEFAULT_KIND(Enum, Name) \
250 #include "llvm/Frontend/OpenMP/OMPKinds.def"
252 llvm_unreachable("Invalid OpenMP 'default' clause type");
255 #define OMP_PROC_BIND_KIND(Enum, Name, Value) \
258 #include "llvm/Frontend/OpenMP/OMPKinds.def"
260 llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
263 case OMPC_SCHEDULE_unknown
:
264 case OMPC_SCHEDULE_MODIFIER_last
:
266 #define OPENMP_SCHEDULE_KIND(Name) \
267 case OMPC_SCHEDULE_##Name: \
269 #define OPENMP_SCHEDULE_MODIFIER(Name) \
270 case OMPC_SCHEDULE_MODIFIER_##Name: \
272 #include "clang/Basic/OpenMPKinds.def"
274 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
277 case OMPC_DEPEND_unknown
:
279 #define OPENMP_DEPEND_KIND(Name) \
280 case OMPC_DEPEND_##Name: \
282 #include "clang/Basic/OpenMPKinds.def"
284 llvm_unreachable("Invalid OpenMP 'depend' clause type");
287 case OMPC_LINEAR_unknown
:
289 #define OPENMP_LINEAR_KIND(Name) \
290 case OMPC_LINEAR_##Name: \
292 #include "clang/Basic/OpenMPKinds.def"
294 llvm_unreachable("Invalid OpenMP 'linear' clause type");
297 case OMPC_MAP_unknown
:
298 case OMPC_MAP_MODIFIER_last
:
300 #define OPENMP_MAP_KIND(Name) \
301 case OMPC_MAP_##Name: \
303 #define OPENMP_MAP_MODIFIER_KIND(Name) \
304 case OMPC_MAP_MODIFIER_##Name: \
306 #include "clang/Basic/OpenMPKinds.def"
310 llvm_unreachable("Invalid OpenMP 'map' clause type");
314 case OMPC_MOTION_MODIFIER_unknown
:
316 #define OPENMP_MOTION_MODIFIER_KIND(Name) \
317 case OMPC_MOTION_MODIFIER_##Name: \
319 #include "clang/Basic/OpenMPKinds.def"
323 llvm_unreachable("Invalid OpenMP 'to' or 'from' clause type");
324 case OMPC_dist_schedule
:
326 case OMPC_DIST_SCHEDULE_unknown
:
328 #define OPENMP_DIST_SCHEDULE_KIND(Name) \
329 case OMPC_DIST_SCHEDULE_##Name: \
331 #include "clang/Basic/OpenMPKinds.def"
333 llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
334 case OMPC_defaultmap
:
336 case OMPC_DEFAULTMAP_unknown
:
337 case OMPC_DEFAULTMAP_MODIFIER_last
:
339 #define OPENMP_DEFAULTMAP_KIND(Name) \
340 case OMPC_DEFAULTMAP_##Name: \
342 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
343 case OMPC_DEFAULTMAP_MODIFIER_##Name: \
345 #include "clang/Basic/OpenMPKinds.def"
347 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
348 case OMPC_atomic_default_mem_order
:
350 case OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
:
352 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
353 case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name: \
355 #include "clang/Basic/OpenMPKinds.def"
357 llvm_unreachable("Invalid OpenMP 'atomic_default_mem_order' clause type");
358 case OMPC_device_type
:
360 case OMPC_DEVICE_TYPE_unknown
:
362 #define OPENMP_DEVICE_TYPE_KIND(Name) \
363 case OMPC_DEVICE_TYPE_##Name: \
365 #include "clang/Basic/OpenMPKinds.def"
367 llvm_unreachable("Invalid OpenMP 'device_type' clause type");
370 case OMPC_AT_unknown
:
372 #define OPENMP_AT_KIND(Name) \
373 case OMPC_AT_##Name: \
375 #include "clang/Basic/OpenMPKinds.def"
377 llvm_unreachable("Invalid OpenMP 'at' clause type");
380 case OMPC_SEVERITY_unknown
:
382 #define OPENMP_SEVERITY_KIND(Name) \
383 case OMPC_SEVERITY_##Name: \
385 #include "clang/Basic/OpenMPKinds.def"
387 llvm_unreachable("Invalid OpenMP 'severity' clause type");
388 case OMPC_lastprivate
:
390 case OMPC_LASTPRIVATE_unknown
:
392 #define OPENMP_LASTPRIVATE_KIND(Name) \
393 case OMPC_LASTPRIVATE_##Name: \
395 #include "clang/Basic/OpenMPKinds.def"
397 llvm_unreachable("Invalid OpenMP 'lastprivate' clause type");
400 case OMPC_ORDER_unknown
:
401 case OMPC_ORDER_MODIFIER_last
:
403 #define OPENMP_ORDER_KIND(Name) \
404 case OMPC_ORDER_##Name: \
406 #define OPENMP_ORDER_MODIFIER(Name) \
407 case OMPC_ORDER_MODIFIER_##Name: \
409 #include "clang/Basic/OpenMPKinds.def"
411 llvm_unreachable("Invalid OpenMP 'order' clause type");
414 case OMPC_DEPEND_unknown
:
416 #define OPENMP_DEPEND_KIND(Name) \
417 case OMPC_DEPEND_##Name: \
419 #include "clang/Basic/OpenMPKinds.def"
421 llvm_unreachable("Invalid OpenMP 'depend' clause type");
424 case OMPC_DEVICE_unknown
:
426 #define OPENMP_DEVICE_MODIFIER(Name) \
427 case OMPC_DEVICE_##Name: \
429 #include "clang/Basic/OpenMPKinds.def"
431 llvm_unreachable("Invalid OpenMP 'device' clause modifier");
434 case OMPC_REDUCTION_unknown
:
436 #define OPENMP_REDUCTION_MODIFIER(Name) \
437 case OMPC_REDUCTION_##Name: \
439 #include "clang/Basic/OpenMPKinds.def"
441 llvm_unreachable("Invalid OpenMP 'reduction' clause modifier");
442 case OMPC_adjust_args
:
444 case OMPC_ADJUST_ARGS_unknown
:
446 #define OPENMP_ADJUST_ARGS_KIND(Name) \
447 case OMPC_ADJUST_ARGS_##Name: \
449 #include "clang/Basic/OpenMPKinds.def"
451 llvm_unreachable("Invalid OpenMP 'adjust_args' clause kind");
454 case OMPC_BIND_unknown
:
456 #define OPENMP_BIND_KIND(Name) \
457 case OMPC_BIND_##Name: \
459 #include "clang/Basic/OpenMPKinds.def"
461 llvm_unreachable("Invalid OpenMP 'bind' clause type");
464 case OMPC_GRAINSIZE_unknown
:
466 #define OPENMP_GRAINSIZE_MODIFIER(Name) \
467 case OMPC_GRAINSIZE_##Name: \
469 #include "clang/Basic/OpenMPKinds.def"
471 llvm_unreachable("Invalid OpenMP 'grainsize' clause modifier");
474 case OMPC_NUMTASKS_unknown
:
476 #define OPENMP_NUMTASKS_MODIFIER(Name) \
477 case OMPC_NUMTASKS_##Name: \
479 #include "clang/Basic/OpenMPKinds.def"
481 llvm_unreachable("Invalid OpenMP 'num_tasks' clause modifier");
483 case OMPC_threadprivate
:
486 case OMPC_num_threads
:
494 case OMPC_firstprivate
:
496 case OMPC_task_reduction
:
497 case OMPC_in_reduction
:
500 case OMPC_copyprivate
:
519 case OMPC_thread_limit
:
524 case OMPC_use_device_ptr
:
525 case OMPC_use_device_addr
:
526 case OMPC_is_device_ptr
:
527 case OMPC_has_device_addr
:
528 case OMPC_unified_address
:
529 case OMPC_unified_shared_memory
:
530 case OMPC_reverse_offload
:
531 case OMPC_dynamic_allocators
:
533 case OMPC_nontemporal
:
536 case OMPC_novariants
:
540 case OMPC_uses_allocators
:
543 case OMPC_append_args
:
548 llvm_unreachable("Invalid OpenMP simple clause kind");
551 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind
) {
552 return DKind
== OMPD_simd
|| DKind
== OMPD_for
|| DKind
== OMPD_for_simd
||
553 DKind
== OMPD_parallel_for
|| DKind
== OMPD_parallel_for_simd
||
554 DKind
== OMPD_taskloop
|| DKind
== OMPD_taskloop_simd
||
555 DKind
== OMPD_master_taskloop
|| DKind
== OMPD_master_taskloop_simd
||
556 DKind
== OMPD_parallel_master_taskloop
||
557 DKind
== OMPD_parallel_master_taskloop_simd
||
558 DKind
== OMPD_masked_taskloop
|| DKind
== OMPD_masked_taskloop_simd
||
559 DKind
== OMPD_parallel_masked_taskloop
|| DKind
== OMPD_distribute
||
560 DKind
== OMPD_parallel_masked_taskloop_simd
||
561 DKind
== OMPD_target_parallel_for
||
562 DKind
== OMPD_distribute_parallel_for
||
563 DKind
== OMPD_distribute_parallel_for_simd
||
564 DKind
== OMPD_distribute_simd
||
565 DKind
== OMPD_target_parallel_for_simd
|| DKind
== OMPD_target_simd
||
566 DKind
== OMPD_teams_distribute
||
567 DKind
== OMPD_teams_distribute_simd
||
568 DKind
== OMPD_teams_distribute_parallel_for_simd
||
569 DKind
== OMPD_teams_distribute_parallel_for
||
570 DKind
== OMPD_target_teams_distribute
||
571 DKind
== OMPD_target_teams_distribute_parallel_for
||
572 DKind
== OMPD_target_teams_distribute_parallel_for_simd
||
573 DKind
== OMPD_target_teams_distribute_simd
|| DKind
== OMPD_tile
||
574 DKind
== OMPD_unroll
|| DKind
== OMPD_loop
||
575 DKind
== OMPD_teams_loop
|| DKind
== OMPD_target_teams_loop
||
576 DKind
== OMPD_parallel_loop
|| DKind
== OMPD_target_parallel_loop
;
579 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind
) {
580 return DKind
== OMPD_for
|| DKind
== OMPD_for_simd
||
581 DKind
== OMPD_sections
|| DKind
== OMPD_section
||
582 DKind
== OMPD_single
|| DKind
== OMPD_parallel_for
||
583 DKind
== OMPD_parallel_for_simd
|| DKind
== OMPD_parallel_sections
||
584 DKind
== OMPD_target_parallel_for
||
585 DKind
== OMPD_distribute_parallel_for
||
586 DKind
== OMPD_distribute_parallel_for_simd
||
587 DKind
== OMPD_target_parallel_for_simd
||
588 DKind
== OMPD_teams_distribute_parallel_for_simd
||
589 DKind
== OMPD_teams_distribute_parallel_for
||
590 DKind
== OMPD_target_teams_distribute_parallel_for
||
591 DKind
== OMPD_target_teams_distribute_parallel_for_simd
;
594 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind
) {
595 return DKind
== OMPD_taskloop
|| DKind
== OMPD_taskloop_simd
||
596 DKind
== OMPD_master_taskloop
|| DKind
== OMPD_master_taskloop_simd
||
597 DKind
== OMPD_parallel_master_taskloop
||
598 DKind
== OMPD_masked_taskloop
|| DKind
== OMPD_masked_taskloop_simd
||
599 DKind
== OMPD_parallel_masked_taskloop
||
600 DKind
== OMPD_parallel_masked_taskloop_simd
||
601 DKind
== OMPD_parallel_master_taskloop_simd
;
604 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind
) {
605 return DKind
== OMPD_parallel
|| DKind
== OMPD_parallel_for
||
606 DKind
== OMPD_parallel_for_simd
|| DKind
== OMPD_parallel_sections
||
607 DKind
== OMPD_target_parallel
|| DKind
== OMPD_target_parallel_for
||
608 DKind
== OMPD_distribute_parallel_for
||
609 DKind
== OMPD_distribute_parallel_for_simd
||
610 DKind
== OMPD_target_parallel_for_simd
||
611 DKind
== OMPD_teams_distribute_parallel_for
||
612 DKind
== OMPD_teams_distribute_parallel_for_simd
||
613 DKind
== OMPD_target_teams_distribute_parallel_for
||
614 DKind
== OMPD_target_teams_distribute_parallel_for_simd
||
615 DKind
== OMPD_parallel_master
|| DKind
== OMPD_parallel_masked
||
616 DKind
== OMPD_parallel_master_taskloop
||
617 DKind
== OMPD_parallel_master_taskloop_simd
||
618 DKind
== OMPD_parallel_masked_taskloop
||
619 DKind
== OMPD_parallel_masked_taskloop_simd
||
620 DKind
== OMPD_parallel_loop
|| DKind
== OMPD_target_parallel_loop
;
623 bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind
) {
624 return DKind
== OMPD_target
|| DKind
== OMPD_target_parallel
||
625 DKind
== OMPD_target_parallel_for
||
626 DKind
== OMPD_target_parallel_for_simd
|| DKind
== OMPD_target_simd
||
627 DKind
== OMPD_target_teams
|| DKind
== OMPD_target_teams_distribute
||
628 DKind
== OMPD_target_teams_distribute_parallel_for
||
629 DKind
== OMPD_target_teams_distribute_parallel_for_simd
||
630 DKind
== OMPD_target_teams_distribute_simd
||
631 DKind
== OMPD_target_teams_loop
|| DKind
== OMPD_target_parallel_loop
;
634 bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind
) {
635 return DKind
== OMPD_target_data
|| DKind
== OMPD_target_enter_data
||
636 DKind
== OMPD_target_exit_data
|| DKind
== OMPD_target_update
;
639 bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind
) {
640 return DKind
== OMPD_teams
|| DKind
== OMPD_teams_distribute
||
641 DKind
== OMPD_teams_distribute_simd
||
642 DKind
== OMPD_teams_distribute_parallel_for_simd
||
643 DKind
== OMPD_teams_distribute_parallel_for
||
644 DKind
== OMPD_teams_loop
;
647 bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind
) {
648 return isOpenMPNestingTeamsDirective(DKind
) || DKind
== OMPD_target_teams
||
649 DKind
== OMPD_target_teams_distribute
||
650 DKind
== OMPD_target_teams_distribute_parallel_for
||
651 DKind
== OMPD_target_teams_distribute_parallel_for_simd
||
652 DKind
== OMPD_target_teams_distribute_simd
||
653 DKind
== OMPD_target_teams_loop
;
656 bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind
) {
657 return DKind
== OMPD_simd
|| DKind
== OMPD_for_simd
||
658 DKind
== OMPD_parallel_for_simd
|| DKind
== OMPD_taskloop_simd
||
659 DKind
== OMPD_master_taskloop_simd
||
660 DKind
== OMPD_masked_taskloop_simd
||
661 DKind
== OMPD_parallel_master_taskloop_simd
||
662 DKind
== OMPD_parallel_masked_taskloop_simd
||
663 DKind
== OMPD_distribute_parallel_for_simd
||
664 DKind
== OMPD_distribute_simd
|| DKind
== OMPD_target_simd
||
665 DKind
== OMPD_teams_distribute_simd
||
666 DKind
== OMPD_teams_distribute_parallel_for_simd
||
667 DKind
== OMPD_target_teams_distribute_parallel_for_simd
||
668 DKind
== OMPD_target_teams_distribute_simd
||
669 DKind
== OMPD_target_parallel_for_simd
;
672 bool clang::isOpenMPNestingDistributeDirective(OpenMPDirectiveKind Kind
) {
673 return Kind
== OMPD_distribute
|| Kind
== OMPD_distribute_parallel_for
||
674 Kind
== OMPD_distribute_parallel_for_simd
||
675 Kind
== OMPD_distribute_simd
;
676 // TODO add next directives.
679 bool clang::isOpenMPDistributeDirective(OpenMPDirectiveKind Kind
) {
680 return isOpenMPNestingDistributeDirective(Kind
) ||
681 Kind
== OMPD_teams_distribute
|| Kind
== OMPD_teams_distribute_simd
||
682 Kind
== OMPD_teams_distribute_parallel_for_simd
||
683 Kind
== OMPD_teams_distribute_parallel_for
||
684 Kind
== OMPD_target_teams_distribute
||
685 Kind
== OMPD_target_teams_distribute_parallel_for
||
686 Kind
== OMPD_target_teams_distribute_parallel_for_simd
||
687 Kind
== OMPD_target_teams_distribute_simd
;
690 bool clang::isOpenMPGenericLoopDirective(OpenMPDirectiveKind Kind
) {
691 return Kind
== OMPD_loop
|| Kind
== OMPD_teams_loop
||
692 Kind
== OMPD_target_teams_loop
|| Kind
== OMPD_parallel_loop
||
693 Kind
== OMPD_target_parallel_loop
;
696 bool clang::isOpenMPPrivate(OpenMPClauseKind Kind
) {
697 return Kind
== OMPC_private
|| Kind
== OMPC_firstprivate
||
698 Kind
== OMPC_lastprivate
|| Kind
== OMPC_linear
||
699 Kind
== OMPC_reduction
|| Kind
== OMPC_task_reduction
||
700 Kind
== OMPC_in_reduction
; // TODO add next clauses like 'reduction'.
703 bool clang::isOpenMPThreadPrivate(OpenMPClauseKind Kind
) {
704 return Kind
== OMPC_threadprivate
|| Kind
== OMPC_copyin
;
707 bool clang::isOpenMPTaskingDirective(OpenMPDirectiveKind Kind
) {
708 return Kind
== OMPD_task
|| isOpenMPTaskLoopDirective(Kind
);
711 bool clang::isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind
) {
712 return Kind
== OMPD_distribute_parallel_for
||
713 Kind
== OMPD_distribute_parallel_for_simd
||
714 Kind
== OMPD_teams_distribute_parallel_for_simd
||
715 Kind
== OMPD_teams_distribute_parallel_for
||
716 Kind
== OMPD_target_teams_distribute_parallel_for
||
717 Kind
== OMPD_target_teams_distribute_parallel_for_simd
;
720 bool clang::isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind
) {
721 return DKind
== OMPD_tile
|| DKind
== OMPD_unroll
;
724 bool clang::isOpenMPCombinedParallelADirective(OpenMPDirectiveKind DKind
) {
725 return DKind
== OMPD_parallel_for
|| DKind
== OMPD_parallel_for_simd
||
726 DKind
== OMPD_parallel_master
||
727 DKind
== OMPD_parallel_master_taskloop
||
728 DKind
== OMPD_parallel_master_taskloop_simd
||
729 DKind
== OMPD_parallel_sections
;
732 void clang::getOpenMPCaptureRegions(
733 SmallVectorImpl
<OpenMPDirectiveKind
> &CaptureRegions
,
734 OpenMPDirectiveKind DKind
) {
735 assert(unsigned(DKind
) < llvm::omp::Directive_enumSize
);
737 case OMPD_metadirective
:
738 CaptureRegions
.push_back(OMPD_metadirective
);
741 case OMPD_parallel_for
:
742 case OMPD_parallel_for_simd
:
743 case OMPD_parallel_master
:
744 case OMPD_parallel_masked
:
745 case OMPD_parallel_sections
:
746 case OMPD_distribute_parallel_for
:
747 case OMPD_distribute_parallel_for_simd
:
748 case OMPD_parallel_loop
:
749 CaptureRegions
.push_back(OMPD_parallel
);
751 case OMPD_target_teams
:
752 case OMPD_target_teams_distribute
:
753 case OMPD_target_teams_distribute_simd
:
754 case OMPD_target_teams_loop
:
755 CaptureRegions
.push_back(OMPD_task
);
756 CaptureRegions
.push_back(OMPD_target
);
757 CaptureRegions
.push_back(OMPD_teams
);
760 case OMPD_teams_distribute
:
761 case OMPD_teams_distribute_simd
:
762 CaptureRegions
.push_back(OMPD_teams
);
765 case OMPD_target_simd
:
766 CaptureRegions
.push_back(OMPD_task
);
767 CaptureRegions
.push_back(OMPD_target
);
769 case OMPD_teams_distribute_parallel_for
:
770 case OMPD_teams_distribute_parallel_for_simd
:
771 CaptureRegions
.push_back(OMPD_teams
);
772 CaptureRegions
.push_back(OMPD_parallel
);
774 case OMPD_target_parallel
:
775 case OMPD_target_parallel_for
:
776 case OMPD_target_parallel_for_simd
:
777 case OMPD_target_parallel_loop
:
778 CaptureRegions
.push_back(OMPD_task
);
779 CaptureRegions
.push_back(OMPD_target
);
780 CaptureRegions
.push_back(OMPD_parallel
);
783 case OMPD_target_enter_data
:
784 case OMPD_target_exit_data
:
785 case OMPD_target_update
:
786 CaptureRegions
.push_back(OMPD_task
);
789 case OMPD_taskloop_simd
:
790 case OMPD_master_taskloop
:
791 case OMPD_master_taskloop_simd
:
792 case OMPD_masked_taskloop
:
793 case OMPD_masked_taskloop_simd
:
794 CaptureRegions
.push_back(OMPD_taskloop
);
796 case OMPD_parallel_masked_taskloop
:
797 case OMPD_parallel_masked_taskloop_simd
:
798 case OMPD_parallel_master_taskloop
:
799 case OMPD_parallel_master_taskloop_simd
:
800 CaptureRegions
.push_back(OMPD_parallel
);
801 CaptureRegions
.push_back(OMPD_taskloop
);
803 case OMPD_target_teams_distribute_parallel_for
:
804 case OMPD_target_teams_distribute_parallel_for_simd
:
805 CaptureRegions
.push_back(OMPD_task
);
806 CaptureRegions
.push_back(OMPD_target
);
807 CaptureRegions
.push_back(OMPD_teams
);
808 CaptureRegions
.push_back(OMPD_parallel
);
810 case OMPD_teams_loop
:
811 CaptureRegions
.push_back(OMPD_teams
);
814 CaptureRegions
.push_back(OMPD_nothing
);
817 // TODO: 'loop' may require different capture regions depending on the bind
818 // clause or the parent directive when there is no bind clause. Use
819 // OMPD_unknown for now.
829 case OMPD_distribute
:
832 case OMPD_target_data
:
833 case OMPD_distribute_simd
:
835 CaptureRegions
.push_back(OMPD_unknown
);
839 // loop transformations do not introduce captures.
841 case OMPD_threadprivate
:
847 case OMPD_cancellation_point
:
852 case OMPD_declare_reduction
:
853 case OMPD_declare_mapper
:
854 case OMPD_declare_simd
:
855 case OMPD_declare_target
:
856 case OMPD_end_declare_target
:
858 case OMPD_declare_variant
:
859 case OMPD_begin_declare_variant
:
860 case OMPD_end_declare_variant
:
861 llvm_unreachable("OpenMP Directive is not allowed");
864 llvm_unreachable("Unknown OpenMP directive");