clang 20.0.0git
OpenMPClause.cpp
Go to the documentation of this file.
1//===- OpenMPClause.cpp - Classes for OpenMP clauses ----------------------===//
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//
9// This file implements the subclesses of Stmt class declared in OpenMPClause.h
10//
11//===----------------------------------------------------------------------===//
12
15#include "clang/AST/Attr.h"
16#include "clang/AST/Decl.h"
18#include "clang/Basic/LLVM.h"
21#include "llvm/ADT/SmallPtrSet.h"
22#include "llvm/Support/Casting.h"
23#include "llvm/Support/ErrorHandling.h"
24#include <algorithm>
25#include <cassert>
26#include <optional>
27
28using namespace clang;
29using namespace llvm;
30using namespace omp;
31
33 switch (getClauseKind()) {
34 default:
35 break;
36#define GEN_CLANG_CLAUSE_CLASS
37#define CLAUSE_CLASS(Enum, Str, Class) \
38 case Enum: \
39 return static_cast<Class *>(this)->children();
40#include "llvm/Frontend/OpenMP/OMP.inc"
41 }
42 llvm_unreachable("unknown OMPClause");
43}
44
46 switch (getClauseKind()) {
47#define GEN_CLANG_CLAUSE_CLASS
48#define CLAUSE_CLASS(Enum, Str, Class) \
49 case Enum: \
50 return static_cast<Class *>(this)->used_children();
51#define CLAUSE_NO_CLASS(Enum, Str) \
52 case Enum: \
53 break;
54#include "llvm/Frontend/OpenMP/OMP.inc"
55 }
56 llvm_unreachable("unknown OMPClause");
57}
58
60 auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
61 return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr;
62}
63
65 switch (C->getClauseKind()) {
66 case OMPC_schedule:
67 return static_cast<const OMPScheduleClause *>(C);
68 case OMPC_dist_schedule:
69 return static_cast<const OMPDistScheduleClause *>(C);
70 case OMPC_firstprivate:
71 return static_cast<const OMPFirstprivateClause *>(C);
72 case OMPC_lastprivate:
73 return static_cast<const OMPLastprivateClause *>(C);
74 case OMPC_reduction:
75 return static_cast<const OMPReductionClause *>(C);
76 case OMPC_task_reduction:
77 return static_cast<const OMPTaskReductionClause *>(C);
78 case OMPC_in_reduction:
79 return static_cast<const OMPInReductionClause *>(C);
80 case OMPC_linear:
81 return static_cast<const OMPLinearClause *>(C);
82 case OMPC_if:
83 return static_cast<const OMPIfClause *>(C);
84 case OMPC_num_threads:
85 return static_cast<const OMPNumThreadsClause *>(C);
86 case OMPC_num_teams:
87 return static_cast<const OMPNumTeamsClause *>(C);
88 case OMPC_thread_limit:
89 return static_cast<const OMPThreadLimitClause *>(C);
90 case OMPC_device:
91 return static_cast<const OMPDeviceClause *>(C);
92 case OMPC_grainsize:
93 return static_cast<const OMPGrainsizeClause *>(C);
94 case OMPC_num_tasks:
95 return static_cast<const OMPNumTasksClause *>(C);
96 case OMPC_final:
97 return static_cast<const OMPFinalClause *>(C);
98 case OMPC_priority:
99 return static_cast<const OMPPriorityClause *>(C);
100 case OMPC_novariants:
101 return static_cast<const OMPNovariantsClause *>(C);
102 case OMPC_nocontext:
103 return static_cast<const OMPNocontextClause *>(C);
104 case OMPC_filter:
105 return static_cast<const OMPFilterClause *>(C);
106 case OMPC_ompx_dyn_cgroup_mem:
107 return static_cast<const OMPXDynCGroupMemClause *>(C);
108 case OMPC_default:
109 case OMPC_proc_bind:
110 case OMPC_safelen:
111 case OMPC_simdlen:
112 case OMPC_sizes:
113 case OMPC_allocator:
114 case OMPC_allocate:
115 case OMPC_collapse:
116 case OMPC_private:
117 case OMPC_shared:
118 case OMPC_aligned:
119 case OMPC_copyin:
120 case OMPC_copyprivate:
121 case OMPC_ordered:
122 case OMPC_nowait:
123 case OMPC_untied:
124 case OMPC_mergeable:
125 case OMPC_threadprivate:
126 case OMPC_flush:
127 case OMPC_depobj:
128 case OMPC_read:
129 case OMPC_write:
130 case OMPC_update:
131 case OMPC_capture:
132 case OMPC_compare:
133 case OMPC_fail:
134 case OMPC_seq_cst:
135 case OMPC_acq_rel:
136 case OMPC_acquire:
137 case OMPC_release:
138 case OMPC_relaxed:
139 case OMPC_depend:
140 case OMPC_threads:
141 case OMPC_simd:
142 case OMPC_map:
143 case OMPC_nogroup:
144 case OMPC_hint:
145 case OMPC_defaultmap:
146 case OMPC_unknown:
147 case OMPC_uniform:
148 case OMPC_to:
149 case OMPC_from:
150 case OMPC_use_device_ptr:
151 case OMPC_use_device_addr:
152 case OMPC_is_device_ptr:
153 case OMPC_has_device_addr:
154 case OMPC_unified_address:
155 case OMPC_unified_shared_memory:
156 case OMPC_reverse_offload:
157 case OMPC_dynamic_allocators:
158 case OMPC_atomic_default_mem_order:
159 case OMPC_at:
160 case OMPC_severity:
161 case OMPC_message:
162 case OMPC_device_type:
163 case OMPC_match:
164 case OMPC_nontemporal:
165 case OMPC_order:
166 case OMPC_destroy:
167 case OMPC_detach:
168 case OMPC_inclusive:
169 case OMPC_exclusive:
170 case OMPC_uses_allocators:
171 case OMPC_affinity:
172 case OMPC_when:
173 case OMPC_bind:
174 case OMPC_ompx_bare:
175 break;
176 default:
177 break;
178 }
179
180 return nullptr;
181}
182
184 auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C));
185 return Res ? const_cast<OMPClauseWithPostUpdate *>(Res) : nullptr;
186}
187
189 switch (C->getClauseKind()) {
190 case OMPC_lastprivate:
191 return static_cast<const OMPLastprivateClause *>(C);
192 case OMPC_reduction:
193 return static_cast<const OMPReductionClause *>(C);
194 case OMPC_task_reduction:
195 return static_cast<const OMPTaskReductionClause *>(C);
196 case OMPC_in_reduction:
197 return static_cast<const OMPInReductionClause *>(C);
198 case OMPC_linear:
199 return static_cast<const OMPLinearClause *>(C);
200 case OMPC_schedule:
201 case OMPC_dist_schedule:
202 case OMPC_firstprivate:
203 case OMPC_default:
204 case OMPC_proc_bind:
205 case OMPC_if:
206 case OMPC_final:
207 case OMPC_num_threads:
208 case OMPC_safelen:
209 case OMPC_simdlen:
210 case OMPC_sizes:
211 case OMPC_allocator:
212 case OMPC_allocate:
213 case OMPC_collapse:
214 case OMPC_private:
215 case OMPC_shared:
216 case OMPC_aligned:
217 case OMPC_copyin:
218 case OMPC_copyprivate:
219 case OMPC_ordered:
220 case OMPC_nowait:
221 case OMPC_untied:
222 case OMPC_mergeable:
223 case OMPC_threadprivate:
224 case OMPC_flush:
225 case OMPC_depobj:
226 case OMPC_read:
227 case OMPC_write:
228 case OMPC_update:
229 case OMPC_capture:
230 case OMPC_compare:
231 case OMPC_fail:
232 case OMPC_seq_cst:
233 case OMPC_acq_rel:
234 case OMPC_acquire:
235 case OMPC_release:
236 case OMPC_relaxed:
237 case OMPC_depend:
238 case OMPC_device:
239 case OMPC_threads:
240 case OMPC_simd:
241 case OMPC_map:
242 case OMPC_num_teams:
243 case OMPC_thread_limit:
244 case OMPC_priority:
245 case OMPC_grainsize:
246 case OMPC_nogroup:
247 case OMPC_num_tasks:
248 case OMPC_hint:
249 case OMPC_defaultmap:
250 case OMPC_unknown:
251 case OMPC_uniform:
252 case OMPC_to:
253 case OMPC_from:
254 case OMPC_use_device_ptr:
255 case OMPC_use_device_addr:
256 case OMPC_is_device_ptr:
257 case OMPC_has_device_addr:
258 case OMPC_unified_address:
259 case OMPC_unified_shared_memory:
260 case OMPC_reverse_offload:
261 case OMPC_dynamic_allocators:
262 case OMPC_atomic_default_mem_order:
263 case OMPC_at:
264 case OMPC_severity:
265 case OMPC_message:
266 case OMPC_device_type:
267 case OMPC_match:
268 case OMPC_nontemporal:
269 case OMPC_order:
270 case OMPC_destroy:
271 case OMPC_novariants:
272 case OMPC_nocontext:
273 case OMPC_detach:
274 case OMPC_inclusive:
275 case OMPC_exclusive:
276 case OMPC_uses_allocators:
277 case OMPC_affinity:
278 case OMPC_when:
279 case OMPC_bind:
280 break;
281 default:
282 break;
283 }
284
285 return nullptr;
286}
287
288/// Gets the address of the original, non-captured, expression used in the
289/// clause as the preinitializer.
291 if (!S)
292 return nullptr;
293 if (auto *DS = dyn_cast<DeclStmt>(S)) {
294 assert(DS->isSingleDecl() && "Only single expression must be captured.");
295 if (auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl()))
296 return OED->getInitAddress();
297 }
298 return nullptr;
299}
300
303 return child_range(C, C + 1);
304 return child_range(&Condition, &Condition + 1);
305}
306
309 return child_range(C, C + 1);
310 return child_range(&Grainsize, &Grainsize + 1);
311}
312
315 return child_range(C, C + 1);
316 return child_range(&NumTasks, &NumTasks + 1);
317}
318
321 return child_range(C, C + 1);
322 return children();
323}
324
327 return child_range(C, C + 1);
328 return child_range(&Priority, &Priority + 1);
329}
330
333 return child_range(C, C + 1);
334 return children();
335}
336
339 return child_range(C, C + 1);
340 return children();
341}
342
344 unsigned NumLoops,
345 SourceLocation StartLoc,
346 SourceLocation LParenLoc,
347 SourceLocation EndLoc) {
348 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
349 auto *Clause =
350 new (Mem) OMPOrderedClause(Num, NumLoops, StartLoc, LParenLoc, EndLoc);
351 for (unsigned I = 0; I < NumLoops; ++I) {
352 Clause->setLoopNumIterations(I, nullptr);
353 Clause->setLoopCounter(I, nullptr);
354 }
355 return Clause;
356}
357
359 unsigned NumLoops) {
360 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
361 auto *Clause = new (Mem) OMPOrderedClause(NumLoops);
362 for (unsigned I = 0; I < NumLoops; ++I) {
363 Clause->setLoopNumIterations(I, nullptr);
364 Clause->setLoopCounter(I, nullptr);
365 }
366 return Clause;
367}
368
370 Expr *NumIterations) {
371 assert(NumLoop < NumberOfLoops && "out of loops number.");
372 getTrailingObjects<Expr *>()[NumLoop] = NumIterations;
373}
374
376 return llvm::ArrayRef(getTrailingObjects<Expr *>(), NumberOfLoops);
377}
378
379void OMPOrderedClause::setLoopCounter(unsigned NumLoop, Expr *Counter) {
380 assert(NumLoop < NumberOfLoops && "out of loops number.");
381 getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop] = Counter;
382}
383
385 assert(NumLoop < NumberOfLoops && "out of loops number.");
386 return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
387}
388
389const Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) const {
390 assert(NumLoop < NumberOfLoops && "out of loops number.");
391 return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
392}
393
395 SourceLocation StartLoc,
396 SourceLocation EndLoc) {
397 return new (C) OMPUpdateClause(StartLoc, EndLoc, /*IsExtended=*/false);
398}
399
402 SourceLocation LParenLoc, SourceLocation ArgumentLoc,
404 void *Mem =
405 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
406 alignof(OMPUpdateClause));
407 auto *Clause =
408 new (Mem) OMPUpdateClause(StartLoc, EndLoc, /*IsExtended=*/true);
409 Clause->setLParenLoc(LParenLoc);
410 Clause->setArgumentLoc(ArgumentLoc);
411 Clause->setDependencyKind(DK);
412 return Clause;
413}
414
416 bool IsExtended) {
417 if (!IsExtended)
418 return new (C) OMPUpdateClause(/*IsExtended=*/false);
419 void *Mem =
420 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
421 alignof(OMPUpdateClause));
422 auto *Clause = new (Mem) OMPUpdateClause(/*IsExtended=*/true);
423 Clause->IsExtended = true;
424 return Clause;
425}
426
427void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
428 assert(VL.size() == varlist_size() &&
429 "Number of private copies is not the same as the preallocated buffer");
430 std::copy(VL.begin(), VL.end(), varlist_end());
431}
432
435 SourceLocation LParenLoc, SourceLocation EndLoc,
436 ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
437 // Allocate space for private variables and initializer expressions.
438 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
439 OMPPrivateClause *Clause =
440 new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
441 Clause->setVarRefs(VL);
442 Clause->setPrivateCopies(PrivateVL);
443 return Clause;
444}
445
447 unsigned N) {
448 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
449 return new (Mem) OMPPrivateClause(N);
450}
451
452void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
453 assert(VL.size() == varlist_size() &&
454 "Number of private copies is not the same as the preallocated buffer");
455 std::copy(VL.begin(), VL.end(), varlist_end());
456}
457
458void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
459 assert(VL.size() == varlist_size() &&
460 "Number of inits is not the same as the preallocated buffer");
461 std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
462}
463
466 SourceLocation LParenLoc, SourceLocation EndLoc,
468 ArrayRef<Expr *> InitVL, Stmt *PreInit) {
469 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
470 OMPFirstprivateClause *Clause =
471 new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
472 Clause->setVarRefs(VL);
473 Clause->setPrivateCopies(PrivateVL);
474 Clause->setInits(InitVL);
475 Clause->setPreInitStmt(PreInit);
476 return Clause;
477}
478
480 unsigned N) {
481 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
482 return new (Mem) OMPFirstprivateClause(N);
483}
484
486 assert(PrivateCopies.size() == varlist_size() &&
487 "Number of private copies is not the same as the preallocated buffer");
488 std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
489}
490
491void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
492 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
493 "not the same as the "
494 "preallocated buffer");
495 std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
496}
497
498void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
499 assert(DstExprs.size() == varlist_size() && "Number of destination "
500 "expressions is not the same as "
501 "the preallocated buffer");
502 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
503}
504
505void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
506 assert(AssignmentOps.size() == varlist_size() &&
507 "Number of assignment expressions is not the same as the preallocated "
508 "buffer");
509 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
510 getDestinationExprs().end());
511}
512
514 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
516 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
518 SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate) {
519 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
520 OMPLastprivateClause *Clause = new (Mem) OMPLastprivateClause(
521 StartLoc, LParenLoc, EndLoc, LPKind, LPKindLoc, ColonLoc, VL.size());
522 Clause->setVarRefs(VL);
523 Clause->setSourceExprs(SrcExprs);
524 Clause->setDestinationExprs(DstExprs);
525 Clause->setAssignmentOps(AssignmentOps);
526 Clause->setPreInitStmt(PreInit);
527 Clause->setPostUpdateExpr(PostUpdate);
528 return Clause;
529}
530
532 unsigned N) {
533 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
534 return new (Mem) OMPLastprivateClause(N);
535}
536
538 SourceLocation StartLoc,
539 SourceLocation LParenLoc,
540 SourceLocation EndLoc,
541 ArrayRef<Expr *> VL) {
542 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
543 OMPSharedClause *Clause =
544 new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
545 Clause->setVarRefs(VL);
546 return Clause;
547}
548
550 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
551 return new (Mem) OMPSharedClause(N);
552}
553
554void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) {
555 assert(PL.size() == varlist_size() &&
556 "Number of privates is not the same as the preallocated buffer");
557 std::copy(PL.begin(), PL.end(), varlist_end());
558}
559
560void OMPLinearClause::setInits(ArrayRef<Expr *> IL) {
561 assert(IL.size() == varlist_size() &&
562 "Number of inits is not the same as the preallocated buffer");
563 std::copy(IL.begin(), IL.end(), getPrivates().end());
564}
565
567 assert(UL.size() == varlist_size() &&
568 "Number of updates is not the same as the preallocated buffer");
569 std::copy(UL.begin(), UL.end(), getInits().end());
570}
571
573 assert(FL.size() == varlist_size() &&
574 "Number of final updates is not the same as the preallocated buffer");
575 std::copy(FL.begin(), FL.end(), getUpdates().end());
576}
577
579 assert(
580 UE.size() == varlist_size() + 1 &&
581 "Number of used expressions is not the same as the preallocated buffer");
582 std::copy(UE.begin(), UE.end(), getFinals().end() + 2);
583}
584
586 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
587 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
588 SourceLocation ColonLoc, SourceLocation StepModifierLoc,
590 ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit,
591 Expr *PostUpdate) {
592 // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions
593 // (Step and CalcStep), list of used expression + step.
594 void *Mem =
595 C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1));
596 OMPLinearClause *Clause =
597 new (Mem) OMPLinearClause(StartLoc, LParenLoc, Modifier, ModifierLoc,
598 ColonLoc, StepModifierLoc, EndLoc, VL.size());
599 Clause->setVarRefs(VL);
600 Clause->setPrivates(PL);
601 Clause->setInits(IL);
602 // Fill update and final expressions with zeroes, they are provided later,
603 // after the directive construction.
604 std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
605 nullptr);
606 std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
607 nullptr);
608 std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(),
609 nullptr);
610 Clause->setStep(Step);
611 Clause->setCalcStep(CalcStep);
612 Clause->setPreInitStmt(PreInit);
613 Clause->setPostUpdateExpr(PostUpdate);
614 return Clause;
615}
616
618 unsigned NumVars) {
619 // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions
620 // (Step and CalcStep), list of used expression + step.
621 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars +1));
622 return new (Mem) OMPLinearClause(NumVars);
623}
624
626 // Range includes only non-nullptr elements.
627 return child_range(
628 reinterpret_cast<Stmt **>(getUsedExprs().begin()),
629 reinterpret_cast<Stmt **>(llvm::find(getUsedExprs(), nullptr)));
630}
631
634 SourceLocation LParenLoc, SourceLocation ColonLoc,
635 SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
636 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
637 OMPAlignedClause *Clause = new (Mem)
638 OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
639 Clause->setVarRefs(VL);
640 Clause->setAlignment(A);
641 return Clause;
642}
643
645 unsigned NumVars) {
646 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
647 return new (Mem) OMPAlignedClause(NumVars);
648}
649
651 SourceLocation StartLoc,
652 SourceLocation LParenLoc,
653 SourceLocation EndLoc) {
654 return new (C) OMPAlignClause(A, StartLoc, LParenLoc, EndLoc);
655}
656
657void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
658 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
659 "not the same as the "
660 "preallocated buffer");
661 std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
662}
663
664void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
665 assert(DstExprs.size() == varlist_size() && "Number of destination "
666 "expressions is not the same as "
667 "the preallocated buffer");
668 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
669}
670
671void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
672 assert(AssignmentOps.size() == varlist_size() &&
673 "Number of assignment expressions is not the same as the preallocated "
674 "buffer");
675 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
676 getDestinationExprs().end());
677}
678
680 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
682 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
683 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
684 OMPCopyinClause *Clause =
685 new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
686 Clause->setVarRefs(VL);
687 Clause->setSourceExprs(SrcExprs);
688 Clause->setDestinationExprs(DstExprs);
689 Clause->setAssignmentOps(AssignmentOps);
690 return Clause;
691}
692
694 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
695 return new (Mem) OMPCopyinClause(N);
696}
697
698void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
699 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
700 "not the same as the "
701 "preallocated buffer");
702 std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
703}
704
705void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
706 assert(DstExprs.size() == varlist_size() && "Number of destination "
707 "expressions is not the same as "
708 "the preallocated buffer");
709 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
710}
711
712void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
713 assert(AssignmentOps.size() == varlist_size() &&
714 "Number of assignment expressions is not the same as the preallocated "
715 "buffer");
716 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
717 getDestinationExprs().end());
718}
719
721 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
723 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
724 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
725 OMPCopyprivateClause *Clause =
726 new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
727 Clause->setVarRefs(VL);
728 Clause->setSourceExprs(SrcExprs);
729 Clause->setDestinationExprs(DstExprs);
730 Clause->setAssignmentOps(AssignmentOps);
731 return Clause;
732}
733
735 unsigned N) {
736 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
737 return new (Mem) OMPCopyprivateClause(N);
738}
739
740void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
741 assert(Privates.size() == varlist_size() &&
742 "Number of private copies is not the same as the preallocated buffer");
743 std::copy(Privates.begin(), Privates.end(), varlist_end());
744}
745
746void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
747 assert(
748 LHSExprs.size() == varlist_size() &&
749 "Number of LHS expressions is not the same as the preallocated buffer");
750 std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
751}
752
753void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
754 assert(
755 RHSExprs.size() == varlist_size() &&
756 "Number of RHS expressions is not the same as the preallocated buffer");
757 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
758}
759
760void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
761 assert(ReductionOps.size() == varlist_size() && "Number of reduction "
762 "expressions is not the same "
763 "as the preallocated buffer");
764 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
765}
766
767void OMPReductionClause::setInscanCopyOps(ArrayRef<Expr *> Ops) {
768 assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
769 assert(Ops.size() == varlist_size() && "Number of copy "
770 "expressions is not the same "
771 "as the preallocated buffer");
772 llvm::copy(Ops, getReductionOps().end());
773}
774
775void OMPReductionClause::setInscanCopyArrayTemps(
776 ArrayRef<Expr *> CopyArrayTemps) {
777 assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
778 assert(CopyArrayTemps.size() == varlist_size() &&
779 "Number of copy temp expressions is not the same as the preallocated "
780 "buffer");
781 llvm::copy(CopyArrayTemps, getInscanCopyOps().end());
782}
783
784void OMPReductionClause::setInscanCopyArrayElems(
785 ArrayRef<Expr *> CopyArrayElems) {
786 assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
787 assert(CopyArrayElems.size() == varlist_size() &&
788 "Number of copy temp expressions is not the same as the preallocated "
789 "buffer");
790 llvm::copy(CopyArrayElems, getInscanCopyArrayTemps().end());
791}
792
794 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
795 SourceLocation ModifierLoc, SourceLocation EndLoc, SourceLocation ColonLoc,
797 NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
798 ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
799 ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
800 ArrayRef<Expr *> CopyOps, ArrayRef<Expr *> CopyArrayTemps,
801 ArrayRef<Expr *> CopyArrayElems, Stmt *PreInit, Expr *PostUpdate) {
802 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(
803 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * VL.size()));
804 auto *Clause = new (Mem)
805 OMPReductionClause(StartLoc, LParenLoc, ModifierLoc, EndLoc, ColonLoc,
806 Modifier, VL.size(), QualifierLoc, NameInfo);
807 Clause->setVarRefs(VL);
808 Clause->setPrivates(Privates);
809 Clause->setLHSExprs(LHSExprs);
810 Clause->setRHSExprs(RHSExprs);
811 Clause->setReductionOps(ReductionOps);
812 Clause->setPreInitStmt(PreInit);
813 Clause->setPostUpdateExpr(PostUpdate);
814 if (Modifier == OMPC_REDUCTION_inscan) {
815 Clause->setInscanCopyOps(CopyOps);
816 Clause->setInscanCopyArrayTemps(CopyArrayTemps);
817 Clause->setInscanCopyArrayElems(CopyArrayElems);
818 } else {
819 assert(CopyOps.empty() &&
820 "copy operations are expected in inscan reductions only.");
821 assert(CopyArrayTemps.empty() &&
822 "copy array temps are expected in inscan reductions only.");
823 assert(CopyArrayElems.empty() &&
824 "copy array temps are expected in inscan reductions only.");
825 }
826 return Clause;
827}
828
832 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(
833 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * N));
834 auto *Clause = new (Mem) OMPReductionClause(N);
835 Clause->setModifier(Modifier);
836 return Clause;
837}
838
839void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
840 assert(Privates.size() == varlist_size() &&
841 "Number of private copies is not the same as the preallocated buffer");
842 std::copy(Privates.begin(), Privates.end(), varlist_end());
843}
844
845void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
846 assert(
847 LHSExprs.size() == varlist_size() &&
848 "Number of LHS expressions is not the same as the preallocated buffer");
849 std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
850}
851
852void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
853 assert(
854 RHSExprs.size() == varlist_size() &&
855 "Number of RHS expressions is not the same as the preallocated buffer");
856 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
857}
858
859void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
860 assert(ReductionOps.size() == varlist_size() && "Number of task reduction "
861 "expressions is not the same "
862 "as the preallocated buffer");
863 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
864}
865
867 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
869 NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
870 ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
871 ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
872 Expr *PostUpdate) {
873 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
875 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
876 Clause->setVarRefs(VL);
877 Clause->setPrivates(Privates);
878 Clause->setLHSExprs(LHSExprs);
879 Clause->setRHSExprs(RHSExprs);
880 Clause->setReductionOps(ReductionOps);
881 Clause->setPreInitStmt(PreInit);
882 Clause->setPostUpdateExpr(PostUpdate);
883 return Clause;
884}
885
887 unsigned N) {
888 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
889 return new (Mem) OMPTaskReductionClause(N);
890}
891
892void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
893 assert(Privates.size() == varlist_size() &&
894 "Number of private copies is not the same as the preallocated buffer");
895 std::copy(Privates.begin(), Privates.end(), varlist_end());
896}
897
898void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
899 assert(
900 LHSExprs.size() == varlist_size() &&
901 "Number of LHS expressions is not the same as the preallocated buffer");
902 std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
903}
904
905void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
906 assert(
907 RHSExprs.size() == varlist_size() &&
908 "Number of RHS expressions is not the same as the preallocated buffer");
909 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
910}
911
912void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
913 assert(ReductionOps.size() == varlist_size() && "Number of in reduction "
914 "expressions is not the same "
915 "as the preallocated buffer");
916 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
917}
918
919void OMPInReductionClause::setTaskgroupDescriptors(
920 ArrayRef<Expr *> TaskgroupDescriptors) {
921 assert(TaskgroupDescriptors.size() == varlist_size() &&
922 "Number of in reduction descriptors is not the same as the "
923 "preallocated buffer");
924 std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(),
925 getReductionOps().end());
926}
927
929 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
931 NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
932 ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
933 ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
934 ArrayRef<Expr *> TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate) {
935 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
936 OMPInReductionClause *Clause = new (Mem) OMPInReductionClause(
937 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
938 Clause->setVarRefs(VL);
939 Clause->setPrivates(Privates);
940 Clause->setLHSExprs(LHSExprs);
941 Clause->setRHSExprs(RHSExprs);
942 Clause->setReductionOps(ReductionOps);
943 Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
944 Clause->setPreInitStmt(PreInit);
945 Clause->setPostUpdateExpr(PostUpdate);
946 return Clause;
947}
948
950 unsigned N) {
951 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
952 return new (Mem) OMPInReductionClause(N);
953}
954
956 SourceLocation StartLoc,
957 SourceLocation LParenLoc,
958 SourceLocation EndLoc,
959 ArrayRef<Expr *> Sizes) {
960 OMPSizesClause *Clause = CreateEmpty(C, Sizes.size());
961 Clause->setLocStart(StartLoc);
962 Clause->setLParenLoc(LParenLoc);
963 Clause->setLocEnd(EndLoc);
964 Clause->setSizesRefs(Sizes);
965 return Clause;
966}
967
969 unsigned NumSizes) {
970 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumSizes));
971 return new (Mem) OMPSizesClause(NumSizes);
972}
973
975 SourceLocation StartLoc,
976 SourceLocation EndLoc) {
977 OMPFullClause *Clause = CreateEmpty(C);
978 Clause->setLocStart(StartLoc);
979 Clause->setLocEnd(EndLoc);
980 return Clause;
981}
982
984 return new (C) OMPFullClause();
985}
986
988 SourceLocation StartLoc,
989 SourceLocation LParenLoc,
990 SourceLocation EndLoc,
991 Expr *Factor) {
992 OMPPartialClause *Clause = CreateEmpty(C);
993 Clause->setLocStart(StartLoc);
994 Clause->setLParenLoc(LParenLoc);
995 Clause->setLocEnd(EndLoc);
996 Clause->setFactor(Factor);
997 return Clause;
998}
999
1001 return new (C) OMPPartialClause();
1002}
1003
1006 SourceLocation LParenLoc, Expr *Allocator,
1007 SourceLocation ColonLoc, SourceLocation EndLoc,
1008 ArrayRef<Expr *> VL) {
1009 // Allocate space for private variables and initializer expressions.
1010 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1011 auto *Clause = new (Mem) OMPAllocateClause(StartLoc, LParenLoc, Allocator,
1012 ColonLoc, EndLoc, VL.size());
1013 Clause->setVarRefs(VL);
1014 return Clause;
1015}
1016
1018 unsigned N) {
1019 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1020 return new (Mem) OMPAllocateClause(N);
1021}
1022
1024 SourceLocation StartLoc,
1025 SourceLocation LParenLoc,
1026 SourceLocation EndLoc,
1027 ArrayRef<Expr *> VL) {
1028 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
1029 OMPFlushClause *Clause =
1030 new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
1031 Clause->setVarRefs(VL);
1032 return Clause;
1033}
1034
1036 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1037 return new (Mem) OMPFlushClause(N);
1038}
1039
1041 SourceLocation StartLoc,
1042 SourceLocation LParenLoc,
1043 SourceLocation RParenLoc,
1044 Expr *Depobj) {
1045 auto *Clause = new (C) OMPDepobjClause(StartLoc, LParenLoc, RParenLoc);
1046 Clause->setDepobj(Depobj);
1047 return Clause;
1048}
1049
1051 return new (C) OMPDepobjClause();
1052}
1053
1056 SourceLocation LParenLoc, SourceLocation EndLoc,
1057 DependDataTy Data, Expr *DepModifier,
1058 ArrayRef<Expr *> VL, unsigned NumLoops) {
1059 void *Mem = C.Allocate(
1060 totalSizeToAlloc<Expr *>(VL.size() + /*depend-modifier*/ 1 + NumLoops),
1061 alignof(OMPDependClause));
1062 OMPDependClause *Clause = new (Mem)
1063 OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
1064 Clause->setDependencyKind(Data.DepKind);
1065 Clause->setDependencyLoc(Data.DepLoc);
1066 Clause->setColonLoc(Data.ColonLoc);
1067 Clause->setOmpAllMemoryLoc(Data.OmpAllMemoryLoc);
1068 Clause->setModifier(DepModifier);
1069 Clause->setVarRefs(VL);
1070 for (unsigned I = 0 ; I < NumLoops; ++I)
1071 Clause->setLoopData(I, nullptr);
1072 return Clause;
1073}
1074
1076 unsigned NumLoops) {
1077 void *Mem =
1078 C.Allocate(totalSizeToAlloc<Expr *>(N + /*depend-modifier*/ 1 + NumLoops),
1079 alignof(OMPDependClause));
1080 return new (Mem) OMPDependClause(N, NumLoops);
1081}
1082
1083void OMPDependClause::setLoopData(unsigned NumLoop, Expr *Cnt) {
1084 assert((getDependencyKind() == OMPC_DEPEND_sink ||
1085 getDependencyKind() == OMPC_DEPEND_source) &&
1086 NumLoop < NumLoops &&
1087 "Expected sink or source depend + loop index must be less number of "
1088 "loops.");
1089 auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1090 *It = Cnt;
1091}
1092
1094 assert((getDependencyKind() == OMPC_DEPEND_sink ||
1095 getDependencyKind() == OMPC_DEPEND_source) &&
1096 NumLoop < NumLoops &&
1097 "Expected sink or source depend + loop index must be less number of "
1098 "loops.");
1099 auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1100 return *It;
1101}
1102
1103const Expr *OMPDependClause::getLoopData(unsigned NumLoop) const {
1104 assert((getDependencyKind() == OMPC_DEPEND_sink ||
1105 getDependencyKind() == OMPC_DEPEND_source) &&
1106 NumLoop < NumLoops &&
1107 "Expected sink or source depend + loop index must be less number of "
1108 "loops.");
1109 const auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1110 return *It;
1111}
1112
1113void OMPDependClause::setModifier(Expr *DepModifier) {
1114 *getVarRefs().end() = DepModifier;
1115}
1117
1119 MappableExprComponentListsRef ComponentLists) {
1120 unsigned TotalNum = 0u;
1121 for (auto &C : ComponentLists)
1122 TotalNum += C.size();
1123 return TotalNum;
1124}
1125
1127 ArrayRef<const ValueDecl *> Declarations) {
1128 unsigned TotalNum = 0u;
1130 for (const ValueDecl *D : Declarations) {
1131 const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
1132 if (Cache.count(VD))
1133 continue;
1134 ++TotalNum;
1135 Cache.insert(VD);
1136 }
1137 return TotalNum;
1138}
1139
1141 const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1142 ArrayRef<ValueDecl *> Declarations,
1143 MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
1144 Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapModifiers,
1145 ArrayRef<SourceLocation> MapModifiersLoc,
1146 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
1147 OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc) {
1149 Sizes.NumVars = Vars.size();
1151 Sizes.NumComponentLists = ComponentLists.size();
1152 Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1153
1154 // We need to allocate:
1155 // 2 x NumVars x Expr* - we have an original list expression and an associated
1156 // user-defined mapper for each clause list entry.
1157 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1158 // with each component list.
1159 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1160 // number of lists for each unique declaration and the size of each component
1161 // list.
1162 // NumComponents x MappableComponent - the total of all the components in all
1163 // the lists.
1164 void *Mem = C.Allocate(
1165 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1167 2 * Sizes.NumVars + 1, Sizes.NumUniqueDeclarations,
1169 Sizes.NumComponents));
1170 OMPMapClause *Clause = new (Mem)
1171 OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
1172 Type, TypeIsImplicit, TypeLoc, Locs, Sizes);
1173
1174 Clause->setVarRefs(Vars);
1175 Clause->setUDMapperRefs(UDMapperRefs);
1176 Clause->setIteratorModifier(IteratorModifier);
1177 Clause->setClauseInfo(Declarations, ComponentLists);
1178 Clause->setMapType(Type);
1179 Clause->setMapLoc(TypeLoc);
1180 return Clause;
1181}
1182
1185 const OMPMappableExprListSizeTy &Sizes) {
1186 void *Mem = C.Allocate(
1187 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1189 2 * Sizes.NumVars + 1, Sizes.NumUniqueDeclarations,
1191 Sizes.NumComponents));
1192 OMPMapClause *Clause = new (Mem) OMPMapClause(Sizes);
1193 Clause->setIteratorModifier(nullptr);
1194 return Clause;
1195}
1196
1198 const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1199 ArrayRef<ValueDecl *> Declarations,
1200 MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
1201 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
1202 ArrayRef<SourceLocation> MotionModifiersLoc,
1203 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) {
1205 Sizes.NumVars = Vars.size();
1207 Sizes.NumComponentLists = ComponentLists.size();
1208 Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1209
1210 // We need to allocate:
1211 // 2 x NumVars x Expr* - we have an original list expression and an associated
1212 // user-defined mapper for each clause list entry.
1213 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1214 // with each component list.
1215 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1216 // number of lists for each unique declaration and the size of each component
1217 // list.
1218 // NumComponents x MappableComponent - the total of all the components in all
1219 // the lists.
1220 void *Mem = C.Allocate(
1221 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1223 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1225 Sizes.NumComponents));
1226
1227 auto *Clause = new (Mem) OMPToClause(MotionModifiers, MotionModifiersLoc,
1228 UDMQualifierLoc, MapperId, Locs, Sizes);
1229
1230 Clause->setVarRefs(Vars);
1231 Clause->setUDMapperRefs(UDMapperRefs);
1232 Clause->setClauseInfo(Declarations, ComponentLists);
1233 return Clause;
1234}
1235
1237 const OMPMappableExprListSizeTy &Sizes) {
1238 void *Mem = C.Allocate(
1239 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1241 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1243 Sizes.NumComponents));
1244 return new (Mem) OMPToClause(Sizes);
1245}
1246
1248 const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1249 ArrayRef<ValueDecl *> Declarations,
1250 MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
1251 ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
1252 ArrayRef<SourceLocation> MotionModifiersLoc,
1253 NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) {
1255 Sizes.NumVars = Vars.size();
1257 Sizes.NumComponentLists = ComponentLists.size();
1258 Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1259
1260 // We need to allocate:
1261 // 2 x NumVars x Expr* - we have an original list expression and an associated
1262 // user-defined mapper for each clause list entry.
1263 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1264 // with each component list.
1265 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1266 // number of lists for each unique declaration and the size of each component
1267 // list.
1268 // NumComponents x MappableComponent - the total of all the components in all
1269 // the lists.
1270 void *Mem = C.Allocate(
1271 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1273 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1275 Sizes.NumComponents));
1276
1277 auto *Clause =
1278 new (Mem) OMPFromClause(MotionModifiers, MotionModifiersLoc,
1279 UDMQualifierLoc, MapperId, Locs, Sizes);
1280
1281 Clause->setVarRefs(Vars);
1282 Clause->setUDMapperRefs(UDMapperRefs);
1283 Clause->setClauseInfo(Declarations, ComponentLists);
1284 return Clause;
1285}
1286
1289 const OMPMappableExprListSizeTy &Sizes) {
1290 void *Mem = C.Allocate(
1291 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1293 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1295 Sizes.NumComponents));
1296 return new (Mem) OMPFromClause(Sizes);
1297}
1298
1299void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) {
1300 assert(VL.size() == varlist_size() &&
1301 "Number of private copies is not the same as the preallocated buffer");
1302 std::copy(VL.begin(), VL.end(), varlist_end());
1303}
1304
1305void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) {
1306 assert(VL.size() == varlist_size() &&
1307 "Number of inits is not the same as the preallocated buffer");
1308 std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
1309}
1310
1312 const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1313 ArrayRef<Expr *> PrivateVars, ArrayRef<Expr *> Inits,
1314 ArrayRef<ValueDecl *> Declarations,
1315 MappableExprComponentListsRef ComponentLists) {
1317 Sizes.NumVars = Vars.size();
1319 Sizes.NumComponentLists = ComponentLists.size();
1320 Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1321
1322 // We need to allocate:
1323 // NumVars x Expr* - we have an original list expression for each clause
1324 // list entry.
1325 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1326 // with each component list.
1327 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1328 // number of lists for each unique declaration and the size of each component
1329 // list.
1330 // NumComponents x MappableComponent - the total of all the components in all
1331 // the lists.
1332 void *Mem = C.Allocate(
1333 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1335 3 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1337 Sizes.NumComponents));
1338
1339 OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(Locs, Sizes);
1340
1341 Clause->setVarRefs(Vars);
1342 Clause->setPrivateCopies(PrivateVars);
1343 Clause->setInits(Inits);
1344 Clause->setClauseInfo(Declarations, ComponentLists);
1345 return Clause;
1346}
1347
1350 const OMPMappableExprListSizeTy &Sizes) {
1351 void *Mem = C.Allocate(
1352 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1354 3 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1356 Sizes.NumComponents));
1357 return new (Mem) OMPUseDevicePtrClause(Sizes);
1358}
1359
1362 ArrayRef<Expr *> Vars,
1363 ArrayRef<ValueDecl *> Declarations,
1364 MappableExprComponentListsRef ComponentLists) {
1366 Sizes.NumVars = Vars.size();
1368 Sizes.NumComponentLists = ComponentLists.size();
1369 Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1370
1371 // We need to allocate:
1372 // 3 x NumVars x Expr* - we have an original list expression for each clause
1373 // list entry and an equal number of private copies and inits.
1374 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1375 // with each component list.
1376 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1377 // number of lists for each unique declaration and the size of each component
1378 // list.
1379 // NumComponents x MappableComponent - the total of all the components in all
1380 // the lists.
1381 void *Mem = C.Allocate(
1382 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1384 Sizes.NumVars, Sizes.NumUniqueDeclarations,
1386 Sizes.NumComponents));
1387
1388 auto *Clause = new (Mem) OMPUseDeviceAddrClause(Locs, Sizes);
1389
1390 Clause->setVarRefs(Vars);
1391 Clause->setClauseInfo(Declarations, ComponentLists);
1392 return Clause;
1393}
1394
1397 const OMPMappableExprListSizeTy &Sizes) {
1398 void *Mem = C.Allocate(
1399 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1401 Sizes.NumVars, Sizes.NumUniqueDeclarations,
1403 Sizes.NumComponents));
1404 return new (Mem) OMPUseDeviceAddrClause(Sizes);
1405}
1406
1409 ArrayRef<Expr *> Vars,
1410 ArrayRef<ValueDecl *> Declarations,
1411 MappableExprComponentListsRef ComponentLists) {
1413 Sizes.NumVars = Vars.size();
1415 Sizes.NumComponentLists = ComponentLists.size();
1416 Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1417
1418 // We need to allocate:
1419 // NumVars x Expr* - we have an original list expression for each clause list
1420 // entry.
1421 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1422 // with each component list.
1423 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1424 // number of lists for each unique declaration and the size of each component
1425 // list.
1426 // NumComponents x MappableComponent - the total of all the components in all
1427 // the lists.
1428 void *Mem = C.Allocate(
1429 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1431 Sizes.NumVars, Sizes.NumUniqueDeclarations,
1433 Sizes.NumComponents));
1434
1435 OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(Locs, Sizes);
1436
1437 Clause->setVarRefs(Vars);
1438 Clause->setClauseInfo(Declarations, ComponentLists);
1439 return Clause;
1440}
1441
1444 const OMPMappableExprListSizeTy &Sizes) {
1445 void *Mem = C.Allocate(
1446 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1448 Sizes.NumVars, Sizes.NumUniqueDeclarations,
1450 Sizes.NumComponents));
1451 return new (Mem) OMPIsDevicePtrClause(Sizes);
1452}
1453
1456 ArrayRef<Expr *> Vars,
1457 ArrayRef<ValueDecl *> Declarations,
1458 MappableExprComponentListsRef ComponentLists) {
1460 Sizes.NumVars = Vars.size();
1462 Sizes.NumComponentLists = ComponentLists.size();
1463 Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1464
1465 // We need to allocate:
1466 // NumVars x Expr* - we have an original list expression for each clause list
1467 // entry.
1468 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1469 // with each component list.
1470 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1471 // number of lists for each unique declaration and the size of each component
1472 // list.
1473 // NumComponents x MappableComponent - the total of all the components in all
1474 // the lists.
1475 void *Mem = C.Allocate(
1476 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1478 Sizes.NumVars, Sizes.NumUniqueDeclarations,
1480 Sizes.NumComponents));
1481
1482 auto *Clause = new (Mem) OMPHasDeviceAddrClause(Locs, Sizes);
1483
1484 Clause->setVarRefs(Vars);
1485 Clause->setClauseInfo(Declarations, ComponentLists);
1486 return Clause;
1487}
1488
1491 const OMPMappableExprListSizeTy &Sizes) {
1492 void *Mem = C.Allocate(
1493 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1495 Sizes.NumVars, Sizes.NumUniqueDeclarations,
1497 Sizes.NumComponents));
1498 return new (Mem) OMPHasDeviceAddrClause(Sizes);
1499}
1500
1502 SourceLocation StartLoc,
1503 SourceLocation LParenLoc,
1504 SourceLocation EndLoc,
1505 ArrayRef<Expr *> VL) {
1506 // Allocate space for nontemporal variables + private references.
1507 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
1508 auto *Clause =
1509 new (Mem) OMPNontemporalClause(StartLoc, LParenLoc, EndLoc, VL.size());
1510 Clause->setVarRefs(VL);
1511 return Clause;
1512}
1513
1515 unsigned N) {
1516 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
1517 return new (Mem) OMPNontemporalClause(N);
1518}
1519
1521 assert(VL.size() == varlist_size() && "Number of private references is not "
1522 "the same as the preallocated buffer");
1523 std::copy(VL.begin(), VL.end(), varlist_end());
1524}
1525
1527 SourceLocation StartLoc,
1528 SourceLocation LParenLoc,
1529 SourceLocation EndLoc,
1530 ArrayRef<Expr *> VL) {
1531 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1532 auto *Clause =
1533 new (Mem) OMPInclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1534 Clause->setVarRefs(VL);
1535 return Clause;
1536}
1537
1539 unsigned N) {
1540 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1541 return new (Mem) OMPInclusiveClause(N);
1542}
1543
1545 SourceLocation StartLoc,
1546 SourceLocation LParenLoc,
1547 SourceLocation EndLoc,
1548 ArrayRef<Expr *> VL) {
1549 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1550 auto *Clause =
1551 new (Mem) OMPExclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1552 Clause->setVarRefs(VL);
1553 return Clause;
1554}
1555
1557 unsigned N) {
1558 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1559 return new (Mem) OMPExclusiveClause(N);
1560}
1561
1562void OMPUsesAllocatorsClause::setAllocatorsData(
1564 assert(Data.size() == NumOfAllocators &&
1565 "Size of allocators data is not the same as the preallocated buffer.");
1566 for (unsigned I = 0, E = Data.size(); I < E; ++I) {
1568 getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1569 static_cast<int>(ExprOffsets::Allocator)] =
1570 D.Allocator;
1571 getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1572 static_cast<int>(
1573 ExprOffsets::AllocatorTraits)] =
1574 D.AllocatorTraits;
1575 getTrailingObjects<
1576 SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1577 static_cast<int>(ParenLocsOffsets::LParen)] =
1578 D.LParenLoc;
1579 getTrailingObjects<
1580 SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1581 static_cast<int>(ParenLocsOffsets::RParen)] =
1582 D.RParenLoc;
1583 }
1584}
1585
1589 Data.Allocator =
1590 getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1591 static_cast<int>(ExprOffsets::Allocator)];
1593 getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1594 static_cast<int>(
1595 ExprOffsets::AllocatorTraits)];
1596 Data.LParenLoc = getTrailingObjects<
1597 SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1598 static_cast<int>(ParenLocsOffsets::LParen)];
1599 Data.RParenLoc = getTrailingObjects<
1600 SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1601 static_cast<int>(ParenLocsOffsets::RParen)];
1602 return Data;
1603}
1604
1607 SourceLocation LParenLoc, SourceLocation EndLoc,
1609 void *Mem = C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1610 static_cast<int>(ExprOffsets::Total) * Data.size(),
1611 static_cast<int>(ParenLocsOffsets::Total) * Data.size()));
1612 auto *Clause = new (Mem)
1613 OMPUsesAllocatorsClause(StartLoc, LParenLoc, EndLoc, Data.size());
1614 Clause->setAllocatorsData(Data);
1615 return Clause;
1616}
1617
1620 void *Mem = C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1621 static_cast<int>(ExprOffsets::Total) * N,
1622 static_cast<int>(ParenLocsOffsets::Total) * N));
1623 return new (Mem) OMPUsesAllocatorsClause(N);
1624}
1625
1628 SourceLocation LParenLoc, SourceLocation ColonLoc,
1629 SourceLocation EndLoc, Expr *Modifier,
1630 ArrayRef<Expr *> Locators) {
1631 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Locators.size() + 1));
1632 auto *Clause = new (Mem)
1633 OMPAffinityClause(StartLoc, LParenLoc, ColonLoc, EndLoc, Locators.size());
1634 Clause->setModifier(Modifier);
1635 Clause->setVarRefs(Locators);
1636 return Clause;
1637}
1638
1640 unsigned N) {
1641 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
1642 return new (Mem) OMPAffinityClause(N);
1643}
1644
1646 OMPInteropInfo &InteropInfo,
1647 SourceLocation StartLoc,
1648 SourceLocation LParenLoc,
1649 SourceLocation VarLoc,
1650 SourceLocation EndLoc) {
1651
1652 void *Mem =
1653 C.Allocate(totalSizeToAlloc<Expr *>(InteropInfo.PreferTypes.size() + 1));
1654 auto *Clause = new (Mem) OMPInitClause(
1655 InteropInfo.IsTarget, InteropInfo.IsTargetSync, StartLoc, LParenLoc,
1656 VarLoc, EndLoc, InteropInfo.PreferTypes.size() + 1);
1657 Clause->setInteropVar(InteropVar);
1658 llvm::copy(InteropInfo.PreferTypes, Clause->getTrailingObjects<Expr *>() + 1);
1659 return Clause;
1660}
1661
1663 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1664 return new (Mem) OMPInitClause(N);
1665}
1666
1669 SourceLocation KLoc, SourceLocation StartLoc,
1670 SourceLocation LParenLoc, SourceLocation EndLoc) {
1671 return new (C) OMPBindClause(K, KLoc, StartLoc, LParenLoc, EndLoc);
1672}
1673
1675 return new (C) OMPBindClause();
1676}
1677
1680 SourceLocation LParenLoc, SourceLocation EndLoc,
1682 SourceLocation DepLoc, SourceLocation ColonLoc,
1683 ArrayRef<Expr *> VL, unsigned NumLoops) {
1684 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + NumLoops),
1685 alignof(OMPDoacrossClause));
1686 OMPDoacrossClause *Clause = new (Mem)
1687 OMPDoacrossClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
1688 Clause->setDependenceType(DepType);
1689 Clause->setDependenceLoc(DepLoc);
1690 Clause->setColonLoc(ColonLoc);
1691 Clause->setVarRefs(VL);
1692 for (unsigned I = 0; I < NumLoops; ++I)
1693 Clause->setLoopData(I, nullptr);
1694 return Clause;
1695}
1696
1698 unsigned N,
1699 unsigned NumLoops) {
1700 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + NumLoops),
1701 alignof(OMPDoacrossClause));
1702 return new (Mem) OMPDoacrossClause(N, NumLoops);
1703}
1704
1705void OMPDoacrossClause::setLoopData(unsigned NumLoop, Expr *Cnt) {
1706 assert(NumLoop < NumLoops && "Loop index must be less number of loops.");
1707 auto *It = std::next(getVarRefs().end(), NumLoop);
1708 *It = Cnt;
1709}
1710
1712 assert(NumLoop < NumLoops && "Loop index must be less number of loops.");
1713 auto *It = std::next(getVarRefs().end(), NumLoop);
1714 return *It;
1715}
1716
1717const Expr *OMPDoacrossClause::getLoopData(unsigned NumLoop) const {
1718 assert(NumLoop < NumLoops && "Loop index must be less number of loops.");
1719 const auto *It = std::next(getVarRefs().end(), NumLoop);
1720 return *It;
1721}
1722
1726 SourceLocation LLoc,
1727 SourceLocation RLoc) {
1728 void *Mem = C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(DKVec.size()),
1729 alignof(OMPAbsentClause));
1730 auto *AC = new (Mem) OMPAbsentClause(Loc, LLoc, RLoc, DKVec.size());
1731 AC->setDirectiveKinds(DKVec);
1732 return AC;
1733}
1734
1736 void *Mem = C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(K),
1737 alignof(OMPAbsentClause));
1738 return new (Mem) OMPAbsentClause(K);
1739}
1740
1744 void *Mem = C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(DKVec.size()),
1745 alignof(OMPContainsClause));
1746 auto *CC = new (Mem) OMPContainsClause(Loc, LLoc, RLoc, DKVec.size());
1747 CC->setDirectiveKinds(DKVec);
1748 return CC;
1749}
1750
1752 unsigned K) {
1753 void *Mem = C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(K),
1754 alignof(OMPContainsClause));
1755 return new (Mem) OMPContainsClause(K);
1756}
1757
1759 const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
1760 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
1761 ArrayRef<Expr *> VL, Stmt *PreInit) {
1762 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1763 OMPNumTeamsClause *Clause =
1764 new (Mem) OMPNumTeamsClause(C, StartLoc, LParenLoc, EndLoc, VL.size());
1765 Clause->setVarRefs(VL);
1766 Clause->setPreInitStmt(PreInit, CaptureRegion);
1767 return Clause;
1768}
1769
1771 unsigned N) {
1772 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1773 return new (Mem) OMPNumTeamsClause(N);
1774}
1775
1777 const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
1778 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
1779 ArrayRef<Expr *> VL, Stmt *PreInit) {
1780 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1781 OMPThreadLimitClause *Clause =
1782 new (Mem) OMPThreadLimitClause(C, StartLoc, LParenLoc, EndLoc, VL.size());
1783 Clause->setVarRefs(VL);
1784 Clause->setPreInitStmt(PreInit, CaptureRegion);
1785 return Clause;
1786}
1787
1789 unsigned N) {
1790 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1791 return new (Mem) OMPThreadLimitClause(N);
1792}
1793
1794//===----------------------------------------------------------------------===//
1795// OpenMP clauses printing methods
1796//===----------------------------------------------------------------------===//
1797
1798void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) {
1799 OS << "if(";
1800 if (Node->getNameModifier() != OMPD_unknown)
1801 OS << getOpenMPDirectiveName(Node->getNameModifier()) << ": ";
1802 Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
1803 OS << ")";
1804}
1805
1806void OMPClausePrinter::VisitOMPFinalClause(OMPFinalClause *Node) {
1807 OS << "final(";
1808 Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
1809 OS << ")";
1810}
1811
1812void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) {
1813 OS << "num_threads(";
1814 Node->getNumThreads()->printPretty(OS, nullptr, Policy, 0);
1815 OS << ")";
1816}
1817
1818void OMPClausePrinter::VisitOMPAlignClause(OMPAlignClause *Node) {
1819 OS << "align(";
1820 Node->getAlignment()->printPretty(OS, nullptr, Policy, 0);
1821 OS << ")";
1822}
1823
1824void OMPClausePrinter::VisitOMPSafelenClause(OMPSafelenClause *Node) {
1825 OS << "safelen(";
1826 Node->getSafelen()->printPretty(OS, nullptr, Policy, 0);
1827 OS << ")";
1828}
1829
1830void OMPClausePrinter::VisitOMPSimdlenClause(OMPSimdlenClause *Node) {
1831 OS << "simdlen(";
1832 Node->getSimdlen()->printPretty(OS, nullptr, Policy, 0);
1833 OS << ")";
1834}
1835
1836void OMPClausePrinter::VisitOMPSizesClause(OMPSizesClause *Node) {
1837 OS << "sizes(";
1838 bool First = true;
1839 for (auto *Size : Node->getSizesRefs()) {
1840 if (!First)
1841 OS << ", ";
1842 Size->printPretty(OS, nullptr, Policy, 0);
1843 First = false;
1844 }
1845 OS << ")";
1846}
1847
1848void OMPClausePrinter::VisitOMPFullClause(OMPFullClause *Node) { OS << "full"; }
1849
1850void OMPClausePrinter::VisitOMPPartialClause(OMPPartialClause *Node) {
1851 OS << "partial";
1852
1853 if (Expr *Factor = Node->getFactor()) {
1854 OS << '(';
1855 Factor->printPretty(OS, nullptr, Policy, 0);
1856 OS << ')';
1857 }
1858}
1859
1860void OMPClausePrinter::VisitOMPAllocatorClause(OMPAllocatorClause *Node) {
1861 OS << "allocator(";
1862 Node->getAllocator()->printPretty(OS, nullptr, Policy, 0);
1863 OS << ")";
1864}
1865
1866void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) {
1867 OS << "collapse(";
1868 Node->getNumForLoops()->printPretty(OS, nullptr, Policy, 0);
1869 OS << ")";
1870}
1871
1872void OMPClausePrinter::VisitOMPDetachClause(OMPDetachClause *Node) {
1873 OS << "detach(";
1874 Node->getEventHandler()->printPretty(OS, nullptr, Policy, 0);
1875 OS << ")";
1876}
1877
1878void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) {
1879 OS << "default("
1880 << getOpenMPSimpleClauseTypeName(OMPC_default,
1881 unsigned(Node->getDefaultKind()))
1882 << ")";
1883}
1884
1885void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
1886 OS << "proc_bind("
1887 << getOpenMPSimpleClauseTypeName(OMPC_proc_bind,
1888 unsigned(Node->getProcBindKind()))
1889 << ")";
1890}
1891
1892void OMPClausePrinter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {
1893 OS << "unified_address";
1894}
1895
1896void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
1898 OS << "unified_shared_memory";
1899}
1900
1901void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {
1902 OS << "reverse_offload";
1903}
1904
1905void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
1907 OS << "dynamic_allocators";
1908}
1909
1910void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
1912 OS << "atomic_default_mem_order("
1913 << getOpenMPSimpleClauseTypeName(OMPC_atomic_default_mem_order,
1914 Node->getAtomicDefaultMemOrderKind())
1915 << ")";
1916}
1917
1918void OMPClausePrinter::VisitOMPAtClause(OMPAtClause *Node) {
1919 OS << "at(" << getOpenMPSimpleClauseTypeName(OMPC_at, Node->getAtKind())
1920 << ")";
1921}
1922
1923void OMPClausePrinter::VisitOMPSeverityClause(OMPSeverityClause *Node) {
1924 OS << "severity("
1925 << getOpenMPSimpleClauseTypeName(OMPC_severity, Node->getSeverityKind())
1926 << ")";
1927}
1928
1929void OMPClausePrinter::VisitOMPMessageClause(OMPMessageClause *Node) {
1930 OS << "message(\""
1931 << cast<StringLiteral>(Node->getMessageString())->getString() << "\")";
1932}
1933
1934void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
1935 OS << "schedule(";
1936 if (Node->getFirstScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) {
1937 OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
1938 Node->getFirstScheduleModifier());
1939 if (Node->getSecondScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) {
1940 OS << ", ";
1941 OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
1942 Node->getSecondScheduleModifier());
1943 }
1944 OS << ": ";
1945 }
1946 OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, Node->getScheduleKind());
1947 if (auto *E = Node->getChunkSize()) {
1948 OS << ", ";
1949 E->printPretty(OS, nullptr, Policy);
1950 }
1951 OS << ")";
1952}
1953
1954void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) {
1955 OS << "ordered";
1956 if (auto *Num = Node->getNumForLoops()) {
1957 OS << "(";
1958 Num->printPretty(OS, nullptr, Policy, 0);
1959 OS << ")";
1960 }
1961}
1962
1963void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) {
1964 OS << "nowait";
1965}
1966
1967void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) {
1968 OS << "untied";
1969}
1970
1971void OMPClausePrinter::VisitOMPNogroupClause(OMPNogroupClause *) {
1972 OS << "nogroup";
1973}
1974
1975void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) {
1976 OS << "mergeable";
1977}
1978
1979void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; }
1980
1981void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; }
1982
1983void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *Node) {
1984 OS << "update";
1985 if (Node->isExtended()) {
1986 OS << "(";
1987 OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
1988 Node->getDependencyKind());
1989 OS << ")";
1990 }
1991}
1992
1993void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {
1994 OS << "capture";
1995}
1996
1997void OMPClausePrinter::VisitOMPCompareClause(OMPCompareClause *) {
1998 OS << "compare";
1999}
2000
2001void OMPClausePrinter::VisitOMPFailClause(OMPFailClause *Node) {
2002 OS << "fail";
2003 if (Node) {
2004 OS << "(";
2006 Node->getClauseKind(), static_cast<int>(Node->getFailParameter()));
2007 OS << ")";
2008 }
2009}
2010
2011void OMPClausePrinter::VisitOMPAbsentClause(OMPAbsentClause *Node) {
2012 OS << "absent(";
2013 bool First = true;
2014 for (auto &D : Node->getDirectiveKinds()) {
2015 if (!First)
2016 OS << ", ";
2017 OS << getOpenMPDirectiveName(D);
2018 First = false;
2019 }
2020 OS << ")";
2021}
2022
2023void OMPClausePrinter::VisitOMPHoldsClause(OMPHoldsClause *Node) {
2024 OS << "holds(";
2025 Node->getExpr()->printPretty(OS, nullptr, Policy, 0);
2026 OS << ")";
2027}
2028
2029void OMPClausePrinter::VisitOMPContainsClause(OMPContainsClause *Node) {
2030 OS << "contains(";
2031 bool First = true;
2032 for (auto &D : Node->getDirectiveKinds()) {
2033 if (!First)
2034 OS << ", ";
2035 OS << getOpenMPDirectiveName(D);
2036 First = false;
2037 }
2038 OS << ")";
2039}
2040
2041void OMPClausePrinter::VisitOMPNoOpenMPClause(OMPNoOpenMPClause *) {
2042 OS << "no_openmp";
2043}
2044
2045void OMPClausePrinter::VisitOMPNoOpenMPRoutinesClause(
2047 OS << "no_openmp_routines";
2048}
2049
2050void OMPClausePrinter::VisitOMPNoParallelismClause(OMPNoParallelismClause *) {
2051 OS << "no_parallelism";
2052}
2053
2054void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
2055 OS << "seq_cst";
2056}
2057
2058void OMPClausePrinter::VisitOMPAcqRelClause(OMPAcqRelClause *) {
2059 OS << "acq_rel";
2060}
2061
2062void OMPClausePrinter::VisitOMPAcquireClause(OMPAcquireClause *) {
2063 OS << "acquire";
2064}
2065
2066void OMPClausePrinter::VisitOMPReleaseClause(OMPReleaseClause *) {
2067 OS << "release";
2068}
2069
2070void OMPClausePrinter::VisitOMPRelaxedClause(OMPRelaxedClause *) {
2071 OS << "relaxed";
2072}
2073
2074void OMPClausePrinter::VisitOMPWeakClause(OMPWeakClause *) { OS << "weak"; }
2075
2076void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) {
2077 OS << "threads";
2078}
2079
2080void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) { OS << "simd"; }
2081
2082void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) {
2083 OS << "device(";
2084 OpenMPDeviceClauseModifier Modifier = Node->getModifier();
2085 if (Modifier != OMPC_DEVICE_unknown) {
2086 OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), Modifier)
2087 << ": ";
2088 }
2089 Node->getDevice()->printPretty(OS, nullptr, Policy, 0);
2090 OS << ")";
2091}
2092
2093void OMPClausePrinter::VisitOMPNumTeamsClause(OMPNumTeamsClause *Node) {
2094 if (!Node->varlist_empty()) {
2095 OS << "num_teams";
2096 VisitOMPClauseList(Node, '(');
2097 OS << ")";
2098 }
2099}
2100
2101void OMPClausePrinter::VisitOMPThreadLimitClause(OMPThreadLimitClause *Node) {
2102 if (!Node->varlist_empty()) {
2103 OS << "thread_limit";
2104 VisitOMPClauseList(Node, '(');
2105 OS << ")";
2106 }
2107}
2108
2109void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) {
2110 OS << "priority(";
2111 Node->getPriority()->printPretty(OS, nullptr, Policy, 0);
2112 OS << ")";
2113}
2114
2115void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) {
2116 OS << "grainsize(";
2117 OpenMPGrainsizeClauseModifier Modifier = Node->getModifier();
2118 if (Modifier != OMPC_GRAINSIZE_unknown) {
2119 OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), Modifier)
2120 << ": ";
2121 }
2122 Node->getGrainsize()->printPretty(OS, nullptr, Policy, 0);
2123 OS << ")";
2124}
2125
2126void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) {
2127 OS << "num_tasks(";
2128 OpenMPNumTasksClauseModifier Modifier = Node->getModifier();
2129 if (Modifier != OMPC_NUMTASKS_unknown) {
2130 OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), Modifier)
2131 << ": ";
2132 }
2133 Node->getNumTasks()->printPretty(OS, nullptr, Policy, 0);
2134 OS << ")";
2135}
2136
2137void OMPClausePrinter::VisitOMPHintClause(OMPHintClause *Node) {
2138 OS << "hint(";
2139 Node->getHint()->printPretty(OS, nullptr, Policy, 0);
2140 OS << ")";
2141}
2142
2143void OMPClausePrinter::VisitOMPInitClause(OMPInitClause *Node) {
2144 OS << "init(";
2145 bool First = true;
2146 for (const Expr *E : Node->prefs()) {
2147 if (First)
2148 OS << "prefer_type(";
2149 else
2150 OS << ",";
2151 E->printPretty(OS, nullptr, Policy);
2152 First = false;
2153 }
2154 if (!First)
2155 OS << "), ";
2156 if (Node->getIsTarget())
2157 OS << "target";
2158 if (Node->getIsTargetSync()) {
2159 if (Node->getIsTarget())
2160 OS << ", ";
2161 OS << "targetsync";
2162 }
2163 OS << " : ";
2164 Node->getInteropVar()->printPretty(OS, nullptr, Policy);
2165 OS << ")";
2166}
2167
2168void OMPClausePrinter::VisitOMPUseClause(OMPUseClause *Node) {
2169 OS << "use(";
2170 Node->getInteropVar()->printPretty(OS, nullptr, Policy);
2171 OS << ")";
2172}
2173
2174void OMPClausePrinter::VisitOMPDestroyClause(OMPDestroyClause *Node) {
2175 OS << "destroy";
2176 if (Expr *E = Node->getInteropVar()) {
2177 OS << "(";
2178 E->printPretty(OS, nullptr, Policy);
2179 OS << ")";
2180 }
2181}
2182
2183void OMPClausePrinter::VisitOMPNovariantsClause(OMPNovariantsClause *Node) {
2184 OS << "novariants";
2185 if (Expr *E = Node->getCondition()) {
2186 OS << "(";
2187 E->printPretty(OS, nullptr, Policy, 0);
2188 OS << ")";
2189 }
2190}
2191
2192void OMPClausePrinter::VisitOMPNocontextClause(OMPNocontextClause *Node) {
2193 OS << "nocontext";
2194 if (Expr *E = Node->getCondition()) {
2195 OS << "(";
2196 E->printPretty(OS, nullptr, Policy, 0);
2197 OS << ")";
2198 }
2199}
2200
2201template<typename T>
2202void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
2203 for (typename T::varlist_iterator I = Node->varlist_begin(),
2204 E = Node->varlist_end();
2205 I != E; ++I) {
2206 assert(*I && "Expected non-null Stmt");
2207 OS << (I == Node->varlist_begin() ? StartSym : ',');
2208 if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
2209 if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
2210 DRE->printPretty(OS, nullptr, Policy, 0);
2211 else
2212 DRE->getDecl()->printQualifiedName(OS);
2213 } else
2214 (*I)->printPretty(OS, nullptr, Policy, 0);
2215 }
2216}
2217
2218void OMPClausePrinter::VisitOMPAllocateClause(OMPAllocateClause *Node) {
2219 if (Node->varlist_empty())
2220 return;
2221 OS << "allocate";
2222 if (Expr *Allocator = Node->getAllocator()) {
2223 OS << "(";
2224 Allocator->printPretty(OS, nullptr, Policy, 0);
2225 OS << ":";
2226 VisitOMPClauseList(Node, ' ');
2227 } else {
2228 VisitOMPClauseList(Node, '(');
2229 }
2230 OS << ")";
2231}
2232
2233void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) {
2234 if (!Node->varlist_empty()) {
2235 OS << "private";
2236 VisitOMPClauseList(Node, '(');
2237 OS << ")";
2238 }
2239}
2240
2241void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) {
2242 if (!Node->varlist_empty()) {
2243 OS << "firstprivate";
2244 VisitOMPClauseList(Node, '(');
2245 OS << ")";
2246 }
2247}
2248
2249void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) {
2250 if (!Node->varlist_empty()) {
2251 OS << "lastprivate";
2252 OpenMPLastprivateModifier LPKind = Node->getKind();
2253 if (LPKind != OMPC_LASTPRIVATE_unknown) {
2254 OS << "("
2255 << getOpenMPSimpleClauseTypeName(OMPC_lastprivate, Node->getKind())
2256 << ":";
2257 }
2258 VisitOMPClauseList(Node, LPKind == OMPC_LASTPRIVATE_unknown ? '(' : ' ');
2259 OS << ")";
2260 }
2261}
2262
2263void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) {
2264 if (!Node->varlist_empty()) {
2265 OS << "shared";
2266 VisitOMPClauseList(Node, '(');
2267 OS << ")";
2268 }
2269}
2270
2271void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) {
2272 if (!Node->varlist_empty()) {
2273 OS << "reduction(";
2274 if (Node->getModifierLoc().isValid())
2275 OS << getOpenMPSimpleClauseTypeName(OMPC_reduction, Node->getModifier())
2276 << ", ";
2277 NestedNameSpecifier *QualifierLoc =
2278 Node->getQualifierLoc().getNestedNameSpecifier();
2280 Node->getNameInfo().getName().getCXXOverloadedOperator();
2281 if (QualifierLoc == nullptr && OOK != OO_None) {
2282 // Print reduction identifier in C format
2283 OS << getOperatorSpelling(OOK);
2284 } else {
2285 // Use C++ format
2286 if (QualifierLoc != nullptr)
2287 QualifierLoc->print(OS, Policy);
2288 OS << Node->getNameInfo();
2289 }
2290 OS << ":";
2291 VisitOMPClauseList(Node, ' ');
2292 OS << ")";
2293 }
2294}
2295
2296void OMPClausePrinter::VisitOMPTaskReductionClause(
2298 if (!Node->varlist_empty()) {
2299 OS << "task_reduction(";
2300 NestedNameSpecifier *QualifierLoc =
2301 Node->getQualifierLoc().getNestedNameSpecifier();
2303 Node->getNameInfo().getName().getCXXOverloadedOperator();
2304 if (QualifierLoc == nullptr && OOK != OO_None) {
2305 // Print reduction identifier in C format
2306 OS << getOperatorSpelling(OOK);
2307 } else {
2308 // Use C++ format
2309 if (QualifierLoc != nullptr)
2310 QualifierLoc->print(OS, Policy);
2311 OS << Node->getNameInfo();
2312 }
2313 OS << ":";
2314 VisitOMPClauseList(Node, ' ');
2315 OS << ")";
2316 }
2317}
2318
2319void OMPClausePrinter::VisitOMPInReductionClause(OMPInReductionClause *Node) {
2320 if (!Node->varlist_empty()) {
2321 OS << "in_reduction(";
2322 NestedNameSpecifier *QualifierLoc =
2323 Node->getQualifierLoc().getNestedNameSpecifier();
2325 Node->getNameInfo().getName().getCXXOverloadedOperator();
2326 if (QualifierLoc == nullptr && OOK != OO_None) {
2327 // Print reduction identifier in C format
2328 OS << getOperatorSpelling(OOK);
2329 } else {
2330 // Use C++ format
2331 if (QualifierLoc != nullptr)
2332 QualifierLoc->print(OS, Policy);
2333 OS << Node->getNameInfo();
2334 }
2335 OS << ":";
2336 VisitOMPClauseList(Node, ' ');
2337 OS << ")";
2338 }
2339}
2340
2341void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) {
2342 if (!Node->varlist_empty()) {
2343 OS << "linear";
2344 VisitOMPClauseList(Node, '(');
2345 if (Node->getModifierLoc().isValid() || Node->getStep() != nullptr) {
2346 OS << ": ";
2347 }
2348 if (Node->getModifierLoc().isValid()) {
2349 OS << getOpenMPSimpleClauseTypeName(OMPC_linear, Node->getModifier());
2350 }
2351 if (Node->getStep() != nullptr) {
2352 if (Node->getModifierLoc().isValid()) {
2353 OS << ", ";
2354 }
2355 OS << "step(";
2356 Node->getStep()->printPretty(OS, nullptr, Policy, 0);
2357 OS << ")";
2358 }
2359 OS << ")";
2360 }
2361}
2362
2363void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) {
2364 if (!Node->varlist_empty()) {
2365 OS << "aligned";
2366 VisitOMPClauseList(Node, '(');
2367 if (Node->getAlignment() != nullptr) {
2368 OS << ": ";
2369 Node->getAlignment()->printPretty(OS, nullptr, Policy, 0);
2370 }
2371 OS << ")";
2372 }
2373}
2374
2375void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) {
2376 if (!Node->varlist_empty()) {
2377 OS << "copyin";
2378 VisitOMPClauseList(Node, '(');
2379 OS << ")";
2380 }
2381}
2382
2383void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) {
2384 if (!Node->varlist_empty()) {
2385 OS << "copyprivate";
2386 VisitOMPClauseList(Node, '(');
2387 OS << ")";
2388 }
2389}
2390
2391void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) {
2392 if (!Node->varlist_empty()) {
2393 VisitOMPClauseList(Node, '(');
2394 OS << ")";
2395 }
2396}
2397
2398void OMPClausePrinter::VisitOMPDepobjClause(OMPDepobjClause *Node) {
2399 OS << "(";
2400 Node->getDepobj()->printPretty(OS, nullptr, Policy, 0);
2401 OS << ")";
2402}
2403
2404void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) {
2405 OS << "depend(";
2406 if (Expr *DepModifier = Node->getModifier()) {
2407 DepModifier->printPretty(OS, nullptr, Policy);
2408 OS << ", ";
2409 }
2410 OpenMPDependClauseKind DepKind = Node->getDependencyKind();
2411 OpenMPDependClauseKind PrintKind = DepKind;
2412 bool IsOmpAllMemory = false;
2413 if (PrintKind == OMPC_DEPEND_outallmemory) {
2414 PrintKind = OMPC_DEPEND_out;
2415 IsOmpAllMemory = true;
2416 } else if (PrintKind == OMPC_DEPEND_inoutallmemory) {
2417 PrintKind = OMPC_DEPEND_inout;
2418 IsOmpAllMemory = true;
2419 }
2420 OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), PrintKind);
2421 if (!Node->varlist_empty() || IsOmpAllMemory)
2422 OS << " :";
2423 VisitOMPClauseList(Node, ' ');
2424 if (IsOmpAllMemory) {
2425 OS << (Node->varlist_empty() ? " " : ",");
2426 OS << "omp_all_memory";
2427 }
2428 OS << ")";
2429}
2430
2431template <typename T>
2432static void PrintMapper(raw_ostream &OS, T *Node,
2433 const PrintingPolicy &Policy) {
2434 OS << '(';
2435 NestedNameSpecifier *MapperNNS =
2436 Node->getMapperQualifierLoc().getNestedNameSpecifier();
2437 if (MapperNNS)
2438 MapperNNS->print(OS, Policy);
2439 OS << Node->getMapperIdInfo() << ')';
2440}
2441
2442template <typename T>
2443static void PrintIterator(raw_ostream &OS, T *Node,
2444 const PrintingPolicy &Policy) {
2445 if (Expr *IteratorModifier = Node->getIteratorModifier())
2446 IteratorModifier->printPretty(OS, nullptr, Policy);
2447}
2448
2449void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) {
2450 if (!Node->varlist_empty()) {
2451 OS << "map(";
2452 if (Node->getMapType() != OMPC_MAP_unknown) {
2453 for (unsigned I = 0; I < NumberOfOMPMapClauseModifiers; ++I) {
2454 if (Node->getMapTypeModifier(I) != OMPC_MAP_MODIFIER_unknown) {
2455 if (Node->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator) {
2456 PrintIterator(OS, Node, Policy);
2457 } else {
2458 OS << getOpenMPSimpleClauseTypeName(OMPC_map,
2459 Node->getMapTypeModifier(I));
2460 if (Node->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_mapper)
2461 PrintMapper(OS, Node, Policy);
2462 }
2463 OS << ',';
2464 }
2465 }
2466 OS << getOpenMPSimpleClauseTypeName(OMPC_map, Node->getMapType());
2467 OS << ':';
2468 }
2469 VisitOMPClauseList(Node, ' ');
2470 OS << ")";
2471 }
2472}
2473
2474template <typename T> void OMPClausePrinter::VisitOMPMotionClause(T *Node) {
2475 if (Node->varlist_empty())
2476 return;
2477 OS << getOpenMPClauseName(Node->getClauseKind());
2478 unsigned ModifierCount = 0;
2479 for (unsigned I = 0; I < NumberOfOMPMotionModifiers; ++I) {
2480 if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown)
2481 ++ModifierCount;
2482 }
2483 if (ModifierCount) {
2484 OS << '(';
2485 for (unsigned I = 0; I < NumberOfOMPMotionModifiers; ++I) {
2486 if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown) {
2487 OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
2488 Node->getMotionModifier(I));
2489 if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper)
2490 PrintMapper(OS, Node, Policy);
2491 if (I < ModifierCount - 1)
2492 OS << ", ";
2493 }
2494 }
2495 OS << ':';
2496 VisitOMPClauseList(Node, ' ');
2497 } else {
2498 VisitOMPClauseList(Node, '(');
2499 }
2500 OS << ")";
2501}
2502
2503void OMPClausePrinter::VisitOMPToClause(OMPToClause *Node) {
2504 VisitOMPMotionClause(Node);
2505}
2506
2507void OMPClausePrinter::VisitOMPFromClause(OMPFromClause *Node) {
2508 VisitOMPMotionClause(Node);
2509}
2510
2511void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) {
2512 OS << "dist_schedule(" << getOpenMPSimpleClauseTypeName(
2513 OMPC_dist_schedule, Node->getDistScheduleKind());
2514 if (auto *E = Node->getChunkSize()) {
2515 OS << ", ";
2516 E->printPretty(OS, nullptr, Policy);
2517 }
2518 OS << ")";
2519}
2520
2521void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) {
2522 OS << "defaultmap(";
2523 OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
2524 Node->getDefaultmapModifier());
2525 if (Node->getDefaultmapKind() != OMPC_DEFAULTMAP_unknown) {
2526 OS << ": ";
2527 OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
2528 Node->getDefaultmapKind());
2529 }
2530 OS << ")";
2531}
2532
2533void OMPClausePrinter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *Node) {
2534 if (!Node->varlist_empty()) {
2535 OS << "use_device_ptr";
2536 VisitOMPClauseList(Node, '(');
2537 OS << ")";
2538 }
2539}
2540
2541void OMPClausePrinter::VisitOMPUseDeviceAddrClause(
2543 if (!Node->varlist_empty()) {
2544 OS << "use_device_addr";
2545 VisitOMPClauseList(Node, '(');
2546 OS << ")";
2547 }
2548}
2549
2550void OMPClausePrinter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *Node) {
2551 if (!Node->varlist_empty()) {
2552 OS << "is_device_ptr";
2553 VisitOMPClauseList(Node, '(');
2554 OS << ")";
2555 }
2556}
2557
2558void OMPClausePrinter::VisitOMPHasDeviceAddrClause(OMPHasDeviceAddrClause *Node) {
2559 if (!Node->varlist_empty()) {
2560 OS << "has_device_addr";
2561 VisitOMPClauseList(Node, '(');
2562 OS << ")";
2563 }
2564}
2565
2566void OMPClausePrinter::VisitOMPNontemporalClause(OMPNontemporalClause *Node) {
2567 if (!Node->varlist_empty()) {
2568 OS << "nontemporal";
2569 VisitOMPClauseList(Node, '(');
2570 OS << ")";
2571 }
2572}
2573
2574void OMPClausePrinter::VisitOMPOrderClause(OMPOrderClause *Node) {
2575 OS << "order(";
2576 if (Node->getModifier() != OMPC_ORDER_MODIFIER_unknown) {
2577 OS << getOpenMPSimpleClauseTypeName(OMPC_order, Node->getModifier());
2578 OS << ": ";
2579 }
2580 OS << getOpenMPSimpleClauseTypeName(OMPC_order, Node->getKind()) << ")";
2581}
2582
2583void OMPClausePrinter::VisitOMPInclusiveClause(OMPInclusiveClause *Node) {
2584 if (!Node->varlist_empty()) {
2585 OS << "inclusive";
2586 VisitOMPClauseList(Node, '(');
2587 OS << ")";
2588 }
2589}
2590
2591void OMPClausePrinter::VisitOMPExclusiveClause(OMPExclusiveClause *Node) {
2592 if (!Node->varlist_empty()) {
2593 OS << "exclusive";
2594 VisitOMPClauseList(Node, '(');
2595 OS << ")";
2596 }
2597}
2598
2599void OMPClausePrinter::VisitOMPUsesAllocatorsClause(
2601 if (Node->getNumberOfAllocators() == 0)
2602 return;
2603 OS << "uses_allocators(";
2604 for (unsigned I = 0, E = Node->getNumberOfAllocators(); I < E; ++I) {
2605 OMPUsesAllocatorsClause::Data Data = Node->getAllocatorData(I);
2606 Data.Allocator->printPretty(OS, nullptr, Policy);
2607 if (Data.AllocatorTraits) {
2608 OS << "(";
2609 Data.AllocatorTraits->printPretty(OS, nullptr, Policy);
2610 OS << ")";
2611 }
2612 if (I < E - 1)
2613 OS << ",";
2614 }
2615 OS << ")";
2616}
2617
2618void OMPClausePrinter::VisitOMPAffinityClause(OMPAffinityClause *Node) {
2619 if (Node->varlist_empty())
2620 return;
2621 OS << "affinity";
2622 char StartSym = '(';
2623 if (Expr *Modifier = Node->getModifier()) {
2624 OS << "(";
2625 Modifier->printPretty(OS, nullptr, Policy);
2626 OS << " :";
2627 StartSym = ' ';
2628 }
2629 VisitOMPClauseList(Node, StartSym);
2630 OS << ")";
2631}
2632
2633void OMPClausePrinter::VisitOMPFilterClause(OMPFilterClause *Node) {
2634 OS << "filter(";
2635 Node->getThreadID()->printPretty(OS, nullptr, Policy, 0);
2636 OS << ")";
2637}
2638
2639void OMPClausePrinter::VisitOMPBindClause(OMPBindClause *Node) {
2640 OS << "bind("
2641 << getOpenMPSimpleClauseTypeName(OMPC_bind, unsigned(Node->getBindKind()))
2642 << ")";
2643}
2644
2645void OMPClausePrinter::VisitOMPXDynCGroupMemClause(
2647 OS << "ompx_dyn_cgroup_mem(";
2648 Node->getSize()->printPretty(OS, nullptr, Policy, 0);
2649 OS << ")";
2650}
2651
2652void OMPClausePrinter::VisitOMPDoacrossClause(OMPDoacrossClause *Node) {
2653 OS << "doacross(";
2654 OpenMPDoacrossClauseModifier DepType = Node->getDependenceType();
2655
2656 switch (DepType) {
2657 case OMPC_DOACROSS_source:
2658 OS << "source:";
2659 break;
2660 case OMPC_DOACROSS_sink:
2661 OS << "sink:";
2662 break;
2663 case OMPC_DOACROSS_source_omp_cur_iteration:
2664 OS << "source: omp_cur_iteration";
2665 break;
2666 case OMPC_DOACROSS_sink_omp_cur_iteration:
2667 OS << "sink: omp_cur_iteration - 1";
2668 break;
2669 default:
2670 llvm_unreachable("unknown docaross modifier");
2671 }
2672 VisitOMPClauseList(Node, ' ');
2673 OS << ")";
2674}
2675
2676void OMPClausePrinter::VisitOMPXAttributeClause(OMPXAttributeClause *Node) {
2677 OS << "ompx_attribute(";
2678 bool IsFirst = true;
2679 for (auto &Attr : Node->getAttrs()) {
2680 if (!IsFirst)
2681 OS << ", ";
2682 Attr->printPretty(OS, Policy);
2683 IsFirst = false;
2684 }
2685 OS << ")";
2686}
2687
2688void OMPClausePrinter::VisitOMPXBareClause(OMPXBareClause *Node) {
2689 OS << "ompx_bare";
2690}
2691
2693 VariantMatchInfo &VMI) const {
2694 for (const OMPTraitSet &Set : Sets) {
2695 for (const OMPTraitSelector &Selector : Set.Selectors) {
2696
2697 // User conditions are special as we evaluate the condition here.
2698 if (Selector.Kind == TraitSelector::user_condition) {
2699 assert(Selector.ScoreOrCondition &&
2700 "Ill-formed user condition, expected condition expression!");
2701 assert(Selector.Properties.size() == 1 &&
2702 Selector.Properties.front().Kind ==
2703 TraitProperty::user_condition_unknown &&
2704 "Ill-formed user condition, expected unknown trait property!");
2705
2706 if (std::optional<APSInt> CondVal =
2707 Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))
2708 VMI.addTrait(CondVal->isZero() ? TraitProperty::user_condition_false
2709 : TraitProperty::user_condition_true,
2710 "<condition>");
2711 else
2712 VMI.addTrait(TraitProperty::user_condition_false, "<condition>");
2713 continue;
2714 }
2715
2716 std::optional<llvm::APSInt> Score;
2717 llvm::APInt *ScorePtr = nullptr;
2718 if (Selector.ScoreOrCondition) {
2719 if ((Score = Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)))
2720 ScorePtr = &*Score;
2721 else
2722 VMI.addTrait(TraitProperty::user_condition_false,
2723 "<non-constant-score>");
2724 }
2725
2726 for (const OMPTraitProperty &Property : Selector.Properties)
2727 VMI.addTrait(Set.Kind, Property.Kind, Property.RawString, ScorePtr);
2728
2729 if (Set.Kind != TraitSet::construct)
2730 continue;
2731
2732 // TODO: This might not hold once we implement SIMD properly.
2733 assert(Selector.Properties.size() == 1 &&
2734 Selector.Properties.front().Kind ==
2735 getOpenMPContextTraitPropertyForSelector(
2736 Selector.Kind) &&
2737 "Ill-formed construct selector!");
2738 }
2739 }
2740}
2741
2742void OMPTraitInfo::print(llvm::raw_ostream &OS,
2743 const PrintingPolicy &Policy) const {
2744 bool FirstSet = true;
2745 for (const OMPTraitSet &Set : Sets) {
2746 if (!FirstSet)
2747 OS << ", ";
2748 FirstSet = false;
2749 OS << getOpenMPContextTraitSetName(Set.Kind) << "={";
2750
2751 bool FirstSelector = true;
2752 for (const OMPTraitSelector &Selector : Set.Selectors) {
2753 if (!FirstSelector)
2754 OS << ", ";
2755 FirstSelector = false;
2756 OS << getOpenMPContextTraitSelectorName(Selector.Kind);
2757
2758 bool AllowsTraitScore = false;
2759 bool RequiresProperty = false;
2760 isValidTraitSelectorForTraitSet(
2761 Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
2762
2763 if (!RequiresProperty)
2764 continue;
2765
2766 OS << "(";
2767 if (Selector.Kind == TraitSelector::user_condition) {
2768 if (Selector.ScoreOrCondition)
2769 Selector.ScoreOrCondition->printPretty(OS, nullptr, Policy);
2770 else
2771 OS << "...";
2772 } else {
2773
2774 if (Selector.ScoreOrCondition) {
2775 OS << "score(";
2776 Selector.ScoreOrCondition->printPretty(OS, nullptr, Policy);
2777 OS << "): ";
2778 }
2779
2780 bool FirstProperty = true;
2781 for (const OMPTraitProperty &Property : Selector.Properties) {
2782 if (!FirstProperty)
2783 OS << ", ";
2784 FirstProperty = false;
2785 OS << getOpenMPContextTraitPropertyName(Property.Kind,
2786 Property.RawString);
2787 }
2788 }
2789 OS << ")";
2790 }
2791 OS << "}";
2792 }
2793}
2794
2795std::string OMPTraitInfo::getMangledName() const {
2796 std::string MangledName;
2797 llvm::raw_string_ostream OS(MangledName);
2798 for (const OMPTraitSet &Set : Sets) {
2799 OS << '$' << 'S' << unsigned(Set.Kind);
2800 for (const OMPTraitSelector &Selector : Set.Selectors) {
2801
2802 bool AllowsTraitScore = false;
2803 bool RequiresProperty = false;
2804 isValidTraitSelectorForTraitSet(
2805 Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
2806 OS << '$' << 's' << unsigned(Selector.Kind);
2807
2808 if (!RequiresProperty ||
2809 Selector.Kind == TraitSelector::user_condition)
2810 continue;
2811
2812 for (const OMPTraitProperty &Property : Selector.Properties)
2813 OS << '$' << 'P'
2814 << getOpenMPContextTraitPropertyName(Property.Kind,
2815 Property.RawString);
2816 }
2817 }
2818 return MangledName;
2819}
2820
2821OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
2822 unsigned long U;
2823 do {
2824 if (!MangledName.consume_front("$S"))
2825 break;
2826 if (MangledName.consumeInteger(10, U))
2827 break;
2828 Sets.push_back(OMPTraitSet());
2829 OMPTraitSet &Set = Sets.back();
2830 Set.Kind = TraitSet(U);
2831 do {
2832 if (!MangledName.consume_front("$s"))
2833 break;
2834 if (MangledName.consumeInteger(10, U))
2835 break;
2836 Set.Selectors.push_back(OMPTraitSelector());
2837 OMPTraitSelector &Selector = Set.Selectors.back();
2838 Selector.Kind = TraitSelector(U);
2839 do {
2840 if (!MangledName.consume_front("$P"))
2841 break;
2842 Selector.Properties.push_back(OMPTraitProperty());
2843 OMPTraitProperty &Property = Selector.Properties.back();
2844 std::pair<StringRef, StringRef> PropRestPair = MangledName.split('$');
2845 Property.RawString = PropRestPair.first;
2846 Property.Kind = getOpenMPContextTraitPropertyKind(
2847 Set.Kind, Selector.Kind, PropRestPair.first);
2848 MangledName = MangledName.drop_front(PropRestPair.first.size());
2849 } while (true);
2850 } while (true);
2851 } while (true);
2852}
2853
2854llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
2855 const OMPTraitInfo &TI) {
2856 LangOptions LO;
2857 PrintingPolicy Policy(LO);
2858 TI.print(OS, Policy);
2859 return OS;
2860}
2861llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
2862 const OMPTraitInfo *TI) {
2863 return TI ? OS << *TI : OS;
2864}
2865
2867 ASTContext &ASTCtx, std::function<void(StringRef)> &&DiagUnknownTrait,
2868 const FunctionDecl *CurrentFunctionDecl,
2869 ArrayRef<llvm::omp::TraitProperty> ConstructTraits)
2870 : OMPContext(ASTCtx.getLangOpts().OpenMPIsTargetDevice,
2871 ASTCtx.getTargetInfo().getTriple()),
2872 FeatureValidityCheck([&](StringRef FeatureName) {
2873 return ASTCtx.getTargetInfo().isValidFeatureName(FeatureName);
2874 }),
2875 DiagUnknownTrait(std::move(DiagUnknownTrait)) {
2876 ASTCtx.getFunctionFeatureMap(FeatureMap, CurrentFunctionDecl);
2877
2878 for (llvm::omp::TraitProperty Property : ConstructTraits)
2879 addTrait(Property);
2880}
2881
2882bool TargetOMPContext::matchesISATrait(StringRef RawString) const {
2883 auto It = FeatureMap.find(RawString);
2884 if (It != FeatureMap.end())
2885 return It->second;
2886 if (!FeatureValidityCheck(RawString))
2887 DiagUnknownTrait(RawString);
2888 return false;
2889}
Defines the clang::ASTContext interface.
DynTypedNode Node
const Decl * D
Expr * E
This file defines OpenMP nodes for declarative directives.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static Stmt ** getAddrOfExprAsWritten(Stmt *S)
Gets the address of the original, non-captured, expression used in the clause as the preinitializer.
static void PrintIterator(raw_ostream &OS, T *Node, const PrintingPolicy &Policy)
static void PrintMapper(raw_ostream &OS, T *Node, const PrintingPolicy &Policy)
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
SourceLocation Loc
Definition: SemaObjC.cpp:759
const char * Data
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:187
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:779
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
Attr - This represents one attribute.
Definition: Attr.h:42
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:968
This represents one expression.
Definition: Expr.h:110
Represents a function declaration or definition.
Definition: Decl.h:1932
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:476
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
This represents the 'absent' clause in the '#pragma omp assume' directive.
static OMPAbsentClause * CreateEmpty(const ASTContext &C, unsigned NumKinds)
static OMPAbsentClause * Create(const ASTContext &C, ArrayRef< OpenMPDirectiveKind > DKVec, SourceLocation Loc, SourceLocation LLoc, SourceLocation RLoc)
This represents 'acq_rel' clause in the '#pragma omp atomic|flush' directives.
This represents 'acquire' clause in the '#pragma omp atomic|flush' directives.
This represents clause 'affinity' in the '#pragma omp task'-based directives.
static OMPAffinityClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Creates clause with a modifier a list of locator items.
static OMPAffinityClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N locator items.
This represents the 'align' clause in the '#pragma omp allocate' directive.
Definition: OpenMPClause.h:448
static OMPAlignClause * Create(const ASTContext &C, Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'align' clause with the given alignment.
This represents clause 'aligned' in the '#pragma omp ...' directives.
static OMPAlignedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, Expr *A)
Creates clause with a list of variables VL and alignment A.
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
This represents clause 'allocate' in the '#pragma omp ...' directives.
Definition: OpenMPClause.h:492
static OMPAllocateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, Expr *Allocator, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
static OMPAllocateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'allocator' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:414
This represents 'at' clause in the '#pragma omp error' directive.
This represents 'atomic_default_mem_order' clause in the '#pragma omp requires' directive.
This represents 'bind' clause in the '#pragma omp ...' directives.
static OMPBindClause * Create(const ASTContext &C, OpenMPBindClauseKind K, SourceLocation KLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'bind' clause with kind K ('teams', 'parallel', or 'thread').
static OMPBindClause * CreateEmpty(const ASTContext &C)
Build an empty 'bind' clause.
This represents 'capture' clause in the '#pragma omp atomic' directive.
Class that represents a component of a mappable expression.
static unsigned getUniqueDeclarationsTotalNumber(ArrayRef< const ValueDecl * > Declarations)
static unsigned getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists)
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc.
Definition: OpenMPClause.h:233
void setPostUpdateExpr(Expr *S)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:245
static OMPClauseWithPostUpdate * get(OMPClause *C)
Class that handles pre-initialization statement for some clauses, like 'schedule',...
Definition: OpenMPClause.h:195
const Stmt * getPreInitStmt() const
Get pre-initialization statement for the clause.
Definition: OpenMPClause.h:219
static OMPClauseWithPreInit * get(OMPClause *C)
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=llvm::omp::OMPD_unknown)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:211
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:55
void setLocStart(SourceLocation Loc)
Sets the starting location of the clause.
Definition: OpenMPClause.h:77
child_range used_children()
Get the iterator range for the expressions used in the clauses.
llvm::iterator_range< child_iterator > child_range
Definition: OpenMPClause.h:89
void setLocEnd(SourceLocation Loc)
Sets the ending location of the clause.
Definition: OpenMPClause.h:80
child_range children()
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
Definition: OpenMPClause.h:83
This represents 'collapse' clause in the '#pragma omp ...' directive.
This represents 'compare' clause in the '#pragma omp atomic' directive.
This represents the 'contains' clause in the '#pragma omp assume' directive.
static OMPContainsClause * CreateEmpty(const ASTContext &C, unsigned NumKinds)
static OMPContainsClause * Create(const ASTContext &C, ArrayRef< OpenMPDirectiveKind > DKVec, SourceLocation Loc, SourceLocation LLoc, SourceLocation RLoc)
This represents clause 'copyin' in the '#pragma omp ...' directives.
static OMPCopyinClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
static OMPCopyprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents 'default' clause in the '#pragma omp ...' directive.
This represents 'defaultmap' clause in the '#pragma omp ...' directive.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
static OMPDependClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, DependDataTy Data, Expr *DepModifier, ArrayRef< Expr * > VL, unsigned NumLoops)
Creates clause with a list of variables VL.
Expr * getModifier()
Return optional depend modifier.
Expr * getLoopData(unsigned NumLoop)
Get the loop data.
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data for the depend clauses with 'sink|source' kind of dependency.
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N variables.
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
This represents implicit clause 'depobj' for the '#pragma omp depobj' directive.
static OMPDepobjClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, Expr *Depobj)
Creates clause.
static OMPDepobjClause * CreateEmpty(const ASTContext &C)
Creates an empty clause.
This represents 'destroy' clause in the '#pragma omp depobj' directive or the '#pragma omp interop' d...
This represents 'detach' clause in the '#pragma omp task' directive.
This represents 'device' clause in the '#pragma omp ...' directive.
void setDirectiveKinds(ArrayRef< OpenMPDirectiveKind > DK)
Definition: OpenMPClause.h:391
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
This represents the 'doacross' clause for the '#pragma omp ordered' directive.
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data.
Expr * getLoopData(unsigned NumLoop)
Get the loop data.
static OMPDoacrossClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VL, unsigned NumLoops)
Creates clause with a list of expressions VL.
static OMPDoacrossClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N expressions.
This represents 'dynamic_allocators' clause in the '#pragma omp requires' directive.
This represents clause 'exclusive' in the '#pragma omp scan' directive.
static OMPExclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPExclusiveClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
This represents 'fail' clause in the '#pragma omp atomic' directive.
This represents 'filter' clause in the '#pragma omp ...' directive.
This represents 'final' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:690
child_range used_children()
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
static OMPFirstprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL, ArrayRef< Expr * > InitVL, Stmt *PreInit)
Creates clause with a list of variables VL.
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPFlushClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
This represents clause 'from' in the '#pragma omp ...' directives.
static OMPFromClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
static OMPFromClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr * > UDMapperRefs, ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
Representation of the 'full' clause of the '#pragma omp unroll' directive.
Definition: OpenMPClause.h:939
static OMPFullClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc)
Build an AST node for a 'full' clause.
static OMPFullClause * CreateEmpty(const ASTContext &C)
Build an empty 'full' AST node for deserialization.
This represents 'grainsize' clause in the '#pragma omp ...' directive.
This represents clause 'has_device_ptr' in the '#pragma omp ...' directives.
static OMPHasDeviceAddrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPHasDeviceAddrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents 'hint' clause in the '#pragma omp ...' directive.
This represents the 'holds' clause in the '#pragma omp assume' directive.
This represents 'if' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:587
child_range used_children()
This represents clause 'in_reduction' in the '#pragma omp task' directives.
static OMPInReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPInReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, ArrayRef< Expr * > TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
This represents clause 'inclusive' in the '#pragma omp scan' directive.
static OMPInclusiveClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
static OMPInclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents the 'init' clause in '#pragma omp ...' directives.
static OMPInitClause * Create(const ASTContext &C, Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Creates a fully specified clause.
static OMPInitClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N expressions.
This represents clause 'is_device_ptr' in the '#pragma omp ...' directives.
static OMPIsDevicePtrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPIsDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
void setPrivateCopies(ArrayRef< Expr * > PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
static OMPLastprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
This represents clause 'linear' in the '#pragma omp ...' directives.
child_range used_children()
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
void setUpdates(ArrayRef< Expr * > UL)
Sets the list of update expressions for linear variables.
void setFinals(ArrayRef< Expr * > FL)
Sets the list of final update expressions for linear variables.
void setUsedExprs(ArrayRef< Expr * > UE)
Sets the list of used expressions for the linear clause.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
This represents clause 'map' in the '#pragma omp ...' directives.
static OMPMapClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr * > UDMapperRefs, Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapModifiers, ArrayRef< SourceLocation > MapModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId, OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc)
Creates clause with a list of variables VL.
static OMPMapClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars original expressions, NumUniqueDeclarations declar...
void setUDMapperRefs(ArrayRef< Expr * > DMDs)
Set the user-defined mappers that are in the trailing objects of the class.
void setClauseInfo(ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Fill the clause information from the list of declarations and associated component lists.
This represents 'mergeable' clause in the '#pragma omp ...' directive.
This represents 'message' clause in the '#pragma omp error' directive.
This represents the 'no_openmp' clause in the '#pragma omp assume' directive.
This represents the 'no_openmp_routines' clause in the '#pragma omp assume' directive.
This represents the 'no_parallelism' clause in the '#pragma omp assume' directive.
This represents 'nocontext' clause in the '#pragma omp ...' directive.
This represents 'nogroup' clause in the '#pragma omp ...' directive.
This represents clause 'nontemporal' in the '#pragma omp ...' directives.
static OMPNontemporalClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPNontemporalClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
void setPrivateRefs(ArrayRef< Expr * > VL)
Sets the list of references to private copies created in private clauses.
This represents 'novariants' clause in the '#pragma omp ...' directive.
This represents 'nowait' clause in the '#pragma omp ...' directive.
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
This represents 'num_teams' clause in the '#pragma omp ...' directive.
static OMPNumTeamsClause * Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, Stmt *PreInit)
Creates clause with a list of variables VL.
static OMPNumTeamsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents 'num_threads' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:736
llvm::iterator_range< child_iterator > child_range
Definition: OpenMPClause.h:173
This represents 'order' clause in the '#pragma omp ...' directive.
This represents 'ordered' clause in the '#pragma omp ...' directive.
void setLoopCounter(unsigned NumLoop, Expr *Counter)
Set loop counter for the specified loop.
void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations)
Set number of iterations for the specified loop.
ArrayRef< Expr * > getLoopNumIterations() const
Get number of iterations for all the loops.
static OMPOrderedClause * Create(const ASTContext &C, Expr *Num, unsigned NumLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'ordered' clause.
static OMPOrderedClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty clause.
Expr * getLoopCounter(unsigned NumLoop)
Get loops counter for the specified loop.
Representation of the 'partial' clause of the '#pragma omp unroll' directive.
Definition: OpenMPClause.h:967
static OMPPartialClause * CreateEmpty(const ASTContext &C)
Build an empty 'partial' AST node for deserialization.
static OMPPartialClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, Expr *Factor)
Build an AST node for a 'partial' clause.
This represents 'priority' clause in the '#pragma omp ...' directive.
This represents clause 'private' in the '#pragma omp ...' directives.
static OMPPrivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL)
Creates clause with a list of variables VL.
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'proc_bind' clause in the '#pragma omp ...' directive.
This represents 'read' clause in the '#pragma omp atomic' directive.
This represents clause 'reduction' in the '#pragma omp ...' directives.
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N, OpenMPReductionClauseModifier Modifier)
Creates an empty clause with the place for N variables.
static OMPReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, ArrayRef< Expr * > CopyOps, ArrayRef< Expr * > CopyArrayTemps, ArrayRef< Expr * > CopyArrayElems, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
This represents 'relaxed' clause in the '#pragma omp atomic' directives.
This represents 'release' clause in the '#pragma omp atomic|flush' directives.
This represents 'reverse_offload' clause in the '#pragma omp requires' directive.
This represents 'simd' clause in the '#pragma omp ...' directive.
This represents 'safelen' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:781
This represents 'schedule' clause in the '#pragma omp ...' directive.
This represents 'seq_cst' clause in the '#pragma omp atomic' directive.
This represents 'severity' clause in the '#pragma omp error' directive.
This represents clause 'shared' in the '#pragma omp ...' directives.
static OMPSharedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents 'simdlen' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:816
This represents the 'sizes' clause in the '#pragma omp tile' directive.
Definition: OpenMPClause.h:848
static OMPSizesClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > Sizes)
Build a 'sizes' AST node.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
Definition: OpenMPClause.h:882
void setSizesRefs(ArrayRef< Expr * > VL)
Sets the tile size expressions.
Definition: OpenMPClause.h:903
static OMPSizesClause * CreateEmpty(const ASTContext &C, unsigned NumSizes)
Build an empty 'sizes' AST node for deserialization.
This represents clause 'task_reduction' in the '#pragma omp taskgroup' directives.
static OMPTaskReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'thread_limit' clause in the '#pragma omp ...' directive.
static OMPThreadLimitClause * Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, Stmt *PreInit)
Creates clause with a list of variables VL.
static OMPThreadLimitClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents 'threads' clause in the '#pragma omp ...' directive.
This represents clause 'to' in the '#pragma omp ...' directives.
static OMPToClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
static OMPToClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr * > UDMapperRefs, ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
std::string getMangledName() const
Return a string representation identifying this context selector.
void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
Print a human readable representation into OS.
void getAsVariantMatchInfo(ASTContext &ASTCtx, llvm::omp::VariantMatchInfo &VMI) const
Create a variant match info object from this trait info object.
llvm::SmallVector< OMPTraitSet, 2 > Sets
The outermost level of selector sets.
This represents 'unified_address' clause in the '#pragma omp requires' directive.
This represents 'unified_shared_memory' clause in the '#pragma omp requires' directive.
This represents 'untied' clause in the '#pragma omp ...' directive.
This represents 'update' clause in the '#pragma omp atomic' directive.
static OMPUpdateClause * CreateEmpty(const ASTContext &C, bool IsExtended)
Creates an empty clause with the place for N variables.
static OMPUpdateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc)
Creates clause for 'atomic' directive.
This represents the 'use' clause in '#pragma omp ...' directives.
This represents clause 'use_device_addr' in the '#pragma omp ...' directives.
static OMPUseDeviceAddrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPUseDeviceAddrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'use_device_ptr' in the '#pragma omp ...' directives.
static OMPUseDevicePtrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< Expr * > PrivateVars, ArrayRef< Expr * > Inits, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'uses_allocators' in the '#pragma omp target'-based directives.
OMPUsesAllocatorsClause::Data getAllocatorData(unsigned I) const
Returns data for the specified allocator.
static OMPUsesAllocatorsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N allocators.
static OMPUsesAllocatorsClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< OMPUsesAllocatorsClause::Data > Data)
Creates clause with a list of allocators Data.
MutableArrayRef< Expr * > getVarRefs()
Fetches list of variables associated with this clause.
Definition: OpenMPClause.h:297
void setVarRefs(ArrayRef< Expr * > VL)
Sets the list of variables for this clause.
Definition: OpenMPClause.h:303
This represents 'weak' clause in the '#pragma omp atomic' directives.
This represents 'write' clause in the '#pragma omp atomic' directive.
This represents 'ompx_attribute' clause in a directive that might generate an outlined function.
This represents 'ompx_bare' clause in the '#pragma omp target teams ...' directive.
This represents 'ompx_dyn_cgroup_mem' clause in the '#pragma omp target ...' directive.
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
Stmt - This represents one statement.
Definition: Stmt.h:84
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
Definition: TargetInfo.h:1393
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:59
The type-property cache.
Definition: Type.cpp:4437
The base class of the type hierarchy.
Definition: Type.h:1829
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:667
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
@ OO_None
Not an overloaded operator.
Definition: OperatorKinds.h:22
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:24
@ OMPC_ORDER_MODIFIER_unknown
Definition: OpenMPKinds.h:172
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
Definition: OpenMPKinds.h:186
@ OMPC_SCHEDULE_MODIFIER_unknown
Definition: OpenMPKinds.h:39
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
Definition: OpenMPKinds.h:219
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
Definition: OpenMPKinds.h:87
@ Property
The type of a property.
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
Definition: OpenMPKinds.h:200
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
Definition: OpenMPKinds.h:157
@ OMPC_LASTPRIVATE_unknown
Definition: OpenMPKinds.h:160
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
Definition: OpenMPKinds.h:54
OpenMPGrainsizeClauseModifier
Definition: OpenMPKinds.h:206
@ OMPC_GRAINSIZE_unknown
Definition: OpenMPKinds.h:209
OpenMPNumTasksClauseModifier
Definition: OpenMPKinds.h:212
@ OMPC_NUMTASKS_unknown
Definition: OpenMPKinds.h:215
static constexpr unsigned NumberOfOMPMotionModifiers
Number of allowed motion-modifiers.
Definition: OpenMPKinds.h:99
@ OMPC_MOTION_MODIFIER_unknown
Definition: OpenMPKinds.h:95
@ OMPC_DEFAULTMAP_unknown
Definition: OpenMPKinds.h:114
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition: OpenMPKinds.h:62
const FunctionProtoType * T
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
Definition: OpenMPKinds.h:47
@ OMPC_DEVICE_unknown
Definition: OpenMPKinds.h:50
@ OMPC_MAP_MODIFIER_unknown
Definition: OpenMPKinds.h:79
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition: OpenMPKinds.h:70
@ OMPC_MAP_unknown
Definition: OpenMPKinds.h:74
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
llvm::SmallVector< Expr *, 4 > PreferTypes
Definition: OpenMPKinds.h:232
This structure contains all sizes needed for by an OMPMappableExprListClause.
unsigned NumComponentLists
Number of component lists.
unsigned NumVars
Number of expressions listed.
unsigned NumUniqueDeclarations
Number of unique base declarations.
unsigned NumComponents
Total number of expression components.
Data for list of allocators.
SourceLocation LParenLoc
Locations of '(' and ')' symbols.
Expr * AllocatorTraits
Allocator traits.
This structure contains most locations needed for by an OMPVarListClause.
Definition: OpenMPClause.h:259
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
bool matchesISATrait(StringRef RawString) const override
See llvm::omp::OMPContext::matchesISATrait.
TargetOMPContext(ASTContext &ASTCtx, std::function< void(StringRef)> &&DiagUnknownTrait, const FunctionDecl *CurrentFunctionDecl, ArrayRef< llvm::omp::TraitProperty > ConstructTraits)