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  .Case("device_type", OMPC_device_type)
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  case OMPC_device_type:
76  return "device_type";
77  }
78  llvm_unreachable("Invalid OpenMP clause kind");
79 }
80 
82  StringRef Str) {
83  switch (Kind) {
84  case OMPC_default:
85  return llvm::StringSwitch<OpenMPDefaultClauseKind>(Str)
86 #define OPENMP_DEFAULT_KIND(Name) .Case(#Name, OMPC_DEFAULT_##Name)
87 #include "clang/Basic/OpenMPKinds.def"
88  .Default(OMPC_DEFAULT_unknown);
89  case OMPC_proc_bind:
90  return llvm::StringSwitch<OpenMPProcBindClauseKind>(Str)
91 #define OPENMP_PROC_BIND_KIND(Name) .Case(#Name, OMPC_PROC_BIND_##Name)
92 #include "clang/Basic/OpenMPKinds.def"
93  .Default(OMPC_PROC_BIND_unknown);
94  case OMPC_schedule:
95  return llvm::StringSwitch<unsigned>(Str)
96 #define OPENMP_SCHEDULE_KIND(Name) \
97  .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_##Name))
98 #define OPENMP_SCHEDULE_MODIFIER(Name) \
99  .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_MODIFIER_##Name))
100 #include "clang/Basic/OpenMPKinds.def"
101  .Default(OMPC_SCHEDULE_unknown);
102  case OMPC_depend:
103  return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
104 #define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
105 #include "clang/Basic/OpenMPKinds.def"
106  .Default(OMPC_DEPEND_unknown);
107  case OMPC_linear:
108  return llvm::StringSwitch<OpenMPLinearClauseKind>(Str)
109 #define OPENMP_LINEAR_KIND(Name) .Case(#Name, OMPC_LINEAR_##Name)
110 #include "clang/Basic/OpenMPKinds.def"
111  .Default(OMPC_LINEAR_unknown);
112  case OMPC_map:
113  return llvm::StringSwitch<unsigned>(Str)
114 #define OPENMP_MAP_KIND(Name) \
115  .Case(#Name, static_cast<unsigned>(OMPC_MAP_##Name))
116 #define OPENMP_MAP_MODIFIER_KIND(Name) \
117  .Case(#Name, static_cast<unsigned>(OMPC_MAP_MODIFIER_##Name))
118 #include "clang/Basic/OpenMPKinds.def"
119  .Default(OMPC_MAP_unknown);
120  case OMPC_to:
121  return llvm::StringSwitch<unsigned>(Str)
122 #define OPENMP_TO_MODIFIER_KIND(Name) \
123  .Case(#Name, static_cast<unsigned>(OMPC_TO_MODIFIER_##Name))
124 #include "clang/Basic/OpenMPKinds.def"
125  .Default(OMPC_TO_MODIFIER_unknown);
126  case OMPC_from:
127  return llvm::StringSwitch<unsigned>(Str)
128 #define OPENMP_FROM_MODIFIER_KIND(Name) \
129  .Case(#Name, static_cast<unsigned>(OMPC_FROM_MODIFIER_##Name))
130 #include "clang/Basic/OpenMPKinds.def"
131  .Default(OMPC_FROM_MODIFIER_unknown);
132  case OMPC_dist_schedule:
133  return llvm::StringSwitch<OpenMPDistScheduleClauseKind>(Str)
134 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
135 #include "clang/Basic/OpenMPKinds.def"
136  .Default(OMPC_DIST_SCHEDULE_unknown);
137  case OMPC_defaultmap:
138  return llvm::StringSwitch<unsigned>(Str)
139 #define OPENMP_DEFAULTMAP_KIND(Name) \
140  .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_##Name))
141 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
142  .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_MODIFIER_##Name))
143 #include "clang/Basic/OpenMPKinds.def"
144  .Default(OMPC_DEFAULTMAP_unknown);
145  case OMPC_atomic_default_mem_order:
146  return llvm::StringSwitch<OpenMPAtomicDefaultMemOrderClauseKind>(Str)
148  .Case(#Name, OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name)
149 #include "clang/Basic/OpenMPKinds.def"
151  case OMPC_device_type:
152  return llvm::StringSwitch<OpenMPDeviceType>(Str)
153 #define OPENMP_DEVICE_TYPE_KIND(Name) .Case(#Name, OMPC_DEVICE_TYPE_##Name)
154 #include "clang/Basic/OpenMPKinds.def"
155  .Default(OMPC_DEVICE_TYPE_unknown);
156  case OMPC_unknown:
157  case OMPC_threadprivate:
158  case OMPC_if:
159  case OMPC_final:
160  case OMPC_num_threads:
161  case OMPC_safelen:
162  case OMPC_simdlen:
163  case OMPC_allocator:
164  case OMPC_allocate:
165  case OMPC_collapse:
166  case OMPC_private:
167  case OMPC_firstprivate:
168  case OMPC_lastprivate:
169  case OMPC_shared:
170  case OMPC_reduction:
171  case OMPC_task_reduction:
172  case OMPC_in_reduction:
173  case OMPC_aligned:
174  case OMPC_copyin:
175  case OMPC_copyprivate:
176  case OMPC_ordered:
177  case OMPC_nowait:
178  case OMPC_untied:
179  case OMPC_mergeable:
180  case OMPC_flush:
181  case OMPC_read:
182  case OMPC_write:
183  case OMPC_update:
184  case OMPC_capture:
185  case OMPC_seq_cst:
186  case OMPC_device:
187  case OMPC_threads:
188  case OMPC_simd:
189  case OMPC_num_teams:
190  case OMPC_thread_limit:
191  case OMPC_priority:
192  case OMPC_grainsize:
193  case OMPC_nogroup:
194  case OMPC_num_tasks:
195  case OMPC_hint:
196  case OMPC_uniform:
197  case OMPC_use_device_ptr:
198  case OMPC_is_device_ptr:
199  case OMPC_unified_address:
200  case OMPC_unified_shared_memory:
201  case OMPC_reverse_offload:
202  case OMPC_dynamic_allocators:
203  break;
204  }
205  llvm_unreachable("Invalid OpenMP simple clause kind");
206 }
207 
209  unsigned Type) {
210  switch (Kind) {
211  case OMPC_default:
212  switch (Type) {
214  return "unknown";
215 #define OPENMP_DEFAULT_KIND(Name) \
216  case OMPC_DEFAULT_##Name: \
217  return #Name;
218 #include "clang/Basic/OpenMPKinds.def"
219  }
220  llvm_unreachable("Invalid OpenMP 'default' clause type");
221  case OMPC_proc_bind:
222  switch (Type) {
224  return "unknown";
225 #define OPENMP_PROC_BIND_KIND(Name) \
226  case OMPC_PROC_BIND_##Name: \
227  return #Name;
228 #include "clang/Basic/OpenMPKinds.def"
229  }
230  llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
231  case OMPC_schedule:
232  switch (Type) {
235  return "unknown";
236 #define OPENMP_SCHEDULE_KIND(Name) \
237  case OMPC_SCHEDULE_##Name: \
238  return #Name;
239 #define OPENMP_SCHEDULE_MODIFIER(Name) \
240  case OMPC_SCHEDULE_MODIFIER_##Name: \
241  return #Name;
242 #include "clang/Basic/OpenMPKinds.def"
243  }
244  llvm_unreachable("Invalid OpenMP 'schedule' clause type");
245  case OMPC_depend:
246  switch (Type) {
247  case OMPC_DEPEND_unknown:
248  return "unknown";
249 #define OPENMP_DEPEND_KIND(Name) \
250  case OMPC_DEPEND_##Name: \
251  return #Name;
252 #include "clang/Basic/OpenMPKinds.def"
253  }
254  llvm_unreachable("Invalid OpenMP 'depend' clause type");
255  case OMPC_linear:
256  switch (Type) {
257  case OMPC_LINEAR_unknown:
258  return "unknown";
259 #define OPENMP_LINEAR_KIND(Name) \
260  case OMPC_LINEAR_##Name: \
261  return #Name;
262 #include "clang/Basic/OpenMPKinds.def"
263  }
264  llvm_unreachable("Invalid OpenMP 'linear' clause type");
265  case OMPC_map:
266  switch (Type) {
267  case OMPC_MAP_unknown:
269  return "unknown";
270 #define OPENMP_MAP_KIND(Name) \
271  case OMPC_MAP_##Name: \
272  return #Name;
273 #define OPENMP_MAP_MODIFIER_KIND(Name) \
274  case OMPC_MAP_MODIFIER_##Name: \
275  return #Name;
276 #include "clang/Basic/OpenMPKinds.def"
277  default:
278  break;
279  }
280  llvm_unreachable("Invalid OpenMP 'map' clause type");
281  case OMPC_to:
282  switch (Type) {
284  return "unknown";
285 #define OPENMP_TO_MODIFIER_KIND(Name) \
286  case OMPC_TO_MODIFIER_##Name: \
287  return #Name;
288 #include "clang/Basic/OpenMPKinds.def"
289  default:
290  break;
291  }
292  llvm_unreachable("Invalid OpenMP 'to' clause type");
293  case OMPC_from:
294  switch (Type) {
296  return "unknown";
297 #define OPENMP_FROM_MODIFIER_KIND(Name) \
298  case OMPC_FROM_MODIFIER_##Name: \
299  return #Name;
300 #include "clang/Basic/OpenMPKinds.def"
301  default:
302  break;
303  }
304  llvm_unreachable("Invalid OpenMP 'from' clause type");
305  case OMPC_dist_schedule:
306  switch (Type) {
308  return "unknown";
309 #define OPENMP_DIST_SCHEDULE_KIND(Name) \
310  case OMPC_DIST_SCHEDULE_##Name: \
311  return #Name;
312 #include "clang/Basic/OpenMPKinds.def"
313  }
314  llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
315  case OMPC_defaultmap:
316  switch (Type) {
319  return "unknown";
320 #define OPENMP_DEFAULTMAP_KIND(Name) \
321  case OMPC_DEFAULTMAP_##Name: \
322  return #Name;
323 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
324  case OMPC_DEFAULTMAP_MODIFIER_##Name: \
325  return #Name;
326 #include "clang/Basic/OpenMPKinds.def"
327  }
328  llvm_unreachable("Invalid OpenMP 'schedule' clause type");
329  case OMPC_atomic_default_mem_order:
330  switch (Type) {
332  return "unknown";
333 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
334  case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name: \
335  return #Name;
336 #include "clang/Basic/OpenMPKinds.def"
337 }
338  llvm_unreachable("Invalid OpenMP 'atomic_default_mem_order' clause type");
339  case OMPC_device_type:
340  switch (Type) {
342  return "unknown";
343 #define OPENMP_DEVICE_TYPE_KIND(Name) \
344  case OMPC_DEVICE_TYPE_##Name: \
345  return #Name;
346 #include "clang/Basic/OpenMPKinds.def"
347  }
348  llvm_unreachable("Invalid OpenMP 'device_type' clause type");
349  case OMPC_unknown:
350  case OMPC_threadprivate:
351  case OMPC_if:
352  case OMPC_final:
353  case OMPC_num_threads:
354  case OMPC_safelen:
355  case OMPC_simdlen:
356  case OMPC_allocator:
357  case OMPC_allocate:
358  case OMPC_collapse:
359  case OMPC_private:
360  case OMPC_firstprivate:
361  case OMPC_lastprivate:
362  case OMPC_shared:
363  case OMPC_reduction:
364  case OMPC_task_reduction:
365  case OMPC_in_reduction:
366  case OMPC_aligned:
367  case OMPC_copyin:
368  case OMPC_copyprivate:
369  case OMPC_ordered:
370  case OMPC_nowait:
371  case OMPC_untied:
372  case OMPC_mergeable:
373  case OMPC_flush:
374  case OMPC_read:
375  case OMPC_write:
376  case OMPC_update:
377  case OMPC_capture:
378  case OMPC_seq_cst:
379  case OMPC_device:
380  case OMPC_threads:
381  case OMPC_simd:
382  case OMPC_num_teams:
383  case OMPC_thread_limit:
384  case OMPC_priority:
385  case OMPC_grainsize:
386  case OMPC_nogroup:
387  case OMPC_num_tasks:
388  case OMPC_hint:
389  case OMPC_uniform:
390  case OMPC_use_device_ptr:
391  case OMPC_is_device_ptr:
392  case OMPC_unified_address:
393  case OMPC_unified_shared_memory:
394  case OMPC_reverse_offload:
395  case OMPC_dynamic_allocators:
396  break;
397  }
398  llvm_unreachable("Invalid OpenMP simple clause kind");
399 }
400 
402  OpenMPClauseKind CKind) {
403  assert(DKind <= OMPD_unknown);
404  assert(CKind <= OMPC_unknown);
405  switch (DKind) {
406  case OMPD_parallel:
407  switch (CKind) {
408 #define OPENMP_PARALLEL_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_simd:
417  switch (CKind) {
418 #define OPENMP_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_for:
427  switch (CKind) {
428 #define OPENMP_FOR_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_for_simd:
437  switch (CKind) {
438 #define OPENMP_FOR_SIMD_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_sections:
447  switch (CKind) {
448 #define OPENMP_SECTIONS_CLAUSE(Name) \
449  case OMPC_##Name: \
450  return true;
451 #include "clang/Basic/OpenMPKinds.def"
452  default:
453  break;
454  }
455  break;
456  case OMPD_single:
457  switch (CKind) {
458 #define OPENMP_SINGLE_CLAUSE(Name) \
459  case OMPC_##Name: \
460  return true;
461 #include "clang/Basic/OpenMPKinds.def"
462  default:
463  break;
464  }
465  break;
466  case OMPD_parallel_for:
467  switch (CKind) {
468 #define OPENMP_PARALLEL_FOR_CLAUSE(Name) \
469  case OMPC_##Name: \
470  return true;
471 #include "clang/Basic/OpenMPKinds.def"
472  default:
473  break;
474  }
475  break;
476  case OMPD_parallel_for_simd:
477  switch (CKind) {
478 #define OPENMP_PARALLEL_FOR_SIMD_CLAUSE(Name) \
479  case OMPC_##Name: \
480  return true;
481 #include "clang/Basic/OpenMPKinds.def"
482  default:
483  break;
484  }
485  break;
486  case OMPD_parallel_sections:
487  switch (CKind) {
488 #define OPENMP_PARALLEL_SECTIONS_CLAUSE(Name) \
489  case OMPC_##Name: \
490  return true;
491 #include "clang/Basic/OpenMPKinds.def"
492  default:
493  break;
494  }
495  break;
496  case OMPD_task:
497  switch (CKind) {
498 #define OPENMP_TASK_CLAUSE(Name) \
499  case OMPC_##Name: \
500  return true;
501 #include "clang/Basic/OpenMPKinds.def"
502  default:
503  break;
504  }
505  break;
506  case OMPD_flush:
507  return CKind == OMPC_flush;
508  break;
509  case OMPD_atomic:
510  switch (CKind) {
511 #define OPENMP_ATOMIC_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:
520  switch (CKind) {
521 #define OPENMP_TARGET_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_requires:
530  switch (CKind) {
531 #define OPENMP_REQUIRES_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_target_data:
540  switch (CKind) {
541 #define OPENMP_TARGET_DATA_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_target_enter_data:
550  switch (CKind) {
551 #define OPENMP_TARGET_ENTER_DATA_CLAUSE(Name) \
552  case OMPC_##Name: \
553  return true;
554 #include "clang/Basic/OpenMPKinds.def"
555  default:
556  break;
557  }
558  break;
559  case OMPD_target_exit_data:
560  switch (CKind) {
561 #define OPENMP_TARGET_EXIT_DATA_CLAUSE(Name) \
562  case OMPC_##Name: \
563  return true;
564 #include "clang/Basic/OpenMPKinds.def"
565  default:
566  break;
567  }
568  break;
569  case OMPD_target_parallel:
570  switch (CKind) {
571 #define OPENMP_TARGET_PARALLEL_CLAUSE(Name) \
572  case OMPC_##Name: \
573  return true;
574 #include "clang/Basic/OpenMPKinds.def"
575  default:
576  break;
577  }
578  break;
579  case OMPD_target_parallel_for:
580  switch (CKind) {
581 #define OPENMP_TARGET_PARALLEL_FOR_CLAUSE(Name) \
582  case OMPC_##Name: \
583  return true;
584 #include "clang/Basic/OpenMPKinds.def"
585  default:
586  break;
587  }
588  break;
589  case OMPD_target_update:
590  switch (CKind) {
591 #define OPENMP_TARGET_UPDATE_CLAUSE(Name) \
592  case OMPC_##Name: \
593  return true;
594 #include "clang/Basic/OpenMPKinds.def"
595  default:
596  break;
597  }
598  break;
599  case OMPD_teams:
600  switch (CKind) {
601 #define OPENMP_TEAMS_CLAUSE(Name) \
602  case OMPC_##Name: \
603  return true;
604 #include "clang/Basic/OpenMPKinds.def"
605  default:
606  break;
607  }
608  break;
609  case OMPD_cancel:
610  switch (CKind) {
611 #define OPENMP_CANCEL_CLAUSE(Name) \
612  case OMPC_##Name: \
613  return true;
614 #include "clang/Basic/OpenMPKinds.def"
615  default:
616  break;
617  }
618  break;
619  case OMPD_ordered:
620  switch (CKind) {
621 #define OPENMP_ORDERED_CLAUSE(Name) \
622  case OMPC_##Name: \
623  return true;
624 #include "clang/Basic/OpenMPKinds.def"
625  default:
626  break;
627  }
628  break;
629  case OMPD_taskloop:
630  switch (CKind) {
631 #define OPENMP_TASKLOOP_CLAUSE(Name) \
632  case OMPC_##Name: \
633  return true;
634 #include "clang/Basic/OpenMPKinds.def"
635  default:
636  break;
637  }
638  break;
639  case OMPD_taskloop_simd:
640  switch (CKind) {
641 #define OPENMP_TASKLOOP_SIMD_CLAUSE(Name) \
642  case OMPC_##Name: \
643  return true;
644 #include "clang/Basic/OpenMPKinds.def"
645  default:
646  break;
647  }
648  break;
649  case OMPD_critical:
650  switch (CKind) {
651 #define OPENMP_CRITICAL_CLAUSE(Name) \
652  case OMPC_##Name: \
653  return true;
654 #include "clang/Basic/OpenMPKinds.def"
655  default:
656  break;
657  }
658  break;
659  case OMPD_distribute:
660  switch (CKind) {
661 #define OPENMP_DISTRIBUTE_CLAUSE(Name) \
662  case OMPC_##Name: \
663  return true;
664 #include "clang/Basic/OpenMPKinds.def"
665  default:
666  break;
667  }
668  break;
669  case OMPD_distribute_parallel_for:
670  switch (CKind) {
671 #define OPENMP_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \
672  case OMPC_##Name: \
673  return true;
674 #include "clang/Basic/OpenMPKinds.def"
675  default:
676  break;
677  }
678  break;
679  case OMPD_distribute_parallel_for_simd:
680  switch (CKind) {
681 #define OPENMP_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \
682  case OMPC_##Name: \
683  return true;
684 #include "clang/Basic/OpenMPKinds.def"
685  default:
686  break;
687  }
688  break;
689  case OMPD_distribute_simd:
690  switch (CKind) {
691 #define OPENMP_DISTRIBUTE_SIMD_CLAUSE(Name) \
692  case OMPC_##Name: \
693  return true;
694 #include "clang/Basic/OpenMPKinds.def"
695  default:
696  break;
697  }
698  break;
699  case OMPD_target_parallel_for_simd:
700  switch (CKind) {
701 #define OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(Name) \
702  case OMPC_##Name: \
703  return true;
704 #include "clang/Basic/OpenMPKinds.def"
705  default:
706  break;
707  }
708  break;
709  case OMPD_target_simd:
710  switch (CKind) {
711 #define OPENMP_TARGET_SIMD_CLAUSE(Name) \
712  case OMPC_##Name: \
713  return true;
714 #include "clang/Basic/OpenMPKinds.def"
715  default:
716  break;
717  }
718  break;
719  case OMPD_teams_distribute:
720  switch (CKind) {
721 #define OPENMP_TEAMS_DISTRIBUTE_CLAUSE(Name) \
722  case OMPC_##Name: \
723  return true;
724 #include "clang/Basic/OpenMPKinds.def"
725  default:
726  break;
727  }
728  break;
729  case OMPD_teams_distribute_simd:
730  switch (CKind) {
731 #define OPENMP_TEAMS_DISTRIBUTE_SIMD_CLAUSE(Name) \
732  case OMPC_##Name: \
733  return true;
734 #include "clang/Basic/OpenMPKinds.def"
735  default:
736  break;
737  }
738  break;
739  case OMPD_teams_distribute_parallel_for_simd:
740  switch (CKind) {
741 #define OPENMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \
742  case OMPC_##Name: \
743  return true;
744 #include "clang/Basic/OpenMPKinds.def"
745  default:
746  break;
747  }
748  break;
749  case OMPD_teams_distribute_parallel_for:
750  switch (CKind) {
751 #define OPENMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \
752  case OMPC_##Name: \
753  return true;
754 #include "clang/Basic/OpenMPKinds.def"
755  default:
756  break;
757  }
758  break;
759  case OMPD_target_teams:
760  switch (CKind) {
761 #define OPENMP_TARGET_TEAMS_CLAUSE(Name) \
762  case OMPC_##Name: \
763  return true;
764 #include "clang/Basic/OpenMPKinds.def"
765  default:
766  break;
767  }
768  break;
769  case OMPD_target_teams_distribute:
770  switch (CKind) {
771 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(Name) \
772  case OMPC_##Name: \
773  return true;
774 #include "clang/Basic/OpenMPKinds.def"
775  default:
776  break;
777  }
778  break;
779  case OMPD_target_teams_distribute_parallel_for:
780  switch (CKind) {
781 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \
782  case OMPC_##Name: \
783  return true;
784 #include "clang/Basic/OpenMPKinds.def"
785  default:
786  break;
787  }
788  break;
789  case OMPD_target_teams_distribute_parallel_for_simd:
790  switch (CKind) {
791 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \
792  case OMPC_##Name: \
793  return true;
794 #include "clang/Basic/OpenMPKinds.def"
795  default:
796  break;
797  }
798  break;
799  case OMPD_target_teams_distribute_simd:
800  switch (CKind) {
801 #define OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(Name) \
802  case OMPC_##Name: \
803  return true;
804 #include "clang/Basic/OpenMPKinds.def"
805  default:
806  break;
807  }
808  break;
809  case OMPD_taskgroup:
810  switch (CKind) {
811 #define OPENMP_TASKGROUP_CLAUSE(Name) \
812  case OMPC_##Name: \
813  return true;
814 #include "clang/Basic/OpenMPKinds.def"
815  default:
816  break;
817  }
818  break;
819  case OMPD_declare_mapper:
820  switch (CKind) {
821 #define OPENMP_DECLARE_MAPPER_CLAUSE(Name) \
822  case OMPC_##Name: \
823  return true;
824 #include "clang/Basic/OpenMPKinds.def"
825  default:
826  break;
827  }
828  break;
829  case OMPD_allocate:
830  switch (CKind) {
831 #define OPENMP_ALLOCATE_CLAUSE(Name) \
832  case OMPC_##Name: \
833  return true;
834 #include "clang/Basic/OpenMPKinds.def"
835  default:
836  break;
837  }
838  break;
839  case OMPD_declare_target:
840  case OMPD_end_declare_target:
841  case OMPD_unknown:
842  case OMPD_threadprivate:
843  case OMPD_section:
844  case OMPD_master:
845  case OMPD_taskyield:
846  case OMPD_barrier:
847  case OMPD_taskwait:
848  case OMPD_cancellation_point:
849  case OMPD_declare_reduction:
850  case OMPD_declare_simd:
851  case OMPD_declare_variant:
852  break;
853  }
854  return false;
855 }
856 
858  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
859  DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
860  DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
861  DKind == OMPD_distribute || DKind == OMPD_target_parallel_for ||
862  DKind == OMPD_distribute_parallel_for ||
863  DKind == OMPD_distribute_parallel_for_simd ||
864  DKind == OMPD_distribute_simd ||
865  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
866  DKind == OMPD_teams_distribute ||
867  DKind == OMPD_teams_distribute_simd ||
868  DKind == OMPD_teams_distribute_parallel_for_simd ||
869  DKind == OMPD_teams_distribute_parallel_for ||
870  DKind == OMPD_target_teams_distribute ||
871  DKind == OMPD_target_teams_distribute_parallel_for ||
872  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
873  DKind == OMPD_target_teams_distribute_simd;
874 }
875 
877  return DKind == OMPD_for || DKind == OMPD_for_simd ||
878  DKind == OMPD_sections || DKind == OMPD_section ||
879  DKind == OMPD_single || DKind == OMPD_parallel_for ||
880  DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
881  DKind == OMPD_target_parallel_for ||
882  DKind == OMPD_distribute_parallel_for ||
883  DKind == OMPD_distribute_parallel_for_simd ||
884  DKind == OMPD_target_parallel_for_simd ||
885  DKind == OMPD_teams_distribute_parallel_for_simd ||
886  DKind == OMPD_teams_distribute_parallel_for ||
887  DKind == OMPD_target_teams_distribute_parallel_for ||
888  DKind == OMPD_target_teams_distribute_parallel_for_simd;
889 }
890 
892  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd;
893 }
894 
896  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
897  DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
898  DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
899  DKind == OMPD_distribute_parallel_for ||
900  DKind == OMPD_distribute_parallel_for_simd ||
901  DKind == OMPD_target_parallel_for_simd ||
902  DKind == OMPD_teams_distribute_parallel_for ||
903  DKind == OMPD_teams_distribute_parallel_for_simd ||
904  DKind == OMPD_target_teams_distribute_parallel_for ||
905  DKind == OMPD_target_teams_distribute_parallel_for_simd;
906 }
907 
909  return DKind == OMPD_target || DKind == OMPD_target_parallel ||
910  DKind == OMPD_target_parallel_for ||
911  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
912  DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
913  DKind == OMPD_target_teams_distribute_parallel_for ||
914  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
915  DKind == OMPD_target_teams_distribute_simd;
916 }
917 
919  return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
920  DKind == OMPD_target_exit_data || DKind == OMPD_target_update;
921 }
922 
924  return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
925  DKind == OMPD_teams_distribute_simd ||
926  DKind == OMPD_teams_distribute_parallel_for_simd ||
927  DKind == OMPD_teams_distribute_parallel_for;
928 }
929 
931  return isOpenMPNestingTeamsDirective(DKind) ||
932  DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
933  DKind == OMPD_target_teams_distribute_parallel_for ||
934  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
935  DKind == OMPD_target_teams_distribute_simd;
936 }
937 
939  return DKind == OMPD_simd || DKind == OMPD_for_simd ||
940  DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
941  DKind == OMPD_distribute_parallel_for_simd ||
942  DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
943  DKind == OMPD_teams_distribute_simd ||
944  DKind == OMPD_teams_distribute_parallel_for_simd ||
945  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
946  DKind == OMPD_target_teams_distribute_simd ||
947  DKind == OMPD_target_parallel_for_simd;
948 }
949 
951  return Kind == OMPD_distribute || Kind == OMPD_distribute_parallel_for ||
952  Kind == OMPD_distribute_parallel_for_simd ||
953  Kind == OMPD_distribute_simd;
954  // TODO add next directives.
955 }
956 
958  return isOpenMPNestingDistributeDirective(Kind) ||
959  Kind == OMPD_teams_distribute || Kind == OMPD_teams_distribute_simd ||
960  Kind == OMPD_teams_distribute_parallel_for_simd ||
961  Kind == OMPD_teams_distribute_parallel_for ||
962  Kind == OMPD_target_teams_distribute ||
963  Kind == OMPD_target_teams_distribute_parallel_for ||
964  Kind == OMPD_target_teams_distribute_parallel_for_simd ||
965  Kind == OMPD_target_teams_distribute_simd;
966 }
967 
969  return Kind == OMPC_private || Kind == OMPC_firstprivate ||
970  Kind == OMPC_lastprivate || Kind == OMPC_linear ||
971  Kind == OMPC_reduction || Kind == OMPC_task_reduction ||
972  Kind == OMPC_in_reduction; // TODO add next clauses like 'reduction'.
973 }
974 
976  return Kind == OMPC_threadprivate || Kind == OMPC_copyin;
977 }
978 
980  return Kind == OMPD_task || isOpenMPTaskLoopDirective(Kind);
981 }
982 
984  return Kind == OMPD_distribute_parallel_for ||
985  Kind == OMPD_distribute_parallel_for_simd ||
986  Kind == OMPD_teams_distribute_parallel_for_simd ||
987  Kind == OMPD_teams_distribute_parallel_for ||
988  Kind == OMPD_target_teams_distribute_parallel_for ||
989  Kind == OMPD_target_teams_distribute_parallel_for_simd;
990 }
991 
993  SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
994  OpenMPDirectiveKind DKind) {
995  assert(DKind <= OMPD_unknown);
996  switch (DKind) {
997  case OMPD_parallel:
998  case OMPD_parallel_for:
999  case OMPD_parallel_for_simd:
1000  case OMPD_parallel_sections:
1001  case OMPD_distribute_parallel_for:
1002  case OMPD_distribute_parallel_for_simd:
1003  CaptureRegions.push_back(OMPD_parallel);
1004  break;
1005  case OMPD_target_teams:
1006  case OMPD_target_teams_distribute:
1007  case OMPD_target_teams_distribute_simd:
1008  CaptureRegions.push_back(OMPD_task);
1009  CaptureRegions.push_back(OMPD_target);
1010  CaptureRegions.push_back(OMPD_teams);
1011  break;
1012  case OMPD_teams:
1013  case OMPD_teams_distribute:
1014  case OMPD_teams_distribute_simd:
1015  CaptureRegions.push_back(OMPD_teams);
1016  break;
1017  case OMPD_target:
1018  case OMPD_target_simd:
1019  CaptureRegions.push_back(OMPD_task);
1020  CaptureRegions.push_back(OMPD_target);
1021  break;
1022  case OMPD_teams_distribute_parallel_for:
1023  case OMPD_teams_distribute_parallel_for_simd:
1024  CaptureRegions.push_back(OMPD_teams);
1025  CaptureRegions.push_back(OMPD_parallel);
1026  break;
1027  case OMPD_target_parallel:
1028  case OMPD_target_parallel_for:
1029  case OMPD_target_parallel_for_simd:
1030  CaptureRegions.push_back(OMPD_task);
1031  CaptureRegions.push_back(OMPD_target);
1032  CaptureRegions.push_back(OMPD_parallel);
1033  break;
1034  case OMPD_task:
1035  case OMPD_target_enter_data:
1036  case OMPD_target_exit_data:
1037  case OMPD_target_update:
1038  CaptureRegions.push_back(OMPD_task);
1039  break;
1040  case OMPD_taskloop:
1041  case OMPD_taskloop_simd:
1042  CaptureRegions.push_back(OMPD_taskloop);
1043  break;
1044  case OMPD_target_teams_distribute_parallel_for:
1045  case OMPD_target_teams_distribute_parallel_for_simd:
1046  CaptureRegions.push_back(OMPD_task);
1047  CaptureRegions.push_back(OMPD_target);
1048  CaptureRegions.push_back(OMPD_teams);
1049  CaptureRegions.push_back(OMPD_parallel);
1050  break;
1051  case OMPD_simd:
1052  case OMPD_for:
1053  case OMPD_for_simd:
1054  case OMPD_sections:
1055  case OMPD_section:
1056  case OMPD_single:
1057  case OMPD_master:
1058  case OMPD_critical:
1059  case OMPD_taskgroup:
1060  case OMPD_distribute:
1061  case OMPD_ordered:
1062  case OMPD_atomic:
1063  case OMPD_target_data:
1064  case OMPD_distribute_simd:
1065  CaptureRegions.push_back(OMPD_unknown);
1066  break;
1067  case OMPD_threadprivate:
1068  case OMPD_allocate:
1069  case OMPD_taskyield:
1070  case OMPD_barrier:
1071  case OMPD_taskwait:
1072  case OMPD_cancellation_point:
1073  case OMPD_cancel:
1074  case OMPD_flush:
1075  case OMPD_declare_reduction:
1076  case OMPD_declare_mapper:
1077  case OMPD_declare_simd:
1078  case OMPD_declare_target:
1079  case OMPD_end_declare_target:
1080  case OMPD_requires:
1081  case OMPD_declare_variant:
1082  llvm_unreachable("OpenMP Directive is not allowed");
1083  case OMPD_unknown:
1084  llvm_unreachable("Unknown OpenMP directive");
1085  }
1086 }
#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:1436
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: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...
#define OPENMP_DEVICE_TYPE_KIND(Name)