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