clang  9.0.0svn
OpenMPKinds.cpp
Go to the documentation of this file.
1 //===--- OpenMPKinds.cpp - Token Kinds Support ----------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 /// \file
9 /// This file implements the OpenMP enum and support functions.
10 ///
11 //===----------------------------------------------------------------------===//
12 
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/ADT/StringSwitch.h"
17 #include "llvm/Support/ErrorHandling.h"
18 #include <cassert>
19 
20 using namespace clang;
21 
23  return llvm::StringSwitch<OpenMPDirectiveKind>(Str)
24 #define OPENMP_DIRECTIVE(Name) .Case(#Name, OMPD_##Name)
25 #define OPENMP_DIRECTIVE_EXT(Name, Str) .Case(Str, OMPD_##Name)
26 #include "clang/Basic/OpenMPKinds.def"
27  .Default(OMPD_unknown);
28 }
29 
31  assert(Kind <= OMPD_unknown);
32  switch (Kind) {
33  case OMPD_unknown:
34  return "unknown";
35 #define OPENMP_DIRECTIVE(Name) \
36  case OMPD_##Name: \
37  return #Name;
38 #define OPENMP_DIRECTIVE_EXT(Name, Str) \
39  case OMPD_##Name: \
40  return Str;
41 #include "clang/Basic/OpenMPKinds.def"
42  break;
43  }
44  llvm_unreachable("Invalid OpenMP directive kind");
45 }
46 
48  // 'flush' clause cannot be specified explicitly, because this is an implicit
49  // clause for 'flush' directive. If the 'flush' clause is explicitly specified
50  // the Parser should generate a warning about extra tokens at the end of the
51  // directive.
52  if (Str == "flush")
53  return OMPC_unknown;
54  return llvm::StringSwitch<OpenMPClauseKind>(Str)
55 #define OPENMP_CLAUSE(Name, Class) .Case(#Name, OMPC_##Name)
56 #include "clang/Basic/OpenMPKinds.def"
57  .Case("uniform", OMPC_uniform)
58  .Default(OMPC_unknown);
59 }
60 
62  assert(Kind <= OMPC_unknown);
63  switch (Kind) {
64  case OMPC_unknown:
65  return "unknown";
66 #define OPENMP_CLAUSE(Name, Class) \
67  case OMPC_##Name: \
68  return #Name;
69 #include "clang/Basic/OpenMPKinds.def"
70  case OMPC_uniform:
71  return "uniform";
72  case OMPC_threadprivate:
73  return "threadprivate or thread local";
74  }
75  llvm_unreachable("Invalid OpenMP clause kind");
76 }
77 
79  StringRef Str) {
80  switch (Kind) {
81  case OMPC_default:
82  return llvm::StringSwitch<OpenMPDefaultClauseKind>(Str)
83 #define OPENMP_DEFAULT_KIND(Name) .Case(#Name, OMPC_DEFAULT_##Name)
84 #include "clang/Basic/OpenMPKinds.def"
85  .Default(OMPC_DEFAULT_unknown);
86  case OMPC_proc_bind:
87  return llvm::StringSwitch<OpenMPProcBindClauseKind>(Str)
88 #define OPENMP_PROC_BIND_KIND(Name) .Case(#Name, OMPC_PROC_BIND_##Name)
89 #include "clang/Basic/OpenMPKinds.def"
90  .Default(OMPC_PROC_BIND_unknown);
91  case OMPC_schedule:
92  return llvm::StringSwitch<unsigned>(Str)
93 #define OPENMP_SCHEDULE_KIND(Name) \
94  .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_##Name))
95 #define OPENMP_SCHEDULE_MODIFIER(Name) \
96  .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_MODIFIER_##Name))
97 #include "clang/Basic/OpenMPKinds.def"
98  .Default(OMPC_SCHEDULE_unknown);
99  case OMPC_depend:
100  return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
101 #define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
102 #include "clang/Basic/OpenMPKinds.def"
103  .Default(OMPC_DEPEND_unknown);
104  case OMPC_linear:
105  return llvm::StringSwitch<OpenMPLinearClauseKind>(Str)
106 #define OPENMP_LINEAR_KIND(Name) .Case(#Name, OMPC_LINEAR_##Name)
107 #include "clang/Basic/OpenMPKinds.def"
108  .Default(OMPC_LINEAR_unknown);
109  case OMPC_map:
110  return llvm::StringSwitch<unsigned>(Str)
111 #define OPENMP_MAP_KIND(Name) \
112  .Case(#Name, static_cast<unsigned>(OMPC_MAP_##Name))
113 #define OPENMP_MAP_MODIFIER_KIND(Name) \
114  .Case(#Name, static_cast<unsigned>(OMPC_MAP_MODIFIER_##Name))
115 #include "clang/Basic/OpenMPKinds.def"
116  .Default(OMPC_MAP_unknown);
117  case OMPC_dist_schedule:
118  return llvm::StringSwitch<OpenMPDistScheduleClauseKind>(Str)
119 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
120 #include "clang/Basic/OpenMPKinds.def"
121  .Default(OMPC_DIST_SCHEDULE_unknown);
122  case OMPC_defaultmap:
123  return llvm::StringSwitch<unsigned>(Str)
124 #define OPENMP_DEFAULTMAP_KIND(Name) \
125  .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_##Name))
126 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
127  .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_MODIFIER_##Name))
128 #include "clang/Basic/OpenMPKinds.def"
129  .Default(OMPC_DEFAULTMAP_unknown);
130  case OMPC_atomic_default_mem_order:
131  return llvm::StringSwitch<OpenMPAtomicDefaultMemOrderClauseKind>(Str)
133  .Case(#Name, OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name)
134 #include "clang/Basic/OpenMPKinds.def"
136  case OMPC_unknown:
137  case OMPC_threadprivate:
138  case OMPC_if:
139  case OMPC_final:
140  case OMPC_num_threads:
141  case OMPC_safelen:
142  case OMPC_simdlen:
143  case OMPC_collapse:
144  case OMPC_private:
145  case OMPC_firstprivate:
146  case OMPC_lastprivate:
147  case OMPC_shared:
148  case OMPC_reduction:
149  case OMPC_task_reduction:
150  case OMPC_in_reduction:
151  case OMPC_aligned:
152  case OMPC_copyin:
153  case OMPC_copyprivate:
154  case OMPC_ordered:
155  case OMPC_nowait:
156  case OMPC_untied:
157  case OMPC_mergeable:
158  case OMPC_flush:
159  case OMPC_read:
160  case OMPC_write:
161  case OMPC_update:
162  case OMPC_capture:
163  case OMPC_seq_cst:
164  case OMPC_device:
165  case OMPC_threads:
166  case OMPC_simd:
167  case OMPC_num_teams:
168  case OMPC_thread_limit:
169  case OMPC_priority:
170  case OMPC_grainsize:
171  case OMPC_nogroup:
172  case OMPC_num_tasks:
173  case OMPC_hint:
174  case OMPC_uniform:
175  case OMPC_to:
176  case OMPC_from:
177  case OMPC_use_device_ptr:
178  case OMPC_is_device_ptr:
179  case OMPC_unified_address:
180  case OMPC_unified_shared_memory:
181  case OMPC_reverse_offload:
182  case OMPC_dynamic_allocators:
183  break;
184  }
185  llvm_unreachable("Invalid OpenMP simple clause kind");
186 }
187 
189  unsigned Type) {
190  switch (Kind) {
191  case OMPC_default:
192  switch (Type) {
194  return "unknown";
195 #define OPENMP_DEFAULT_KIND(Name) \
196  case OMPC_DEFAULT_##Name: \
197  return #Name;
198 #include "clang/Basic/OpenMPKinds.def"
199  }
200  llvm_unreachable("Invalid OpenMP 'default' clause type");
201  case OMPC_proc_bind:
202  switch (Type) {
204  return "unknown";
205 #define OPENMP_PROC_BIND_KIND(Name) \
206  case OMPC_PROC_BIND_##Name: \
207  return #Name;
208 #include "clang/Basic/OpenMPKinds.def"
209  }
210  llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
211  case OMPC_schedule:
212  switch (Type) {
215  return "unknown";
216 #define OPENMP_SCHEDULE_KIND(Name) \
217  case OMPC_SCHEDULE_##Name: \
218  return #Name;
219 #define OPENMP_SCHEDULE_MODIFIER(Name) \
220  case OMPC_SCHEDULE_MODIFIER_##Name: \
221  return #Name;
222 #include "clang/Basic/OpenMPKinds.def"
223  }
224  llvm_unreachable("Invalid OpenMP 'schedule' clause type");
225  case OMPC_depend:
226  switch (Type) {
227  case OMPC_DEPEND_unknown:
228  return "unknown";
229 #define OPENMP_DEPEND_KIND(Name) \
230  case OMPC_DEPEND_##Name: \
231  return #Name;
232 #include "clang/Basic/OpenMPKinds.def"
233  }
234  llvm_unreachable("Invalid OpenMP 'depend' clause type");
235  case OMPC_linear:
236  switch (Type) {
237  case OMPC_LINEAR_unknown:
238  return "unknown";
239 #define OPENMP_LINEAR_KIND(Name) \
240  case OMPC_LINEAR_##Name: \
241  return #Name;
242 #include "clang/Basic/OpenMPKinds.def"
243  }
244  llvm_unreachable("Invalid OpenMP 'linear' clause type");
245  case OMPC_map:
246  switch (Type) {
247  case OMPC_MAP_unknown:
249  return "unknown";
250 #define OPENMP_MAP_KIND(Name) \
251  case OMPC_MAP_##Name: \
252  return #Name;
253 #define OPENMP_MAP_MODIFIER_KIND(Name) \
254  case OMPC_MAP_MODIFIER_##Name: \
255  return #Name;
256 #include "clang/Basic/OpenMPKinds.def"
257  default:
258  break;
259  }
260  llvm_unreachable("Invalid OpenMP 'map' clause type");
261  case OMPC_dist_schedule:
262  switch (Type) {
264  return "unknown";
265 #define OPENMP_DIST_SCHEDULE_KIND(Name) \
266  case OMPC_DIST_SCHEDULE_##Name: \
267  return #Name;
268 #include "clang/Basic/OpenMPKinds.def"
269  }
270  llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
271  case OMPC_defaultmap:
272  switch (Type) {
275  return "unknown";
276 #define OPENMP_DEFAULTMAP_KIND(Name) \
277  case OMPC_DEFAULTMAP_##Name: \
278  return #Name;
279 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
280  case OMPC_DEFAULTMAP_MODIFIER_##Name: \
281  return #Name;
282 #include "clang/Basic/OpenMPKinds.def"
283  }
284  llvm_unreachable("Invalid OpenMP 'schedule' clause type");
285  case OMPC_atomic_default_mem_order:
286  switch (Type) {
288  return "unknown";
289 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
290  case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name: \
291  return #Name;
292 #include "clang/Basic/OpenMPKinds.def"
293 }
294  llvm_unreachable("Invalid OpenMP 'atomic_default_mem_order' clause type");
295  case OMPC_unknown:
296  case OMPC_threadprivate:
297  case OMPC_if:
298  case OMPC_final:
299  case OMPC_num_threads:
300  case OMPC_safelen:
301  case OMPC_simdlen:
302  case OMPC_collapse:
303  case OMPC_private:
304  case OMPC_firstprivate:
305  case OMPC_lastprivate:
306  case OMPC_shared:
307  case OMPC_reduction:
308  case OMPC_task_reduction:
309  case OMPC_in_reduction:
310  case OMPC_aligned:
311  case OMPC_copyin:
312  case OMPC_copyprivate:
313  case OMPC_ordered:
314  case OMPC_nowait:
315  case OMPC_untied:
316  case OMPC_mergeable:
317  case OMPC_flush:
318  case OMPC_read:
319  case OMPC_write:
320  case OMPC_update:
321  case OMPC_capture:
322  case OMPC_seq_cst:
323  case OMPC_device:
324  case OMPC_threads:
325  case OMPC_simd:
326  case OMPC_num_teams:
327  case OMPC_thread_limit:
328  case OMPC_priority:
329  case OMPC_grainsize:
330  case OMPC_nogroup:
331  case OMPC_num_tasks:
332  case OMPC_hint:
333  case OMPC_uniform:
334  case OMPC_to:
335  case OMPC_from:
336  case OMPC_use_device_ptr:
337  case OMPC_is_device_ptr:
338  case OMPC_unified_address:
339  case OMPC_unified_shared_memory:
340  case OMPC_reverse_offload:
341  case OMPC_dynamic_allocators:
342  break;
343  }
344  llvm_unreachable("Invalid OpenMP simple clause kind");
345 }
346 
348  OpenMPClauseKind CKind) {
349  assert(DKind <= OMPD_unknown);
350  assert(CKind <= OMPC_unknown);
351  switch (DKind) {
352  case OMPD_parallel:
353  switch (CKind) {
354 #define OPENMP_PARALLEL_CLAUSE(Name) \
355  case OMPC_##Name: \
356  return true;
357 #include "clang/Basic/OpenMPKinds.def"
358  default:
359  break;
360  }
361  break;
362  case OMPD_simd:
363  switch (CKind) {
364 #define OPENMP_SIMD_CLAUSE(Name) \
365  case OMPC_##Name: \
366  return true;
367 #include "clang/Basic/OpenMPKinds.def"
368  default:
369  break;
370  }
371  break;
372  case OMPD_for:
373  switch (CKind) {
374 #define OPENMP_FOR_CLAUSE(Name) \
375  case OMPC_##Name: \
376  return true;
377 #include "clang/Basic/OpenMPKinds.def"
378  default:
379  break;
380  }
381  break;
382  case OMPD_for_simd:
383  switch (CKind) {
384 #define OPENMP_FOR_SIMD_CLAUSE(Name) \
385  case OMPC_##Name: \
386  return true;
387 #include "clang/Basic/OpenMPKinds.def"
388  default:
389  break;
390  }
391  break;
392  case OMPD_sections:
393  switch (CKind) {
394 #define OPENMP_SECTIONS_CLAUSE(Name) \
395  case OMPC_##Name: \
396  return true;
397 #include "clang/Basic/OpenMPKinds.def"
398  default:
399  break;
400  }
401  break;
402  case OMPD_single:
403  switch (CKind) {
404 #define OPENMP_SINGLE_CLAUSE(Name) \
405  case OMPC_##Name: \
406  return true;
407 #include "clang/Basic/OpenMPKinds.def"
408  default:
409  break;
410  }
411  break;
412  case OMPD_parallel_for:
413  switch (CKind) {
414 #define OPENMP_PARALLEL_FOR_CLAUSE(Name) \
415  case OMPC_##Name: \
416  return true;
417 #include "clang/Basic/OpenMPKinds.def"
418  default:
419  break;
420  }
421  break;
422  case OMPD_parallel_for_simd:
423  switch (CKind) {
424 #define OPENMP_PARALLEL_FOR_SIMD_CLAUSE(Name) \
425  case OMPC_##Name: \
426  return true;
427 #include "clang/Basic/OpenMPKinds.def"
428  default:
429  break;
430  }
431  break;
432  case OMPD_parallel_sections:
433  switch (CKind) {
434 #define OPENMP_PARALLEL_SECTIONS_CLAUSE(Name) \
435  case OMPC_##Name: \
436  return true;
437 #include "clang/Basic/OpenMPKinds.def"
438  default:
439  break;
440  }
441  break;
442  case OMPD_task:
443  switch (CKind) {
444 #define OPENMP_TASK_CLAUSE(Name) \
445  case OMPC_##Name: \
446  return true;
447 #include "clang/Basic/OpenMPKinds.def"
448  default:
449  break;
450  }
451  break;
452  case OMPD_flush:
453  return CKind == OMPC_flush;
454  break;
455  case OMPD_atomic:
456  switch (CKind) {
457 #define OPENMP_ATOMIC_CLAUSE(Name) \
458  case OMPC_##Name: \
459  return true;
460 #include "clang/Basic/OpenMPKinds.def"
461  default:
462  break;
463  }
464  break;
465  case OMPD_target:
466  switch (CKind) {
467 #define OPENMP_TARGET_CLAUSE(Name) \
468  case OMPC_##Name: \
469  return true;
470 #include "clang/Basic/OpenMPKinds.def"
471  default:
472  break;
473  }
474  break;
475  case OMPD_requires:
476  switch (CKind) {
477 #define OPENMP_REQUIRES_CLAUSE(Name) \
478  case OMPC_##Name: \
479  return true;
480 #include "clang/Basic/OpenMPKinds.def"
481  default:
482  break;
483  }
484  break;
485  case OMPD_target_data:
486  switch (CKind) {
487 #define OPENMP_TARGET_DATA_CLAUSE(Name) \
488  case OMPC_##Name: \
489  return true;
490 #include "clang/Basic/OpenMPKinds.def"
491  default:
492  break;
493  }
494  break;
495  case OMPD_target_enter_data:
496  switch (CKind) {
497 #define OPENMP_TARGET_ENTER_DATA_CLAUSE(Name) \
498  case OMPC_##Name: \
499  return true;
500 #include "clang/Basic/OpenMPKinds.def"
501  default:
502  break;
503  }
504  break;
505  case OMPD_target_exit_data:
506  switch (CKind) {
507 #define OPENMP_TARGET_EXIT_DATA_CLAUSE(Name) \
508  case OMPC_##Name: \
509  return true;
510 #include "clang/Basic/OpenMPKinds.def"
511  default:
512  break;
513  }
514  break;
515  case OMPD_target_parallel:
516  switch (CKind) {
517 #define OPENMP_TARGET_PARALLEL_CLAUSE(Name) \
518  case OMPC_##Name: \
519  return true;
520 #include "clang/Basic/OpenMPKinds.def"
521  default:
522  break;
523  }
524  break;
525  case OMPD_target_parallel_for:
526  switch (CKind) {
527 #define OPENMP_TARGET_PARALLEL_FOR_CLAUSE(Name) \
528  case OMPC_##Name: \
529  return true;
530 #include "clang/Basic/OpenMPKinds.def"
531  default:
532  break;
533  }
534  break;
535  case OMPD_target_update:
536  switch (CKind) {
537 #define OPENMP_TARGET_UPDATE_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_teams:
546  switch (CKind) {
547 #define OPENMP_TEAMS_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_declare_simd:
556  break;
557  case OMPD_cancel:
558  switch (CKind) {
559 #define OPENMP_CANCEL_CLAUSE(Name) \
560  case OMPC_##Name: \
561  return true;
562 #include "clang/Basic/OpenMPKinds.def"
563  default:
564  break;
565  }
566  break;
567  case OMPD_ordered:
568  switch (CKind) {
569 #define OPENMP_ORDERED_CLAUSE(Name) \
570  case OMPC_##Name: \
571  return true;
572 #include "clang/Basic/OpenMPKinds.def"
573  default:
574  break;
575  }
576  break;
577  case OMPD_taskloop:
578  switch (CKind) {
579 #define OPENMP_TASKLOOP_CLAUSE(Name) \
580  case OMPC_##Name: \
581  return true;
582 #include "clang/Basic/OpenMPKinds.def"
583  default:
584  break;
585  }
586  break;
587  case OMPD_taskloop_simd:
588  switch (CKind) {
589 #define OPENMP_TASKLOOP_SIMD_CLAUSE(Name) \
590  case OMPC_##Name: \
591  return true;
592 #include "clang/Basic/OpenMPKinds.def"
593  default:
594  break;
595  }
596  break;
597  case OMPD_critical:
598  switch (CKind) {
599 #define OPENMP_CRITICAL_CLAUSE(Name) \
600  case OMPC_##Name: \
601  return true;
602 #include "clang/Basic/OpenMPKinds.def"
603  default:
604  break;
605  }
606  break;
607  case OMPD_distribute:
608  switch (CKind) {
609 #define OPENMP_DISTRIBUTE_CLAUSE(Name) \
610  case OMPC_##Name: \
611  return true;
612 #include "clang/Basic/OpenMPKinds.def"
613  default:
614  break;
615  }
616  break;
617  case OMPD_distribute_parallel_for:
618  switch (CKind) {
619 #define OPENMP_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \
620  case OMPC_##Name: \
621  return true;
622 #include "clang/Basic/OpenMPKinds.def"
623  default:
624  break;
625  }
626  break;
627  case OMPD_distribute_parallel_for_simd:
628  switch (CKind) {
629 #define OPENMP_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \
630  case OMPC_##Name: \
631  return true;
632 #include "clang/Basic/OpenMPKinds.def"
633  default:
634  break;
635  }
636  break;
637  case OMPD_distribute_simd:
638  switch (CKind) {
639 #define OPENMP_DISTRIBUTE_SIMD_CLAUSE(Name) \
640  case OMPC_##Name: \
641  return true;
642 #include "clang/Basic/OpenMPKinds.def"
643  default:
644  break;
645  }
646  break;
647  case OMPD_target_parallel_for_simd:
648  switch (CKind) {
649 #define OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(Name) \
650  case OMPC_##Name: \
651  return true;
652 #include "clang/Basic/OpenMPKinds.def"
653  default:
654  break;
655  }
656  break;
657  case OMPD_target_simd:
658  switch (CKind) {
659 #define OPENMP_TARGET_SIMD_CLAUSE(Name) \
660  case OMPC_##Name: \
661  return true;
662 #include "clang/Basic/OpenMPKinds.def"
663  default:
664  break;
665  }
666  break;
667  case OMPD_teams_distribute:
668  switch (CKind) {
669 #define OPENMP_TEAMS_DISTRIBUTE_CLAUSE(Name) \
670  case OMPC_##Name: \
671  return true;
672 #include "clang/Basic/OpenMPKinds.def"
673  default:
674  break;
675  }
676  break;
677  case OMPD_teams_distribute_simd:
678  switch (CKind) {
679 #define OPENMP_TEAMS_DISTRIBUTE_SIMD_CLAUSE(Name) \
680  case OMPC_##Name: \
681  return true;
682 #include "clang/Basic/OpenMPKinds.def"
683  default:
684  break;
685  }
686  break;
687  case OMPD_teams_distribute_parallel_for_simd:
688  switch (CKind) {
689 #define OPENMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \
690  case OMPC_##Name: \
691  return true;
692 #include "clang/Basic/OpenMPKinds.def"
693  default:
694  break;
695  }
696  break;
697  case OMPD_teams_distribute_parallel_for:
698  switch (CKind) {
699 #define OPENMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \
700  case OMPC_##Name: \
701  return true;
702 #include "clang/Basic/OpenMPKinds.def"
703  default:
704  break;
705  }
706  break;
707  case OMPD_target_teams:
708  switch (CKind) {
709 #define OPENMP_TARGET_TEAMS_CLAUSE(Name) \
710  case OMPC_##Name: \
711  return true;
712 #include "clang/Basic/OpenMPKinds.def"
713  default:
714  break;
715  }
716  break;
717  case OMPD_target_teams_distribute:
718  switch (CKind) {
719 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(Name) \
720  case OMPC_##Name: \
721  return true;
722 #include "clang/Basic/OpenMPKinds.def"
723  default:
724  break;
725  }
726  break;
727  case OMPD_target_teams_distribute_parallel_for:
728  switch (CKind) {
729 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \
730  case OMPC_##Name: \
731  return true;
732 #include "clang/Basic/OpenMPKinds.def"
733  default:
734  break;
735  }
736  break;
737  case OMPD_target_teams_distribute_parallel_for_simd:
738  switch (CKind) {
739 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \
740  case OMPC_##Name: \
741  return true;
742 #include "clang/Basic/OpenMPKinds.def"
743  default:
744  break;
745  }
746  break;
747  case OMPD_target_teams_distribute_simd:
748  switch (CKind) {
749 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(Name) \
750  case OMPC_##Name: \
751  return true;
752 #include "clang/Basic/OpenMPKinds.def"
753  default:
754  break;
755  }
756  break;
757  case OMPD_taskgroup:
758  switch (CKind) {
759 #define OPENMP_TASKGROUP_CLAUSE(Name) \
760  case OMPC_##Name: \
761  return true;
762 #include "clang/Basic/OpenMPKinds.def"
763  default:
764  break;
765  }
766  break;
767  case OMPD_declare_target:
768  case OMPD_end_declare_target:
769  case OMPD_unknown:
770  case OMPD_threadprivate:
771  case OMPD_section:
772  case OMPD_master:
773  case OMPD_taskyield:
774  case OMPD_barrier:
775  case OMPD_taskwait:
776  case OMPD_cancellation_point:
777  case OMPD_declare_reduction:
778  break;
779  }
780  return false;
781 }
782 
784  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
785  DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
786  DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
787  DKind == OMPD_distribute || DKind == OMPD_target_parallel_for ||
788  DKind == OMPD_distribute_parallel_for ||
789  DKind == OMPD_distribute_parallel_for_simd ||
790  DKind == OMPD_distribute_simd ||
791  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
792  DKind == OMPD_teams_distribute ||
793  DKind == OMPD_teams_distribute_simd ||
794  DKind == OMPD_teams_distribute_parallel_for_simd ||
795  DKind == OMPD_teams_distribute_parallel_for ||
796  DKind == OMPD_target_teams_distribute ||
797  DKind == OMPD_target_teams_distribute_parallel_for ||
798  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
799  DKind == OMPD_target_teams_distribute_simd;
800 }
801 
803  return DKind == OMPD_for || DKind == OMPD_for_simd ||
804  DKind == OMPD_sections || DKind == OMPD_section ||
805  DKind == OMPD_single || DKind == OMPD_parallel_for ||
806  DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
807  DKind == OMPD_target_parallel_for ||
808  DKind == OMPD_distribute_parallel_for ||
809  DKind == OMPD_distribute_parallel_for_simd ||
810  DKind == OMPD_target_parallel_for_simd ||
811  DKind == OMPD_teams_distribute_parallel_for_simd ||
812  DKind == OMPD_teams_distribute_parallel_for ||
813  DKind == OMPD_target_teams_distribute_parallel_for ||
814  DKind == OMPD_target_teams_distribute_parallel_for_simd;
815 }
816 
818  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd;
819 }
820 
822  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
823  DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
824  DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
825  DKind == OMPD_distribute_parallel_for ||
826  DKind == OMPD_distribute_parallel_for_simd ||
827  DKind == OMPD_target_parallel_for_simd ||
828  DKind == OMPD_teams_distribute_parallel_for ||
829  DKind == OMPD_teams_distribute_parallel_for_simd ||
830  DKind == OMPD_target_teams_distribute_parallel_for ||
831  DKind == OMPD_target_teams_distribute_parallel_for_simd;
832 }
833 
835  return DKind == OMPD_target || DKind == OMPD_target_parallel ||
836  DKind == OMPD_target_parallel_for ||
837  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
838  DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
839  DKind == OMPD_target_teams_distribute_parallel_for ||
840  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
841  DKind == OMPD_target_teams_distribute_simd;
842 }
843 
845  return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
846  DKind == OMPD_target_exit_data || DKind == OMPD_target_update;
847 }
848 
850  return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
851  DKind == OMPD_teams_distribute_simd ||
852  DKind == OMPD_teams_distribute_parallel_for_simd ||
853  DKind == OMPD_teams_distribute_parallel_for;
854 }
855 
857  return isOpenMPNestingTeamsDirective(DKind) ||
858  DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
859  DKind == OMPD_target_teams_distribute_parallel_for ||
860  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
861  DKind == OMPD_target_teams_distribute_simd;
862 }
863 
865  return DKind == OMPD_simd || DKind == OMPD_for_simd ||
866  DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
867  DKind == OMPD_distribute_parallel_for_simd ||
868  DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
869  DKind == OMPD_teams_distribute_simd ||
870  DKind == OMPD_teams_distribute_parallel_for_simd ||
871  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
872  DKind == OMPD_target_teams_distribute_simd ||
873  DKind == OMPD_target_parallel_for_simd;
874 }
875 
877  return Kind == OMPD_distribute || Kind == OMPD_distribute_parallel_for ||
878  Kind == OMPD_distribute_parallel_for_simd ||
879  Kind == OMPD_distribute_simd;
880  // TODO add next directives.
881 }
882 
884  return isOpenMPNestingDistributeDirective(Kind) ||
885  Kind == OMPD_teams_distribute || Kind == OMPD_teams_distribute_simd ||
886  Kind == OMPD_teams_distribute_parallel_for_simd ||
887  Kind == OMPD_teams_distribute_parallel_for ||
888  Kind == OMPD_target_teams_distribute ||
889  Kind == OMPD_target_teams_distribute_parallel_for ||
890  Kind == OMPD_target_teams_distribute_parallel_for_simd ||
891  Kind == OMPD_target_teams_distribute_simd;
892 }
893 
895  return Kind == OMPC_private || Kind == OMPC_firstprivate ||
896  Kind == OMPC_lastprivate || Kind == OMPC_linear ||
897  Kind == OMPC_reduction || Kind == OMPC_task_reduction ||
898  Kind == OMPC_in_reduction; // TODO add next clauses like 'reduction'.
899 }
900 
902  return Kind == OMPC_threadprivate || Kind == OMPC_copyin;
903 }
904 
906  return Kind == OMPD_task || isOpenMPTaskLoopDirective(Kind);
907 }
908 
910  return Kind == OMPD_distribute_parallel_for ||
911  Kind == OMPD_distribute_parallel_for_simd ||
912  Kind == OMPD_teams_distribute_parallel_for_simd ||
913  Kind == OMPD_teams_distribute_parallel_for ||
914  Kind == OMPD_target_teams_distribute_parallel_for ||
915  Kind == OMPD_target_teams_distribute_parallel_for_simd;
916 }
917 
919  SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
920  OpenMPDirectiveKind DKind) {
921  assert(DKind <= OMPD_unknown);
922  switch (DKind) {
923  case OMPD_parallel:
924  case OMPD_parallel_for:
925  case OMPD_parallel_for_simd:
926  case OMPD_parallel_sections:
927  case OMPD_distribute_parallel_for:
928  case OMPD_distribute_parallel_for_simd:
929  CaptureRegions.push_back(OMPD_parallel);
930  break;
931  case OMPD_target_teams:
932  case OMPD_target_teams_distribute:
933  case OMPD_target_teams_distribute_simd:
934  CaptureRegions.push_back(OMPD_task);
935  CaptureRegions.push_back(OMPD_target);
936  CaptureRegions.push_back(OMPD_teams);
937  break;
938  case OMPD_teams:
939  case OMPD_teams_distribute:
940  case OMPD_teams_distribute_simd:
941  CaptureRegions.push_back(OMPD_teams);
942  break;
943  case OMPD_target:
944  case OMPD_target_simd:
945  CaptureRegions.push_back(OMPD_task);
946  CaptureRegions.push_back(OMPD_target);
947  break;
948  case OMPD_teams_distribute_parallel_for:
949  case OMPD_teams_distribute_parallel_for_simd:
950  CaptureRegions.push_back(OMPD_teams);
951  CaptureRegions.push_back(OMPD_parallel);
952  break;
953  case OMPD_target_parallel:
954  case OMPD_target_parallel_for:
955  case OMPD_target_parallel_for_simd:
956  CaptureRegions.push_back(OMPD_task);
957  CaptureRegions.push_back(OMPD_target);
958  CaptureRegions.push_back(OMPD_parallel);
959  break;
960  case OMPD_task:
961  case OMPD_target_enter_data:
962  case OMPD_target_exit_data:
963  case OMPD_target_update:
964  CaptureRegions.push_back(OMPD_task);
965  break;
966  case OMPD_taskloop:
967  case OMPD_taskloop_simd:
968  CaptureRegions.push_back(OMPD_taskloop);
969  break;
970  case OMPD_target_teams_distribute_parallel_for:
971  case OMPD_target_teams_distribute_parallel_for_simd:
972  CaptureRegions.push_back(OMPD_task);
973  CaptureRegions.push_back(OMPD_target);
974  CaptureRegions.push_back(OMPD_teams);
975  CaptureRegions.push_back(OMPD_parallel);
976  break;
977  case OMPD_simd:
978  case OMPD_for:
979  case OMPD_for_simd:
980  case OMPD_sections:
981  case OMPD_section:
982  case OMPD_single:
983  case OMPD_master:
984  case OMPD_critical:
985  case OMPD_taskgroup:
986  case OMPD_distribute:
987  case OMPD_ordered:
988  case OMPD_atomic:
989  case OMPD_target_data:
990  case OMPD_distribute_simd:
991  CaptureRegions.push_back(OMPD_unknown);
992  break;
993  case OMPD_threadprivate:
994  case OMPD_taskyield:
995  case OMPD_barrier:
996  case OMPD_taskwait:
997  case OMPD_cancellation_point:
998  case OMPD_cancel:
999  case OMPD_flush:
1000  case OMPD_declare_reduction:
1001  case OMPD_declare_simd:
1002  case OMPD_declare_target:
1003  case OMPD_end_declare_target:
1004  case OMPD_requires:
1005  llvm_unreachable("OpenMP Directive is not allowed");
1006  case OMPD_unknown:
1007  llvm_unreachable("Unknown OpenMP directive");
1008  }
1009 }
#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:1406
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:61
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:32
#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:22
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:30
#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...