clang  15.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_lastprivate:
108  return llvm::StringSwitch<OpenMPLastprivateModifier>(Str)
109 #define OPENMP_LASTPRIVATE_KIND(Name) .Case(#Name, OMPC_LASTPRIVATE_##Name)
110 #include "clang/Basic/OpenMPKinds.def"
111  .Default(OMPC_LASTPRIVATE_unknown);
112  case OMPC_order:
113  return llvm::StringSwitch<OpenMPOrderClauseKind>(Str)
114 #define OPENMP_ORDER_KIND(Name) .Case(#Name, OMPC_ORDER_##Name)
115 #include "clang/Basic/OpenMPKinds.def"
116  .Default(OMPC_ORDER_unknown);
117  case OMPC_update:
118  return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
119 #define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
120 #include "clang/Basic/OpenMPKinds.def"
121  .Default(OMPC_DEPEND_unknown);
122  case OMPC_device:
123  return llvm::StringSwitch<OpenMPDeviceClauseModifier>(Str)
124 #define OPENMP_DEVICE_MODIFIER(Name) .Case(#Name, OMPC_DEVICE_##Name)
125 #include "clang/Basic/OpenMPKinds.def"
126  .Default(OMPC_DEVICE_unknown);
127  case OMPC_reduction:
128  return llvm::StringSwitch<OpenMPReductionClauseModifier>(Str)
129 #define OPENMP_REDUCTION_MODIFIER(Name) .Case(#Name, OMPC_REDUCTION_##Name)
130 #include "clang/Basic/OpenMPKinds.def"
131  .Default(OMPC_REDUCTION_unknown);
132  case OMPC_adjust_args:
133  return llvm::StringSwitch<OpenMPAdjustArgsOpKind>(Str)
134 #define OPENMP_ADJUST_ARGS_KIND(Name) .Case(#Name, OMPC_ADJUST_ARGS_##Name)
135 #include "clang/Basic/OpenMPKinds.def"
136  .Default(OMPC_ADJUST_ARGS_unknown);
137  case OMPC_bind:
138  return llvm::StringSwitch<unsigned>(Str)
139 #define OPENMP_BIND_KIND(Name) .Case(#Name, OMPC_BIND_##Name)
140 #include "clang/Basic/OpenMPKinds.def"
141  .Default(OMPC_BIND_unknown);
142  case OMPC_unknown:
143  case OMPC_threadprivate:
144  case OMPC_if:
145  case OMPC_final:
146  case OMPC_num_threads:
147  case OMPC_safelen:
148  case OMPC_simdlen:
149  case OMPC_sizes:
150  case OMPC_allocator:
151  case OMPC_allocate:
152  case OMPC_collapse:
153  case OMPC_private:
154  case OMPC_firstprivate:
155  case OMPC_shared:
156  case OMPC_task_reduction:
157  case OMPC_in_reduction:
158  case OMPC_aligned:
159  case OMPC_copyin:
160  case OMPC_copyprivate:
161  case OMPC_ordered:
162  case OMPC_nowait:
163  case OMPC_untied:
164  case OMPC_mergeable:
165  case OMPC_flush:
166  case OMPC_depobj:
167  case OMPC_read:
168  case OMPC_write:
169  case OMPC_capture:
170  case OMPC_compare:
171  case OMPC_seq_cst:
172  case OMPC_acq_rel:
173  case OMPC_acquire:
174  case OMPC_release:
175  case OMPC_relaxed:
176  case OMPC_threads:
177  case OMPC_simd:
178  case OMPC_num_teams:
179  case OMPC_thread_limit:
180  case OMPC_priority:
181  case OMPC_grainsize:
182  case OMPC_nogroup:
183  case OMPC_num_tasks:
184  case OMPC_hint:
185  case OMPC_uniform:
186  case OMPC_use_device_ptr:
187  case OMPC_use_device_addr:
188  case OMPC_is_device_ptr:
189  case OMPC_has_device_addr:
190  case OMPC_unified_address:
191  case OMPC_unified_shared_memory:
192  case OMPC_reverse_offload:
193  case OMPC_dynamic_allocators:
194  case OMPC_match:
195  case OMPC_nontemporal:
196  case OMPC_destroy:
197  case OMPC_novariants:
198  case OMPC_nocontext:
199  case OMPC_detach:
200  case OMPC_inclusive:
201  case OMPC_exclusive:
202  case OMPC_uses_allocators:
203  case OMPC_affinity:
204  case OMPC_when:
205  case OMPC_append_args:
206  break;
207  default:
208  break;
209  }
210  llvm_unreachable("Invalid OpenMP simple clause kind");
211 }
212 
214  unsigned Type) {
215  switch (Kind) {
216  case OMPC_default:
217  switch (llvm::omp::DefaultKind(Type)) {
218 #define OMP_DEFAULT_KIND(Enum, Name) \
219  case Enum: \
220  return Name;
221 #include "llvm/Frontend/OpenMP/OMPKinds.def"
222  }
223  llvm_unreachable("Invalid OpenMP 'default' clause type");
224  case OMPC_proc_bind:
225  switch (Type) {
226 #define OMP_PROC_BIND_KIND(Enum, Name, Value) \
227  case Value: \
228  return Name;
229 #include "llvm/Frontend/OpenMP/OMPKinds.def"
230  }
231  llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
232  case OMPC_schedule:
233  switch (Type) {
236  return "unknown";
237 #define OPENMP_SCHEDULE_KIND(Name) \
238  case OMPC_SCHEDULE_##Name: \
239  return #Name;
240 #define OPENMP_SCHEDULE_MODIFIER(Name) \
241  case OMPC_SCHEDULE_MODIFIER_##Name: \
242  return #Name;
243 #include "clang/Basic/OpenMPKinds.def"
244  }
245  llvm_unreachable("Invalid OpenMP 'schedule' clause type");
246  case OMPC_depend:
247  switch (Type) {
248  case OMPC_DEPEND_unknown:
249  return "unknown";
250 #define OPENMP_DEPEND_KIND(Name) \
251  case OMPC_DEPEND_##Name: \
252  return #Name;
253 #include "clang/Basic/OpenMPKinds.def"
254  }
255  llvm_unreachable("Invalid OpenMP 'depend' clause type");
256  case OMPC_linear:
257  switch (Type) {
258  case OMPC_LINEAR_unknown:
259  return "unknown";
260 #define OPENMP_LINEAR_KIND(Name) \
261  case OMPC_LINEAR_##Name: \
262  return #Name;
263 #include "clang/Basic/OpenMPKinds.def"
264  }
265  llvm_unreachable("Invalid OpenMP 'linear' clause type");
266  case OMPC_map:
267  switch (Type) {
268  case OMPC_MAP_unknown:
270  return "unknown";
271 #define OPENMP_MAP_KIND(Name) \
272  case OMPC_MAP_##Name: \
273  return #Name;
274 #define OPENMP_MAP_MODIFIER_KIND(Name) \
275  case OMPC_MAP_MODIFIER_##Name: \
276  return #Name;
277 #include "clang/Basic/OpenMPKinds.def"
278  default:
279  break;
280  }
281  llvm_unreachable("Invalid OpenMP 'map' clause type");
282  case OMPC_to:
283  case OMPC_from:
284  switch (Type) {
286  return "unknown";
287 #define OPENMP_MOTION_MODIFIER_KIND(Name) \
288  case OMPC_MOTION_MODIFIER_##Name: \
289  return #Name;
290 #include "clang/Basic/OpenMPKinds.def"
291  default:
292  break;
293  }
294  llvm_unreachable("Invalid OpenMP 'to' or 'from' clause type");
295  case OMPC_dist_schedule:
296  switch (Type) {
298  return "unknown";
299 #define OPENMP_DIST_SCHEDULE_KIND(Name) \
300  case OMPC_DIST_SCHEDULE_##Name: \
301  return #Name;
302 #include "clang/Basic/OpenMPKinds.def"
303  }
304  llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
305  case OMPC_defaultmap:
306  switch (Type) {
309  return "unknown";
310 #define OPENMP_DEFAULTMAP_KIND(Name) \
311  case OMPC_DEFAULTMAP_##Name: \
312  return #Name;
313 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
314  case OMPC_DEFAULTMAP_MODIFIER_##Name: \
315  return #Name;
316 #include "clang/Basic/OpenMPKinds.def"
317  }
318  llvm_unreachable("Invalid OpenMP 'schedule' clause type");
319  case OMPC_atomic_default_mem_order:
320  switch (Type) {
322  return "unknown";
323 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
324  case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name: \
325  return #Name;
326 #include "clang/Basic/OpenMPKinds.def"
327 }
328  llvm_unreachable("Invalid OpenMP 'atomic_default_mem_order' clause type");
329  case OMPC_device_type:
330  switch (Type) {
332  return "unknown";
333 #define OPENMP_DEVICE_TYPE_KIND(Name) \
334  case OMPC_DEVICE_TYPE_##Name: \
335  return #Name;
336 #include "clang/Basic/OpenMPKinds.def"
337  }
338  llvm_unreachable("Invalid OpenMP 'device_type' clause type");
339  case OMPC_lastprivate:
340  switch (Type) {
342  return "unknown";
343 #define OPENMP_LASTPRIVATE_KIND(Name) \
344  case OMPC_LASTPRIVATE_##Name: \
345  return #Name;
346 #include "clang/Basic/OpenMPKinds.def"
347  }
348  llvm_unreachable("Invalid OpenMP 'lastprivate' clause type");
349  case OMPC_order:
350  switch (Type) {
351  case OMPC_ORDER_unknown:
352  return "unknown";
353 #define OPENMP_ORDER_KIND(Name) \
354  case OMPC_ORDER_##Name: \
355  return #Name;
356 #include "clang/Basic/OpenMPKinds.def"
357  }
358  llvm_unreachable("Invalid OpenMP 'order' clause type");
359  case OMPC_update:
360  switch (Type) {
361  case OMPC_DEPEND_unknown:
362  return "unknown";
363 #define OPENMP_DEPEND_KIND(Name) \
364  case OMPC_DEPEND_##Name: \
365  return #Name;
366 #include "clang/Basic/OpenMPKinds.def"
367  }
368  llvm_unreachable("Invalid OpenMP 'depend' clause type");
369  case OMPC_device:
370  switch (Type) {
371  case OMPC_DEVICE_unknown:
372  return "unknown";
373 #define OPENMP_DEVICE_MODIFIER(Name) \
374  case OMPC_DEVICE_##Name: \
375  return #Name;
376 #include "clang/Basic/OpenMPKinds.def"
377  }
378  llvm_unreachable("Invalid OpenMP 'device' clause modifier");
379  case OMPC_reduction:
380  switch (Type) {
382  return "unknown";
383 #define OPENMP_REDUCTION_MODIFIER(Name) \
384  case OMPC_REDUCTION_##Name: \
385  return #Name;
386 #include "clang/Basic/OpenMPKinds.def"
387  }
388  llvm_unreachable("Invalid OpenMP 'reduction' clause modifier");
389  case OMPC_adjust_args:
390  switch (Type) {
392  return "unknown";
393 #define OPENMP_ADJUST_ARGS_KIND(Name) \
394  case OMPC_ADJUST_ARGS_##Name: \
395  return #Name;
396 #include "clang/Basic/OpenMPKinds.def"
397  }
398  llvm_unreachable("Invalid OpenMP 'adjust_args' clause kind");
399  case OMPC_bind:
400  switch (Type) {
401  case OMPC_BIND_unknown:
402  return "unknown";
403 #define OPENMP_BIND_KIND(Name) \
404  case OMPC_BIND_##Name: \
405  return #Name;
406 #include "clang/Basic/OpenMPKinds.def"
407  }
408  llvm_unreachable("Invalid OpenMP 'bind' clause type");
409  case OMPC_unknown:
410  case OMPC_threadprivate:
411  case OMPC_if:
412  case OMPC_final:
413  case OMPC_num_threads:
414  case OMPC_safelen:
415  case OMPC_simdlen:
416  case OMPC_sizes:
417  case OMPC_allocator:
418  case OMPC_allocate:
419  case OMPC_collapse:
420  case OMPC_private:
421  case OMPC_firstprivate:
422  case OMPC_shared:
423  case OMPC_task_reduction:
424  case OMPC_in_reduction:
425  case OMPC_aligned:
426  case OMPC_copyin:
427  case OMPC_copyprivate:
428  case OMPC_ordered:
429  case OMPC_nowait:
430  case OMPC_untied:
431  case OMPC_mergeable:
432  case OMPC_flush:
433  case OMPC_depobj:
434  case OMPC_read:
435  case OMPC_write:
436  case OMPC_capture:
437  case OMPC_compare:
438  case OMPC_seq_cst:
439  case OMPC_acq_rel:
440  case OMPC_acquire:
441  case OMPC_release:
442  case OMPC_relaxed:
443  case OMPC_threads:
444  case OMPC_simd:
445  case OMPC_num_teams:
446  case OMPC_thread_limit:
447  case OMPC_priority:
448  case OMPC_grainsize:
449  case OMPC_nogroup:
450  case OMPC_num_tasks:
451  case OMPC_hint:
452  case OMPC_uniform:
453  case OMPC_use_device_ptr:
454  case OMPC_use_device_addr:
455  case OMPC_is_device_ptr:
456  case OMPC_has_device_addr:
457  case OMPC_unified_address:
458  case OMPC_unified_shared_memory:
459  case OMPC_reverse_offload:
460  case OMPC_dynamic_allocators:
461  case OMPC_match:
462  case OMPC_nontemporal:
463  case OMPC_destroy:
464  case OMPC_detach:
465  case OMPC_novariants:
466  case OMPC_nocontext:
467  case OMPC_inclusive:
468  case OMPC_exclusive:
469  case OMPC_uses_allocators:
470  case OMPC_affinity:
471  case OMPC_when:
472  case OMPC_append_args:
473  break;
474  default:
475  break;
476  }
477  llvm_unreachable("Invalid OpenMP simple clause kind");
478 }
479 
481  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
482  DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
483  DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
484  DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
485  DKind == OMPD_parallel_master_taskloop ||
486  DKind == OMPD_parallel_master_taskloop_simd ||
487  DKind == OMPD_masked_taskloop ||
488  DKind == OMPD_distribute || DKind == OMPD_target_parallel_for ||
489  DKind == OMPD_distribute_parallel_for ||
490  DKind == OMPD_distribute_parallel_for_simd ||
491  DKind == OMPD_distribute_simd ||
492  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
493  DKind == OMPD_teams_distribute ||
494  DKind == OMPD_teams_distribute_simd ||
495  DKind == OMPD_teams_distribute_parallel_for_simd ||
496  DKind == OMPD_teams_distribute_parallel_for ||
497  DKind == OMPD_target_teams_distribute ||
498  DKind == OMPD_target_teams_distribute_parallel_for ||
499  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
500  DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
501  DKind == OMPD_unroll || DKind == OMPD_loop ||
502  DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
503  DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
504 }
505 
507  return DKind == OMPD_for || DKind == OMPD_for_simd ||
508  DKind == OMPD_sections || DKind == OMPD_section ||
509  DKind == OMPD_single || DKind == OMPD_parallel_for ||
510  DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
511  DKind == OMPD_target_parallel_for ||
512  DKind == OMPD_distribute_parallel_for ||
513  DKind == OMPD_distribute_parallel_for_simd ||
514  DKind == OMPD_target_parallel_for_simd ||
515  DKind == OMPD_teams_distribute_parallel_for_simd ||
516  DKind == OMPD_teams_distribute_parallel_for ||
517  DKind == OMPD_target_teams_distribute_parallel_for ||
518  DKind == OMPD_target_teams_distribute_parallel_for_simd;
519 }
520 
522  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
523  DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
524  DKind == OMPD_parallel_master_taskloop ||
525  DKind == OMPD_masked_taskloop ||
526  DKind == OMPD_parallel_master_taskloop_simd;
527 }
528 
530  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
531  DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
532  DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
533  DKind == OMPD_distribute_parallel_for ||
534  DKind == OMPD_distribute_parallel_for_simd ||
535  DKind == OMPD_target_parallel_for_simd ||
536  DKind == OMPD_teams_distribute_parallel_for ||
537  DKind == OMPD_teams_distribute_parallel_for_simd ||
538  DKind == OMPD_target_teams_distribute_parallel_for ||
539  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
540  DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
541  DKind == OMPD_parallel_master_taskloop ||
542  DKind == OMPD_parallel_master_taskloop_simd ||
543  DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
544 }
545 
547  return DKind == OMPD_target || DKind == OMPD_target_parallel ||
548  DKind == OMPD_target_parallel_for ||
549  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
550  DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
551  DKind == OMPD_target_teams_distribute_parallel_for ||
552  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
553  DKind == OMPD_target_teams_distribute_simd ||
554  DKind == OMPD_target_teams_loop || DKind == OMPD_target_parallel_loop;
555 }
556 
558  return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
559  DKind == OMPD_target_exit_data || DKind == OMPD_target_update;
560 }
561 
563  return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
564  DKind == OMPD_teams_distribute_simd ||
565  DKind == OMPD_teams_distribute_parallel_for_simd ||
566  DKind == OMPD_teams_distribute_parallel_for ||
567  DKind == OMPD_teams_loop;
568 }
569 
571  return isOpenMPNestingTeamsDirective(DKind) || DKind == OMPD_target_teams ||
572  DKind == OMPD_target_teams_distribute ||
573  DKind == OMPD_target_teams_distribute_parallel_for ||
574  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
575  DKind == OMPD_target_teams_distribute_simd ||
576  DKind == OMPD_target_teams_loop;
577 }
578 
580  return DKind == OMPD_simd || DKind == OMPD_for_simd ||
581  DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
582  DKind == OMPD_master_taskloop_simd ||
583  DKind == OMPD_parallel_master_taskloop_simd ||
584  DKind == OMPD_distribute_parallel_for_simd ||
585  DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
586  DKind == OMPD_teams_distribute_simd ||
587  DKind == OMPD_teams_distribute_parallel_for_simd ||
588  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
589  DKind == OMPD_target_teams_distribute_simd ||
590  DKind == OMPD_target_parallel_for_simd;
591 }
592 
594  return Kind == OMPD_distribute || Kind == OMPD_distribute_parallel_for ||
595  Kind == OMPD_distribute_parallel_for_simd ||
596  Kind == OMPD_distribute_simd;
597  // TODO add next directives.
598 }
599 
602  Kind == OMPD_teams_distribute || Kind == OMPD_teams_distribute_simd ||
603  Kind == OMPD_teams_distribute_parallel_for_simd ||
604  Kind == OMPD_teams_distribute_parallel_for ||
605  Kind == OMPD_target_teams_distribute ||
606  Kind == OMPD_target_teams_distribute_parallel_for ||
607  Kind == OMPD_target_teams_distribute_parallel_for_simd ||
608  Kind == OMPD_target_teams_distribute_simd;
609 }
610 
612  return Kind == OMPD_loop || Kind == OMPD_teams_loop ||
613  Kind == OMPD_target_teams_loop || Kind == OMPD_parallel_loop ||
614  Kind == OMPD_target_parallel_loop;
615 }
616 
618  return Kind == OMPC_private || Kind == OMPC_firstprivate ||
619  Kind == OMPC_lastprivate || Kind == OMPC_linear ||
620  Kind == OMPC_reduction || Kind == OMPC_task_reduction ||
621  Kind == OMPC_in_reduction; // TODO add next clauses like 'reduction'.
622 }
623 
625  return Kind == OMPC_threadprivate || Kind == OMPC_copyin;
626 }
627 
629  return Kind == OMPD_task || isOpenMPTaskLoopDirective(Kind);
630 }
631 
633  return Kind == OMPD_distribute_parallel_for ||
634  Kind == OMPD_distribute_parallel_for_simd ||
635  Kind == OMPD_teams_distribute_parallel_for_simd ||
636  Kind == OMPD_teams_distribute_parallel_for ||
637  Kind == OMPD_target_teams_distribute_parallel_for ||
638  Kind == OMPD_target_teams_distribute_parallel_for_simd;
639 }
640 
642  return DKind == OMPD_tile || DKind == OMPD_unroll;
643 }
644 
646  SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
647  OpenMPDirectiveKind DKind) {
648  assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
649  switch (DKind) {
650  case OMPD_metadirective:
651  CaptureRegions.push_back(OMPD_metadirective);
652  break;
653  case OMPD_parallel:
654  case OMPD_parallel_for:
655  case OMPD_parallel_for_simd:
656  case OMPD_parallel_master:
657  case OMPD_parallel_masked:
658  case OMPD_parallel_sections:
659  case OMPD_distribute_parallel_for:
660  case OMPD_distribute_parallel_for_simd:
661  case OMPD_parallel_loop:
662  CaptureRegions.push_back(OMPD_parallel);
663  break;
664  case OMPD_target_teams:
665  case OMPD_target_teams_distribute:
666  case OMPD_target_teams_distribute_simd:
667  case OMPD_target_teams_loop:
668  CaptureRegions.push_back(OMPD_task);
669  CaptureRegions.push_back(OMPD_target);
670  CaptureRegions.push_back(OMPD_teams);
671  break;
672  case OMPD_teams:
673  case OMPD_teams_distribute:
674  case OMPD_teams_distribute_simd:
675  CaptureRegions.push_back(OMPD_teams);
676  break;
677  case OMPD_target:
678  case OMPD_target_simd:
679  CaptureRegions.push_back(OMPD_task);
680  CaptureRegions.push_back(OMPD_target);
681  break;
682  case OMPD_teams_distribute_parallel_for:
683  case OMPD_teams_distribute_parallel_for_simd:
684  CaptureRegions.push_back(OMPD_teams);
685  CaptureRegions.push_back(OMPD_parallel);
686  break;
687  case OMPD_target_parallel:
688  case OMPD_target_parallel_for:
689  case OMPD_target_parallel_for_simd:
690  case OMPD_target_parallel_loop:
691  CaptureRegions.push_back(OMPD_task);
692  CaptureRegions.push_back(OMPD_target);
693  CaptureRegions.push_back(OMPD_parallel);
694  break;
695  case OMPD_task:
696  case OMPD_target_enter_data:
697  case OMPD_target_exit_data:
698  case OMPD_target_update:
699  CaptureRegions.push_back(OMPD_task);
700  break;
701  case OMPD_taskloop:
702  case OMPD_taskloop_simd:
703  case OMPD_master_taskloop:
704  case OMPD_master_taskloop_simd:
705  case OMPD_masked_taskloop:
706  CaptureRegions.push_back(OMPD_taskloop);
707  break;
708  case OMPD_parallel_master_taskloop:
709  case OMPD_parallel_master_taskloop_simd:
710  CaptureRegions.push_back(OMPD_parallel);
711  CaptureRegions.push_back(OMPD_taskloop);
712  break;
713  case OMPD_target_teams_distribute_parallel_for:
714  case OMPD_target_teams_distribute_parallel_for_simd:
715  CaptureRegions.push_back(OMPD_task);
716  CaptureRegions.push_back(OMPD_target);
717  CaptureRegions.push_back(OMPD_teams);
718  CaptureRegions.push_back(OMPD_parallel);
719  break;
720  case OMPD_teams_loop:
721  CaptureRegions.push_back(OMPD_teams);
722  break;
723  case OMPD_nothing:
724  CaptureRegions.push_back(OMPD_nothing);
725  break;
726  case OMPD_loop:
727  // TODO: 'loop' may require different capture regions depending on the bind
728  // clause or the parent directive when there is no bind clause. Use
729  // OMPD_unknown for now.
730  case OMPD_simd:
731  case OMPD_for:
732  case OMPD_for_simd:
733  case OMPD_sections:
734  case OMPD_section:
735  case OMPD_single:
736  case OMPD_master:
737  case OMPD_critical:
738  case OMPD_taskgroup:
739  case OMPD_distribute:
740  case OMPD_ordered:
741  case OMPD_atomic:
742  case OMPD_target_data:
743  case OMPD_distribute_simd:
744  case OMPD_dispatch:
745  CaptureRegions.push_back(OMPD_unknown);
746  break;
747  case OMPD_tile:
748  case OMPD_unroll:
749  // loop transformations do not introduce captures.
750  break;
751  case OMPD_threadprivate:
752  case OMPD_allocate:
753  case OMPD_taskyield:
754  case OMPD_barrier:
755  case OMPD_taskwait:
756  case OMPD_cancellation_point:
757  case OMPD_cancel:
758  case OMPD_flush:
759  case OMPD_depobj:
760  case OMPD_scan:
761  case OMPD_declare_reduction:
762  case OMPD_declare_mapper:
763  case OMPD_declare_simd:
764  case OMPD_declare_target:
765  case OMPD_end_declare_target:
766  case OMPD_requires:
767  case OMPD_declare_variant:
768  case OMPD_begin_declare_variant:
769  case OMPD_end_declare_variant:
770  llvm_unreachable("OpenMP Directive is not allowed");
771  case OMPD_unknown:
772  default:
773  llvm_unreachable("Unknown OpenMP directive");
774  }
775 }
clang::isOpenMPTargetDataManagementDirective
bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a target data offload directive.
Definition: OpenMPKinds.cpp:557
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:562
clang::isOpenMPParallelDirective
bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a parallel-kind directive.
Definition: OpenMPKinds.cpp:529
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:624
clang::isOpenMPLoopDirective
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
Definition: OpenMPKinds.cpp:480
clang::OMPC_LASTPRIVATE_unknown
@ OMPC_LASTPRIVATE_unknown
Definition: OpenMPKinds.h:146
clang::OMPC_REDUCTION_unknown
@ OMPC_REDUCTION_unknown
Definition: OpenMPKinds.h:167
clang::OMPC_BIND_unknown
@ OMPC_BIND_unknown
Definition: OpenMPKinds.h:181
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1556
clang::isOpenMPDistributeDirective
bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a distribute directive.
Definition: OpenMPKinds.cpp:600
clang::isOpenMPLoopTransformationDirective
bool isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a loop transformation directive.
Definition: OpenMPKinds.cpp:641
clang::OMPC_LINEAR_unknown
@ OMPC_LINEAR_unknown
Definition: OpenMPKinds.h:66
clang::getOpenMPCaptureRegions
void getOpenMPCaptureRegions(llvm::SmallVectorImpl< OpenMPDirectiveKind > &CaptureRegions, OpenMPDirectiveKind DKind)
Return the captured regions of an OpenMP directive.
Definition: OpenMPKinds.cpp:645
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:139
clang::isOpenMPGenericLoopDirective
bool isOpenMPGenericLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive constitutes a 'loop' directive in the outermost nest.
Definition: OpenMPKinds.cpp:611
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:617
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:570
clang::getOpenMPSimpleClauseTypeName
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
Definition: OpenMPKinds.cpp:213
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_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:521
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:593
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:78
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:632
clang::isOpenMPWorksharingDirective
bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a worksharing directive.
Definition: OpenMPKinds.cpp:506
clang::isOpenMPTaskingDirective
bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind)
Checks if the specified directive kind is one of tasking directives - task, taskloop,...
Definition: OpenMPKinds.cpp:628
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:153
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:546
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:174
clang::isOpenMPSimdDirective
bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a simd directive.
Definition: OpenMPKinds.cpp:579