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