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