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