clang 22.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
20using namespace clang;
21using namespace llvm::omp;
22
25 const LangOptions &LangOpts) {
26 return llvm::StringSwitch<OpenMPDefaultClauseVariableCategory>(Str)
27#define OPENMP_DEFAULT_VARIABLE_CATEGORY(Name) \
28 .Case(#Name, OMPC_DEFAULT_VC_##Name)
29#include "clang/Basic/OpenMPKinds.def"
31}
32
34 switch (VC) {
35#define OPENMP_DEFAULT_VARIABLE_CATEGORY(Name) \
36 case OMPC_DEFAULT_VC_##Name: \
37 return #Name;
38#include "clang/Basic/OpenMPKinds.def"
39 }
40 llvm_unreachable("Invalid Variable Category in the default clause");
41}
42
43unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
44 const LangOptions &LangOpts) {
45 switch (Kind) {
46 case OMPC_default:
47 return llvm::StringSwitch<unsigned>(Str)
48#define OMP_DEFAULT_KIND(Enum, Name) .Case(Name, unsigned(Enum))
49#include "llvm/Frontend/OpenMP/OMPKinds.def"
50 .Default(unsigned(llvm::omp::OMP_DEFAULT_unknown));
51 case OMPC_proc_bind:
52 return llvm::StringSwitch<unsigned>(Str)
53#define OMP_PROC_BIND_KIND(Enum, Name, Value) .Case(Name, Value)
54#include "llvm/Frontend/OpenMP/OMPKinds.def"
55 .Default(unsigned(llvm::omp::OMP_PROC_BIND_unknown));
56 case OMPC_schedule:
57 return llvm::StringSwitch<unsigned>(Str)
58#define OPENMP_SCHEDULE_KIND(Name) \
59 .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_##Name))
60#define OPENMP_SCHEDULE_MODIFIER(Name) \
61 .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_MODIFIER_##Name))
62#include "clang/Basic/OpenMPKinds.def"
63 .Default(OMPC_SCHEDULE_unknown);
64 case OMPC_depend: {
65 unsigned Type = llvm::StringSwitch<unsigned>(Str)
66#define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
67#include "clang/Basic/OpenMPKinds.def"
68 .Default(OMPC_DEPEND_unknown);
69 if (LangOpts.OpenMP < 51 && Type == OMPC_DEPEND_inoutset)
71 return Type;
72 }
73 case OMPC_doacross:
74 return llvm::StringSwitch<OpenMPDoacrossClauseModifier>(Str)
75#define OPENMP_DOACROSS_MODIFIER(Name) .Case(#Name, OMPC_DOACROSS_##Name)
76#include "clang/Basic/OpenMPKinds.def"
77 .Default(OMPC_DOACROSS_unknown);
78 case OMPC_linear:
79 return llvm::StringSwitch<OpenMPLinearClauseKind>(Str)
80#define OPENMP_LINEAR_KIND(Name) .Case(#Name, OMPC_LINEAR_##Name)
81#include "clang/Basic/OpenMPKinds.def"
82 .Default(OMPC_LINEAR_unknown);
83 case OMPC_map: {
84 unsigned Type = llvm::StringSwitch<unsigned>(Str)
85#define OPENMP_MAP_KIND(Name) \
86 .Case(#Name, static_cast<unsigned>(OMPC_MAP_##Name))
87#define OPENMP_MAP_MODIFIER_KIND(Name) \
88 .Case(#Name, static_cast<unsigned>(OMPC_MAP_MODIFIER_##Name))
89#include "clang/Basic/OpenMPKinds.def"
90 .Default(OMPC_MAP_unknown);
91 if (LangOpts.OpenMP < 51 && Type == OMPC_MAP_MODIFIER_present)
93 if (!LangOpts.OpenMPExtensions && Type == OMPC_MAP_MODIFIER_ompx_hold)
95 return Type;
96 }
97 case OMPC_to:
98 case OMPC_from: {
99 unsigned Type = llvm::StringSwitch<unsigned>(Str)
100#define OPENMP_MOTION_MODIFIER_KIND(Name) \
101 .Case(#Name, static_cast<unsigned>(OMPC_MOTION_MODIFIER_##Name))
102#include "clang/Basic/OpenMPKinds.def"
104 if (LangOpts.OpenMP < 51 && Type == OMPC_MOTION_MODIFIER_present)
106 return Type;
107 }
108 case OMPC_dist_schedule:
109 return llvm::StringSwitch<OpenMPDistScheduleClauseKind>(Str)
110#define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
111#include "clang/Basic/OpenMPKinds.def"
113 case OMPC_defaultmap: {
114 unsigned Type = llvm::StringSwitch<unsigned>(Str)
115#define OPENMP_DEFAULTMAP_KIND(Name) \
116 .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_##Name))
117#define OPENMP_DEFAULTMAP_MODIFIER(Name) \
118 .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_MODIFIER_##Name))
119#include "clang/Basic/OpenMPKinds.def"
120 .Default(OMPC_DEFAULTMAP_unknown);
121 if (LangOpts.OpenMP < 60 && (Type == OMPC_DEFAULTMAP_MODIFIER_storage ||
122 Type == OMPC_DEFAULTMAP_MODIFIER_private))
124 return Type;
125 }
126 case OMPC_atomic_default_mem_order:
127 return llvm::StringSwitch<OpenMPAtomicDefaultMemOrderClauseKind>(Str)
128#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
129 .Case(#Name, OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name)
130#include "clang/Basic/OpenMPKinds.def"
132 case OMPC_fail:
133 return static_cast<unsigned int>(llvm::StringSwitch<llvm::omp::Clause>(Str)
134#define OPENMP_ATOMIC_FAIL_MODIFIER(Name) .Case(#Name, OMPC_##Name)
135#include "clang/Basic/OpenMPKinds.def"
136 .Default(OMPC_unknown));
137 case OMPC_device_type:
138 return llvm::StringSwitch<OpenMPDeviceType>(Str)
139#define OPENMP_DEVICE_TYPE_KIND(Name) .Case(#Name, OMPC_DEVICE_TYPE_##Name)
140#include "clang/Basic/OpenMPKinds.def"
141 .Default(OMPC_DEVICE_TYPE_unknown);
142 case OMPC_at:
143 return llvm::StringSwitch<OpenMPAtClauseKind>(Str)
144#define OPENMP_AT_KIND(Name) .Case(#Name, OMPC_AT_##Name)
145#include "clang/Basic/OpenMPKinds.def"
146 .Default(OMPC_AT_unknown);
147 case OMPC_severity:
148 return llvm::StringSwitch<OpenMPSeverityClauseKind>(Str)
149#define OPENMP_SEVERITY_KIND(Name) .Case(#Name, OMPC_SEVERITY_##Name)
150#include "clang/Basic/OpenMPKinds.def"
151 .Default(OMPC_SEVERITY_unknown);
152 case OMPC_lastprivate:
153 return llvm::StringSwitch<OpenMPLastprivateModifier>(Str)
154#define OPENMP_LASTPRIVATE_KIND(Name) .Case(#Name, OMPC_LASTPRIVATE_##Name)
155#include "clang/Basic/OpenMPKinds.def"
156 .Default(OMPC_LASTPRIVATE_unknown);
157 case OMPC_order:
158 return llvm::StringSwitch<unsigned>(Str)
159#define OPENMP_ORDER_KIND(Name) \
160 .Case(#Name, static_cast<unsigned>(OMPC_ORDER_##Name))
161#define OPENMP_ORDER_MODIFIER(Name) \
162 .Case(#Name, static_cast<unsigned>(OMPC_ORDER_MODIFIER_##Name))
163#include "clang/Basic/OpenMPKinds.def"
164 .Default(OMPC_ORDER_unknown);
165 case OMPC_update:
166 return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
167#define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
168#include "clang/Basic/OpenMPKinds.def"
169 .Default(OMPC_DEPEND_unknown);
170 case OMPC_device:
171 return llvm::StringSwitch<OpenMPDeviceClauseModifier>(Str)
172#define OPENMP_DEVICE_MODIFIER(Name) .Case(#Name, OMPC_DEVICE_##Name)
173#include "clang/Basic/OpenMPKinds.def"
174 .Default(OMPC_DEVICE_unknown);
175 case OMPC_reduction:
176 return llvm::StringSwitch<OpenMPReductionClauseModifier>(Str)
177#define OPENMP_REDUCTION_MODIFIER(Name) .Case(#Name, OMPC_REDUCTION_##Name)
178#include "clang/Basic/OpenMPKinds.def"
179 .Default(OMPC_REDUCTION_unknown);
180 case OMPC_adjust_args:
181 return llvm::StringSwitch<OpenMPAdjustArgsOpKind>(Str)
182#define OPENMP_ADJUST_ARGS_KIND(Name) .Case(#Name, OMPC_ADJUST_ARGS_##Name)
183#include "clang/Basic/OpenMPKinds.def"
184 .Default(OMPC_ADJUST_ARGS_unknown);
185 case OMPC_bind:
186 return llvm::StringSwitch<unsigned>(Str)
187#define OPENMP_BIND_KIND(Name) .Case(#Name, OMPC_BIND_##Name)
188#include "clang/Basic/OpenMPKinds.def"
189 .Default(OMPC_BIND_unknown);
190 case OMPC_grainsize: {
191 unsigned Type = llvm::StringSwitch<unsigned>(Str)
192#define OPENMP_GRAINSIZE_MODIFIER(Name) .Case(#Name, OMPC_GRAINSIZE_##Name)
193#include "clang/Basic/OpenMPKinds.def"
194 .Default(OMPC_GRAINSIZE_unknown);
195 if (LangOpts.OpenMP < 51)
197 return Type;
198 }
199 case OMPC_num_tasks: {
200 unsigned Type = llvm::StringSwitch<unsigned>(Str)
201#define OPENMP_NUMTASKS_MODIFIER(Name) .Case(#Name, OMPC_NUMTASKS_##Name)
202#include "clang/Basic/OpenMPKinds.def"
203 .Default(OMPC_NUMTASKS_unknown);
204 if (LangOpts.OpenMP < 51)
206 return Type;
207 }
208 case OMPC_allocate:
209 return llvm::StringSwitch<OpenMPAllocateClauseModifier>(Str)
210#define OPENMP_ALLOCATE_MODIFIER(Name) .Case(#Name, OMPC_ALLOCATE_##Name)
211#include "clang/Basic/OpenMPKinds.def"
212 .Default(OMPC_ALLOCATE_unknown);
213 case OMPC_num_threads: {
214 unsigned Type = llvm::StringSwitch<unsigned>(Str)
215#define OPENMP_NUMTHREADS_MODIFIER(Name) .Case(#Name, OMPC_NUMTHREADS_##Name)
216#include "clang/Basic/OpenMPKinds.def"
217 .Default(OMPC_NUMTHREADS_unknown);
218 if (LangOpts.OpenMP < 60)
220 return Type;
221 }
222 case OMPC_unknown:
223 case OMPC_threadprivate:
224 case OMPC_groupprivate:
225 case OMPC_if:
226 case OMPC_final:
227 case OMPC_safelen:
228 case OMPC_simdlen:
229 case OMPC_sizes:
230 case OMPC_permutation:
231 case OMPC_allocator:
232 case OMPC_collapse:
233 case OMPC_private:
234 case OMPC_firstprivate:
235 case OMPC_shared:
236 case OMPC_task_reduction:
237 case OMPC_in_reduction:
238 case OMPC_aligned:
239 case OMPC_copyin:
240 case OMPC_copyprivate:
241 case OMPC_ordered:
242 case OMPC_nowait:
243 case OMPC_untied:
244 case OMPC_mergeable:
245 case OMPC_flush:
246 case OMPC_depobj:
247 case OMPC_read:
248 case OMPC_write:
249 case OMPC_capture:
250 case OMPC_compare:
251 case OMPC_seq_cst:
252 case OMPC_acq_rel:
253 case OMPC_acquire:
254 case OMPC_release:
255 case OMPC_relaxed:
256 case OMPC_threads:
257 case OMPC_simd:
258 case OMPC_num_teams:
259 case OMPC_thread_limit:
260 case OMPC_priority:
261 case OMPC_nogroup:
262 case OMPC_hint:
263 case OMPC_uniform:
264 case OMPC_use_device_ptr:
265 case OMPC_use_device_addr:
266 case OMPC_is_device_ptr:
267 case OMPC_has_device_addr:
268 case OMPC_unified_address:
269 case OMPC_unified_shared_memory:
270 case OMPC_reverse_offload:
271 case OMPC_dynamic_allocators:
272 case OMPC_self_maps:
273 case OMPC_match:
274 case OMPC_nontemporal:
275 case OMPC_destroy:
276 case OMPC_novariants:
277 case OMPC_nocontext:
278 case OMPC_detach:
279 case OMPC_inclusive:
280 case OMPC_exclusive:
281 case OMPC_uses_allocators:
282 case OMPC_affinity:
283 case OMPC_when:
284 case OMPC_append_args:
285 case OMPC_looprange:
286 break;
287 default:
288 break;
289 }
290 llvm_unreachable("Invalid OpenMP simple clause kind");
291}
292
294 unsigned Type) {
295 switch (Kind) {
296 case OMPC_default:
297 switch (llvm::omp::DefaultKind(Type)) {
298#define OMP_DEFAULT_KIND(Enum, Name) \
299 case Enum: \
300 return Name;
301#include "llvm/Frontend/OpenMP/OMPKinds.def"
302 }
303 llvm_unreachable("Invalid OpenMP 'default' clause type");
304 case OMPC_proc_bind:
305 switch (Type) {
306#define OMP_PROC_BIND_KIND(Enum, Name, Value) \
307 case Value: \
308 return Name;
309#include "llvm/Frontend/OpenMP/OMPKinds.def"
310 }
311 llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
312 case OMPC_schedule:
313 switch (Type) {
316 return "unknown";
317#define OPENMP_SCHEDULE_KIND(Name) \
318 case OMPC_SCHEDULE_##Name: \
319 return #Name;
320#define OPENMP_SCHEDULE_MODIFIER(Name) \
321 case OMPC_SCHEDULE_MODIFIER_##Name: \
322 return #Name;
323#include "clang/Basic/OpenMPKinds.def"
324 }
325 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
326 case OMPC_depend:
327 switch (Type) {
329 return "unknown";
330#define OPENMP_DEPEND_KIND(Name) \
331 case OMPC_DEPEND_##Name: \
332 return #Name;
333#include "clang/Basic/OpenMPKinds.def"
334 }
335 llvm_unreachable("Invalid OpenMP 'depend' clause type");
336 case OMPC_doacross:
337 switch (Type) {
339 return "unknown";
340#define OPENMP_DOACROSS_MODIFIER(Name) \
341 case OMPC_DOACROSS_##Name: \
342 return #Name;
343#include "clang/Basic/OpenMPKinds.def"
344 }
345 llvm_unreachable("Invalid OpenMP 'doacross' clause type");
346 case OMPC_linear:
347 switch (Type) {
349 return "unknown";
350#define OPENMP_LINEAR_KIND(Name) \
351 case OMPC_LINEAR_##Name: \
352 return #Name;
353#include "clang/Basic/OpenMPKinds.def"
354 }
355 llvm_unreachable("Invalid OpenMP 'linear' clause type");
356 case OMPC_map:
357 switch (Type) {
358 case OMPC_MAP_unknown:
360 return "unknown";
361#define OPENMP_MAP_KIND(Name) \
362 case OMPC_MAP_##Name: \
363 return #Name;
364#define OPENMP_MAP_MODIFIER_KIND(Name) \
365 case OMPC_MAP_MODIFIER_##Name: \
366 return #Name;
367#include "clang/Basic/OpenMPKinds.def"
368 default:
369 break;
370 }
371 llvm_unreachable("Invalid OpenMP 'map' clause type");
372 case OMPC_to:
373 case OMPC_from:
374 switch (Type) {
376 return "unknown";
377#define OPENMP_MOTION_MODIFIER_KIND(Name) \
378 case OMPC_MOTION_MODIFIER_##Name: \
379 return #Name;
380#include "clang/Basic/OpenMPKinds.def"
381 default:
382 break;
383 }
384 llvm_unreachable("Invalid OpenMP 'to' or 'from' clause type");
385 case OMPC_dist_schedule:
386 switch (Type) {
388 return "unknown";
389#define OPENMP_DIST_SCHEDULE_KIND(Name) \
390 case OMPC_DIST_SCHEDULE_##Name: \
391 return #Name;
392#include "clang/Basic/OpenMPKinds.def"
393 }
394 llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
395 case OMPC_defaultmap:
396 switch (Type) {
399 return "unknown";
400#define OPENMP_DEFAULTMAP_KIND(Name) \
401 case OMPC_DEFAULTMAP_##Name: \
402 return #Name;
403#define OPENMP_DEFAULTMAP_MODIFIER(Name) \
404 case OMPC_DEFAULTMAP_MODIFIER_##Name: \
405 return #Name;
406#include "clang/Basic/OpenMPKinds.def"
407 }
408 llvm_unreachable("Invalid OpenMP 'defaultmap' clause type");
409 case OMPC_atomic_default_mem_order:
410 switch (Type) {
412 return "unknown";
413#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
414 case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name: \
415 return #Name;
416#include "clang/Basic/OpenMPKinds.def"
417}
418 llvm_unreachable("Invalid OpenMP 'atomic_default_mem_order' clause type");
419 case OMPC_device_type:
420 switch (Type) {
422 return "unknown";
423#define OPENMP_DEVICE_TYPE_KIND(Name) \
424 case OMPC_DEVICE_TYPE_##Name: \
425 return #Name;
426#include "clang/Basic/OpenMPKinds.def"
427 }
428 llvm_unreachable("Invalid OpenMP 'device_type' clause type");
429 case OMPC_at:
430 switch (Type) {
431 case OMPC_AT_unknown:
432 return "unknown";
433#define OPENMP_AT_KIND(Name) \
434 case OMPC_AT_##Name: \
435 return #Name;
436#include "clang/Basic/OpenMPKinds.def"
437 }
438 llvm_unreachable("Invalid OpenMP 'at' clause type");
439 case OMPC_severity:
440 switch (Type) {
442 return "unknown";
443#define OPENMP_SEVERITY_KIND(Name) \
444 case OMPC_SEVERITY_##Name: \
445 return #Name;
446#include "clang/Basic/OpenMPKinds.def"
447 }
448 llvm_unreachable("Invalid OpenMP 'severity' clause type");
449 case OMPC_lastprivate:
450 switch (Type) {
452 return "unknown";
453#define OPENMP_LASTPRIVATE_KIND(Name) \
454 case OMPC_LASTPRIVATE_##Name: \
455 return #Name;
456#include "clang/Basic/OpenMPKinds.def"
457 }
458 llvm_unreachable("Invalid OpenMP 'lastprivate' clause type");
459 case OMPC_order:
460 switch (Type) {
463 return "unknown";
464#define OPENMP_ORDER_KIND(Name) \
465 case OMPC_ORDER_##Name: \
466 return #Name;
467#define OPENMP_ORDER_MODIFIER(Name) \
468 case OMPC_ORDER_MODIFIER_##Name: \
469 return #Name;
470#include "clang/Basic/OpenMPKinds.def"
471 }
472 llvm_unreachable("Invalid OpenMP 'order' clause type");
473 case OMPC_update:
474 switch (Type) {
476 return "unknown";
477#define OPENMP_DEPEND_KIND(Name) \
478 case OMPC_DEPEND_##Name: \
479 return #Name;
480#include "clang/Basic/OpenMPKinds.def"
481 }
482 llvm_unreachable("Invalid OpenMP 'depend' clause type");
483 case OMPC_fail: {
484 OpenMPClauseKind CK = static_cast<OpenMPClauseKind>(Type);
485 return getOpenMPClauseName(CK).data();
486 llvm_unreachable("Invalid OpenMP 'fail' clause modifier");
487 }
488 case OMPC_device:
489 switch (Type) {
491 return "unknown";
492#define OPENMP_DEVICE_MODIFIER(Name) \
493 case OMPC_DEVICE_##Name: \
494 return #Name;
495#include "clang/Basic/OpenMPKinds.def"
496 }
497 llvm_unreachable("Invalid OpenMP 'device' clause modifier");
498 case OMPC_reduction:
499 switch (Type) {
501 return "unknown";
502#define OPENMP_REDUCTION_MODIFIER(Name) \
503 case OMPC_REDUCTION_##Name: \
504 return #Name;
505#include "clang/Basic/OpenMPKinds.def"
506 }
507 llvm_unreachable("Invalid OpenMP 'reduction' clause modifier");
508 case OMPC_adjust_args:
509 switch (Type) {
511 return "unknown";
512#define OPENMP_ADJUST_ARGS_KIND(Name) \
513 case OMPC_ADJUST_ARGS_##Name: \
514 return #Name;
515#include "clang/Basic/OpenMPKinds.def"
516 }
517 llvm_unreachable("Invalid OpenMP 'adjust_args' clause kind");
518 case OMPC_bind:
519 switch (Type) {
521 return "unknown";
522#define OPENMP_BIND_KIND(Name) \
523 case OMPC_BIND_##Name: \
524 return #Name;
525#include "clang/Basic/OpenMPKinds.def"
526 }
527 llvm_unreachable("Invalid OpenMP 'bind' clause type");
528 case OMPC_grainsize:
529 switch (Type) {
531 return "unknown";
532#define OPENMP_GRAINSIZE_MODIFIER(Name) \
533 case OMPC_GRAINSIZE_##Name: \
534 return #Name;
535#include "clang/Basic/OpenMPKinds.def"
536 }
537 llvm_unreachable("Invalid OpenMP 'grainsize' clause modifier");
538 case OMPC_num_tasks:
539 switch (Type) {
541 return "unknown";
542#define OPENMP_NUMTASKS_MODIFIER(Name) \
543 case OMPC_NUMTASKS_##Name: \
544 return #Name;
545#include "clang/Basic/OpenMPKinds.def"
546 }
547 llvm_unreachable("Invalid OpenMP 'num_tasks' clause modifier");
548 case OMPC_allocate:
549 switch (Type) {
551 return "unknown";
552#define OPENMP_ALLOCATE_MODIFIER(Name) \
553 case OMPC_ALLOCATE_##Name: \
554 return #Name;
555#include "clang/Basic/OpenMPKinds.def"
556 }
557 llvm_unreachable("Invalid OpenMP 'allocate' clause modifier");
558 case OMPC_num_threads:
559 switch (Type) {
561 return "unknown";
562#define OPENMP_NUMTHREADS_MODIFIER(Name) \
563 case OMPC_NUMTHREADS_##Name: \
564 return #Name;
565#include "clang/Basic/OpenMPKinds.def"
566 }
567 llvm_unreachable("Invalid OpenMP 'num_threads' clause modifier");
568 case OMPC_unknown:
569 case OMPC_threadprivate:
570 case OMPC_groupprivate:
571 case OMPC_if:
572 case OMPC_final:
573 case OMPC_safelen:
574 case OMPC_simdlen:
575 case OMPC_sizes:
576 case OMPC_permutation:
577 case OMPC_allocator:
578 case OMPC_collapse:
579 case OMPC_private:
580 case OMPC_firstprivate:
581 case OMPC_shared:
582 case OMPC_task_reduction:
583 case OMPC_in_reduction:
584 case OMPC_aligned:
585 case OMPC_copyin:
586 case OMPC_copyprivate:
587 case OMPC_ordered:
588 case OMPC_nowait:
589 case OMPC_untied:
590 case OMPC_mergeable:
591 case OMPC_flush:
592 case OMPC_depobj:
593 case OMPC_read:
594 case OMPC_write:
595 case OMPC_capture:
596 case OMPC_compare:
597 case OMPC_seq_cst:
598 case OMPC_acq_rel:
599 case OMPC_acquire:
600 case OMPC_release:
601 case OMPC_relaxed:
602 case OMPC_threads:
603 case OMPC_simd:
604 case OMPC_num_teams:
605 case OMPC_thread_limit:
606 case OMPC_priority:
607 case OMPC_nogroup:
608 case OMPC_hint:
609 case OMPC_uniform:
610 case OMPC_use_device_ptr:
611 case OMPC_use_device_addr:
612 case OMPC_is_device_ptr:
613 case OMPC_has_device_addr:
614 case OMPC_unified_address:
615 case OMPC_unified_shared_memory:
616 case OMPC_reverse_offload:
617 case OMPC_dynamic_allocators:
618 case OMPC_self_maps:
619 case OMPC_match:
620 case OMPC_nontemporal:
621 case OMPC_destroy:
622 case OMPC_detach:
623 case OMPC_novariants:
624 case OMPC_nocontext:
625 case OMPC_inclusive:
626 case OMPC_exclusive:
627 case OMPC_uses_allocators:
628 case OMPC_affinity:
629 case OMPC_when:
630 case OMPC_append_args:
631 case OMPC_looprange:
632 break;
633 default:
634 break;
635 }
636 llvm_unreachable("Invalid OpenMP simple clause kind");
637}
638
640 return getDirectiveAssociation(DKind) == Association::Loop;
641}
642
644 return DKind == OMPD_for || DKind == OMPD_for_simd ||
645 DKind == OMPD_sections || DKind == OMPD_section ||
646 DKind == OMPD_single || DKind == OMPD_parallel_for ||
647 DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
648 DKind == OMPD_target_parallel_for ||
649 DKind == OMPD_distribute_parallel_for ||
650 DKind == OMPD_distribute_parallel_for_simd ||
651 DKind == OMPD_target_parallel_for_simd ||
652 DKind == OMPD_teams_distribute_parallel_for_simd ||
653 DKind == OMPD_teams_distribute_parallel_for ||
654 DKind == OMPD_target_teams_distribute_parallel_for ||
655 DKind == OMPD_target_teams_distribute_parallel_for_simd ||
656 DKind == OMPD_parallel_loop || DKind == OMPD_teams_loop ||
657 DKind == OMPD_target_parallel_loop || DKind == OMPD_target_teams_loop;
658}
659
661 return DKind == OMPD_taskloop ||
662 llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
663}
664
666 if (DKind == OMPD_teams_loop)
667 return true;
668 return DKind == OMPD_parallel ||
669 llvm::is_contained(getLeafConstructs(DKind), OMPD_parallel);
670}
671
673 return DKind == OMPD_target ||
674 llvm::is_contained(getLeafConstructs(DKind), OMPD_target);
675}
676
678 return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
679 DKind == OMPD_target_exit_data || DKind == OMPD_target_update;
680}
681
683 return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
685}
686
688 if (DKind == OMPD_teams)
689 return true;
690 ArrayRef<Directive> Leaves = getLeafConstructs(DKind);
691 return !Leaves.empty() && Leaves.front() == OMPD_teams;
692}
693
695 return DKind == OMPD_teams ||
696 llvm::is_contained(getLeafConstructs(DKind), OMPD_teams);
697}
698
700 // Avoid OMPD_declare_simd
701 if (getDirectiveAssociation(DKind) != Association::Loop)
702 return false;
703 // Formally, OMPD_end_do_simd also has a loop association, but
704 // it's a Fortran-specific directive.
705
706 return DKind == OMPD_simd ||
707 llvm::is_contained(getLeafConstructs(DKind), OMPD_simd);
708}
709
711 if (Kind == OMPD_distribute)
712 return true;
713 ArrayRef<Directive> Leaves = getLeafConstructs(Kind);
714 return !Leaves.empty() && Leaves.front() == OMPD_distribute;
715}
716
718 return Kind == OMPD_distribute ||
719 llvm::is_contained(getLeafConstructs(Kind), OMPD_distribute);
720}
721
723 if (Kind == OMPD_loop)
724 return true;
725 ArrayRef<Directive> Leaves = getLeafConstructs(Kind);
726 return !Leaves.empty() && Leaves.back() == OMPD_loop;
727}
728
730 return Kind == OMPC_private || Kind == OMPC_firstprivate ||
731 Kind == OMPC_lastprivate || Kind == OMPC_linear ||
732 Kind == OMPC_reduction || Kind == OMPC_task_reduction ||
733 Kind == OMPC_in_reduction; // TODO add next clauses like 'reduction'.
734}
735
737 return Kind == OMPC_threadprivate || Kind == OMPC_copyin;
738}
739
741 return Kind == OMPD_task || isOpenMPTaskLoopDirective(Kind);
742}
743
745 return Kind == OMPD_distribute_parallel_for ||
746 Kind == OMPD_distribute_parallel_for_simd ||
747 Kind == OMPD_teams_distribute_parallel_for_simd ||
748 Kind == OMPD_teams_distribute_parallel_for ||
749 Kind == OMPD_target_teams_distribute_parallel_for ||
750 Kind == OMPD_target_teams_distribute_parallel_for_simd ||
751 Kind == OMPD_teams_loop || Kind == OMPD_target_teams_loop;
752}
753
755 OpenMPDirectiveKind DKind) {
756 return DKind == OMPD_tile || DKind == OMPD_unroll || DKind == OMPD_reverse ||
757 DKind == OMPD_interchange || DKind == OMPD_stripe;
758}
759
761 OpenMPDirectiveKind DKind) {
762 return DKind == OMPD_fuse;
763}
764
769
771 return DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
772 DKind == OMPD_parallel_master ||
773 DKind == OMPD_parallel_master_taskloop ||
774 DKind == OMPD_parallel_master_taskloop_simd ||
775 DKind == OMPD_parallel_sections;
776}
777
779 return DKind == OMPD_target || DKind == OMPD_target_parallel ||
780 DKind == OMPD_target_parallel_for ||
781 DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
782 DKind == OMPD_target_parallel_loop;
783}
784
786 if (DKind == OMPD_error)
787 return true;
788 Category Cat = getDirectiveCategory(DKind);
789 return Cat == Category::Executable || Cat == Category::Subsidiary;
790}
791
793 if (DKind == OMPD_error)
794 return true;
795 Category Cat = getDirectiveCategory(DKind);
796 return Cat == Category::Informational;
797}
798
800 if (isOpenMPExecutableDirective(DKind)) {
801 switch (DKind) {
802 case OMPD_atomic:
803 case OMPD_barrier:
804 case OMPD_cancel:
805 case OMPD_cancellation_point:
806 case OMPD_critical:
807 case OMPD_depobj:
808 case OMPD_error:
809 case OMPD_flush:
810 case OMPD_masked:
811 case OMPD_master:
812 case OMPD_section:
813 case OMPD_taskwait:
814 case OMPD_taskyield:
815 case OMPD_assume:
816 return false;
817 default:
819 }
820 }
821 // Non-executable directives.
822 switch (DKind) {
823 case OMPD_metadirective:
824 case OMPD_nothing:
825 return true;
826 default:
827 break;
828 }
829 return false;
830}
831
833 OpenMPDirectiveKind DKind, const LangOptions &LangOpts) {
834 // Directives strictly nestable in a construct with order(concurrent) are:
835 // OpenMP 5.x: loop, parallel, simd, combined directive starting with parallel
836 // OpenMP 6.0: above plus atomic and all loop-transformation directives
837
838 if (DKind == OMPD_loop || DKind == OMPD_parallel || DKind == OMPD_simd ||
840 return true;
841
842 if (LangOpts.OpenMP >= 60)
843 return DKind == OMPD_atomic ||
845
846 return false;
847}
848
851 OpenMPDirectiveKind DKind) {
852 assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
853 assert(isOpenMPCapturingDirective(DKind) && "Expecting capturing directive");
854
855 auto GetRegionsForLeaf = [&](OpenMPDirectiveKind LKind) {
856 assert(isLeafConstruct(LKind) && "Epecting leaf directive");
857 // Whether a leaf would require OMPD_unknown if it occured on its own.
858 switch (LKind) {
859 case OMPD_metadirective:
860 CaptureRegions.push_back(OMPD_metadirective);
861 break;
862 case OMPD_nothing:
863 CaptureRegions.push_back(OMPD_nothing);
864 break;
865 case OMPD_parallel:
866 CaptureRegions.push_back(OMPD_parallel);
867 break;
868 case OMPD_target:
869 CaptureRegions.push_back(OMPD_task);
870 CaptureRegions.push_back(OMPD_target);
871 break;
872 case OMPD_task:
873 case OMPD_target_enter_data:
874 case OMPD_target_exit_data:
875 case OMPD_target_update:
876 CaptureRegions.push_back(OMPD_task);
877 break;
878 case OMPD_teams:
879 CaptureRegions.push_back(OMPD_teams);
880 break;
881 case OMPD_taskloop:
882 CaptureRegions.push_back(OMPD_taskloop);
883 break;
884 case OMPD_loop:
885 // TODO: 'loop' may require different capture regions depending on the
886 // bind clause or the parent directive when there is no bind clause.
887 // If any of the directives that push regions here are parents of 'loop',
888 // assume 'parallel'. Otherwise do nothing.
889 if (!CaptureRegions.empty() &&
890 !llvm::is_contained(CaptureRegions, OMPD_parallel))
891 CaptureRegions.push_back(OMPD_parallel);
892 else
893 return true;
894 break;
895 case OMPD_dispatch:
896 case OMPD_distribute:
897 case OMPD_for:
898 case OMPD_ordered:
899 case OMPD_scope:
900 case OMPD_sections:
901 case OMPD_simd:
902 case OMPD_single:
903 case OMPD_target_data:
904 case OMPD_taskgroup:
905 case OMPD_stripe:
906 // These directives (when standalone) use OMPD_unknown as the region,
907 // but when they're constituents of a compound directive, and other
908 // leafs from that directive have specific regions, then these directives
909 // add no additional regions.
910 return true;
911 case OMPD_masked:
912 case OMPD_master:
913 return false;
914 default:
915 llvm::errs() << getOpenMPDirectiveName(LKind, llvm::omp::FallbackVersion)
916 << '\n';
917 llvm_unreachable("Unexpected directive");
918 }
919 return false;
920 };
921
922 bool MayNeedUnknownRegion = false;
923 for (OpenMPDirectiveKind L : getLeafConstructsOrSelf(DKind))
924 MayNeedUnknownRegion |= GetRegionsForLeaf(L);
925
926 // We need OMPD_unknown when no regions were added, and specific leaf
927 // constructs were present. Push a single OMPD_unknown as the capture
928 /// region.
929 if (CaptureRegions.empty() && MayNeedUnknownRegion)
930 CaptureRegions.push_back(OMPD_unknown);
931
932 // OMPD_unknown is only expected as the only region. If other regions
933 // are present OMPD_unknown should not be present.
934 assert((CaptureRegions[0] == OMPD_unknown ||
935 !llvm::is_contained(CaptureRegions, OMPD_unknown)) &&
936 "Misplaced OMPD_unknown");
937}
938
940 return FailClauseParameter == llvm::omp::OMPC_acquire ||
941 FailClauseParameter == llvm::omp::OMPC_relaxed ||
942 FailClauseParameter == llvm::omp::OMPC_seq_cst;
943}
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Defines some OpenMP-specific enums and functions.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
The base class of the type hierarchy.
Definition TypeBase.h:1833
The JSON file list parser is used to communicate input to InstallAPI.
bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a worksharing directive.
bool needsTaskBasedThreadLimit(OpenMPDirectiveKind DKind)
Checks if the specified target directive, combined or not, needs task based thread_limit.
bool isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind)
Checks if the specified composite/combined directive constitutes a teams directive in the outermost n...
bool checkFailClauseParameter(OpenMPClauseKind FailClauseParameter)
Checks if the parameter to the fail clause in "#pragma atomic compare fail" is restricted only to mem...
bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a target data offload directive.
OpenMPDefaultClauseVariableCategory
OpenMP variable-category for 'default' clause.
@ OMPC_DEFAULT_VC_unknown
bool isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a loop transformation directive.
@ OMPC_DEFAULTMAP_MODIFIER_last
@ OMPC_DEFAULTMAP_MODIFIER_unknown
@ OMPC_ORDER_MODIFIER_last
@ OMPC_ADJUST_ARGS_unknown
@ OMPC_AT_unknown
bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a distribute directive.
@ OMPC_REDUCTION_unknown
@ OMPC_DEVICE_TYPE_unknown
@ OMPC_SCHEDULE_MODIFIER_last
Definition OpenMPKinds.h:44
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a parallel-kind directive.
bool isOpenMPPrivate(OpenMPClauseKind Kind)
Checks if the specified clause is one of private clauses like 'private', 'firstprivate',...
@ OMPC_DIST_SCHEDULE_unknown
@ OMPC_DOACROSS_unknown
bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind)
Checks if the specified directive kind is one of tasking directives - task, taskloop,...
bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a target code offload directive.
bool isOpenMPTeamsDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a teams-kind directive.
bool isOpenMPGenericLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive constitutes a 'loop' directive in the outermost nest.
@ OMPC_BIND_unknown
@ OMPC_LASTPRIVATE_unknown
@ OMPC_DEPEND_unknown
Definition OpenMPKinds.h:59
bool isOpenMPCanonicalLoopSequenceTransformationDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a loop transformation directive that applies to a canonical loop...
@ OMPC_GRAINSIZE_unknown
unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str, const LangOptions &LangOpts)
bool isOpenMPCanonicalLoopNestTransformationDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a loop transformation directive that applies to a canonical loop...
@ OMPC_NUMTASKS_unknown
bool isOpenMPTargetMapEnteringDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a map-entering target directive.
bool isOpenMPOrderConcurrentNestableDirective(OpenMPDirectiveKind DKind, const LangOptions &LangOpts)
Checks if the specified directive is an order concurrent nestable directive that can be nested within...
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
bool isOpenMPCapturingDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive can capture variables.
@ OMPC_SEVERITY_unknown
bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind)
Checks if the specified directive kind is one of the composite or combined directives that need loop ...
@ OMPC_MOTION_MODIFIER_unknown
Definition OpenMPKinds.h:96
@ OMPC_DEFAULTMAP_unknown
@ OMPC_ALLOCATE_unknown
bool isOpenMPThreadPrivate(OpenMPClauseKind Kind)
Checks if the specified clause is one of threadprivate clauses like 'threadprivate',...
@ OMPC_LINEAR_unknown
Definition OpenMPKinds.h:67
bool isOpenMPExecutableDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is considered as "executable".
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition OpenMPKinds.h:25
bool isOpenMPInformationalDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is considered as "informational".
bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a simd directive.
void getOpenMPCaptureRegions(llvm::SmallVectorImpl< OpenMPDirectiveKind > &CaptureRegions, OpenMPDirectiveKind DKind)
Return the captured regions of an OpenMP directive.
@ OMPC_NUMTHREADS_unknown
@ OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
const char * getOpenMPDefaultVariableCategoryName(unsigned VC)
@ OMPC_DEVICE_unknown
Definition OpenMPKinds.h:51
@ OMPC_MAP_MODIFIER_last
Definition OpenMPKinds.h:84
@ OMPC_MAP_MODIFIER_unknown
Definition OpenMPKinds.h:80
bool isOpenMPCombinedParallelADirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a combined construct for which the first construct is a parallel...
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
Definition OpenMPKinds.h:28
bool isOpenMPNestingDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified composite/combined directive constitutes a distribute directive in the outerm...
@ OMPC_ORDER_unknown
@ OMPC_SCHEDULE_unknown
Definition OpenMPKinds.h:35
bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a taskloop directive.
OpenMPDefaultClauseVariableCategory getOpenMPDefaultVariableCategory(StringRef Str, const LangOptions &LangOpts)
@ OMPC_MAP_unknown
Definition OpenMPKinds.h:75