1 //===--- OpenMPKinds.cpp - Token Kinds Support ----------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 /// \brief This file implements the OpenMP enum and support functions.
11 ///
12 //===----------------------------------------------------------------------===//
13
14 #include "clang/Basic/OpenMPKinds.h"
15 #include "clang/Basic/IdentifierTable.h"
16 #include "llvm/ADT/StringRef.h"
17 #include "llvm/ADT/StringSwitch.h"
18 #include "llvm/Support/ErrorHandling.h"
19 #include <cassert>
20
21 using namespace clang;
22
getOpenMPDirectiveKind(StringRef Str)23 OpenMPDirectiveKind clang::getOpenMPDirectiveKind(StringRef Str) {
24 return llvm::StringSwitch<OpenMPDirectiveKind>(Str)
25 #define OPENMP_DIRECTIVE(Name) .Case(#Name, OMPD_##Name)
26 #define OPENMP_DIRECTIVE_EXT(Name, Str) .Case(Str, OMPD_##Name)
27 #include "clang/Basic/OpenMPKinds.def"
28 .Default(OMPD_unknown);
29 }
30
getOpenMPDirectiveName(OpenMPDirectiveKind Kind)31 const char *clang::getOpenMPDirectiveName(OpenMPDirectiveKind Kind) {
32 assert(Kind <= OMPD_unknown);
33 switch (Kind) {
34 case OMPD_unknown:
35 return "unknown";
36 #define OPENMP_DIRECTIVE(Name) \
37 case OMPD_##Name: \
38 return #Name;
39 #define OPENMP_DIRECTIVE_EXT(Name, Str) \
40 case OMPD_##Name: \
41 return Str;
42 #include "clang/Basic/OpenMPKinds.def"
43 break;
44 }
45 llvm_unreachable("Invalid OpenMP directive kind");
46 }
47
getOpenMPClauseKind(StringRef Str)48 OpenMPClauseKind clang::getOpenMPClauseKind(StringRef Str) {
49 // 'flush' clause cannot be specified explicitly, because this is an implicit
50 // clause for 'flush' directive. If the 'flush' clause is explicitly specified
51 // the Parser should generate a warning about extra tokens at the end of the
52 // directive.
53 if (Str == "flush")
54 return OMPC_unknown;
55 return llvm::StringSwitch<OpenMPClauseKind>(Str)
56 #define OPENMP_CLAUSE(Name, Class) .Case(#Name, OMPC_##Name)
57 #include "clang/Basic/OpenMPKinds.def"
58 .Case("uniform", OMPC_uniform)
59 .Default(OMPC_unknown);
60 }
61
getOpenMPClauseName(OpenMPClauseKind Kind)62 const char *clang::getOpenMPClauseName(OpenMPClauseKind Kind) {
63 assert(Kind <= OMPC_unknown);
64 switch (Kind) {
65 case OMPC_unknown:
66 return "unknown";
67 #define OPENMP_CLAUSE(Name, Class) \
68 case OMPC_##Name: \
69 return #Name;
70 #include "clang/Basic/OpenMPKinds.def"
71 case OMPC_uniform:
72 return "uniform";
73 case OMPC_threadprivate:
74 return "threadprivate or thread local";
75 }
76 llvm_unreachable("Invalid OpenMP clause kind");
77 }
78
getOpenMPSimpleClauseType(OpenMPClauseKind Kind,StringRef Str)79 unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind,
80 StringRef Str) {
81 switch (Kind) {
82 case OMPC_default:
83 return llvm::StringSwitch<OpenMPDefaultClauseKind>(Str)
84 #define OPENMP_DEFAULT_KIND(Name) .Case(#Name, OMPC_DEFAULT_##Name)
85 #include "clang/Basic/OpenMPKinds.def"
86 .Default(OMPC_DEFAULT_unknown);
87 case OMPC_proc_bind:
88 return llvm::StringSwitch<OpenMPProcBindClauseKind>(Str)
89 #define OPENMP_PROC_BIND_KIND(Name) .Case(#Name, OMPC_PROC_BIND_##Name)
90 #include "clang/Basic/OpenMPKinds.def"
91 .Default(OMPC_PROC_BIND_unknown);
92 case OMPC_schedule:
93 return llvm::StringSwitch<unsigned>(Str)
94 #define OPENMP_SCHEDULE_KIND(Name) \
95 .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_##Name))
96 #define OPENMP_SCHEDULE_MODIFIER(Name) \
97 .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_MODIFIER_##Name))
98 #include "clang/Basic/OpenMPKinds.def"
99 .Default(OMPC_SCHEDULE_unknown);
100 case OMPC_depend:
101 return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
102 #define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
103 #include "clang/Basic/OpenMPKinds.def"
104 .Default(OMPC_DEPEND_unknown);
105 case OMPC_linear:
106 return llvm::StringSwitch<OpenMPLinearClauseKind>(Str)
107 #define OPENMP_LINEAR_KIND(Name) .Case(#Name, OMPC_LINEAR_##Name)
108 #include "clang/Basic/OpenMPKinds.def"
109 .Default(OMPC_LINEAR_unknown);
110 case OMPC_map:
111 return llvm::StringSwitch<OpenMPMapClauseKind>(Str)
112 #define OPENMP_MAP_KIND(Name) .Case(#Name, OMPC_MAP_##Name)
113 #include "clang/Basic/OpenMPKinds.def"
114 .Default(OMPC_MAP_unknown);
115 case OMPC_dist_schedule:
116 return llvm::StringSwitch<OpenMPDistScheduleClauseKind>(Str)
117 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
118 #include "clang/Basic/OpenMPKinds.def"
119 .Default(OMPC_DIST_SCHEDULE_unknown);
120 case OMPC_defaultmap:
121 return llvm::StringSwitch<unsigned>(Str)
122 #define OPENMP_DEFAULTMAP_KIND(Name) \
123 .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_##Name))
124 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
125 .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_MODIFIER_##Name))
126 #include "clang/Basic/OpenMPKinds.def"
127 .Default(OMPC_DEFAULTMAP_unknown);
128 case OMPC_unknown:
129 case OMPC_threadprivate:
130 case OMPC_if:
131 case OMPC_final:
132 case OMPC_num_threads:
133 case OMPC_safelen:
134 case OMPC_simdlen:
135 case OMPC_collapse:
136 case OMPC_private:
137 case OMPC_firstprivate:
138 case OMPC_lastprivate:
139 case OMPC_shared:
140 case OMPC_reduction:
141 case OMPC_aligned:
142 case OMPC_copyin:
143 case OMPC_copyprivate:
144 case OMPC_ordered:
145 case OMPC_nowait:
146 case OMPC_untied:
147 case OMPC_mergeable:
148 case OMPC_flush:
149 case OMPC_read:
150 case OMPC_write:
151 case OMPC_update:
152 case OMPC_capture:
153 case OMPC_seq_cst:
154 case OMPC_device:
155 case OMPC_threads:
156 case OMPC_simd:
157 case OMPC_num_teams:
158 case OMPC_thread_limit:
159 case OMPC_priority:
160 case OMPC_grainsize:
161 case OMPC_nogroup:
162 case OMPC_num_tasks:
163 case OMPC_hint:
164 case OMPC_uniform:
165 case OMPC_to:
166 case OMPC_from:
167 case OMPC_use_device_ptr:
168 case OMPC_is_device_ptr:
169 break;
170 }
171 llvm_unreachable("Invalid OpenMP simple clause kind");
172 }
173
getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,unsigned Type)174 const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
175 unsigned Type) {
176 switch (Kind) {
177 case OMPC_default:
178 switch (Type) {
179 case OMPC_DEFAULT_unknown:
180 return "unknown";
181 #define OPENMP_DEFAULT_KIND(Name) \
182 case OMPC_DEFAULT_##Name: \
183 return #Name;
184 #include "clang/Basic/OpenMPKinds.def"
185 }
186 llvm_unreachable("Invalid OpenMP 'default' clause type");
187 case OMPC_proc_bind:
188 switch (Type) {
189 case OMPC_PROC_BIND_unknown:
190 return "unknown";
191 #define OPENMP_PROC_BIND_KIND(Name) \
192 case OMPC_PROC_BIND_##Name: \
193 return #Name;
194 #include "clang/Basic/OpenMPKinds.def"
195 }
196 llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
197 case OMPC_schedule:
198 switch (Type) {
199 case OMPC_SCHEDULE_unknown:
200 case OMPC_SCHEDULE_MODIFIER_last:
201 return "unknown";
202 #define OPENMP_SCHEDULE_KIND(Name) \
203 case OMPC_SCHEDULE_##Name: \
204 return #Name;
205 #define OPENMP_SCHEDULE_MODIFIER(Name) \
206 case OMPC_SCHEDULE_MODIFIER_##Name: \
207 return #Name;
208 #include "clang/Basic/OpenMPKinds.def"
209 }
210 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
211 case OMPC_depend:
212 switch (Type) {
213 case OMPC_DEPEND_unknown:
214 return "unknown";
215 #define OPENMP_DEPEND_KIND(Name) \
216 case OMPC_DEPEND_##Name: \
217 return #Name;
218 #include "clang/Basic/OpenMPKinds.def"
219 }
220 llvm_unreachable("Invalid OpenMP 'depend' clause type");
221 case OMPC_linear:
222 switch (Type) {
223 case OMPC_LINEAR_unknown:
224 return "unknown";
225 #define OPENMP_LINEAR_KIND(Name) \
226 case OMPC_LINEAR_##Name: \
227 return #Name;
228 #include "clang/Basic/OpenMPKinds.def"
229 }
230 llvm_unreachable("Invalid OpenMP 'linear' clause type");
231 case OMPC_map:
232 switch (Type) {
233 case OMPC_MAP_unknown:
234 return "unknown";
235 #define OPENMP_MAP_KIND(Name) \
236 case OMPC_MAP_##Name: \
237 return #Name;
238 #include "clang/Basic/OpenMPKinds.def"
239 default:
240 break;
241 }
242 llvm_unreachable("Invalid OpenMP 'map' clause type");
243 case OMPC_dist_schedule:
244 switch (Type) {
245 case OMPC_DIST_SCHEDULE_unknown:
246 return "unknown";
247 #define OPENMP_DIST_SCHEDULE_KIND(Name) \
248 case OMPC_DIST_SCHEDULE_##Name: \
249 return #Name;
250 #include "clang/Basic/OpenMPKinds.def"
251 }
252 llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
253 case OMPC_defaultmap:
254 switch (Type) {
255 case OMPC_DEFAULTMAP_unknown:
256 case OMPC_DEFAULTMAP_MODIFIER_last:
257 return "unknown";
258 #define OPENMP_DEFAULTMAP_KIND(Name) \
259 case OMPC_DEFAULTMAP_##Name: \
260 return #Name;
261 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
262 case OMPC_DEFAULTMAP_MODIFIER_##Name: \
263 return #Name;
264 #include "clang/Basic/OpenMPKinds.def"
265 }
266 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
267 case OMPC_unknown:
268 case OMPC_threadprivate:
269 case OMPC_if:
270 case OMPC_final:
271 case OMPC_num_threads:
272 case OMPC_safelen:
273 case OMPC_simdlen:
274 case OMPC_collapse:
275 case OMPC_private:
276 case OMPC_firstprivate:
277 case OMPC_lastprivate:
278 case OMPC_shared:
279 case OMPC_reduction:
280 case OMPC_aligned:
281 case OMPC_copyin:
282 case OMPC_copyprivate:
283 case OMPC_ordered:
284 case OMPC_nowait:
285 case OMPC_untied:
286 case OMPC_mergeable:
287 case OMPC_flush:
288 case OMPC_read:
289 case OMPC_write:
290 case OMPC_update:
291 case OMPC_capture:
292 case OMPC_seq_cst:
293 case OMPC_device:
294 case OMPC_threads:
295 case OMPC_simd:
296 case OMPC_num_teams:
297 case OMPC_thread_limit:
298 case OMPC_priority:
299 case OMPC_grainsize:
300 case OMPC_nogroup:
301 case OMPC_num_tasks:
302 case OMPC_hint:
303 case OMPC_uniform:
304 case OMPC_to:
305 case OMPC_from:
306 case OMPC_use_device_ptr:
307 case OMPC_is_device_ptr:
308 break;
309 }
310 llvm_unreachable("Invalid OpenMP simple clause kind");
311 }
312
isAllowedClauseForDirective(OpenMPDirectiveKind DKind,OpenMPClauseKind CKind)313 bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
314 OpenMPClauseKind CKind) {
315 assert(DKind <= OMPD_unknown);
316 assert(CKind <= OMPC_unknown);
317 switch (DKind) {
318 case OMPD_parallel:
319 switch (CKind) {
320 #define OPENMP_PARALLEL_CLAUSE(Name) \
321 case OMPC_##Name: \
322 return true;
323 #include "clang/Basic/OpenMPKinds.def"
324 default:
325 break;
326 }
327 break;
328 case OMPD_simd:
329 switch (CKind) {
330 #define OPENMP_SIMD_CLAUSE(Name) \
331 case OMPC_##Name: \
332 return true;
333 #include "clang/Basic/OpenMPKinds.def"
334 default:
335 break;
336 }
337 break;
338 case OMPD_for:
339 switch (CKind) {
340 #define OPENMP_FOR_CLAUSE(Name) \
341 case OMPC_##Name: \
342 return true;
343 #include "clang/Basic/OpenMPKinds.def"
344 default:
345 break;
346 }
347 break;
348 case OMPD_for_simd:
349 switch (CKind) {
350 #define OPENMP_FOR_SIMD_CLAUSE(Name) \
351 case OMPC_##Name: \
352 return true;
353 #include "clang/Basic/OpenMPKinds.def"
354 default:
355 break;
356 }
357 break;
358 case OMPD_sections:
359 switch (CKind) {
360 #define OPENMP_SECTIONS_CLAUSE(Name) \
361 case OMPC_##Name: \
362 return true;
363 #include "clang/Basic/OpenMPKinds.def"
364 default:
365 break;
366 }
367 break;
368 case OMPD_single:
369 switch (CKind) {
370 #define OPENMP_SINGLE_CLAUSE(Name) \
371 case OMPC_##Name: \
372 return true;
373 #include "clang/Basic/OpenMPKinds.def"
374 default:
375 break;
376 }
377 break;
378 case OMPD_parallel_for:
379 switch (CKind) {
380 #define OPENMP_PARALLEL_FOR_CLAUSE(Name) \
381 case OMPC_##Name: \
382 return true;
383 #include "clang/Basic/OpenMPKinds.def"
384 default:
385 break;
386 }
387 break;
388 case OMPD_parallel_for_simd:
389 switch (CKind) {
390 #define OPENMP_PARALLEL_FOR_SIMD_CLAUSE(Name) \
391 case OMPC_##Name: \
392 return true;
393 #include "clang/Basic/OpenMPKinds.def"
394 default:
395 break;
396 }
397 break;
398 case OMPD_parallel_sections:
399 switch (CKind) {
400 #define OPENMP_PARALLEL_SECTIONS_CLAUSE(Name) \
401 case OMPC_##Name: \
402 return true;
403 #include "clang/Basic/OpenMPKinds.def"
404 default:
405 break;
406 }
407 break;
408 case OMPD_task:
409 switch (CKind) {
410 #define OPENMP_TASK_CLAUSE(Name) \
411 case OMPC_##Name: \
412 return true;
413 #include "clang/Basic/OpenMPKinds.def"
414 default:
415 break;
416 }
417 break;
418 case OMPD_flush:
419 return CKind == OMPC_flush;
420 break;
421 case OMPD_atomic:
422 switch (CKind) {
423 #define OPENMP_ATOMIC_CLAUSE(Name) \
424 case OMPC_##Name: \
425 return true;
426 #include "clang/Basic/OpenMPKinds.def"
427 default:
428 break;
429 }
430 break;
431 case OMPD_target:
432 switch (CKind) {
433 #define OPENMP_TARGET_CLAUSE(Name) \
434 case OMPC_##Name: \
435 return true;
436 #include "clang/Basic/OpenMPKinds.def"
437 default:
438 break;
439 }
440 break;
441 case OMPD_target_data:
442 switch (CKind) {
443 #define OPENMP_TARGET_DATA_CLAUSE(Name) \
444 case OMPC_##Name: \
445 return true;
446 #include "clang/Basic/OpenMPKinds.def"
447 default:
448 break;
449 }
450 break;
451 case OMPD_target_enter_data:
452 switch (CKind) {
453 #define OPENMP_TARGET_ENTER_DATA_CLAUSE(Name) \
454 case OMPC_##Name: \
455 return true;
456 #include "clang/Basic/OpenMPKinds.def"
457 default:
458 break;
459 }
460 break;
461 case OMPD_target_exit_data:
462 switch (CKind) {
463 #define OPENMP_TARGET_EXIT_DATA_CLAUSE(Name) \
464 case OMPC_##Name: \
465 return true;
466 #include "clang/Basic/OpenMPKinds.def"
467 default:
468 break;
469 }
470 break;
471 case OMPD_target_parallel:
472 switch (CKind) {
473 #define OPENMP_TARGET_PARALLEL_CLAUSE(Name) \
474 case OMPC_##Name: \
475 return true;
476 #include "clang/Basic/OpenMPKinds.def"
477 default:
478 break;
479 }
480 break;
481 case OMPD_target_parallel_for:
482 switch (CKind) {
483 #define OPENMP_TARGET_PARALLEL_FOR_CLAUSE(Name) \
484 case OMPC_##Name: \
485 return true;
486 #include "clang/Basic/OpenMPKinds.def"
487 default:
488 break;
489 }
490 break;
491 case OMPD_target_update:
492 switch (CKind) {
493 #define OPENMP_TARGET_UPDATE_CLAUSE(Name) \
494 case OMPC_##Name: \
495 return true;
496 #include "clang/Basic/OpenMPKinds.def"
497 default:
498 break;
499 }
500 break;
501 case OMPD_teams:
502 switch (CKind) {
503 #define OPENMP_TEAMS_CLAUSE(Name) \
504 case OMPC_##Name: \
505 return true;
506 #include "clang/Basic/OpenMPKinds.def"
507 default:
508 break;
509 }
510 break;
511 case OMPD_declare_simd:
512 break;
513 case OMPD_cancel:
514 switch (CKind) {
515 #define OPENMP_CANCEL_CLAUSE(Name) \
516 case OMPC_##Name: \
517 return true;
518 #include "clang/Basic/OpenMPKinds.def"
519 default:
520 break;
521 }
522 break;
523 case OMPD_ordered:
524 switch (CKind) {
525 #define OPENMP_ORDERED_CLAUSE(Name) \
526 case OMPC_##Name: \
527 return true;
528 #include "clang/Basic/OpenMPKinds.def"
529 default:
530 break;
531 }
532 break;
533 case OMPD_taskloop:
534 switch (CKind) {
535 #define OPENMP_TASKLOOP_CLAUSE(Name) \
536 case OMPC_##Name: \
537 return true;
538 #include "clang/Basic/OpenMPKinds.def"
539 default:
540 break;
541 }
542 break;
543 case OMPD_taskloop_simd:
544 switch (CKind) {
545 #define OPENMP_TASKLOOP_SIMD_CLAUSE(Name) \
546 case OMPC_##Name: \
547 return true;
548 #include "clang/Basic/OpenMPKinds.def"
549 default:
550 break;
551 }
552 break;
553 case OMPD_critical:
554 switch (CKind) {
555 #define OPENMP_CRITICAL_CLAUSE(Name) \
556 case OMPC_##Name: \
557 return true;
558 #include "clang/Basic/OpenMPKinds.def"
559 default:
560 break;
561 }
562 break;
563 case OMPD_distribute:
564 switch (CKind) {
565 #define OPENMP_DISTRIBUTE_CLAUSE(Name) \
566 case OMPC_##Name: \
567 return true;
568 #include "clang/Basic/OpenMPKinds.def"
569 default:
570 break;
571 }
572 break;
573 case OMPD_distribute_parallel_for:
574 switch (CKind) {
575 #define OPENMP_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \
576 case OMPC_##Name: \
577 return true;
578 #include "clang/Basic/OpenMPKinds.def"
579 default:
580 break;
581 }
582 break;
583 case OMPD_distribute_parallel_for_simd:
584 switch (CKind) {
585 #define OPENMP_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \
586 case OMPC_##Name: \
587 return true;
588 #include "clang/Basic/OpenMPKinds.def"
589 default:
590 break;
591 }
592 break;
593 case OMPD_distribute_simd:
594 switch (CKind) {
595 #define OPENMP_DISTRIBUTE_SIMD_CLAUSE(Name) \
596 case OMPC_##Name: \
597 return true;
598 #include "clang/Basic/OpenMPKinds.def"
599 default:
600 break;
601 }
602 break;
603 case OMPD_target_parallel_for_simd:
604 switch (CKind) {
605 #define OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(Name) \
606 case OMPC_##Name: \
607 return true;
608 #include "clang/Basic/OpenMPKinds.def"
609 default:
610 break;
611 }
612 break;
613 case OMPD_declare_target:
614 case OMPD_end_declare_target:
615 case OMPD_unknown:
616 case OMPD_threadprivate:
617 case OMPD_section:
618 case OMPD_master:
619 case OMPD_taskyield:
620 case OMPD_barrier:
621 case OMPD_taskwait:
622 case OMPD_taskgroup:
623 case OMPD_cancellation_point:
624 case OMPD_declare_reduction:
625 break;
626 }
627 return false;
628 }
629
isOpenMPLoopDirective(OpenMPDirectiveKind DKind)630 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
631 return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
632 DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
633 DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
634 DKind == OMPD_distribute || DKind == OMPD_target_parallel_for ||
635 DKind == OMPD_distribute_parallel_for ||
636 DKind == OMPD_distribute_parallel_for_simd ||
637 DKind == OMPD_distribute_simd ||
638 DKind == OMPD_target_parallel_for_simd;
639 // TODO add next directives.
640 }
641
isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind)642 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
643 return DKind == OMPD_for || DKind == OMPD_for_simd ||
644 DKind == OMPD_sections || DKind == OMPD_section ||
645 DKind == OMPD_single || DKind == OMPD_parallel_for ||
646 DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
647 DKind == OMPD_target_parallel_for ||
648 DKind == OMPD_distribute_parallel_for ||
649 DKind == OMPD_distribute_parallel_for_simd ||
650 DKind == OMPD_target_parallel_for_simd;
651 // TODO add next directives.
652 }
653
isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind)654 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
655 return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd;
656 }
657
isOpenMPParallelDirective(OpenMPDirectiveKind DKind)658 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
659 return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
660 DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
661 DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
662 DKind == OMPD_distribute_parallel_for ||
663 DKind == OMPD_distribute_parallel_for_simd ||
664 DKind == OMPD_target_parallel_for_simd;
665 // TODO add next directives.
666 }
667
isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind)668 bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
669 // TODO add next directives.
670 return DKind == OMPD_target || DKind == OMPD_target_parallel ||
671 DKind == OMPD_target_parallel_for ||
672 DKind == OMPD_target_parallel_for_simd;
673 }
674
isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind)675 bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
676 return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
677 DKind == OMPD_target_exit_data || DKind == OMPD_target_update;
678 }
679
isOpenMPTeamsDirective(OpenMPDirectiveKind DKind)680 bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {
681 return DKind == OMPD_teams; // TODO add next directives.
682 }
683
isOpenMPSimdDirective(OpenMPDirectiveKind DKind)684 bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
685 return DKind == OMPD_simd || DKind == OMPD_for_simd ||
686 DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
687 DKind == OMPD_distribute_parallel_for_simd ||
688 DKind == OMPD_distribute_simd;
689 // TODO add next directives.
690 }
691
isOpenMPDistributeDirective(OpenMPDirectiveKind Kind)692 bool clang::isOpenMPDistributeDirective(OpenMPDirectiveKind Kind) {
693 return Kind == OMPD_distribute || Kind == OMPD_distribute_parallel_for ||
694 Kind == OMPD_distribute_parallel_for_simd ||
695 Kind == OMPD_distribute_simd;
696 // TODO add next directives.
697 }
698
isOpenMPPrivate(OpenMPClauseKind Kind)699 bool clang::isOpenMPPrivate(OpenMPClauseKind Kind) {
700 return Kind == OMPC_private || Kind == OMPC_firstprivate ||
701 Kind == OMPC_lastprivate || Kind == OMPC_linear ||
702 Kind == OMPC_reduction; // TODO add next clauses like 'reduction'.
703 }
704
isOpenMPThreadPrivate(OpenMPClauseKind Kind)705 bool clang::isOpenMPThreadPrivate(OpenMPClauseKind Kind) {
706 return Kind == OMPC_threadprivate || Kind == OMPC_copyin;
707 }
708
isOpenMPTaskingDirective(OpenMPDirectiveKind Kind)709 bool clang::isOpenMPTaskingDirective(OpenMPDirectiveKind Kind) {
710 return Kind == OMPD_task || isOpenMPTaskLoopDirective(Kind);
711 }
712
isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind)713 bool clang::isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind) {
714 return Kind == OMPD_distribute_parallel_for ||
715 Kind == OMPD_distribute_parallel_for_simd ||
716 Kind == OMPD_distribute_simd;
717 }
718