clang  8.0.0svn
OpenMPKinds.cpp
Go to the documentation of this file.
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 /// This file implements the OpenMP enum and support functions.
11 ///
12 //===----------------------------------------------------------------------===//
13 
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 
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 
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 
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 
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 
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_task_reduction:
142  case OMPC_in_reduction:
143  case OMPC_aligned:
144  case OMPC_copyin:
145  case OMPC_copyprivate:
146  case OMPC_ordered:
147  case OMPC_nowait:
148  case OMPC_untied:
149  case OMPC_mergeable:
150  case OMPC_flush:
151  case OMPC_read:
152  case OMPC_write:
153  case OMPC_update:
154  case OMPC_capture:
155  case OMPC_seq_cst:
156  case OMPC_device:
157  case OMPC_threads:
158  case OMPC_simd:
159  case OMPC_num_teams:
160  case OMPC_thread_limit:
161  case OMPC_priority:
162  case OMPC_grainsize:
163  case OMPC_nogroup:
164  case OMPC_num_tasks:
165  case OMPC_hint:
166  case OMPC_uniform:
167  case OMPC_to:
168  case OMPC_from:
169  case OMPC_use_device_ptr:
170  case OMPC_is_device_ptr:
171  case OMPC_unified_address:
172  case OMPC_unified_shared_memory:
173  case OMPC_reverse_offload:
174  case OMPC_dynamic_allocators:
175  break;
176  }
177  llvm_unreachable("Invalid OpenMP simple clause kind");
178 }
179 
181  unsigned Type) {
182  switch (Kind) {
183  case OMPC_default:
184  switch (Type) {
186  return "unknown";
187 #define OPENMP_DEFAULT_KIND(Name) \
188  case OMPC_DEFAULT_##Name: \
189  return #Name;
190 #include "clang/Basic/OpenMPKinds.def"
191  }
192  llvm_unreachable("Invalid OpenMP 'default' clause type");
193  case OMPC_proc_bind:
194  switch (Type) {
196  return "unknown";
197 #define OPENMP_PROC_BIND_KIND(Name) \
198  case OMPC_PROC_BIND_##Name: \
199  return #Name;
200 #include "clang/Basic/OpenMPKinds.def"
201  }
202  llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
203  case OMPC_schedule:
204  switch (Type) {
207  return "unknown";
208 #define OPENMP_SCHEDULE_KIND(Name) \
209  case OMPC_SCHEDULE_##Name: \
210  return #Name;
211 #define OPENMP_SCHEDULE_MODIFIER(Name) \
212  case OMPC_SCHEDULE_MODIFIER_##Name: \
213  return #Name;
214 #include "clang/Basic/OpenMPKinds.def"
215  }
216  llvm_unreachable("Invalid OpenMP 'schedule' clause type");
217  case OMPC_depend:
218  switch (Type) {
219  case OMPC_DEPEND_unknown:
220  return "unknown";
221 #define OPENMP_DEPEND_KIND(Name) \
222  case OMPC_DEPEND_##Name: \
223  return #Name;
224 #include "clang/Basic/OpenMPKinds.def"
225  }
226  llvm_unreachable("Invalid OpenMP 'depend' clause type");
227  case OMPC_linear:
228  switch (Type) {
229  case OMPC_LINEAR_unknown:
230  return "unknown";
231 #define OPENMP_LINEAR_KIND(Name) \
232  case OMPC_LINEAR_##Name: \
233  return #Name;
234 #include "clang/Basic/OpenMPKinds.def"
235  }
236  llvm_unreachable("Invalid OpenMP 'linear' clause type");
237  case OMPC_map:
238  switch (Type) {
239  case OMPC_MAP_unknown:
240  return "unknown";
241 #define OPENMP_MAP_KIND(Name) \
242  case OMPC_MAP_##Name: \
243  return #Name;
244 #include "clang/Basic/OpenMPKinds.def"
245  default:
246  break;
247  }
248  llvm_unreachable("Invalid OpenMP 'map' clause type");
249  case OMPC_dist_schedule:
250  switch (Type) {
252  return "unknown";
253 #define OPENMP_DIST_SCHEDULE_KIND(Name) \
254  case OMPC_DIST_SCHEDULE_##Name: \
255  return #Name;
256 #include "clang/Basic/OpenMPKinds.def"
257  }
258  llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
259  case OMPC_defaultmap:
260  switch (Type) {
263  return "unknown";
264 #define OPENMP_DEFAULTMAP_KIND(Name) \
265  case OMPC_DEFAULTMAP_##Name: \
266  return #Name;
267 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
268  case OMPC_DEFAULTMAP_MODIFIER_##Name: \
269  return #Name;
270 #include "clang/Basic/OpenMPKinds.def"
271  }
272  llvm_unreachable("Invalid OpenMP 'schedule' clause type");
273  case OMPC_unknown:
274  case OMPC_threadprivate:
275  case OMPC_if:
276  case OMPC_final:
277  case OMPC_num_threads:
278  case OMPC_safelen:
279  case OMPC_simdlen:
280  case OMPC_collapse:
281  case OMPC_private:
282  case OMPC_firstprivate:
283  case OMPC_lastprivate:
284  case OMPC_shared:
285  case OMPC_reduction:
286  case OMPC_task_reduction:
287  case OMPC_in_reduction:
288  case OMPC_aligned:
289  case OMPC_copyin:
290  case OMPC_copyprivate:
291  case OMPC_ordered:
292  case OMPC_nowait:
293  case OMPC_untied:
294  case OMPC_mergeable:
295  case OMPC_flush:
296  case OMPC_read:
297  case OMPC_write:
298  case OMPC_update:
299  case OMPC_capture:
300  case OMPC_seq_cst:
301  case OMPC_device:
302  case OMPC_threads:
303  case OMPC_simd:
304  case OMPC_num_teams:
305  case OMPC_thread_limit:
306  case OMPC_priority:
307  case OMPC_grainsize:
308  case OMPC_nogroup:
309  case OMPC_num_tasks:
310  case OMPC_hint:
311  case OMPC_uniform:
312  case OMPC_to:
313  case OMPC_from:
314  case OMPC_use_device_ptr:
315  case OMPC_is_device_ptr:
316  case OMPC_unified_address:
317  case OMPC_unified_shared_memory:
318  case OMPC_reverse_offload:
319  case OMPC_dynamic_allocators:
320  break;
321  }
322  llvm_unreachable("Invalid OpenMP simple clause kind");
323 }
324 
326  OpenMPClauseKind CKind) {
327  assert(DKind <= OMPD_unknown);
328  assert(CKind <= OMPC_unknown);
329  switch (DKind) {
330  case OMPD_parallel:
331  switch (CKind) {
332 #define OPENMP_PARALLEL_CLAUSE(Name) \
333  case OMPC_##Name: \
334  return true;
335 #include "clang/Basic/OpenMPKinds.def"
336  default:
337  break;
338  }
339  break;
340  case OMPD_simd:
341  switch (CKind) {
342 #define OPENMP_SIMD_CLAUSE(Name) \
343  case OMPC_##Name: \
344  return true;
345 #include "clang/Basic/OpenMPKinds.def"
346  default:
347  break;
348  }
349  break;
350  case OMPD_for:
351  switch (CKind) {
352 #define OPENMP_FOR_CLAUSE(Name) \
353  case OMPC_##Name: \
354  return true;
355 #include "clang/Basic/OpenMPKinds.def"
356  default:
357  break;
358  }
359  break;
360  case OMPD_for_simd:
361  switch (CKind) {
362 #define OPENMP_FOR_SIMD_CLAUSE(Name) \
363  case OMPC_##Name: \
364  return true;
365 #include "clang/Basic/OpenMPKinds.def"
366  default:
367  break;
368  }
369  break;
370  case OMPD_sections:
371  switch (CKind) {
372 #define OPENMP_SECTIONS_CLAUSE(Name) \
373  case OMPC_##Name: \
374  return true;
375 #include "clang/Basic/OpenMPKinds.def"
376  default:
377  break;
378  }
379  break;
380  case OMPD_single:
381  switch (CKind) {
382 #define OPENMP_SINGLE_CLAUSE(Name) \
383  case OMPC_##Name: \
384  return true;
385 #include "clang/Basic/OpenMPKinds.def"
386  default:
387  break;
388  }
389  break;
390  case OMPD_parallel_for:
391  switch (CKind) {
392 #define OPENMP_PARALLEL_FOR_CLAUSE(Name) \
393  case OMPC_##Name: \
394  return true;
395 #include "clang/Basic/OpenMPKinds.def"
396  default:
397  break;
398  }
399  break;
400  case OMPD_parallel_for_simd:
401  switch (CKind) {
402 #define OPENMP_PARALLEL_FOR_SIMD_CLAUSE(Name) \
403  case OMPC_##Name: \
404  return true;
405 #include "clang/Basic/OpenMPKinds.def"
406  default:
407  break;
408  }
409  break;
410  case OMPD_parallel_sections:
411  switch (CKind) {
412 #define OPENMP_PARALLEL_SECTIONS_CLAUSE(Name) \
413  case OMPC_##Name: \
414  return true;
415 #include "clang/Basic/OpenMPKinds.def"
416  default:
417  break;
418  }
419  break;
420  case OMPD_task:
421  switch (CKind) {
422 #define OPENMP_TASK_CLAUSE(Name) \
423  case OMPC_##Name: \
424  return true;
425 #include "clang/Basic/OpenMPKinds.def"
426  default:
427  break;
428  }
429  break;
430  case OMPD_flush:
431  return CKind == OMPC_flush;
432  break;
433  case OMPD_atomic:
434  switch (CKind) {
435 #define OPENMP_ATOMIC_CLAUSE(Name) \
436  case OMPC_##Name: \
437  return true;
438 #include "clang/Basic/OpenMPKinds.def"
439  default:
440  break;
441  }
442  break;
443  case OMPD_target:
444  switch (CKind) {
445 #define OPENMP_TARGET_CLAUSE(Name) \
446  case OMPC_##Name: \
447  return true;
448 #include "clang/Basic/OpenMPKinds.def"
449  default:
450  break;
451  }
452  break;
453  case OMPD_requires:
454  switch (CKind) {
455 #define OPENMP_REQUIRES_CLAUSE(Name) \
456  case OMPC_##Name: \
457  return true;
458 #include "clang/Basic/OpenMPKinds.def"
459  default:
460  break;
461  }
462  break;
463  case OMPD_target_data:
464  switch (CKind) {
465 #define OPENMP_TARGET_DATA_CLAUSE(Name) \
466  case OMPC_##Name: \
467  return true;
468 #include "clang/Basic/OpenMPKinds.def"
469  default:
470  break;
471  }
472  break;
473  case OMPD_target_enter_data:
474  switch (CKind) {
475 #define OPENMP_TARGET_ENTER_DATA_CLAUSE(Name) \
476  case OMPC_##Name: \
477  return true;
478 #include "clang/Basic/OpenMPKinds.def"
479  default:
480  break;
481  }
482  break;
483  case OMPD_target_exit_data:
484  switch (CKind) {
485 #define OPENMP_TARGET_EXIT_DATA_CLAUSE(Name) \
486  case OMPC_##Name: \
487  return true;
488 #include "clang/Basic/OpenMPKinds.def"
489  default:
490  break;
491  }
492  break;
493  case OMPD_target_parallel:
494  switch (CKind) {
495 #define OPENMP_TARGET_PARALLEL_CLAUSE(Name) \
496  case OMPC_##Name: \
497  return true;
498 #include "clang/Basic/OpenMPKinds.def"
499  default:
500  break;
501  }
502  break;
503  case OMPD_target_parallel_for:
504  switch (CKind) {
505 #define OPENMP_TARGET_PARALLEL_FOR_CLAUSE(Name) \
506  case OMPC_##Name: \
507  return true;
508 #include "clang/Basic/OpenMPKinds.def"
509  default:
510  break;
511  }
512  break;
513  case OMPD_target_update:
514  switch (CKind) {
515 #define OPENMP_TARGET_UPDATE_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_teams:
524  switch (CKind) {
525 #define OPENMP_TEAMS_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_declare_simd:
534  break;
535  case OMPD_cancel:
536  switch (CKind) {
537 #define OPENMP_CANCEL_CLAUSE(Name) \
538  case OMPC_##Name: \
539  return true;
540 #include "clang/Basic/OpenMPKinds.def"
541  default:
542  break;
543  }
544  break;
545  case OMPD_ordered:
546  switch (CKind) {
547 #define OPENMP_ORDERED_CLAUSE(Name) \
548  case OMPC_##Name: \
549  return true;
550 #include "clang/Basic/OpenMPKinds.def"
551  default:
552  break;
553  }
554  break;
555  case OMPD_taskloop:
556  switch (CKind) {
557 #define OPENMP_TASKLOOP_CLAUSE(Name) \
558  case OMPC_##Name: \
559  return true;
560 #include "clang/Basic/OpenMPKinds.def"
561  default:
562  break;
563  }
564  break;
565  case OMPD_taskloop_simd:
566  switch (CKind) {
567 #define OPENMP_TASKLOOP_SIMD_CLAUSE(Name) \
568  case OMPC_##Name: \
569  return true;
570 #include "clang/Basic/OpenMPKinds.def"
571  default:
572  break;
573  }
574  break;
575  case OMPD_critical:
576  switch (CKind) {
577 #define OPENMP_CRITICAL_CLAUSE(Name) \
578  case OMPC_##Name: \
579  return true;
580 #include "clang/Basic/OpenMPKinds.def"
581  default:
582  break;
583  }
584  break;
585  case OMPD_distribute:
586  switch (CKind) {
587 #define OPENMP_DISTRIBUTE_CLAUSE(Name) \
588  case OMPC_##Name: \
589  return true;
590 #include "clang/Basic/OpenMPKinds.def"
591  default:
592  break;
593  }
594  break;
595  case OMPD_distribute_parallel_for:
596  switch (CKind) {
597 #define OPENMP_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \
598  case OMPC_##Name: \
599  return true;
600 #include "clang/Basic/OpenMPKinds.def"
601  default:
602  break;
603  }
604  break;
605  case OMPD_distribute_parallel_for_simd:
606  switch (CKind) {
607 #define OPENMP_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \
608  case OMPC_##Name: \
609  return true;
610 #include "clang/Basic/OpenMPKinds.def"
611  default:
612  break;
613  }
614  break;
615  case OMPD_distribute_simd:
616  switch (CKind) {
617 #define OPENMP_DISTRIBUTE_SIMD_CLAUSE(Name) \
618  case OMPC_##Name: \
619  return true;
620 #include "clang/Basic/OpenMPKinds.def"
621  default:
622  break;
623  }
624  break;
625  case OMPD_target_parallel_for_simd:
626  switch (CKind) {
627 #define OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(Name) \
628  case OMPC_##Name: \
629  return true;
630 #include "clang/Basic/OpenMPKinds.def"
631  default:
632  break;
633  }
634  break;
635  case OMPD_target_simd:
636  switch (CKind) {
637 #define OPENMP_TARGET_SIMD_CLAUSE(Name) \
638  case OMPC_##Name: \
639  return true;
640 #include "clang/Basic/OpenMPKinds.def"
641  default:
642  break;
643  }
644  break;
645  case OMPD_teams_distribute:
646  switch (CKind) {
647 #define OPENMP_TEAMS_DISTRIBUTE_CLAUSE(Name) \
648  case OMPC_##Name: \
649  return true;
650 #include "clang/Basic/OpenMPKinds.def"
651  default:
652  break;
653  }
654  break;
655  case OMPD_teams_distribute_simd:
656  switch (CKind) {
657 #define OPENMP_TEAMS_DISTRIBUTE_SIMD_CLAUSE(Name) \
658  case OMPC_##Name: \
659  return true;
660 #include "clang/Basic/OpenMPKinds.def"
661  default:
662  break;
663  }
664  break;
665  case OMPD_teams_distribute_parallel_for_simd:
666  switch (CKind) {
667 #define OPENMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \
668  case OMPC_##Name: \
669  return true;
670 #include "clang/Basic/OpenMPKinds.def"
671  default:
672  break;
673  }
674  break;
675  case OMPD_teams_distribute_parallel_for:
676  switch (CKind) {
677 #define OPENMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \
678  case OMPC_##Name: \
679  return true;
680 #include "clang/Basic/OpenMPKinds.def"
681  default:
682  break;
683  }
684  break;
685  case OMPD_target_teams:
686  switch (CKind) {
687 #define OPENMP_TARGET_TEAMS_CLAUSE(Name) \
688  case OMPC_##Name: \
689  return true;
690 #include "clang/Basic/OpenMPKinds.def"
691  default:
692  break;
693  }
694  break;
695  case OMPD_target_teams_distribute:
696  switch (CKind) {
697 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(Name) \
698  case OMPC_##Name: \
699  return true;
700 #include "clang/Basic/OpenMPKinds.def"
701  default:
702  break;
703  }
704  break;
705  case OMPD_target_teams_distribute_parallel_for:
706  switch (CKind) {
707 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \
708  case OMPC_##Name: \
709  return true;
710 #include "clang/Basic/OpenMPKinds.def"
711  default:
712  break;
713  }
714  break;
715  case OMPD_target_teams_distribute_parallel_for_simd:
716  switch (CKind) {
717 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \
718  case OMPC_##Name: \
719  return true;
720 #include "clang/Basic/OpenMPKinds.def"
721  default:
722  break;
723  }
724  break;
725  case OMPD_target_teams_distribute_simd:
726  switch (CKind) {
727 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(Name) \
728  case OMPC_##Name: \
729  return true;
730 #include "clang/Basic/OpenMPKinds.def"
731  default:
732  break;
733  }
734  break;
735  case OMPD_taskgroup:
736  switch (CKind) {
737 #define OPENMP_TASKGROUP_CLAUSE(Name) \
738  case OMPC_##Name: \
739  return true;
740 #include "clang/Basic/OpenMPKinds.def"
741  default:
742  break;
743  }
744  break;
745  case OMPD_declare_target:
746  case OMPD_end_declare_target:
747  case OMPD_unknown:
748  case OMPD_threadprivate:
749  case OMPD_section:
750  case OMPD_master:
751  case OMPD_taskyield:
752  case OMPD_barrier:
753  case OMPD_taskwait:
754  case OMPD_cancellation_point:
755  case OMPD_declare_reduction:
756  break;
757  }
758  return false;
759 }
760 
762  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
763  DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
764  DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
765  DKind == OMPD_distribute || DKind == OMPD_target_parallel_for ||
766  DKind == OMPD_distribute_parallel_for ||
767  DKind == OMPD_distribute_parallel_for_simd ||
768  DKind == OMPD_distribute_simd ||
769  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
770  DKind == OMPD_teams_distribute ||
771  DKind == OMPD_teams_distribute_simd ||
772  DKind == OMPD_teams_distribute_parallel_for_simd ||
773  DKind == OMPD_teams_distribute_parallel_for ||
774  DKind == OMPD_target_teams_distribute ||
775  DKind == OMPD_target_teams_distribute_parallel_for ||
776  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
777  DKind == OMPD_target_teams_distribute_simd;
778 }
779 
781  return DKind == OMPD_for || DKind == OMPD_for_simd ||
782  DKind == OMPD_sections || DKind == OMPD_section ||
783  DKind == OMPD_single || DKind == OMPD_parallel_for ||
784  DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
785  DKind == OMPD_target_parallel_for ||
786  DKind == OMPD_distribute_parallel_for ||
787  DKind == OMPD_distribute_parallel_for_simd ||
788  DKind == OMPD_target_parallel_for_simd ||
789  DKind == OMPD_teams_distribute_parallel_for_simd ||
790  DKind == OMPD_teams_distribute_parallel_for ||
791  DKind == OMPD_target_teams_distribute_parallel_for ||
792  DKind == OMPD_target_teams_distribute_parallel_for_simd;
793 }
794 
796  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd;
797 }
798 
800  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
801  DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
802  DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
803  DKind == OMPD_distribute_parallel_for ||
804  DKind == OMPD_distribute_parallel_for_simd ||
805  DKind == OMPD_target_parallel_for_simd ||
806  DKind == OMPD_teams_distribute_parallel_for ||
807  DKind == OMPD_teams_distribute_parallel_for_simd ||
808  DKind == OMPD_target_teams_distribute_parallel_for ||
809  DKind == OMPD_target_teams_distribute_parallel_for_simd;
810 }
811 
813  return DKind == OMPD_target || DKind == OMPD_target_parallel ||
814  DKind == OMPD_target_parallel_for ||
815  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
816  DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
817  DKind == OMPD_target_teams_distribute_parallel_for ||
818  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
819  DKind == OMPD_target_teams_distribute_simd;
820 }
821 
823  return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
824  DKind == OMPD_target_exit_data || DKind == OMPD_target_update;
825 }
826 
828  return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
829  DKind == OMPD_teams_distribute_simd ||
830  DKind == OMPD_teams_distribute_parallel_for_simd ||
831  DKind == OMPD_teams_distribute_parallel_for;
832 }
833 
835  return isOpenMPNestingTeamsDirective(DKind) ||
836  DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
837  DKind == OMPD_target_teams_distribute_parallel_for ||
838  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
839  DKind == OMPD_target_teams_distribute_simd;
840 }
841 
843  return DKind == OMPD_simd || DKind == OMPD_for_simd ||
844  DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
845  DKind == OMPD_distribute_parallel_for_simd ||
846  DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
847  DKind == OMPD_teams_distribute_simd ||
848  DKind == OMPD_teams_distribute_parallel_for_simd ||
849  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
850  DKind == OMPD_target_teams_distribute_simd ||
851  DKind == OMPD_target_parallel_for_simd;
852 }
853 
855  return Kind == OMPD_distribute || Kind == OMPD_distribute_parallel_for ||
856  Kind == OMPD_distribute_parallel_for_simd ||
857  Kind == OMPD_distribute_simd;
858  // TODO add next directives.
859 }
860 
862  return isOpenMPNestingDistributeDirective(Kind) ||
863  Kind == OMPD_teams_distribute || Kind == OMPD_teams_distribute_simd ||
864  Kind == OMPD_teams_distribute_parallel_for_simd ||
865  Kind == OMPD_teams_distribute_parallel_for ||
866  Kind == OMPD_target_teams_distribute ||
867  Kind == OMPD_target_teams_distribute_parallel_for ||
868  Kind == OMPD_target_teams_distribute_parallel_for_simd ||
869  Kind == OMPD_target_teams_distribute_simd;
870 }
871 
873  return Kind == OMPC_private || Kind == OMPC_firstprivate ||
874  Kind == OMPC_lastprivate || Kind == OMPC_linear ||
875  Kind == OMPC_reduction || Kind == OMPC_task_reduction ||
876  Kind == OMPC_in_reduction; // TODO add next clauses like 'reduction'.
877 }
878 
880  return Kind == OMPC_threadprivate || Kind == OMPC_copyin;
881 }
882 
884  return Kind == OMPD_task || isOpenMPTaskLoopDirective(Kind);
885 }
886 
888  return Kind == OMPD_distribute_parallel_for ||
889  Kind == OMPD_distribute_parallel_for_simd ||
890  Kind == OMPD_teams_distribute_parallel_for_simd ||
891  Kind == OMPD_teams_distribute_parallel_for ||
892  Kind == OMPD_target_teams_distribute_parallel_for ||
893  Kind == OMPD_target_teams_distribute_parallel_for_simd;
894 }
895 
897  SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
898  OpenMPDirectiveKind DKind) {
899  assert(DKind <= OMPD_unknown);
900  switch (DKind) {
901  case OMPD_parallel:
902  case OMPD_parallel_for:
903  case OMPD_parallel_for_simd:
904  case OMPD_parallel_sections:
905  case OMPD_distribute_parallel_for:
906  case OMPD_distribute_parallel_for_simd:
907  CaptureRegions.push_back(OMPD_parallel);
908  break;
909  case OMPD_target_teams:
910  case OMPD_target_teams_distribute:
911  case OMPD_target_teams_distribute_simd:
912  CaptureRegions.push_back(OMPD_task);
913  CaptureRegions.push_back(OMPD_target);
914  CaptureRegions.push_back(OMPD_teams);
915  break;
916  case OMPD_teams:
917  case OMPD_teams_distribute:
918  case OMPD_teams_distribute_simd:
919  CaptureRegions.push_back(OMPD_teams);
920  break;
921  case OMPD_target:
922  case OMPD_target_simd:
923  CaptureRegions.push_back(OMPD_task);
924  CaptureRegions.push_back(OMPD_target);
925  break;
926  case OMPD_teams_distribute_parallel_for:
927  case OMPD_teams_distribute_parallel_for_simd:
928  CaptureRegions.push_back(OMPD_teams);
929  CaptureRegions.push_back(OMPD_parallel);
930  break;
931  case OMPD_target_parallel:
932  case OMPD_target_parallel_for:
933  case OMPD_target_parallel_for_simd:
934  CaptureRegions.push_back(OMPD_task);
935  CaptureRegions.push_back(OMPD_target);
936  CaptureRegions.push_back(OMPD_parallel);
937  break;
938  case OMPD_task:
939  case OMPD_target_enter_data:
940  case OMPD_target_exit_data:
941  case OMPD_target_update:
942  CaptureRegions.push_back(OMPD_task);
943  break;
944  case OMPD_taskloop:
945  case OMPD_taskloop_simd:
946  CaptureRegions.push_back(OMPD_taskloop);
947  break;
948  case OMPD_target_teams_distribute_parallel_for:
949  case OMPD_target_teams_distribute_parallel_for_simd:
950  CaptureRegions.push_back(OMPD_task);
951  CaptureRegions.push_back(OMPD_target);
952  CaptureRegions.push_back(OMPD_teams);
953  CaptureRegions.push_back(OMPD_parallel);
954  break;
955  case OMPD_simd:
956  case OMPD_for:
957  case OMPD_for_simd:
958  case OMPD_sections:
959  case OMPD_section:
960  case OMPD_single:
961  case OMPD_master:
962  case OMPD_critical:
963  case OMPD_taskgroup:
964  case OMPD_distribute:
965  case OMPD_ordered:
966  case OMPD_atomic:
967  case OMPD_target_data:
968  case OMPD_distribute_simd:
969  CaptureRegions.push_back(OMPD_unknown);
970  break;
971  case OMPD_threadprivate:
972  case OMPD_taskyield:
973  case OMPD_barrier:
974  case OMPD_taskwait:
975  case OMPD_cancellation_point:
976  case OMPD_cancel:
977  case OMPD_flush:
978  case OMPD_declare_reduction:
979  case OMPD_declare_simd:
980  case OMPD_declare_target:
981  case OMPD_end_declare_target:
982  case OMPD_requires:
983  llvm_unreachable("OpenMP Directive is not allowed");
984  case OMPD_unknown:
985  llvm_unreachable("Unknown OpenMP directive");
986  }
987 }
#define OPENMP_MAP_KIND(Name)
bool isOpenMPNestingDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified composite/combined directive constitutes a distribute directive in the outerm...
bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a target data offload directive.
The base class of the type hierarchy.
Definition: Type.h:1415
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
bool isAllowedClauseForDirective(OpenMPDirectiveKind DKind, OpenMPClauseKind CKind)
#define OPENMP_LINEAR_KIND(Name)
const char * getOpenMPClauseName(OpenMPClauseKind Kind)
Definition: OpenMPKinds.cpp:62
bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind)
Checks if the specified directive kind is one of tasking directives - task, taskloop or taksloop simd...
Defines some OpenMP-specific enums and functions.
bool isOpenMPTeamsDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a teams-kind directive.
OpenMPClauseKind getOpenMPClauseKind(llvm::StringRef Str)
bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a target code offload directive.
#define OPENMP_DEFAULTMAP_KIND(Name)
bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a worksharing directive.
#define OPENMP_CLAUSE(Name, Class)
#define OPENMP_PROC_BIND_KIND(Name)
bool isOpenMPPrivate(OpenMPClauseKind Kind)
Checks if the specified clause is one of private clauses like &#39;private&#39;, &#39;firstprivate&#39;, &#39;reduction&#39; etc.
bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a parallel-kind directive.
#define OPENMP_DEPEND_KIND(Name)
OpenMPClauseKind
OpenMP clauses.
Definition: OpenMPKinds.h:33
#define OPENMP_DIRECTIVE(Name)
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a taskloop directive.
Kind
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind)
Checks if the specified directive kind is one of the composite or combined directives that need loop ...
Dataflow Directional Tag Classes.
bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a simd directive.
#define OPENMP_DEFAULT_KIND(Name)
bool isOpenMPThreadPrivate(OpenMPClauseKind Kind)
Checks if the specified clause is one of threadprivate clauses like &#39;threadprivate&#39;, &#39;copyin&#39; or &#39;copyprivate&#39;.
void getOpenMPCaptureRegions(llvm::SmallVectorImpl< OpenMPDirectiveKind > &CaptureRegions, OpenMPDirectiveKind DKind)
Return the captured regions of an OpenMP directive.
unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str)
bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a distribute directive.
OpenMPDirectiveKind getOpenMPDirectiveKind(llvm::StringRef Str)
const char * getOpenMPDirectiveName(OpenMPDirectiveKind Kind)
Definition: OpenMPKinds.cpp:31
#define OPENMP_SCHEDULE_KIND(Name)
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
#define OPENMP_DIST_SCHEDULE_KIND(Name)
bool isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind)
Checks if the specified composite/combined directive constitutes a teams directive in the outermost n...