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