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