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)
123 return Type;
124 }
125 case OMPC_atomic_default_mem_order:
126 return llvm::StringSwitch<OpenMPAtomicDefaultMemOrderClauseKind>(Str)
127#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
128 .Case(#Name, OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name)
129#include "clang/Basic/OpenMPKinds.def"
131 case OMPC_fail:
132 return static_cast<unsigned int>(llvm::StringSwitch<llvm::omp::Clause>(Str)
133#define OPENMP_ATOMIC_FAIL_MODIFIER(Name) .Case(#Name, OMPC_##Name)
134#include "clang/Basic/OpenMPKinds.def"
135 .Default(OMPC_unknown));
136 case OMPC_device_type:
137 return llvm::StringSwitch<OpenMPDeviceType>(Str)
138#define OPENMP_DEVICE_TYPE_KIND(Name) .Case(#Name, OMPC_DEVICE_TYPE_##Name)
139#include "clang/Basic/OpenMPKinds.def"
140 .Default(OMPC_DEVICE_TYPE_unknown);
141 case OMPC_at:
142 return llvm::StringSwitch<OpenMPAtClauseKind>(Str)
143#define OPENMP_AT_KIND(Name) .Case(#Name, OMPC_AT_##Name)
144#include "clang/Basic/OpenMPKinds.def"
145 .Default(OMPC_AT_unknown);
146 case OMPC_severity:
147 return llvm::StringSwitch<OpenMPSeverityClauseKind>(Str)
148#define OPENMP_SEVERITY_KIND(Name) .Case(#Name, OMPC_SEVERITY_##Name)
149#include "clang/Basic/OpenMPKinds.def"
150 .Default(OMPC_SEVERITY_unknown);
151 case OMPC_lastprivate:
152 return llvm::StringSwitch<OpenMPLastprivateModifier>(Str)
153#define OPENMP_LASTPRIVATE_KIND(Name) .Case(#Name, OMPC_LASTPRIVATE_##Name)
154#include "clang/Basic/OpenMPKinds.def"
155 .Default(OMPC_LASTPRIVATE_unknown);
156 case OMPC_order:
157 return llvm::StringSwitch<unsigned>(Str)
158#define OPENMP_ORDER_KIND(Name) \
159 .Case(#Name, static_cast<unsigned>(OMPC_ORDER_##Name))
160#define OPENMP_ORDER_MODIFIER(Name) \
161 .Case(#Name, static_cast<unsigned>(OMPC_ORDER_MODIFIER_##Name))
162#include "clang/Basic/OpenMPKinds.def"
163 .Default(OMPC_ORDER_unknown);
164 case OMPC_update:
165 return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
166#define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
167#include "clang/Basic/OpenMPKinds.def"
168 .Default(OMPC_DEPEND_unknown);
169 case OMPC_device:
170 return llvm::StringSwitch<OpenMPDeviceClauseModifier>(Str)
171#define OPENMP_DEVICE_MODIFIER(Name) .Case(#Name, OMPC_DEVICE_##Name)
172#include "clang/Basic/OpenMPKinds.def"
173 .Default(OMPC_DEVICE_unknown);
174 case OMPC_reduction:
175 return llvm::StringSwitch<OpenMPReductionClauseModifier>(Str)
176#define OPENMP_REDUCTION_MODIFIER(Name) .Case(#Name, OMPC_REDUCTION_##Name)
177#include "clang/Basic/OpenMPKinds.def"
178 .Default(OMPC_REDUCTION_unknown);
179 case OMPC_adjust_args:
180 return llvm::StringSwitch<OpenMPAdjustArgsOpKind>(Str)
181#define OPENMP_ADJUST_ARGS_KIND(Name) .Case(#Name, OMPC_ADJUST_ARGS_##Name)
182#include "clang/Basic/OpenMPKinds.def"
183 .Default(OMPC_ADJUST_ARGS_unknown);
184 case OMPC_bind:
185 return llvm::StringSwitch<unsigned>(Str)
186#define OPENMP_BIND_KIND(Name) .Case(#Name, OMPC_BIND_##Name)
187#include "clang/Basic/OpenMPKinds.def"
188 .Default(OMPC_BIND_unknown);
189 case OMPC_grainsize: {
190 unsigned Type = llvm::StringSwitch<unsigned>(Str)
191#define OPENMP_GRAINSIZE_MODIFIER(Name) .Case(#Name, OMPC_GRAINSIZE_##Name)
192#include "clang/Basic/OpenMPKinds.def"
193 .Default(OMPC_GRAINSIZE_unknown);
194 if (LangOpts.OpenMP < 51)
196 return Type;
197 }
198 case OMPC_num_tasks: {
199 unsigned Type = llvm::StringSwitch<unsigned>(Str)
200#define OPENMP_NUMTASKS_MODIFIER(Name) .Case(#Name, OMPC_NUMTASKS_##Name)
201#include "clang/Basic/OpenMPKinds.def"
202 .Default(OMPC_NUMTASKS_unknown);
203 if (LangOpts.OpenMP < 51)
205 return Type;
206 }
207 case OMPC_allocate:
208 return llvm::StringSwitch<OpenMPAllocateClauseModifier>(Str)
209#define OPENMP_ALLOCATE_MODIFIER(Name) .Case(#Name, OMPC_ALLOCATE_##Name)
210#include "clang/Basic/OpenMPKinds.def"
211 .Default(OMPC_ALLOCATE_unknown);
212 case OMPC_num_threads: {
213 unsigned Type = llvm::StringSwitch<unsigned>(Str)
214#define OPENMP_NUMTHREADS_MODIFIER(Name) .Case(#Name, OMPC_NUMTHREADS_##Name)
215#include "clang/Basic/OpenMPKinds.def"
216 .Default(OMPC_NUMTHREADS_unknown);
217 if (LangOpts.OpenMP < 60)
219 return Type;
220 }
221 case OMPC_unknown:
222 case OMPC_threadprivate:
223 case OMPC_if:
224 case OMPC_final:
225 case OMPC_safelen:
226 case OMPC_simdlen:
227 case OMPC_sizes:
228 case OMPC_permutation:
229 case OMPC_allocator:
230 case OMPC_collapse:
231 case OMPC_private:
232 case OMPC_firstprivate:
233 case OMPC_shared:
234 case OMPC_task_reduction:
235 case OMPC_in_reduction:
236 case OMPC_aligned:
237 case OMPC_copyin:
238 case OMPC_copyprivate:
239 case OMPC_ordered:
240 case OMPC_nowait:
241 case OMPC_untied:
242 case OMPC_mergeable:
243 case OMPC_flush:
244 case OMPC_depobj:
245 case OMPC_read:
246 case OMPC_write:
247 case OMPC_capture:
248 case OMPC_compare:
249 case OMPC_seq_cst:
250 case OMPC_acq_rel:
251 case OMPC_acquire:
252 case OMPC_release:
253 case OMPC_relaxed:
254 case OMPC_threads:
255 case OMPC_simd:
256 case OMPC_num_teams:
257 case OMPC_thread_limit:
258 case OMPC_priority:
259 case OMPC_nogroup:
260 case OMPC_hint:
261 case OMPC_uniform:
262 case OMPC_use_device_ptr:
263 case OMPC_use_device_addr:
264 case OMPC_is_device_ptr:
265 case OMPC_has_device_addr:
266 case OMPC_unified_address:
267 case OMPC_unified_shared_memory:
268 case OMPC_reverse_offload:
269 case OMPC_dynamic_allocators:
270 case OMPC_self_maps:
271 case OMPC_match:
272 case OMPC_nontemporal:
273 case OMPC_destroy:
274 case OMPC_novariants:
275 case OMPC_nocontext:
276 case OMPC_detach:
277 case OMPC_inclusive:
278 case OMPC_exclusive:
279 case OMPC_uses_allocators:
280 case OMPC_affinity:
281 case OMPC_when:
282 case OMPC_append_args:
283 break;
284 default:
285 break;
286 }
287 llvm_unreachable("Invalid OpenMP simple clause kind");
288}
289
291 unsigned Type) {
292 switch (Kind) {
293 case OMPC_default:
294 switch (llvm::omp::DefaultKind(Type)) {
295#define OMP_DEFAULT_KIND(Enum, Name) \
296 case Enum: \
297 return Name;
298#include "llvm/Frontend/OpenMP/OMPKinds.def"
299 }
300 llvm_unreachable("Invalid OpenMP 'default' clause type");
301 case OMPC_proc_bind:
302 switch (Type) {
303#define OMP_PROC_BIND_KIND(Enum, Name, Value) \
304 case Value: \
305 return Name;
306#include "llvm/Frontend/OpenMP/OMPKinds.def"
307 }
308 llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
309 case OMPC_schedule:
310 switch (Type) {
313 return "unknown";
314#define OPENMP_SCHEDULE_KIND(Name) \
315 case OMPC_SCHEDULE_##Name: \
316 return #Name;
317#define OPENMP_SCHEDULE_MODIFIER(Name) \
318 case OMPC_SCHEDULE_MODIFIER_##Name: \
319 return #Name;
320#include "clang/Basic/OpenMPKinds.def"
321 }
322 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
323 case OMPC_depend:
324 switch (Type) {
326 return "unknown";
327#define OPENMP_DEPEND_KIND(Name) \
328 case OMPC_DEPEND_##Name: \
329 return #Name;
330#include "clang/Basic/OpenMPKinds.def"
331 }
332 llvm_unreachable("Invalid OpenMP 'depend' clause type");
333 case OMPC_doacross:
334 switch (Type) {
336 return "unknown";
337#define OPENMP_DOACROSS_MODIFIER(Name) \
338 case OMPC_DOACROSS_##Name: \
339 return #Name;
340#include "clang/Basic/OpenMPKinds.def"
341 }
342 llvm_unreachable("Invalid OpenMP 'doacross' clause type");
343 case OMPC_linear:
344 switch (Type) {
346 return "unknown";
347#define OPENMP_LINEAR_KIND(Name) \
348 case OMPC_LINEAR_##Name: \
349 return #Name;
350#include "clang/Basic/OpenMPKinds.def"
351 }
352 llvm_unreachable("Invalid OpenMP 'linear' clause type");
353 case OMPC_map:
354 switch (Type) {
355 case OMPC_MAP_unknown:
357 return "unknown";
358#define OPENMP_MAP_KIND(Name) \
359 case OMPC_MAP_##Name: \
360 return #Name;
361#define OPENMP_MAP_MODIFIER_KIND(Name) \
362 case OMPC_MAP_MODIFIER_##Name: \
363 return #Name;
364#include "clang/Basic/OpenMPKinds.def"
365 default:
366 break;
367 }
368 llvm_unreachable("Invalid OpenMP 'map' clause type");
369 case OMPC_to:
370 case OMPC_from:
371 switch (Type) {
373 return "unknown";
374#define OPENMP_MOTION_MODIFIER_KIND(Name) \
375 case OMPC_MOTION_MODIFIER_##Name: \
376 return #Name;
377#include "clang/Basic/OpenMPKinds.def"
378 default:
379 break;
380 }
381 llvm_unreachable("Invalid OpenMP 'to' or 'from' clause type");
382 case OMPC_dist_schedule:
383 switch (Type) {
385 return "unknown";
386#define OPENMP_DIST_SCHEDULE_KIND(Name) \
387 case OMPC_DIST_SCHEDULE_##Name: \
388 return #Name;
389#include "clang/Basic/OpenMPKinds.def"
390 }
391 llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
392 case OMPC_defaultmap:
393 switch (Type) {
396 return "unknown";
397#define OPENMP_DEFAULTMAP_KIND(Name) \
398 case OMPC_DEFAULTMAP_##Name: \
399 return #Name;
400#define OPENMP_DEFAULTMAP_MODIFIER(Name) \
401 case OMPC_DEFAULTMAP_MODIFIER_##Name: \
402 return #Name;
403#include "clang/Basic/OpenMPKinds.def"
404 }
405 llvm_unreachable("Invalid OpenMP 'defaultmap' clause type");
406 case OMPC_atomic_default_mem_order:
407 switch (Type) {
409 return "unknown";
410#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
411 case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name: \
412 return #Name;
413#include "clang/Basic/OpenMPKinds.def"
414}
415 llvm_unreachable("Invalid OpenMP 'atomic_default_mem_order' clause type");
416 case OMPC_device_type:
417 switch (Type) {
419 return "unknown";
420#define OPENMP_DEVICE_TYPE_KIND(Name) \
421 case OMPC_DEVICE_TYPE_##Name: \
422 return #Name;
423#include "clang/Basic/OpenMPKinds.def"
424 }
425 llvm_unreachable("Invalid OpenMP 'device_type' clause type");
426 case OMPC_at:
427 switch (Type) {
428 case OMPC_AT_unknown:
429 return "unknown";
430#define OPENMP_AT_KIND(Name) \
431 case OMPC_AT_##Name: \
432 return #Name;
433#include "clang/Basic/OpenMPKinds.def"
434 }
435 llvm_unreachable("Invalid OpenMP 'at' clause type");
436 case OMPC_severity:
437 switch (Type) {
439 return "unknown";
440#define OPENMP_SEVERITY_KIND(Name) \
441 case OMPC_SEVERITY_##Name: \
442 return #Name;
443#include "clang/Basic/OpenMPKinds.def"
444 }
445 llvm_unreachable("Invalid OpenMP 'severity' clause type");
446 case OMPC_lastprivate:
447 switch (Type) {
449 return "unknown";
450#define OPENMP_LASTPRIVATE_KIND(Name) \
451 case OMPC_LASTPRIVATE_##Name: \
452 return #Name;
453#include "clang/Basic/OpenMPKinds.def"
454 }
455 llvm_unreachable("Invalid OpenMP 'lastprivate' clause type");
456 case OMPC_order:
457 switch (Type) {
460 return "unknown";
461#define OPENMP_ORDER_KIND(Name) \
462 case OMPC_ORDER_##Name: \
463 return #Name;
464#define OPENMP_ORDER_MODIFIER(Name) \
465 case OMPC_ORDER_MODIFIER_##Name: \
466 return #Name;
467#include "clang/Basic/OpenMPKinds.def"
468 }
469 llvm_unreachable("Invalid OpenMP 'order' clause type");
470 case OMPC_update:
471 switch (Type) {
473 return "unknown";
474#define OPENMP_DEPEND_KIND(Name) \
475 case OMPC_DEPEND_##Name: \
476 return #Name;
477#include "clang/Basic/OpenMPKinds.def"
478 }
479 llvm_unreachable("Invalid OpenMP 'depend' clause type");
480 case OMPC_fail: {
481 OpenMPClauseKind CK = static_cast<OpenMPClauseKind>(Type);
482 return getOpenMPClauseName(CK).data();
483 llvm_unreachable("Invalid OpenMP 'fail' clause modifier");
484 }
485 case OMPC_device:
486 switch (Type) {
488 return "unknown";
489#define OPENMP_DEVICE_MODIFIER(Name) \
490 case OMPC_DEVICE_##Name: \
491 return #Name;
492#include "clang/Basic/OpenMPKinds.def"
493 }
494 llvm_unreachable("Invalid OpenMP 'device' clause modifier");
495 case OMPC_reduction:
496 switch (Type) {
498 return "unknown";
499#define OPENMP_REDUCTION_MODIFIER(Name) \
500 case OMPC_REDUCTION_##Name: \
501 return #Name;
502#include "clang/Basic/OpenMPKinds.def"
503 }
504 llvm_unreachable("Invalid OpenMP 'reduction' clause modifier");
505 case OMPC_adjust_args:
506 switch (Type) {
508 return "unknown";
509#define OPENMP_ADJUST_ARGS_KIND(Name) \
510 case OMPC_ADJUST_ARGS_##Name: \
511 return #Name;
512#include "clang/Basic/OpenMPKinds.def"
513 }
514 llvm_unreachable("Invalid OpenMP 'adjust_args' clause kind");
515 case OMPC_bind:
516 switch (Type) {
518 return "unknown";
519#define OPENMP_BIND_KIND(Name) \
520 case OMPC_BIND_##Name: \
521 return #Name;
522#include "clang/Basic/OpenMPKinds.def"
523 }
524 llvm_unreachable("Invalid OpenMP 'bind' clause type");
525 case OMPC_grainsize:
526 switch (Type) {
528 return "unknown";
529#define OPENMP_GRAINSIZE_MODIFIER(Name) \
530 case OMPC_GRAINSIZE_##Name: \
531 return #Name;
532#include "clang/Basic/OpenMPKinds.def"
533 }
534 llvm_unreachable("Invalid OpenMP 'grainsize' clause modifier");
535 case OMPC_num_tasks:
536 switch (Type) {
538 return "unknown";
539#define OPENMP_NUMTASKS_MODIFIER(Name) \
540 case OMPC_NUMTASKS_##Name: \
541 return #Name;
542#include "clang/Basic/OpenMPKinds.def"
543 }
544 llvm_unreachable("Invalid OpenMP 'num_tasks' clause modifier");
545 case OMPC_allocate:
546 switch (Type) {
548 return "unknown";
549#define OPENMP_ALLOCATE_MODIFIER(Name) \
550 case OMPC_ALLOCATE_##Name: \
551 return #Name;
552#include "clang/Basic/OpenMPKinds.def"
553 }
554 llvm_unreachable("Invalid OpenMP 'allocate' clause modifier");
555 case OMPC_num_threads:
556 switch (Type) {
558 return "unknown";
559#define OPENMP_NUMTHREADS_MODIFIER(Name) \
560 case OMPC_NUMTHREADS_##Name: \
561 return #Name;
562#include "clang/Basic/OpenMPKinds.def"
563 }
564 llvm_unreachable("Invalid OpenMP 'num_threads' clause modifier");
565 case OMPC_unknown:
566 case OMPC_threadprivate:
567 case OMPC_if:
568 case OMPC_final:
569 case OMPC_safelen:
570 case OMPC_simdlen:
571 case OMPC_sizes:
572 case OMPC_permutation:
573 case OMPC_allocator:
574 case OMPC_collapse:
575 case OMPC_private:
576 case OMPC_firstprivate:
577 case OMPC_shared:
578 case OMPC_task_reduction:
579 case OMPC_in_reduction:
580 case OMPC_aligned:
581 case OMPC_copyin:
582 case OMPC_copyprivate:
583 case OMPC_ordered:
584 case OMPC_nowait:
585 case OMPC_untied:
586 case OMPC_mergeable:
587 case OMPC_flush:
588 case OMPC_depobj:
589 case OMPC_read:
590 case OMPC_write:
591 case OMPC_capture:
592 case OMPC_compare:
593 case OMPC_seq_cst:
594 case OMPC_acq_rel:
595 case OMPC_acquire:
596 case OMPC_release:
597 case OMPC_relaxed:
598 case OMPC_threads:
599 case OMPC_simd:
600 case OMPC_num_teams:
601 case OMPC_thread_limit:
602 case OMPC_priority:
603 case OMPC_nogroup:
604 case OMPC_hint:
605 case OMPC_uniform:
606 case OMPC_use_device_ptr:
607 case OMPC_use_device_addr:
608 case OMPC_is_device_ptr:
609 case OMPC_has_device_addr:
610 case OMPC_unified_address:
611 case OMPC_unified_shared_memory:
612 case OMPC_reverse_offload:
613 case OMPC_dynamic_allocators:
614 case OMPC_self_maps:
615 case OMPC_match:
616 case OMPC_nontemporal:
617 case OMPC_destroy:
618 case OMPC_detach:
619 case OMPC_novariants:
620 case OMPC_nocontext:
621 case OMPC_inclusive:
622 case OMPC_exclusive:
623 case OMPC_uses_allocators:
624 case OMPC_affinity:
625 case OMPC_when:
626 case OMPC_append_args:
627 break;
628 default:
629 break;
630 }
631 llvm_unreachable("Invalid OpenMP simple clause kind");
632}
633
635 return getDirectiveAssociation(DKind) == Association::Loop;
636}
637
639 return DKind == OMPD_for || DKind == OMPD_for_simd ||
640 DKind == OMPD_sections || DKind == OMPD_section ||
641 DKind == OMPD_single || DKind == OMPD_parallel_for ||
642 DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
643 DKind == OMPD_target_parallel_for ||
644 DKind == OMPD_distribute_parallel_for ||
645 DKind == OMPD_distribute_parallel_for_simd ||
646 DKind == OMPD_target_parallel_for_simd ||
647 DKind == OMPD_teams_distribute_parallel_for_simd ||
648 DKind == OMPD_teams_distribute_parallel_for ||
649 DKind == OMPD_target_teams_distribute_parallel_for ||
650 DKind == OMPD_target_teams_distribute_parallel_for_simd ||
651 DKind == OMPD_parallel_loop || DKind == OMPD_teams_loop ||
652 DKind == OMPD_target_parallel_loop || DKind == OMPD_target_teams_loop;
653}
654
656 return DKind == OMPD_taskloop ||
657 llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
658}
659
661 if (DKind == OMPD_teams_loop)
662 return true;
663 return DKind == OMPD_parallel ||
664 llvm::is_contained(getLeafConstructs(DKind), OMPD_parallel);
665}
666
668 return DKind == OMPD_target ||
669 llvm::is_contained(getLeafConstructs(DKind), OMPD_target);
670}
671
673 return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
674 DKind == OMPD_target_exit_data || DKind == OMPD_target_update;
675}
676
678 if (DKind == OMPD_teams)
679 return true;
680 ArrayRef<Directive> Leaves = getLeafConstructs(DKind);
681 return !Leaves.empty() && Leaves.front() == OMPD_teams;
682}
683
685 return DKind == OMPD_teams ||
686 llvm::is_contained(getLeafConstructs(DKind), OMPD_teams);
687}
688
690 // Avoid OMPD_declare_simd
691 if (getDirectiveAssociation(DKind) != Association::Loop)
692 return false;
693 // Formally, OMPD_end_do_simd also has a loop association, but
694 // it's a Fortran-specific directive.
695
696 return DKind == OMPD_simd ||
697 llvm::is_contained(getLeafConstructs(DKind), OMPD_simd);
698}
699
701 if (Kind == OMPD_distribute)
702 return true;
703 ArrayRef<Directive> Leaves = getLeafConstructs(Kind);
704 return !Leaves.empty() && Leaves.front() == OMPD_distribute;
705}
706
708 return Kind == OMPD_distribute ||
709 llvm::is_contained(getLeafConstructs(Kind), OMPD_distribute);
710}
711
713 if (Kind == OMPD_loop)
714 return true;
715 ArrayRef<Directive> Leaves = getLeafConstructs(Kind);
716 return !Leaves.empty() && Leaves.back() == OMPD_loop;
717}
718
720 return Kind == OMPC_private || Kind == OMPC_firstprivate ||
721 Kind == OMPC_lastprivate || Kind == OMPC_linear ||
722 Kind == OMPC_reduction || Kind == OMPC_task_reduction ||
723 Kind == OMPC_in_reduction; // TODO add next clauses like 'reduction'.
724}
725
727 return Kind == OMPC_threadprivate || Kind == OMPC_copyin;
728}
729
731 return Kind == OMPD_task || isOpenMPTaskLoopDirective(Kind);
732}
733
735 return Kind == OMPD_distribute_parallel_for ||
736 Kind == OMPD_distribute_parallel_for_simd ||
737 Kind == OMPD_teams_distribute_parallel_for_simd ||
738 Kind == OMPD_teams_distribute_parallel_for ||
739 Kind == OMPD_target_teams_distribute_parallel_for ||
740 Kind == OMPD_target_teams_distribute_parallel_for_simd ||
741 Kind == OMPD_teams_loop || Kind == OMPD_target_teams_loop;
742}
743
745 OpenMPDirectiveKind DKind) {
746 return DKind == OMPD_tile || DKind == OMPD_unroll || DKind == OMPD_reverse ||
747 DKind == OMPD_interchange || DKind == OMPD_stripe;
748}
749
751 // FIXME: There will be more cases when we implement 'fuse'.
753}
754
756 return DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
757 DKind == OMPD_parallel_master ||
758 DKind == OMPD_parallel_master_taskloop ||
759 DKind == OMPD_parallel_master_taskloop_simd ||
760 DKind == OMPD_parallel_sections;
761}
762
764 return DKind == OMPD_target || DKind == OMPD_target_parallel ||
765 DKind == OMPD_target_parallel_for ||
766 DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
767 DKind == OMPD_target_parallel_loop;
768}
769
771 if (DKind == OMPD_error)
772 return true;
773 Category Cat = getDirectiveCategory(DKind);
774 return Cat == Category::Executable || Cat == Category::Subsidiary;
775}
776
778 if (DKind == OMPD_error)
779 return true;
780 Category Cat = getDirectiveCategory(DKind);
781 return Cat == Category::Informational;
782}
783
785 if (isOpenMPExecutableDirective(DKind)) {
786 switch (DKind) {
787 case OMPD_atomic:
788 case OMPD_barrier:
789 case OMPD_cancel:
790 case OMPD_cancellation_point:
791 case OMPD_critical:
792 case OMPD_depobj:
793 case OMPD_error:
794 case OMPD_flush:
795 case OMPD_masked:
796 case OMPD_master:
797 case OMPD_section:
798 case OMPD_taskwait:
799 case OMPD_taskyield:
800 case OMPD_assume:
801 return false;
802 default:
804 }
805 }
806 // Non-executable directives.
807 switch (DKind) {
808 case OMPD_metadirective:
809 case OMPD_nothing:
810 return true;
811 default:
812 break;
813 }
814 return false;
815}
816
818 OpenMPDirectiveKind DKind, const LangOptions &LangOpts) {
819 // Directives strictly nestable in a construct with order(concurrent) are:
820 // OpenMP 5.x: loop, parallel, simd, combined directive starting with parallel
821 // OpenMP 6.0: above plus atomic and all loop-transformation directives
822
823 if (DKind == OMPD_loop || DKind == OMPD_parallel || DKind == OMPD_simd ||
825 return true;
826
827 if (LangOpts.OpenMP >= 60)
828 return DKind == OMPD_atomic ||
830
831 return false;
832}
833
836 OpenMPDirectiveKind DKind) {
837 assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
838 assert(isOpenMPCapturingDirective(DKind) && "Expecting capturing directive");
839
840 auto GetRegionsForLeaf = [&](OpenMPDirectiveKind LKind) {
841 assert(isLeafConstruct(LKind) && "Epecting leaf directive");
842 // Whether a leaf would require OMPD_unknown if it occured on its own.
843 switch (LKind) {
844 case OMPD_metadirective:
845 CaptureRegions.push_back(OMPD_metadirective);
846 break;
847 case OMPD_nothing:
848 CaptureRegions.push_back(OMPD_nothing);
849 break;
850 case OMPD_parallel:
851 CaptureRegions.push_back(OMPD_parallel);
852 break;
853 case OMPD_target:
854 CaptureRegions.push_back(OMPD_task);
855 CaptureRegions.push_back(OMPD_target);
856 break;
857 case OMPD_task:
858 case OMPD_target_enter_data:
859 case OMPD_target_exit_data:
860 case OMPD_target_update:
861 CaptureRegions.push_back(OMPD_task);
862 break;
863 case OMPD_teams:
864 CaptureRegions.push_back(OMPD_teams);
865 break;
866 case OMPD_taskloop:
867 CaptureRegions.push_back(OMPD_taskloop);
868 break;
869 case OMPD_loop:
870 // TODO: 'loop' may require different capture regions depending on the
871 // bind clause or the parent directive when there is no bind clause.
872 // If any of the directives that push regions here are parents of 'loop',
873 // assume 'parallel'. Otherwise do nothing.
874 if (!CaptureRegions.empty() &&
875 !llvm::is_contained(CaptureRegions, OMPD_parallel))
876 CaptureRegions.push_back(OMPD_parallel);
877 else
878 return true;
879 break;
880 case OMPD_dispatch:
881 case OMPD_distribute:
882 case OMPD_for:
883 case OMPD_ordered:
884 case OMPD_scope:
885 case OMPD_sections:
886 case OMPD_simd:
887 case OMPD_single:
888 case OMPD_target_data:
889 case OMPD_taskgroup:
890 case OMPD_stripe:
891 // These directives (when standalone) use OMPD_unknown as the region,
892 // but when they're constituents of a compound directive, and other
893 // leafs from that directive have specific regions, then these directives
894 // add no additional regions.
895 return true;
896 case OMPD_masked:
897 case OMPD_master:
898 return false;
899 default:
900 llvm::errs() << getOpenMPDirectiveName(LKind, llvm::omp::FallbackVersion)
901 << '\n';
902 llvm_unreachable("Unexpected directive");
903 }
904 return false;
905 };
906
907 bool MayNeedUnknownRegion = false;
908 for (OpenMPDirectiveKind L : getLeafConstructsOrSelf(DKind))
909 MayNeedUnknownRegion |= GetRegionsForLeaf(L);
910
911 // We need OMPD_unknown when no regions were added, and specific leaf
912 // constructs were present. Push a single OMPD_unknown as the capture
913 /// region.
914 if (CaptureRegions.empty() && MayNeedUnknownRegion)
915 CaptureRegions.push_back(OMPD_unknown);
916
917 // OMPD_unknown is only expected as the only region. If other regions
918 // are present OMPD_unknown should not be present.
919 assert((CaptureRegions[0] == OMPD_unknown ||
920 !llvm::is_contained(CaptureRegions, OMPD_unknown)) &&
921 "Misplaced OMPD_unknown");
922}
923
925 return FailClauseParameter == llvm::omp::OMPC_acquire ||
926 FailClauseParameter == llvm::omp::OMPC_relaxed ||
927 FailClauseParameter == llvm::omp::OMPC_seq_cst;
928}
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
@ 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 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