clang 20.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
23unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
24 const LangOptions &LangOpts) {
25 switch (Kind) {
26 case OMPC_default:
27 return llvm::StringSwitch<unsigned>(Str)
28#define OMP_DEFAULT_KIND(Enum, Name) .Case(Name, unsigned(Enum))
29#include "llvm/Frontend/OpenMP/OMPKinds.def"
30 .Default(unsigned(llvm::omp::OMP_DEFAULT_unknown));
31 case OMPC_proc_bind:
32 return llvm::StringSwitch<unsigned>(Str)
33#define OMP_PROC_BIND_KIND(Enum, Name, Value) .Case(Name, Value)
34#include "llvm/Frontend/OpenMP/OMPKinds.def"
35 .Default(unsigned(llvm::omp::OMP_PROC_BIND_unknown));
36 case OMPC_schedule:
37 return llvm::StringSwitch<unsigned>(Str)
38#define OPENMP_SCHEDULE_KIND(Name) \
39 .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_##Name))
40#define OPENMP_SCHEDULE_MODIFIER(Name) \
41 .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_MODIFIER_##Name))
42#include "clang/Basic/OpenMPKinds.def"
43 .Default(OMPC_SCHEDULE_unknown);
44 case OMPC_depend: {
45 unsigned Type = llvm::StringSwitch<unsigned>(Str)
46#define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
47#include "clang/Basic/OpenMPKinds.def"
48 .Default(OMPC_DEPEND_unknown);
49 if (LangOpts.OpenMP < 51 && Type == OMPC_DEPEND_inoutset)
51 return Type;
52 }
53 case OMPC_doacross:
54 return llvm::StringSwitch<OpenMPDoacrossClauseModifier>(Str)
55#define OPENMP_DOACROSS_MODIFIER(Name) .Case(#Name, OMPC_DOACROSS_##Name)
56#include "clang/Basic/OpenMPKinds.def"
57 .Default(OMPC_DOACROSS_unknown);
58 case OMPC_linear:
59 return llvm::StringSwitch<OpenMPLinearClauseKind>(Str)
60#define OPENMP_LINEAR_KIND(Name) .Case(#Name, OMPC_LINEAR_##Name)
61#include "clang/Basic/OpenMPKinds.def"
62 .Default(OMPC_LINEAR_unknown);
63 case OMPC_map: {
64 unsigned Type = llvm::StringSwitch<unsigned>(Str)
65#define OPENMP_MAP_KIND(Name) \
66 .Case(#Name, static_cast<unsigned>(OMPC_MAP_##Name))
67#define OPENMP_MAP_MODIFIER_KIND(Name) \
68 .Case(#Name, static_cast<unsigned>(OMPC_MAP_MODIFIER_##Name))
69#include "clang/Basic/OpenMPKinds.def"
70 .Default(OMPC_MAP_unknown);
71 if (LangOpts.OpenMP < 51 && Type == OMPC_MAP_MODIFIER_present)
73 if (!LangOpts.OpenMPExtensions && Type == OMPC_MAP_MODIFIER_ompx_hold)
75 return Type;
76 }
77 case OMPC_to:
78 case OMPC_from: {
79 unsigned Type = llvm::StringSwitch<unsigned>(Str)
80#define OPENMP_MOTION_MODIFIER_KIND(Name) \
81 .Case(#Name, static_cast<unsigned>(OMPC_MOTION_MODIFIER_##Name))
82#include "clang/Basic/OpenMPKinds.def"
84 if (LangOpts.OpenMP < 51 && Type == OMPC_MOTION_MODIFIER_present)
86 return Type;
87 }
88 case OMPC_dist_schedule:
89 return llvm::StringSwitch<OpenMPDistScheduleClauseKind>(Str)
90#define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
91#include "clang/Basic/OpenMPKinds.def"
93 case OMPC_defaultmap:
94 return llvm::StringSwitch<unsigned>(Str)
95#define OPENMP_DEFAULTMAP_KIND(Name) \
96 .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_##Name))
97#define OPENMP_DEFAULTMAP_MODIFIER(Name) \
98 .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_MODIFIER_##Name))
99#include "clang/Basic/OpenMPKinds.def"
100 .Default(OMPC_DEFAULTMAP_unknown);
101 case OMPC_atomic_default_mem_order:
102 return llvm::StringSwitch<OpenMPAtomicDefaultMemOrderClauseKind>(Str)
103#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
104 .Case(#Name, OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name)
105#include "clang/Basic/OpenMPKinds.def"
107 case OMPC_fail:
108 return static_cast<unsigned int>(llvm::StringSwitch<llvm::omp::Clause>(Str)
109#define OPENMP_ATOMIC_FAIL_MODIFIER(Name) .Case(#Name, OMPC_##Name)
110#include "clang/Basic/OpenMPKinds.def"
111 .Default(OMPC_unknown));
112 case OMPC_device_type:
113 return llvm::StringSwitch<OpenMPDeviceType>(Str)
114#define OPENMP_DEVICE_TYPE_KIND(Name) .Case(#Name, OMPC_DEVICE_TYPE_##Name)
115#include "clang/Basic/OpenMPKinds.def"
116 .Default(OMPC_DEVICE_TYPE_unknown);
117 case OMPC_at:
118 return llvm::StringSwitch<OpenMPAtClauseKind>(Str)
119#define OPENMP_AT_KIND(Name) .Case(#Name, OMPC_AT_##Name)
120#include "clang/Basic/OpenMPKinds.def"
121 .Default(OMPC_AT_unknown);
122 case OMPC_severity:
123 return llvm::StringSwitch<OpenMPSeverityClauseKind>(Str)
124#define OPENMP_SEVERITY_KIND(Name) .Case(#Name, OMPC_SEVERITY_##Name)
125#include "clang/Basic/OpenMPKinds.def"
126 .Default(OMPC_SEVERITY_unknown);
127 case OMPC_lastprivate:
128 return llvm::StringSwitch<OpenMPLastprivateModifier>(Str)
129#define OPENMP_LASTPRIVATE_KIND(Name) .Case(#Name, OMPC_LASTPRIVATE_##Name)
130#include "clang/Basic/OpenMPKinds.def"
131 .Default(OMPC_LASTPRIVATE_unknown);
132 case OMPC_order:
133 return llvm::StringSwitch<unsigned>(Str)
134#define OPENMP_ORDER_KIND(Name) \
135 .Case(#Name, static_cast<unsigned>(OMPC_ORDER_##Name))
136#define OPENMP_ORDER_MODIFIER(Name) \
137 .Case(#Name, static_cast<unsigned>(OMPC_ORDER_MODIFIER_##Name))
138#include "clang/Basic/OpenMPKinds.def"
139 .Default(OMPC_ORDER_unknown);
140 case OMPC_update:
141 return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
142#define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
143#include "clang/Basic/OpenMPKinds.def"
144 .Default(OMPC_DEPEND_unknown);
145 case OMPC_device:
146 return llvm::StringSwitch<OpenMPDeviceClauseModifier>(Str)
147#define OPENMP_DEVICE_MODIFIER(Name) .Case(#Name, OMPC_DEVICE_##Name)
148#include "clang/Basic/OpenMPKinds.def"
149 .Default(OMPC_DEVICE_unknown);
150 case OMPC_reduction:
151 return llvm::StringSwitch<OpenMPReductionClauseModifier>(Str)
152#define OPENMP_REDUCTION_MODIFIER(Name) .Case(#Name, OMPC_REDUCTION_##Name)
153#include "clang/Basic/OpenMPKinds.def"
154 .Default(OMPC_REDUCTION_unknown);
155 case OMPC_adjust_args:
156 return llvm::StringSwitch<OpenMPAdjustArgsOpKind>(Str)
157#define OPENMP_ADJUST_ARGS_KIND(Name) .Case(#Name, OMPC_ADJUST_ARGS_##Name)
158#include "clang/Basic/OpenMPKinds.def"
159 .Default(OMPC_ADJUST_ARGS_unknown);
160 case OMPC_bind:
161 return llvm::StringSwitch<unsigned>(Str)
162#define OPENMP_BIND_KIND(Name) .Case(#Name, OMPC_BIND_##Name)
163#include "clang/Basic/OpenMPKinds.def"
164 .Default(OMPC_BIND_unknown);
165 case OMPC_grainsize: {
166 unsigned Type = llvm::StringSwitch<unsigned>(Str)
167#define OPENMP_GRAINSIZE_MODIFIER(Name) .Case(#Name, OMPC_GRAINSIZE_##Name)
168#include "clang/Basic/OpenMPKinds.def"
169 .Default(OMPC_GRAINSIZE_unknown);
170 if (LangOpts.OpenMP < 51)
172 return Type;
173 }
174 case OMPC_num_tasks: {
175 unsigned Type = llvm::StringSwitch<unsigned>(Str)
176#define OPENMP_NUMTASKS_MODIFIER(Name) .Case(#Name, OMPC_NUMTASKS_##Name)
177#include "clang/Basic/OpenMPKinds.def"
178 .Default(OMPC_NUMTASKS_unknown);
179 if (LangOpts.OpenMP < 51)
181 return Type;
182 }
183 case OMPC_unknown:
184 case OMPC_threadprivate:
185 case OMPC_if:
186 case OMPC_final:
187 case OMPC_num_threads:
188 case OMPC_safelen:
189 case OMPC_simdlen:
190 case OMPC_sizes:
191 case OMPC_allocator:
192 case OMPC_allocate:
193 case OMPC_collapse:
194 case OMPC_private:
195 case OMPC_firstprivate:
196 case OMPC_shared:
197 case OMPC_task_reduction:
198 case OMPC_in_reduction:
199 case OMPC_aligned:
200 case OMPC_copyin:
201 case OMPC_copyprivate:
202 case OMPC_ordered:
203 case OMPC_nowait:
204 case OMPC_untied:
205 case OMPC_mergeable:
206 case OMPC_flush:
207 case OMPC_depobj:
208 case OMPC_read:
209 case OMPC_write:
210 case OMPC_capture:
211 case OMPC_compare:
212 case OMPC_seq_cst:
213 case OMPC_acq_rel:
214 case OMPC_acquire:
215 case OMPC_release:
216 case OMPC_relaxed:
217 case OMPC_threads:
218 case OMPC_simd:
219 case OMPC_num_teams:
220 case OMPC_thread_limit:
221 case OMPC_priority:
222 case OMPC_nogroup:
223 case OMPC_hint:
224 case OMPC_uniform:
225 case OMPC_use_device_ptr:
226 case OMPC_use_device_addr:
227 case OMPC_is_device_ptr:
228 case OMPC_has_device_addr:
229 case OMPC_unified_address:
230 case OMPC_unified_shared_memory:
231 case OMPC_reverse_offload:
232 case OMPC_dynamic_allocators:
233 case OMPC_match:
234 case OMPC_nontemporal:
235 case OMPC_destroy:
236 case OMPC_novariants:
237 case OMPC_nocontext:
238 case OMPC_detach:
239 case OMPC_inclusive:
240 case OMPC_exclusive:
241 case OMPC_uses_allocators:
242 case OMPC_affinity:
243 case OMPC_when:
244 case OMPC_append_args:
245 break;
246 default:
247 break;
248 }
249 llvm_unreachable("Invalid OpenMP simple clause kind");
250}
251
253 unsigned Type) {
254 switch (Kind) {
255 case OMPC_default:
256 switch (llvm::omp::DefaultKind(Type)) {
257#define OMP_DEFAULT_KIND(Enum, Name) \
258 case Enum: \
259 return Name;
260#include "llvm/Frontend/OpenMP/OMPKinds.def"
261 }
262 llvm_unreachable("Invalid OpenMP 'default' clause type");
263 case OMPC_proc_bind:
264 switch (Type) {
265#define OMP_PROC_BIND_KIND(Enum, Name, Value) \
266 case Value: \
267 return Name;
268#include "llvm/Frontend/OpenMP/OMPKinds.def"
269 }
270 llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
271 case OMPC_schedule:
272 switch (Type) {
275 return "unknown";
276#define OPENMP_SCHEDULE_KIND(Name) \
277 case OMPC_SCHEDULE_##Name: \
278 return #Name;
279#define OPENMP_SCHEDULE_MODIFIER(Name) \
280 case OMPC_SCHEDULE_MODIFIER_##Name: \
281 return #Name;
282#include "clang/Basic/OpenMPKinds.def"
283 }
284 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
285 case OMPC_depend:
286 switch (Type) {
288 return "unknown";
289#define OPENMP_DEPEND_KIND(Name) \
290 case OMPC_DEPEND_##Name: \
291 return #Name;
292#include "clang/Basic/OpenMPKinds.def"
293 }
294 llvm_unreachable("Invalid OpenMP 'depend' clause type");
295 case OMPC_doacross:
296 switch (Type) {
298 return "unknown";
299#define OPENMP_DOACROSS_MODIFIER(Name) \
300 case OMPC_DOACROSS_##Name: \
301 return #Name;
302#include "clang/Basic/OpenMPKinds.def"
303 }
304 llvm_unreachable("Invalid OpenMP 'doacross' clause type");
305 case OMPC_linear:
306 switch (Type) {
308 return "unknown";
309#define OPENMP_LINEAR_KIND(Name) \
310 case OMPC_LINEAR_##Name: \
311 return #Name;
312#include "clang/Basic/OpenMPKinds.def"
313 }
314 llvm_unreachable("Invalid OpenMP 'linear' clause type");
315 case OMPC_map:
316 switch (Type) {
317 case OMPC_MAP_unknown:
319 return "unknown";
320#define OPENMP_MAP_KIND(Name) \
321 case OMPC_MAP_##Name: \
322 return #Name;
323#define OPENMP_MAP_MODIFIER_KIND(Name) \
324 case OMPC_MAP_MODIFIER_##Name: \
325 return #Name;
326#include "clang/Basic/OpenMPKinds.def"
327 default:
328 break;
329 }
330 llvm_unreachable("Invalid OpenMP 'map' clause type");
331 case OMPC_to:
332 case OMPC_from:
333 switch (Type) {
335 return "unknown";
336#define OPENMP_MOTION_MODIFIER_KIND(Name) \
337 case OMPC_MOTION_MODIFIER_##Name: \
338 return #Name;
339#include "clang/Basic/OpenMPKinds.def"
340 default:
341 break;
342 }
343 llvm_unreachable("Invalid OpenMP 'to' or 'from' clause type");
344 case OMPC_dist_schedule:
345 switch (Type) {
347 return "unknown";
348#define OPENMP_DIST_SCHEDULE_KIND(Name) \
349 case OMPC_DIST_SCHEDULE_##Name: \
350 return #Name;
351#include "clang/Basic/OpenMPKinds.def"
352 }
353 llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
354 case OMPC_defaultmap:
355 switch (Type) {
358 return "unknown";
359#define OPENMP_DEFAULTMAP_KIND(Name) \
360 case OMPC_DEFAULTMAP_##Name: \
361 return #Name;
362#define OPENMP_DEFAULTMAP_MODIFIER(Name) \
363 case OMPC_DEFAULTMAP_MODIFIER_##Name: \
364 return #Name;
365#include "clang/Basic/OpenMPKinds.def"
366 }
367 llvm_unreachable("Invalid OpenMP 'schedule' clause type");
368 case OMPC_atomic_default_mem_order:
369 switch (Type) {
371 return "unknown";
372#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
373 case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name: \
374 return #Name;
375#include "clang/Basic/OpenMPKinds.def"
376}
377 llvm_unreachable("Invalid OpenMP 'atomic_default_mem_order' clause type");
378 case OMPC_device_type:
379 switch (Type) {
381 return "unknown";
382#define OPENMP_DEVICE_TYPE_KIND(Name) \
383 case OMPC_DEVICE_TYPE_##Name: \
384 return #Name;
385#include "clang/Basic/OpenMPKinds.def"
386 }
387 llvm_unreachable("Invalid OpenMP 'device_type' clause type");
388 case OMPC_at:
389 switch (Type) {
390 case OMPC_AT_unknown:
391 return "unknown";
392#define OPENMP_AT_KIND(Name) \
393 case OMPC_AT_##Name: \
394 return #Name;
395#include "clang/Basic/OpenMPKinds.def"
396 }
397 llvm_unreachable("Invalid OpenMP 'at' clause type");
398 case OMPC_severity:
399 switch (Type) {
401 return "unknown";
402#define OPENMP_SEVERITY_KIND(Name) \
403 case OMPC_SEVERITY_##Name: \
404 return #Name;
405#include "clang/Basic/OpenMPKinds.def"
406 }
407 llvm_unreachable("Invalid OpenMP 'severity' clause type");
408 case OMPC_lastprivate:
409 switch (Type) {
411 return "unknown";
412#define OPENMP_LASTPRIVATE_KIND(Name) \
413 case OMPC_LASTPRIVATE_##Name: \
414 return #Name;
415#include "clang/Basic/OpenMPKinds.def"
416 }
417 llvm_unreachable("Invalid OpenMP 'lastprivate' clause type");
418 case OMPC_order:
419 switch (Type) {
422 return "unknown";
423#define OPENMP_ORDER_KIND(Name) \
424 case OMPC_ORDER_##Name: \
425 return #Name;
426#define OPENMP_ORDER_MODIFIER(Name) \
427 case OMPC_ORDER_MODIFIER_##Name: \
428 return #Name;
429#include "clang/Basic/OpenMPKinds.def"
430 }
431 llvm_unreachable("Invalid OpenMP 'order' clause type");
432 case OMPC_update:
433 switch (Type) {
435 return "unknown";
436#define OPENMP_DEPEND_KIND(Name) \
437 case OMPC_DEPEND_##Name: \
438 return #Name;
439#include "clang/Basic/OpenMPKinds.def"
440 }
441 llvm_unreachable("Invalid OpenMP 'depend' clause type");
442 case OMPC_fail: {
443 OpenMPClauseKind CK = static_cast<OpenMPClauseKind>(Type);
444 return getOpenMPClauseName(CK).data();
445 llvm_unreachable("Invalid OpenMP 'fail' clause modifier");
446 }
447 case OMPC_device:
448 switch (Type) {
450 return "unknown";
451#define OPENMP_DEVICE_MODIFIER(Name) \
452 case OMPC_DEVICE_##Name: \
453 return #Name;
454#include "clang/Basic/OpenMPKinds.def"
455 }
456 llvm_unreachable("Invalid OpenMP 'device' clause modifier");
457 case OMPC_reduction:
458 switch (Type) {
460 return "unknown";
461#define OPENMP_REDUCTION_MODIFIER(Name) \
462 case OMPC_REDUCTION_##Name: \
463 return #Name;
464#include "clang/Basic/OpenMPKinds.def"
465 }
466 llvm_unreachable("Invalid OpenMP 'reduction' clause modifier");
467 case OMPC_adjust_args:
468 switch (Type) {
470 return "unknown";
471#define OPENMP_ADJUST_ARGS_KIND(Name) \
472 case OMPC_ADJUST_ARGS_##Name: \
473 return #Name;
474#include "clang/Basic/OpenMPKinds.def"
475 }
476 llvm_unreachable("Invalid OpenMP 'adjust_args' clause kind");
477 case OMPC_bind:
478 switch (Type) {
480 return "unknown";
481#define OPENMP_BIND_KIND(Name) \
482 case OMPC_BIND_##Name: \
483 return #Name;
484#include "clang/Basic/OpenMPKinds.def"
485 }
486 llvm_unreachable("Invalid OpenMP 'bind' clause type");
487 case OMPC_grainsize:
488 switch (Type) {
490 return "unknown";
491#define OPENMP_GRAINSIZE_MODIFIER(Name) \
492 case OMPC_GRAINSIZE_##Name: \
493 return #Name;
494#include "clang/Basic/OpenMPKinds.def"
495 }
496 llvm_unreachable("Invalid OpenMP 'grainsize' clause modifier");
497 case OMPC_num_tasks:
498 switch (Type) {
500 return "unknown";
501#define OPENMP_NUMTASKS_MODIFIER(Name) \
502 case OMPC_NUMTASKS_##Name: \
503 return #Name;
504#include "clang/Basic/OpenMPKinds.def"
505 }
506 llvm_unreachable("Invalid OpenMP 'num_tasks' clause modifier");
507 case OMPC_unknown:
508 case OMPC_threadprivate:
509 case OMPC_if:
510 case OMPC_final:
511 case OMPC_num_threads:
512 case OMPC_safelen:
513 case OMPC_simdlen:
514 case OMPC_sizes:
515 case OMPC_allocator:
516 case OMPC_allocate:
517 case OMPC_collapse:
518 case OMPC_private:
519 case OMPC_firstprivate:
520 case OMPC_shared:
521 case OMPC_task_reduction:
522 case OMPC_in_reduction:
523 case OMPC_aligned:
524 case OMPC_copyin:
525 case OMPC_copyprivate:
526 case OMPC_ordered:
527 case OMPC_nowait:
528 case OMPC_untied:
529 case OMPC_mergeable:
530 case OMPC_flush:
531 case OMPC_depobj:
532 case OMPC_read:
533 case OMPC_write:
534 case OMPC_capture:
535 case OMPC_compare:
536 case OMPC_seq_cst:
537 case OMPC_acq_rel:
538 case OMPC_acquire:
539 case OMPC_release:
540 case OMPC_relaxed:
541 case OMPC_threads:
542 case OMPC_simd:
543 case OMPC_num_teams:
544 case OMPC_thread_limit:
545 case OMPC_priority:
546 case OMPC_nogroup:
547 case OMPC_hint:
548 case OMPC_uniform:
549 case OMPC_use_device_ptr:
550 case OMPC_use_device_addr:
551 case OMPC_is_device_ptr:
552 case OMPC_has_device_addr:
553 case OMPC_unified_address:
554 case OMPC_unified_shared_memory:
555 case OMPC_reverse_offload:
556 case OMPC_dynamic_allocators:
557 case OMPC_match:
558 case OMPC_nontemporal:
559 case OMPC_destroy:
560 case OMPC_detach:
561 case OMPC_novariants:
562 case OMPC_nocontext:
563 case OMPC_inclusive:
564 case OMPC_exclusive:
565 case OMPC_uses_allocators:
566 case OMPC_affinity:
567 case OMPC_when:
568 case OMPC_append_args:
569 break;
570 default:
571 break;
572 }
573 llvm_unreachable("Invalid OpenMP simple clause kind");
574}
575
577 return getDirectiveAssociation(DKind) == Association::Loop;
578}
579
581 return DKind == OMPD_for || DKind == OMPD_for_simd ||
582 DKind == OMPD_sections || DKind == OMPD_section ||
583 DKind == OMPD_single || DKind == OMPD_parallel_for ||
584 DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
585 DKind == OMPD_target_parallel_for ||
586 DKind == OMPD_distribute_parallel_for ||
587 DKind == OMPD_distribute_parallel_for_simd ||
588 DKind == OMPD_target_parallel_for_simd ||
589 DKind == OMPD_teams_distribute_parallel_for_simd ||
590 DKind == OMPD_teams_distribute_parallel_for ||
591 DKind == OMPD_target_teams_distribute_parallel_for ||
592 DKind == OMPD_target_teams_distribute_parallel_for_simd ||
593 DKind == OMPD_parallel_loop || DKind == OMPD_teams_loop ||
594 DKind == OMPD_target_parallel_loop || DKind == OMPD_target_teams_loop;
595}
596
598 return DKind == OMPD_taskloop ||
599 llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
600}
601
603 if (DKind == OMPD_teams_loop)
604 return true;
605 return DKind == OMPD_parallel ||
606 llvm::is_contained(getLeafConstructs(DKind), OMPD_parallel);
607}
608
610 return DKind == OMPD_target ||
611 llvm::is_contained(getLeafConstructs(DKind), OMPD_target);
612}
613
615 return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
616 DKind == OMPD_target_exit_data || DKind == OMPD_target_update;
617}
618
620 if (DKind == OMPD_teams)
621 return true;
622 ArrayRef<Directive> Leaves = getLeafConstructs(DKind);
623 return !Leaves.empty() && Leaves.front() == OMPD_teams;
624}
625
627 return DKind == OMPD_teams ||
628 llvm::is_contained(getLeafConstructs(DKind), OMPD_teams);
629}
630
632 // Avoid OMPD_declare_simd
633 if (getDirectiveAssociation(DKind) != Association::Loop)
634 return false;
635 // Formally, OMPD_end_do_simd also has a loop association, but
636 // it's a Fortran-specific directive.
637
638 return DKind == OMPD_simd ||
639 llvm::is_contained(getLeafConstructs(DKind), OMPD_simd);
640}
641
643 if (Kind == OMPD_distribute)
644 return true;
645 ArrayRef<Directive> Leaves = getLeafConstructs(Kind);
646 return !Leaves.empty() && Leaves.front() == OMPD_distribute;
647}
648
650 return Kind == OMPD_distribute ||
651 llvm::is_contained(getLeafConstructs(Kind), OMPD_distribute);
652}
653
655 if (Kind == OMPD_loop)
656 return true;
657 ArrayRef<Directive> Leaves = getLeafConstructs(Kind);
658 return !Leaves.empty() && Leaves.back() == OMPD_loop;
659}
660
662 return Kind == OMPC_private || Kind == OMPC_firstprivate ||
663 Kind == OMPC_lastprivate || Kind == OMPC_linear ||
664 Kind == OMPC_reduction || Kind == OMPC_task_reduction ||
665 Kind == OMPC_in_reduction; // TODO add next clauses like 'reduction'.
666}
667
669 return Kind == OMPC_threadprivate || Kind == OMPC_copyin;
670}
671
673 return Kind == OMPD_task || isOpenMPTaskLoopDirective(Kind);
674}
675
677 return Kind == OMPD_distribute_parallel_for ||
678 Kind == OMPD_distribute_parallel_for_simd ||
679 Kind == OMPD_teams_distribute_parallel_for_simd ||
680 Kind == OMPD_teams_distribute_parallel_for ||
681 Kind == OMPD_target_teams_distribute_parallel_for ||
682 Kind == OMPD_target_teams_distribute_parallel_for_simd ||
683 Kind == OMPD_teams_loop || Kind == OMPD_target_teams_loop;
684}
685
687 return DKind == OMPD_tile || DKind == OMPD_unroll || DKind == OMPD_reverse ||
688 DKind == OMPD_interchange;
689}
690
692 return DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
693 DKind == OMPD_parallel_master ||
694 DKind == OMPD_parallel_master_taskloop ||
695 DKind == OMPD_parallel_master_taskloop_simd ||
696 DKind == OMPD_parallel_sections;
697}
698
700 return DKind == OMPD_target || DKind == OMPD_target_parallel ||
701 DKind == OMPD_target_parallel_for ||
702 DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
703 DKind == OMPD_target_parallel_loop;
704}
705
707 if (DKind == OMPD_error)
708 return true;
709 Category Cat = getDirectiveCategory(DKind);
710 return Cat == Category::Executable || Cat == Category::Subsidiary;
711}
712
714 if (DKind == OMPD_error)
715 return true;
716 Category Cat = getDirectiveCategory(DKind);
717 return Cat == Category::Informational;
718}
719
721 if (isOpenMPExecutableDirective(DKind)) {
722 switch (DKind) {
723 case OMPD_atomic:
724 case OMPD_barrier:
725 case OMPD_cancel:
726 case OMPD_cancellation_point:
727 case OMPD_critical:
728 case OMPD_depobj:
729 case OMPD_error:
730 case OMPD_flush:
731 case OMPD_masked:
732 case OMPD_master:
733 case OMPD_section:
734 case OMPD_taskwait:
735 case OMPD_taskyield:
736 case OMPD_assume:
737 return false;
738 default:
740 }
741 }
742 // Non-executable directives.
743 switch (DKind) {
744 case OMPD_metadirective:
745 case OMPD_nothing:
746 return true;
747 default:
748 break;
749 }
750 return false;
751}
752
755 OpenMPDirectiveKind DKind) {
756 assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
757 assert(isOpenMPCapturingDirective(DKind) && "Expecting capturing directive");
758
759 auto GetRegionsForLeaf = [&](OpenMPDirectiveKind LKind) {
760 assert(isLeafConstruct(LKind) && "Epecting leaf directive");
761 // Whether a leaf would require OMPD_unknown if it occured on its own.
762 switch (LKind) {
763 case OMPD_metadirective:
764 CaptureRegions.push_back(OMPD_metadirective);
765 break;
766 case OMPD_nothing:
767 CaptureRegions.push_back(OMPD_nothing);
768 break;
769 case OMPD_parallel:
770 CaptureRegions.push_back(OMPD_parallel);
771 break;
772 case OMPD_target:
773 CaptureRegions.push_back(OMPD_task);
774 CaptureRegions.push_back(OMPD_target);
775 break;
776 case OMPD_task:
777 case OMPD_target_enter_data:
778 case OMPD_target_exit_data:
779 case OMPD_target_update:
780 CaptureRegions.push_back(OMPD_task);
781 break;
782 case OMPD_teams:
783 CaptureRegions.push_back(OMPD_teams);
784 break;
785 case OMPD_taskloop:
786 CaptureRegions.push_back(OMPD_taskloop);
787 break;
788 case OMPD_loop:
789 // TODO: 'loop' may require different capture regions depending on the
790 // bind clause or the parent directive when there is no bind clause.
791 // If any of the directives that push regions here are parents of 'loop',
792 // assume 'parallel'. Otherwise do nothing.
793 if (!CaptureRegions.empty() &&
794 !llvm::is_contained(CaptureRegions, OMPD_parallel))
795 CaptureRegions.push_back(OMPD_parallel);
796 else
797 return true;
798 break;
799 case OMPD_dispatch:
800 case OMPD_distribute:
801 case OMPD_for:
802 case OMPD_masked:
803 case OMPD_master:
804 case OMPD_ordered:
805 case OMPD_scope:
806 case OMPD_sections:
807 case OMPD_simd:
808 case OMPD_single:
809 case OMPD_target_data:
810 case OMPD_taskgroup:
811 // These directives (when standalone) use OMPD_unknown as the region,
812 // but when they're constituents of a compound directive, and other
813 // leafs from that directive have specific regions, then these directives
814 // add no additional regions.
815 return true;
816 default:
817 llvm::errs() << getOpenMPDirectiveName(LKind) << '\n';
818 llvm_unreachable("Unexpected directive");
819 }
820 return false;
821 };
822
823 bool MayNeedUnknownRegion = false;
824 for (OpenMPDirectiveKind L : getLeafConstructsOrSelf(DKind))
825 MayNeedUnknownRegion |= GetRegionsForLeaf(L);
826
827 // We need OMPD_unknown when no regions were added, and specific leaf
828 // constructs were present. Push a single OMPD_unknown as the capture
829 /// region.
830 if (CaptureRegions.empty() && MayNeedUnknownRegion)
831 CaptureRegions.push_back(OMPD_unknown);
832
833 // OMPD_unknown is only expected as the only region. If other regions
834 // are present OMPD_unknown should not be present.
835 assert((CaptureRegions[0] == OMPD_unknown ||
836 !llvm::is_contained(CaptureRegions, OMPD_unknown)) &&
837 "Misplaced OMPD_unknown");
838}
839
841 return FailClauseParameter == llvm::omp::OMPC_acquire ||
842 FailClauseParameter == llvm::omp::OMPC_relaxed ||
843 FailClauseParameter == llvm::omp::OMPC_seq_cst;
844}
845
int Category
Definition: Format.cpp:3004
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...
Definition: LangOptions.h:461
The base class of the type hierarchy.
Definition: Type.h:1829
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.
bool isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a loop transformation directive.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:24
@ OMPC_DEFAULTMAP_MODIFIER_last
Definition: OpenMPKinds.h:123
@ OMPC_ORDER_MODIFIER_last
Definition: OpenMPKinds.h:175
@ OMPC_ADJUST_ARGS_unknown
Definition: OpenMPKinds.h:196
@ OMPC_AT_unknown
Definition: OpenMPKinds.h:138
bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a distribute directive.
@ OMPC_REDUCTION_unknown
Definition: OpenMPKinds.h:189
@ OMPC_DEVICE_TYPE_unknown
Definition: OpenMPKinds.h:153
@ OMPC_SCHEDULE_MODIFIER_last
Definition: OpenMPKinds.h:43
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
Definition: OpenMPKinds.h:27
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
Definition: OpenMPKinds.h:106
@ OMPC_DOACROSS_unknown
Definition: OpenMPKinds.h:222
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
Definition: OpenMPKinds.h:203
@ OMPC_LASTPRIVATE_unknown
Definition: OpenMPKinds.h:160
@ OMPC_DEPEND_unknown
Definition: OpenMPKinds.h:58
@ OMPC_GRAINSIZE_unknown
Definition: OpenMPKinds.h:209
unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str, const LangOptions &LangOpts)
@ OMPC_NUMTASKS_unknown
Definition: OpenMPKinds.h:215
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
Definition: OpenMPKinds.h:145
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:95
@ OMPC_DEFAULTMAP_unknown
Definition: OpenMPKinds.h:114
bool isOpenMPThreadPrivate(OpenMPClauseKind Kind)
Checks if the specified clause is one of threadprivate clauses like 'threadprivate',...
@ OMPC_LINEAR_unknown
Definition: OpenMPKinds.h:66
bool isOpenMPExecutableDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is considered as "executable".
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_ATOMIC_DEFAULT_MEM_ORDER_unknown
Definition: OpenMPKinds.h:131
@ OMPC_DEVICE_unknown
Definition: OpenMPKinds.h:50
@ OMPC_MAP_MODIFIER_last
Definition: OpenMPKinds.h:83
@ OMPC_MAP_MODIFIER_unknown
Definition: OpenMPKinds.h:79
bool isOpenMPCombinedParallelADirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a combined construct for which the first construct is a parallel...
bool isOpenMPNestingDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified composite/combined directive constitutes a distribute directive in the outerm...
@ OMPC_ORDER_unknown
Definition: OpenMPKinds.h:167
@ OMPC_SCHEDULE_unknown
Definition: OpenMPKinds.h:34
bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a taskloop directive.
@ OMPC_MAP_unknown
Definition: OpenMPKinds.h:74