clang  16.0.0git
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 using namespace llvm::omp;
22 
24  const LangOptions &LangOpts) {
25  switch (Kind) {
26  case OMPC_default:
27  return llvm::StringSwitch<unsigned>(Str)
28 #define OMP_DEFAULT_KIND(Enum, Name) .Case(Name, unsigned(Enum))
29 #include "llvm/Frontend/OpenMP/OMPKinds.def"
30  .Default(unsigned(llvm::omp::OMP_DEFAULT_unknown));
31  case OMPC_proc_bind:
32  return llvm::StringSwitch<unsigned>(Str)
33 #define OMP_PROC_BIND_KIND(Enum, Name, Value) .Case(Name, Value)
34 #include "llvm/Frontend/OpenMP/OMPKinds.def"
35  .Default(unsigned(llvm::omp::OMP_PROC_BIND_unknown));
36  case OMPC_schedule:
37  return llvm::StringSwitch<unsigned>(Str)
38 #define OPENMP_SCHEDULE_KIND(Name) \
39  .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_##Name))
40 #define OPENMP_SCHEDULE_MODIFIER(Name) \
41  .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_MODIFIER_##Name))
42 #include "clang/Basic/OpenMPKinds.def"
43  .Default(OMPC_SCHEDULE_unknown);
44  case OMPC_depend: {
45  unsigned Type = llvm::StringSwitch<unsigned>(Str)
46 #define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
47 #include "clang/Basic/OpenMPKinds.def"
48  .Default(OMPC_DEPEND_unknown);
49  if (LangOpts.OpenMP < 51 && Type == OMPC_DEPEND_inoutset)
50  return OMPC_DEPEND_unknown;
51  return Type;
52  }
53  case OMPC_linear:
54  return llvm::StringSwitch<OpenMPLinearClauseKind>(Str)
55 #define OPENMP_LINEAR_KIND(Name) .Case(#Name, OMPC_LINEAR_##Name)
56 #include "clang/Basic/OpenMPKinds.def"
57  .Default(OMPC_LINEAR_unknown);
58  case OMPC_map: {
59  unsigned Type = llvm::StringSwitch<unsigned>(Str)
60 #define OPENMP_MAP_KIND(Name) \
61  .Case(#Name, static_cast<unsigned>(OMPC_MAP_##Name))
62 #define OPENMP_MAP_MODIFIER_KIND(Name) \
63  .Case(#Name, static_cast<unsigned>(OMPC_MAP_MODIFIER_##Name))
64 #include "clang/Basic/OpenMPKinds.def"
65  .Default(OMPC_MAP_unknown);
66  if (LangOpts.OpenMP < 51 && Type == OMPC_MAP_MODIFIER_present)
68  if (!LangOpts.OpenMPExtensions && Type == OMPC_MAP_MODIFIER_ompx_hold)
70  return Type;
71  }
72  case OMPC_to:
73  case OMPC_from: {
74  unsigned Type = llvm::StringSwitch<unsigned>(Str)
75 #define OPENMP_MOTION_MODIFIER_KIND(Name) \
76  .Case(#Name, static_cast<unsigned>(OMPC_MOTION_MODIFIER_##Name))
77 #include "clang/Basic/OpenMPKinds.def"
79  if (LangOpts.OpenMP < 51 && Type == OMPC_MOTION_MODIFIER_present)
81  return Type;
82  }
83  case OMPC_dist_schedule:
84  return llvm::StringSwitch<OpenMPDistScheduleClauseKind>(Str)
85 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
86 #include "clang/Basic/OpenMPKinds.def"
88  case OMPC_defaultmap:
89  return llvm::StringSwitch<unsigned>(Str)
90 #define OPENMP_DEFAULTMAP_KIND(Name) \
91  .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_##Name))
92 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
93  .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_MODIFIER_##Name))
94 #include "clang/Basic/OpenMPKinds.def"
95  .Default(OMPC_DEFAULTMAP_unknown);
96  case OMPC_atomic_default_mem_order:
97  return llvm::StringSwitch<OpenMPAtomicDefaultMemOrderClauseKind>(Str)
98 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
99  .Case(#Name, OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name)
100 #include "clang/Basic/OpenMPKinds.def"
102  case OMPC_device_type:
103  return llvm::StringSwitch<OpenMPDeviceType>(Str)
104 #define OPENMP_DEVICE_TYPE_KIND(Name) .Case(#Name, OMPC_DEVICE_TYPE_##Name)
105 #include "clang/Basic/OpenMPKinds.def"
106  .Default(OMPC_DEVICE_TYPE_unknown);
107  case OMPC_at:
108  return llvm::StringSwitch<OpenMPAtClauseKind>(Str)
109 #define OPENMP_AT_KIND(Name) .Case(#Name, OMPC_AT_##Name)
110 #include "clang/Basic/OpenMPKinds.def"
111  .Default(OMPC_AT_unknown);
112  case OMPC_severity:
113  return llvm::StringSwitch<OpenMPSeverityClauseKind>(Str)
114 #define OPENMP_SEVERITY_KIND(Name) .Case(#Name, OMPC_SEVERITY_##Name)
115 #include "clang/Basic/OpenMPKinds.def"
116  .Default(OMPC_SEVERITY_unknown);
117  case OMPC_lastprivate:
118  return llvm::StringSwitch<OpenMPLastprivateModifier>(Str)
119 #define OPENMP_LASTPRIVATE_KIND(Name) .Case(#Name, OMPC_LASTPRIVATE_##Name)
120 #include "clang/Basic/OpenMPKinds.def"
121  .Default(OMPC_LASTPRIVATE_unknown);
122  case OMPC_order:
123  return llvm::StringSwitch<OpenMPOrderClauseKind>(Str)
124 #define OPENMP_ORDER_KIND(Name) .Case(#Name, OMPC_ORDER_##Name)
125 #include "clang/Basic/OpenMPKinds.def"
126  .Default(OMPC_ORDER_unknown);
127  case OMPC_update:
128  return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
129 #define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
130 #include "clang/Basic/OpenMPKinds.def"
131  .Default(OMPC_DEPEND_unknown);
132  case OMPC_device:
133  return llvm::StringSwitch<OpenMPDeviceClauseModifier>(Str)
134 #define OPENMP_DEVICE_MODIFIER(Name) .Case(#Name, OMPC_DEVICE_##Name)
135 #include "clang/Basic/OpenMPKinds.def"
136  .Default(OMPC_DEVICE_unknown);
137  case OMPC_reduction:
138  return llvm::StringSwitch<OpenMPReductionClauseModifier>(Str)
139 #define OPENMP_REDUCTION_MODIFIER(Name) .Case(#Name, OMPC_REDUCTION_##Name)
140 #include "clang/Basic/OpenMPKinds.def"
141  .Default(OMPC_REDUCTION_unknown);
142  case OMPC_adjust_args:
143  return llvm::StringSwitch<OpenMPAdjustArgsOpKind>(Str)
144 #define OPENMP_ADJUST_ARGS_KIND(Name) .Case(#Name, OMPC_ADJUST_ARGS_##Name)
145 #include "clang/Basic/OpenMPKinds.def"
146  .Default(OMPC_ADJUST_ARGS_unknown);
147  case OMPC_bind:
148  return llvm::StringSwitch<unsigned>(Str)
149 #define OPENMP_BIND_KIND(Name) .Case(#Name, OMPC_BIND_##Name)
150 #include "clang/Basic/OpenMPKinds.def"
151  .Default(OMPC_BIND_unknown);
152  case OMPC_grainsize: {
153  unsigned Type = llvm::StringSwitch<unsigned>(Str)
154 #define OPENMP_GRAINSIZE_MODIFIER(Name) .Case(#Name, OMPC_GRAINSIZE_##Name)
155 #include "clang/Basic/OpenMPKinds.def"
156  .Default(OMPC_GRAINSIZE_unknown);
157  if (LangOpts.OpenMP < 51)
158  return OMPC_GRAINSIZE_unknown;
159  return Type;
160  }
161  case OMPC_num_tasks: {
162  unsigned Type = llvm::StringSwitch<unsigned>(Str)
163 #define OPENMP_NUMTASKS_MODIFIER(Name) .Case(#Name, OMPC_NUMTASKS_##Name)
164 #include "clang/Basic/OpenMPKinds.def"
165  .Default(OMPC_NUMTASKS_unknown);
166  if (LangOpts.OpenMP < 51)
167  return OMPC_NUMTASKS_unknown;
168  return Type;
169  }
170  case OMPC_unknown:
171  case OMPC_threadprivate:
172  case OMPC_if:
173  case OMPC_final:
174  case OMPC_num_threads:
175  case OMPC_safelen:
176  case OMPC_simdlen:
177  case OMPC_sizes:
178  case OMPC_allocator:
179  case OMPC_allocate:
180  case OMPC_collapse:
181  case OMPC_private:
182  case OMPC_firstprivate:
183  case OMPC_shared:
184  case OMPC_task_reduction:
185  case OMPC_in_reduction:
186  case OMPC_aligned:
187  case OMPC_copyin:
188  case OMPC_copyprivate:
189  case OMPC_ordered:
190  case OMPC_nowait:
191  case OMPC_untied:
192  case OMPC_mergeable:
193  case OMPC_flush:
194  case OMPC_depobj:
195  case OMPC_read:
196  case OMPC_write:
197  case OMPC_capture:
198  case OMPC_compare:
199  case OMPC_seq_cst:
200  case OMPC_acq_rel:
201  case OMPC_acquire:
202  case OMPC_release:
203  case OMPC_relaxed:
204  case OMPC_threads:
205  case OMPC_simd:
206  case OMPC_num_teams:
207  case OMPC_thread_limit:
208  case OMPC_priority:
209  case OMPC_nogroup:
210  case OMPC_hint:
211  case OMPC_uniform:
212  case OMPC_use_device_ptr:
213  case OMPC_use_device_addr:
214  case OMPC_is_device_ptr:
215  case OMPC_has_device_addr:
216  case OMPC_unified_address:
217  case OMPC_unified_shared_memory:
218  case OMPC_reverse_offload:
219  case OMPC_dynamic_allocators:
220  case OMPC_match:
221  case OMPC_nontemporal:
222  case OMPC_destroy:
223  case OMPC_novariants:
224  case OMPC_nocontext:
225  case OMPC_detach:
226  case OMPC_inclusive:
227  case OMPC_exclusive:
228  case OMPC_uses_allocators:
229  case OMPC_affinity:
230  case OMPC_when:
231  case OMPC_append_args:
232  break;
233  default:
234  break;
235  }
236  llvm_unreachable("Invalid OpenMP simple clause kind");
237 }
238 
240  unsigned Type) {
241  switch (Kind) {
242  case OMPC_default:
243  switch (llvm::omp::DefaultKind(Type)) {
244 #define OMP_DEFAULT_KIND(Enum, Name) \
245  case Enum: \
246  return Name;
247 #include "llvm/Frontend/OpenMP/OMPKinds.def"
248  }
249  llvm_unreachable("Invalid OpenMP 'default' clause type");
250  case OMPC_proc_bind:
251  switch (Type) {
252 #define OMP_PROC_BIND_KIND(Enum, Name, Value) \
253  case Value: \
254  return Name;
255 #include "llvm/Frontend/OpenMP/OMPKinds.def"
256  }
257  llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
258  case OMPC_schedule:
259  switch (Type) {
262  return "unknown";
263 #define OPENMP_SCHEDULE_KIND(Name) \
264  case OMPC_SCHEDULE_##Name: \
265  return #Name;
266 #define OPENMP_SCHEDULE_MODIFIER(Name) \
267  case OMPC_SCHEDULE_MODIFIER_##Name: \
268  return #Name;
269 #include "clang/Basic/OpenMPKinds.def"
270  }
271  llvm_unreachable("Invalid OpenMP 'schedule' clause type");
272  case OMPC_depend:
273  switch (Type) {
274  case OMPC_DEPEND_unknown:
275  return "unknown";
276 #define OPENMP_DEPEND_KIND(Name) \
277  case OMPC_DEPEND_##Name: \
278  return #Name;
279 #include "clang/Basic/OpenMPKinds.def"
280  }
281  llvm_unreachable("Invalid OpenMP 'depend' clause type");
282  case OMPC_linear:
283  switch (Type) {
284  case OMPC_LINEAR_unknown:
285  return "unknown";
286 #define OPENMP_LINEAR_KIND(Name) \
287  case OMPC_LINEAR_##Name: \
288  return #Name;
289 #include "clang/Basic/OpenMPKinds.def"
290  }
291  llvm_unreachable("Invalid OpenMP 'linear' clause type");
292  case OMPC_map:
293  switch (Type) {
294  case OMPC_MAP_unknown:
296  return "unknown";
297 #define OPENMP_MAP_KIND(Name) \
298  case OMPC_MAP_##Name: \
299  return #Name;
300 #define OPENMP_MAP_MODIFIER_KIND(Name) \
301  case OMPC_MAP_MODIFIER_##Name: \
302  return #Name;
303 #include "clang/Basic/OpenMPKinds.def"
304  default:
305  break;
306  }
307  llvm_unreachable("Invalid OpenMP 'map' clause type");
308  case OMPC_to:
309  case OMPC_from:
310  switch (Type) {
312  return "unknown";
313 #define OPENMP_MOTION_MODIFIER_KIND(Name) \
314  case OMPC_MOTION_MODIFIER_##Name: \
315  return #Name;
316 #include "clang/Basic/OpenMPKinds.def"
317  default:
318  break;
319  }
320  llvm_unreachable("Invalid OpenMP 'to' or 'from' clause type");
321  case OMPC_dist_schedule:
322  switch (Type) {
324  return "unknown";
325 #define OPENMP_DIST_SCHEDULE_KIND(Name) \
326  case OMPC_DIST_SCHEDULE_##Name: \
327  return #Name;
328 #include "clang/Basic/OpenMPKinds.def"
329  }
330  llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
331  case OMPC_defaultmap:
332  switch (Type) {
335  return "unknown";
336 #define OPENMP_DEFAULTMAP_KIND(Name) \
337  case OMPC_DEFAULTMAP_##Name: \
338  return #Name;
339 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
340  case OMPC_DEFAULTMAP_MODIFIER_##Name: \
341  return #Name;
342 #include "clang/Basic/OpenMPKinds.def"
343  }
344  llvm_unreachable("Invalid OpenMP 'schedule' clause type");
345  case OMPC_atomic_default_mem_order:
346  switch (Type) {
348  return "unknown";
349 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
350  case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name: \
351  return #Name;
352 #include "clang/Basic/OpenMPKinds.def"
353 }
354  llvm_unreachable("Invalid OpenMP 'atomic_default_mem_order' clause type");
355  case OMPC_device_type:
356  switch (Type) {
358  return "unknown";
359 #define OPENMP_DEVICE_TYPE_KIND(Name) \
360  case OMPC_DEVICE_TYPE_##Name: \
361  return #Name;
362 #include "clang/Basic/OpenMPKinds.def"
363  }
364  llvm_unreachable("Invalid OpenMP 'device_type' clause type");
365  case OMPC_at:
366  switch (Type) {
367  case OMPC_AT_unknown:
368  return "unknown";
369 #define OPENMP_AT_KIND(Name) \
370  case OMPC_AT_##Name: \
371  return #Name;
372 #include "clang/Basic/OpenMPKinds.def"
373  }
374  llvm_unreachable("Invalid OpenMP 'at' clause type");
375  case OMPC_severity:
376  switch (Type) {
378  return "unknown";
379 #define OPENMP_SEVERITY_KIND(Name) \
380  case OMPC_SEVERITY_##Name: \
381  return #Name;
382 #include "clang/Basic/OpenMPKinds.def"
383  }
384  llvm_unreachable("Invalid OpenMP 'severity' clause type");
385  case OMPC_lastprivate:
386  switch (Type) {
388  return "unknown";
389 #define OPENMP_LASTPRIVATE_KIND(Name) \
390  case OMPC_LASTPRIVATE_##Name: \
391  return #Name;
392 #include "clang/Basic/OpenMPKinds.def"
393  }
394  llvm_unreachable("Invalid OpenMP 'lastprivate' clause type");
395  case OMPC_order:
396  switch (Type) {
397  case OMPC_ORDER_unknown:
398  return "unknown";
399 #define OPENMP_ORDER_KIND(Name) \
400  case OMPC_ORDER_##Name: \
401  return #Name;
402 #include "clang/Basic/OpenMPKinds.def"
403  }
404  llvm_unreachable("Invalid OpenMP 'order' clause type");
405  case OMPC_update:
406  switch (Type) {
407  case OMPC_DEPEND_unknown:
408  return "unknown";
409 #define OPENMP_DEPEND_KIND(Name) \
410  case OMPC_DEPEND_##Name: \
411  return #Name;
412 #include "clang/Basic/OpenMPKinds.def"
413  }
414  llvm_unreachable("Invalid OpenMP 'depend' clause type");
415  case OMPC_device:
416  switch (Type) {
417  case OMPC_DEVICE_unknown:
418  return "unknown";
419 #define OPENMP_DEVICE_MODIFIER(Name) \
420  case OMPC_DEVICE_##Name: \
421  return #Name;
422 #include "clang/Basic/OpenMPKinds.def"
423  }
424  llvm_unreachable("Invalid OpenMP 'device' clause modifier");
425  case OMPC_reduction:
426  switch (Type) {
428  return "unknown";
429 #define OPENMP_REDUCTION_MODIFIER(Name) \
430  case OMPC_REDUCTION_##Name: \
431  return #Name;
432 #include "clang/Basic/OpenMPKinds.def"
433  }
434  llvm_unreachable("Invalid OpenMP 'reduction' clause modifier");
435  case OMPC_adjust_args:
436  switch (Type) {
438  return "unknown";
439 #define OPENMP_ADJUST_ARGS_KIND(Name) \
440  case OMPC_ADJUST_ARGS_##Name: \
441  return #Name;
442 #include "clang/Basic/OpenMPKinds.def"
443  }
444  llvm_unreachable("Invalid OpenMP 'adjust_args' clause kind");
445  case OMPC_bind:
446  switch (Type) {
447  case OMPC_BIND_unknown:
448  return "unknown";
449 #define OPENMP_BIND_KIND(Name) \
450  case OMPC_BIND_##Name: \
451  return #Name;
452 #include "clang/Basic/OpenMPKinds.def"
453  }
454  llvm_unreachable("Invalid OpenMP 'bind' clause type");
455  case OMPC_grainsize:
456  switch (Type) {
458  return "unknown";
459 #define OPENMP_GRAINSIZE_MODIFIER(Name) \
460  case OMPC_GRAINSIZE_##Name: \
461  return #Name;
462 #include "clang/Basic/OpenMPKinds.def"
463  }
464  llvm_unreachable("Invalid OpenMP 'grainsize' clause modifier");
465  case OMPC_num_tasks:
466  switch (Type) {
468  return "unknown";
469 #define OPENMP_NUMTASKS_MODIFIER(Name) \
470  case OMPC_NUMTASKS_##Name: \
471  return #Name;
472 #include "clang/Basic/OpenMPKinds.def"
473  }
474  llvm_unreachable("Invalid OpenMP 'num_tasks' clause modifier");
475  case OMPC_unknown:
476  case OMPC_threadprivate:
477  case OMPC_if:
478  case OMPC_final:
479  case OMPC_num_threads:
480  case OMPC_safelen:
481  case OMPC_simdlen:
482  case OMPC_sizes:
483  case OMPC_allocator:
484  case OMPC_allocate:
485  case OMPC_collapse:
486  case OMPC_private:
487  case OMPC_firstprivate:
488  case OMPC_shared:
489  case OMPC_task_reduction:
490  case OMPC_in_reduction:
491  case OMPC_aligned:
492  case OMPC_copyin:
493  case OMPC_copyprivate:
494  case OMPC_ordered:
495  case OMPC_nowait:
496  case OMPC_untied:
497  case OMPC_mergeable:
498  case OMPC_flush:
499  case OMPC_depobj:
500  case OMPC_read:
501  case OMPC_write:
502  case OMPC_capture:
503  case OMPC_compare:
504  case OMPC_seq_cst:
505  case OMPC_acq_rel:
506  case OMPC_acquire:
507  case OMPC_release:
508  case OMPC_relaxed:
509  case OMPC_threads:
510  case OMPC_simd:
511  case OMPC_num_teams:
512  case OMPC_thread_limit:
513  case OMPC_priority:
514  case OMPC_nogroup:
515  case OMPC_hint:
516  case OMPC_uniform:
517  case OMPC_use_device_ptr:
518  case OMPC_use_device_addr:
519  case OMPC_is_device_ptr:
520  case OMPC_has_device_addr:
521  case OMPC_unified_address:
522  case OMPC_unified_shared_memory:
523  case OMPC_reverse_offload:
524  case OMPC_dynamic_allocators:
525  case OMPC_match:
526  case OMPC_nontemporal:
527  case OMPC_destroy:
528  case OMPC_detach:
529  case OMPC_novariants:
530  case OMPC_nocontext:
531  case OMPC_inclusive:
532  case OMPC_exclusive:
533  case OMPC_uses_allocators:
534  case OMPC_affinity:
535  case OMPC_when:
536  case OMPC_append_args:
537  break;
538  default:
539  break;
540  }
541  llvm_unreachable("Invalid OpenMP simple clause kind");
542 }
543 
545  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
546  DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
547  DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
548  DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
549  DKind == OMPD_parallel_master_taskloop ||
550  DKind == OMPD_parallel_master_taskloop_simd ||
551  DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
552  DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
553  DKind == OMPD_parallel_masked_taskloop_simd ||
554  DKind == OMPD_target_parallel_for ||
555  DKind == OMPD_distribute_parallel_for ||
556  DKind == OMPD_distribute_parallel_for_simd ||
557  DKind == OMPD_distribute_simd ||
558  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
559  DKind == OMPD_teams_distribute ||
560  DKind == OMPD_teams_distribute_simd ||
561  DKind == OMPD_teams_distribute_parallel_for_simd ||
562  DKind == OMPD_teams_distribute_parallel_for ||
563  DKind == OMPD_target_teams_distribute ||
564  DKind == OMPD_target_teams_distribute_parallel_for ||
565  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
566  DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
567  DKind == OMPD_unroll || DKind == OMPD_loop ||
568  DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
569  DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
570 }
571 
573  return DKind == OMPD_for || DKind == OMPD_for_simd ||
574  DKind == OMPD_sections || DKind == OMPD_section ||
575  DKind == OMPD_single || DKind == OMPD_parallel_for ||
576  DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
577  DKind == OMPD_target_parallel_for ||
578  DKind == OMPD_distribute_parallel_for ||
579  DKind == OMPD_distribute_parallel_for_simd ||
580  DKind == OMPD_target_parallel_for_simd ||
581  DKind == OMPD_teams_distribute_parallel_for_simd ||
582  DKind == OMPD_teams_distribute_parallel_for ||
583  DKind == OMPD_target_teams_distribute_parallel_for ||
584  DKind == OMPD_target_teams_distribute_parallel_for_simd;
585 }
586 
588  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
589  DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
590  DKind == OMPD_parallel_master_taskloop ||
591  DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
592  DKind == OMPD_parallel_masked_taskloop ||
593  DKind == OMPD_parallel_masked_taskloop_simd ||
594  DKind == OMPD_parallel_master_taskloop_simd;
595 }
596 
598  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
599  DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
600  DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
601  DKind == OMPD_distribute_parallel_for ||
602  DKind == OMPD_distribute_parallel_for_simd ||
603  DKind == OMPD_target_parallel_for_simd ||
604  DKind == OMPD_teams_distribute_parallel_for ||
605  DKind == OMPD_teams_distribute_parallel_for_simd ||
606  DKind == OMPD_target_teams_distribute_parallel_for ||
607  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
608  DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
609  DKind == OMPD_parallel_master_taskloop ||
610  DKind == OMPD_parallel_master_taskloop_simd ||
611  DKind == OMPD_parallel_masked_taskloop ||
612  DKind == OMPD_parallel_masked_taskloop_simd ||
613  DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
614 }
615 
617  return DKind == OMPD_target || DKind == OMPD_target_parallel ||
618  DKind == OMPD_target_parallel_for ||
619  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
620  DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
621  DKind == OMPD_target_teams_distribute_parallel_for ||
622  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
623  DKind == OMPD_target_teams_distribute_simd ||
624  DKind == OMPD_target_teams_loop || DKind == OMPD_target_parallel_loop;
625 }
626 
628  return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
629  DKind == OMPD_target_exit_data || DKind == OMPD_target_update;
630 }
631 
633  return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
634  DKind == OMPD_teams_distribute_simd ||
635  DKind == OMPD_teams_distribute_parallel_for_simd ||
636  DKind == OMPD_teams_distribute_parallel_for ||
637  DKind == OMPD_teams_loop;
638 }
639 
641  return isOpenMPNestingTeamsDirective(DKind) || DKind == OMPD_target_teams ||
642  DKind == OMPD_target_teams_distribute ||
643  DKind == OMPD_target_teams_distribute_parallel_for ||
644  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
645  DKind == OMPD_target_teams_distribute_simd ||
646  DKind == OMPD_target_teams_loop;
647 }
648 
650  return DKind == OMPD_simd || DKind == OMPD_for_simd ||
651  DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
652  DKind == OMPD_master_taskloop_simd ||
653  DKind == OMPD_masked_taskloop_simd ||
654  DKind == OMPD_parallel_master_taskloop_simd ||
655  DKind == OMPD_parallel_masked_taskloop_simd ||
656  DKind == OMPD_distribute_parallel_for_simd ||
657  DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
658  DKind == OMPD_teams_distribute_simd ||
659  DKind == OMPD_teams_distribute_parallel_for_simd ||
660  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
661  DKind == OMPD_target_teams_distribute_simd ||
662  DKind == OMPD_target_parallel_for_simd;
663 }
664 
666  return Kind == OMPD_distribute || Kind == OMPD_distribute_parallel_for ||
667  Kind == OMPD_distribute_parallel_for_simd ||
668  Kind == OMPD_distribute_simd;
669  // TODO add next directives.
670 }
671 
674  Kind == OMPD_teams_distribute || Kind == OMPD_teams_distribute_simd ||
675  Kind == OMPD_teams_distribute_parallel_for_simd ||
676  Kind == OMPD_teams_distribute_parallel_for ||
677  Kind == OMPD_target_teams_distribute ||
678  Kind == OMPD_target_teams_distribute_parallel_for ||
679  Kind == OMPD_target_teams_distribute_parallel_for_simd ||
680  Kind == OMPD_target_teams_distribute_simd;
681 }
682 
684  return Kind == OMPD_loop || Kind == OMPD_teams_loop ||
685  Kind == OMPD_target_teams_loop || Kind == OMPD_parallel_loop ||
686  Kind == OMPD_target_parallel_loop;
687 }
688 
690  return Kind == OMPC_private || Kind == OMPC_firstprivate ||
691  Kind == OMPC_lastprivate || Kind == OMPC_linear ||
692  Kind == OMPC_reduction || Kind == OMPC_task_reduction ||
693  Kind == OMPC_in_reduction; // TODO add next clauses like 'reduction'.
694 }
695 
697  return Kind == OMPC_threadprivate || Kind == OMPC_copyin;
698 }
699 
701  return Kind == OMPD_task || isOpenMPTaskLoopDirective(Kind);
702 }
703 
705  return Kind == OMPD_distribute_parallel_for ||
706  Kind == OMPD_distribute_parallel_for_simd ||
707  Kind == OMPD_teams_distribute_parallel_for_simd ||
708  Kind == OMPD_teams_distribute_parallel_for ||
709  Kind == OMPD_target_teams_distribute_parallel_for ||
710  Kind == OMPD_target_teams_distribute_parallel_for_simd;
711 }
712 
714  return DKind == OMPD_tile || DKind == OMPD_unroll;
715 }
716 
718  SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
719  OpenMPDirectiveKind DKind) {
720  assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
721  switch (DKind) {
722  case OMPD_metadirective:
723  CaptureRegions.push_back(OMPD_metadirective);
724  break;
725  case OMPD_parallel:
726  case OMPD_parallel_for:
727  case OMPD_parallel_for_simd:
728  case OMPD_parallel_master:
729  case OMPD_parallel_masked:
730  case OMPD_parallel_sections:
731  case OMPD_distribute_parallel_for:
732  case OMPD_distribute_parallel_for_simd:
733  case OMPD_parallel_loop:
734  CaptureRegions.push_back(OMPD_parallel);
735  break;
736  case OMPD_target_teams:
737  case OMPD_target_teams_distribute:
738  case OMPD_target_teams_distribute_simd:
739  case OMPD_target_teams_loop:
740  CaptureRegions.push_back(OMPD_task);
741  CaptureRegions.push_back(OMPD_target);
742  CaptureRegions.push_back(OMPD_teams);
743  break;
744  case OMPD_teams:
745  case OMPD_teams_distribute:
746  case OMPD_teams_distribute_simd:
747  CaptureRegions.push_back(OMPD_teams);
748  break;
749  case OMPD_target:
750  case OMPD_target_simd:
751  CaptureRegions.push_back(OMPD_task);
752  CaptureRegions.push_back(OMPD_target);
753  break;
754  case OMPD_teams_distribute_parallel_for:
755  case OMPD_teams_distribute_parallel_for_simd:
756  CaptureRegions.push_back(OMPD_teams);
757  CaptureRegions.push_back(OMPD_parallel);
758  break;
759  case OMPD_target_parallel:
760  case OMPD_target_parallel_for:
761  case OMPD_target_parallel_for_simd:
762  case OMPD_target_parallel_loop:
763  CaptureRegions.push_back(OMPD_task);
764  CaptureRegions.push_back(OMPD_target);
765  CaptureRegions.push_back(OMPD_parallel);
766  break;
767  case OMPD_task:
768  case OMPD_target_enter_data:
769  case OMPD_target_exit_data:
770  case OMPD_target_update:
771  CaptureRegions.push_back(OMPD_task);
772  break;
773  case OMPD_taskloop:
774  case OMPD_taskloop_simd:
775  case OMPD_master_taskloop:
776  case OMPD_master_taskloop_simd:
777  case OMPD_masked_taskloop:
778  case OMPD_masked_taskloop_simd:
779  CaptureRegions.push_back(OMPD_taskloop);
780  break;
781  case OMPD_parallel_masked_taskloop:
782  case OMPD_parallel_masked_taskloop_simd:
783  case OMPD_parallel_master_taskloop:
784  case OMPD_parallel_master_taskloop_simd:
785  CaptureRegions.push_back(OMPD_parallel);
786  CaptureRegions.push_back(OMPD_taskloop);
787  break;
788  case OMPD_target_teams_distribute_parallel_for:
789  case OMPD_target_teams_distribute_parallel_for_simd:
790  CaptureRegions.push_back(OMPD_task);
791  CaptureRegions.push_back(OMPD_target);
792  CaptureRegions.push_back(OMPD_teams);
793  CaptureRegions.push_back(OMPD_parallel);
794  break;
795  case OMPD_teams_loop:
796  CaptureRegions.push_back(OMPD_teams);
797  break;
798  case OMPD_nothing:
799  CaptureRegions.push_back(OMPD_nothing);
800  break;
801  case OMPD_loop:
802  // TODO: 'loop' may require different capture regions depending on the bind
803  // clause or the parent directive when there is no bind clause. Use
804  // OMPD_unknown for now.
805  case OMPD_simd:
806  case OMPD_for:
807  case OMPD_for_simd:
808  case OMPD_sections:
809  case OMPD_section:
810  case OMPD_single:
811  case OMPD_master:
812  case OMPD_critical:
813  case OMPD_taskgroup:
814  case OMPD_distribute:
815  case OMPD_ordered:
816  case OMPD_atomic:
817  case OMPD_target_data:
818  case OMPD_distribute_simd:
819  case OMPD_dispatch:
820  CaptureRegions.push_back(OMPD_unknown);
821  break;
822  case OMPD_tile:
823  case OMPD_unroll:
824  // loop transformations do not introduce captures.
825  break;
826  case OMPD_threadprivate:
827  case OMPD_allocate:
828  case OMPD_taskyield:
829  case OMPD_barrier:
830  case OMPD_error:
831  case OMPD_taskwait:
832  case OMPD_cancellation_point:
833  case OMPD_cancel:
834  case OMPD_flush:
835  case OMPD_depobj:
836  case OMPD_scan:
837  case OMPD_declare_reduction:
838  case OMPD_declare_mapper:
839  case OMPD_declare_simd:
840  case OMPD_declare_target:
841  case OMPD_end_declare_target:
842  case OMPD_requires:
843  case OMPD_declare_variant:
844  case OMPD_begin_declare_variant:
845  case OMPD_end_declare_variant:
846  llvm_unreachable("OpenMP Directive is not allowed");
847  case OMPD_unknown:
848  default:
849  llvm_unreachable("Unknown OpenMP directive");
850  }
851 }
clang::isOpenMPTargetDataManagementDirective
bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a target data offload directive.
Definition: OpenMPKinds.cpp:627
clang::OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
@ OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
Definition: OpenMPKinds.h:131
clang::isOpenMPNestingTeamsDirective
bool isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind)
Checks if the specified composite/combined directive constitutes a teams directive in the outermost n...
Definition: OpenMPKinds.cpp:632
clang::isOpenMPParallelDirective
bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a parallel-kind directive.
Definition: OpenMPKinds.cpp:597
clang::OMPC_AT_unknown
@ OMPC_AT_unknown
Definition: OpenMPKinds.h:138
clang::OMPC_DEPEND_unknown
@ OMPC_DEPEND_unknown
Definition: OpenMPKinds.h:58
clang::isOpenMPThreadPrivate
bool isOpenMPThreadPrivate(OpenMPClauseKind Kind)
Checks if the specified clause is one of threadprivate clauses like 'threadprivate',...
Definition: OpenMPKinds.cpp:696
clang::isOpenMPLoopDirective
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
Definition: OpenMPKinds.cpp:544
clang::OMPC_LASTPRIVATE_unknown
@ OMPC_LASTPRIVATE_unknown
Definition: OpenMPKinds.h:160
clang::OMPC_REDUCTION_unknown
@ OMPC_REDUCTION_unknown
Definition: OpenMPKinds.h:181
clang::OMPC_BIND_unknown
@ OMPC_BIND_unknown
Definition: OpenMPKinds.h:195
clang::OMPC_GRAINSIZE_unknown
@ OMPC_GRAINSIZE_unknown
Definition: OpenMPKinds.h:201
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1565
clang::isOpenMPDistributeDirective
bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a distribute directive.
Definition: OpenMPKinds.cpp:672
clang::isOpenMPLoopTransformationDirective
bool isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a loop transformation directive.
Definition: OpenMPKinds.cpp:713
clang::OMPC_LINEAR_unknown
@ OMPC_LINEAR_unknown
Definition: OpenMPKinds.h:66
clang::OMPC_NUMTASKS_unknown
@ OMPC_NUMTASKS_unknown
Definition: OpenMPKinds.h:207
clang::getOpenMPCaptureRegions
void getOpenMPCaptureRegions(llvm::SmallVectorImpl< OpenMPDirectiveKind > &CaptureRegions, OpenMPDirectiveKind DKind)
Return the captured regions of an OpenMP directive.
Definition: OpenMPKinds.cpp:717
OpenMPKinds.h
IdentifierTable.h
clang::OpenMPClauseKind
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
Definition: OpenMPKinds.h:27
clang::OMPC_MOTION_MODIFIER_unknown
@ OMPC_MOTION_MODIFIER_unknown
Definition: OpenMPKinds.h:95
clang::OMPC_DEVICE_unknown
@ OMPC_DEVICE_unknown
Definition: OpenMPKinds.h:50
clang::OMPC_DEVICE_TYPE_unknown
@ OMPC_DEVICE_TYPE_unknown
Definition: OpenMPKinds.h:153
clang::isOpenMPGenericLoopDirective
bool isOpenMPGenericLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive constitutes a 'loop' directive in the outermost nest.
Definition: OpenMPKinds.cpp:683
clang::OMPC_SCHEDULE_unknown
@ OMPC_SCHEDULE_unknown
Definition: OpenMPKinds.h:34
clang::isOpenMPPrivate
bool isOpenMPPrivate(OpenMPClauseKind Kind)
Checks if the specified clause is one of private clauses like 'private', 'firstprivate',...
Definition: OpenMPKinds.cpp:689
clang::OMPC_MAP_unknown
@ OMPC_MAP_unknown
Definition: OpenMPKinds.h:74
clang::isOpenMPTeamsDirective
bool isOpenMPTeamsDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a teams-kind directive.
Definition: OpenMPKinds.cpp:640
clang::getOpenMPSimpleClauseTypeName
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
Definition: OpenMPKinds.cpp:239
clang::OMPC_DEFAULTMAP_MODIFIER_last
@ OMPC_DEFAULTMAP_MODIFIER_last
Definition: OpenMPKinds.h:123
clang::OMPC_MAP_MODIFIER_last
@ OMPC_MAP_MODIFIER_last
Definition: OpenMPKinds.h:83
clang::OMPC_SEVERITY_unknown
@ OMPC_SEVERITY_unknown
Definition: OpenMPKinds.h:145
clang::OMPC_SCHEDULE_MODIFIER_last
@ OMPC_SCHEDULE_MODIFIER_last
Definition: OpenMPKinds.h:43
clang::isOpenMPTaskLoopDirective
bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a taskloop directive.
Definition: OpenMPKinds.cpp:587
clang::getOpenMPSimpleClauseType
unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str, const LangOptions &LangOpts)
clang::isOpenMPNestingDistributeDirective
bool isOpenMPNestingDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified composite/combined directive constitutes a distribute directive in the outerm...
Definition: OpenMPKinds.cpp:665
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:81
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::isOpenMPLoopBoundSharingDirective
bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind)
Checks if the specified directive kind is one of the composite or combined directives that need loop ...
Definition: OpenMPKinds.cpp:704
clang::isOpenMPWorksharingDirective
bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a worksharing directive.
Definition: OpenMPKinds.cpp:572
clang::isOpenMPTaskingDirective
bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind)
Checks if the specified directive kind is one of tasking directives - task, taskloop,...
Definition: OpenMPKinds.cpp:700
clang
Definition: CalledOnceCheck.h:17
clang::OMPC_MAP_MODIFIER_unknown
@ OMPC_MAP_MODIFIER_unknown
Definition: OpenMPKinds.h:79
clang::OMPC_DIST_SCHEDULE_unknown
@ OMPC_DIST_SCHEDULE_unknown
Definition: OpenMPKinds.h:106
clang::OMPC_ORDER_unknown
@ OMPC_ORDER_unknown
Definition: OpenMPKinds.h:167
clang::OpenMPDirectiveKind
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:24
clang::isOpenMPTargetExecutionDirective
bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a target code offload directive.
Definition: OpenMPKinds.cpp:616
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::OMPC_DEFAULTMAP_unknown
@ OMPC_DEFAULTMAP_unknown
Definition: OpenMPKinds.h:114
clang::OMPC_ADJUST_ARGS_unknown
@ OMPC_ADJUST_ARGS_unknown
Definition: OpenMPKinds.h:188
clang::isOpenMPSimdDirective
bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a simd directive.
Definition: OpenMPKinds.cpp:649