1//===--- StmtOpenMP.cpp - Classes for OpenMP directives -------------------===//
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 subclasses of Stmt class declared in StmtOpenMP.h
10//
11//===----------------------------------------------------------------------===//
12
13#include "clang/AST/StmtOpenMP.h"
14#include "clang/AST/ASTContext.h"
15#include "clang/AST/Attr.h"
16#include "clang/AST/Stmt.h"
17
18using namespace clang;
19using namespace llvm::omp;
20
21/// Returns the intra-tile hint attribute for the given statement.
22const OMPInvariantPredicateBoundAttr *
23OMPLoopBasedDirective::getIntraTileHint(const Stmt *S) {
24 if (const auto *AS = dyn_cast_or_null<AttributedStmt>(Val: S))
25 return getSpecificAttr<OMPInvariantPredicateBoundAttr>(container: AS->getAttrs());
26 return nullptr;
27}
28
29/// Peek through an intra-tile hint wrapper to return the underlying loop.
30Stmt *OMPLoopBasedDirective::ignoreIntraTileHint(Stmt *S) {
31 if (auto *AS = dyn_cast_or_null<AttributedStmt>(Val: S))
32 if (hasSpecificAttr<OMPInvariantPredicateBoundAttr>(container: AS->getAttrs()))
33 return AS->getSubStmt();
34 return S;
35}
36
37ArrayRef<Stmt *> OMPLoopBasedDirective::getStmtsBeforeNestedLoop(Stmt *Body) {
38 auto *CS = dyn_cast_or_null<CompoundStmt>(Val: Body);
39 if (!CS || CS->size() < 2)
40 return {};
41 return ArrayRef(CS->body_begin(), CS->size() - 1);
42}
43
44/// Like `Stmt::IgnoreContainers`, but stops at (and preserves) an intra-tile
45/// hint wrapper so that the enclosing loop walker can deliver the hint to
46/// loop-associated analysis (e.g. `collapse`). Non-hint attributed statements
47/// and single-statement compounds are still skipped.
48static Stmt *ignoreContainersKeepingIntraTileHint(Stmt *S) {
49 while (true) {
50 if (auto *AS = dyn_cast_or_null<AttributedStmt>(Val: S)) {
51 if (hasSpecificAttr<OMPInvariantPredicateBoundAttr>(container: AS->getAttrs()))
52 break;
53 S = AS->getSubStmt();
54 continue;
55 }
56 if (auto *CS = dyn_cast_or_null<CompoundStmt>(Val: S)) {
57 if (CS->size() != 1)
58 break;
59 S = CS->body_back();
60 continue;
61 }
62 break;
63 }
64 return S;
65}
66
67size_t OMPChildren::size(unsigned NumClauses, bool HasAssociatedStmt,
68 unsigned NumChildren) {
69 return llvm::alignTo(
70 Value: totalSizeToAlloc<OMPClause *, Stmt *>(
71 Counts: NumClauses, Counts: NumChildren + (HasAssociatedStmt ? 1 : 0)),
72 Align: alignof(OMPChildren));
73}
74
75void OMPChildren::setClauses(ArrayRef<OMPClause *> Clauses) {
76 assert(Clauses.size() == NumClauses &&
77 "Number of clauses is not the same as the preallocated buffer");
78 llvm::copy(Range&: Clauses, Out: getTrailingObjects<OMPClause *>());
79}
80
81MutableArrayRef<Stmt *> OMPChildren::getChildren() {
82 return getTrailingObjects<Stmt *>(N: NumChildren);
83}
84
85OMPChildren *OMPChildren::Create(void *Mem, ArrayRef<OMPClause *> Clauses) {
86 auto *Data = CreateEmpty(Mem, NumClauses: Clauses.size());
87 Data->setClauses(Clauses);
88 return Data;
89}
90
91OMPChildren *OMPChildren::Create(void *Mem, ArrayRef<OMPClause *> Clauses,
92 Stmt *S, unsigned NumChildren) {
93 auto *Data = CreateEmpty(Mem, NumClauses: Clauses.size(), HasAssociatedStmt: S, NumChildren);
94 Data->setClauses(Clauses);
95 if (S)
96 Data->setAssociatedStmt(S);
97 return Data;
98}
99
100OMPChildren *OMPChildren::CreateEmpty(void *Mem, unsigned NumClauses,
101 bool HasAssociatedStmt,
102 unsigned NumChildren) {
103 return new (Mem) OMPChildren(NumClauses, NumChildren, HasAssociatedStmt);
104}
105
106bool OMPExecutableDirective::isStandaloneDirective() const {
107 // Special case: 'omp target enter data', 'omp target exit data',
108 // 'omp target update' are stand-alone directives, but for implementation
109 // reasons they have empty synthetic structured block, to simplify codegen.
110 if (isa<OMPTargetEnterDataDirective>(Val: this) ||
111 isa<OMPTargetExitDataDirective>(Val: this) ||
112 isa<OMPTargetUpdateDirective>(Val: this))
113 return true;
114 return !hasAssociatedStmt();
115}
116
117Stmt *OMPExecutableDirective::getStructuredBlock() {
118 assert(!isStandaloneDirective() &&
119 "Standalone Executable Directives don't have Structured Blocks.");
120 // The loop body is unknwown while a loop transformation is deferred in
121 // a dependent context, so use the whole associated statement instead.
122 if (auto *LD = dyn_cast<OMPLoopDirective>(Val: this))
123 if (Stmt *Body = LD->getBody())
124 return Body;
125 return getRawStmt();
126}
127
128Stmt *
129OMPLoopBasedDirective::tryToFindNextInnerLoop(Stmt *CurStmt,
130 bool TryImperfectlyNestedLoops) {
131 Stmt *OrigStmt = CurStmt;
132 CurStmt = ignoreContainersKeepingIntraTileHint(S: CurStmt);
133 // Additional work for imperfectly nested loops, introduced in OpenMP 5.0.
134 if (TryImperfectlyNestedLoops) {
135 if (auto *CS = dyn_cast<CompoundStmt>(Val: CurStmt)) {
136 CurStmt = nullptr;
137 SmallVector<CompoundStmt *, 4> Statements(1, CS);
138 SmallVector<CompoundStmt *, 4> NextStatements;
139 while (!Statements.empty()) {
140 CS = Statements.pop_back_val();
141 if (!CS)
142 continue;
143 for (Stmt *S : CS->body()) {
144 if (!S)
145 continue;
146 // Peek past a single-child container so a nested loop or
147 // loop-transformation directive (e.g. `#pragma omp reverse` inside
148 // the body of an outer loop) is recognized here. Preserve any
149 // intra-tile hint wrapper so it still reaches the loop-analysis
150 // callback.
151 S = ignoreContainersKeepingIntraTileHint(S);
152 Stmt *Inner = S;
153 if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(Val: Inner))
154 Inner = CanonLoop->getLoopStmt();
155 Inner = OMPLoopBasedDirective::ignoreIntraTileHint(S: Inner);
156 if (isa<ForStmt>(Val: Inner) || isa<CXXForRangeStmt>(Val: Inner) ||
157 (isa<OMPLoopBasedDirective>(Val: Inner) &&
158 !isa<OMPLoopDirective>(Val: Inner))) {
159 // Only single loop construct is allowed.
160 if (CurStmt) {
161 CurStmt = OrigStmt;
162 break;
163 }
164 CurStmt = S;
165 continue;
166 }
167 S = OMPLoopBasedDirective::ignoreIntraTileHint(S);
168 if (auto *InnerCS = dyn_cast_or_null<CompoundStmt>(Val: S))
169 NextStatements.push_back(Elt: InnerCS);
170 }
171 if (Statements.empty()) {
172 // Found single inner loop or multiple loops - exit.
173 if (CurStmt)
174 break;
175 Statements.swap(RHS&: NextStatements);
176 }
177 }
178 if (!CurStmt)
179 CurStmt = OrigStmt;
180 }
181 }
182 return CurStmt;
183}
184
185bool OMPLoopBasedDirective::doForAllLoops(
186 Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops,
187 llvm::function_ref<bool(unsigned, Stmt *, Stmt *)> Callback,
188 llvm::function_ref<void(OMPLoopTransformationDirective *)>
189 OnTransformationCallback,
190 bool RelaxNestForPeeledTransformation) {
191 CurStmt = ignoreContainersKeepingIntraTileHint(S: CurStmt);
192 for (unsigned Cnt = 0; Cnt < NumLoops; ++Cnt) {
193 // A loop generated by a peeled transformation may hold statements before
194 // the next loop (e.g. `reverse` recomputes the user counter there). They
195 // are not intervening user code, so callers that re-emit them may look
196 // through them; the rest of the nest is still checked as usual.
197 bool PeeledTransformation = false;
198 while (true) {
199 auto *Dir = dyn_cast<OMPLoopTransformationDirective>(Val: CurStmt);
200 if (!Dir)
201 break;
202
203 OnTransformationCallback(Dir);
204
205 Stmt *TransformedStmt = Dir->getTransformedStmt();
206 if (!TransformedStmt) {
207 unsigned NumGeneratedTopLevelLoops =
208 Dir->getNumGeneratedTopLevelLoops();
209 if (NumGeneratedTopLevelLoops == 0) {
210 // May happen if the loop transformation does not result in a
211 // generated loop (such as full unrolling).
212 break;
213 }
214 if (NumGeneratedTopLevelLoops > 0) {
215 // The loop transformation construct has generated loops, but these
216 // may not have been generated yet due to being in a dependent
217 // context.
218 return true;
219 }
220 }
221
222 CurStmt = TransformedStmt;
223 PeeledTransformation = true;
224 }
225 if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(Val: CurStmt))
226 CurStmt = CanonLoop->getLoopStmt();
227 // Always hand the real loop to the callback and pass the hint wrapper
228 // separately so the callee can read it.
229 Stmt *LoopStmt = ignoreIntraTileHint(S: CurStmt);
230 Stmt *HintWrapper = LoopStmt != CurStmt ? CurStmt : nullptr;
231 if (Callback(Cnt, LoopStmt, HintWrapper))
232 return false;
233 // Move on to the next nested for loop, or to the loop body.
234 // OpenMP [2.8.1, simd construct, Restrictions]
235 // All loops associated with the construct must be perfectly nested; that
236 // is, there must be no intervening code nor any OpenMP directive between
237 // any two loops.
238 if (auto *For = dyn_cast<ForStmt>(Val: LoopStmt)) {
239 CurStmt = For->getBody();
240 } else {
241 assert(isa<CXXForRangeStmt>(LoopStmt) &&
242 "Expected canonical for or range-based for loops.");
243 CurStmt = cast<CXXForRangeStmt>(Val: LoopStmt)->getBody();
244 }
245 if (RelaxNestForPeeledTransformation && PeeledTransformation &&
246 !getStmtsBeforeNestedLoop(Body: CurStmt).empty())
247 CurStmt = cast<CompoundStmt>(Val: CurStmt)->body_back();
248 CurStmt = OMPLoopBasedDirective::tryToFindNextInnerLoop(
249 CurStmt, TryImperfectlyNestedLoops);
250 }
251 return true;
252}
253
254void OMPLoopBasedDirective::doForAllLoopsBodies(
255 Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops,
256 llvm::function_ref<void(unsigned, Stmt *, Stmt *)> Callback) {
257 bool Res = OMPLoopBasedDirective::doForAllLoops(
258 CurStmt, TryImperfectlyNestedLoops, NumLoops,
259 Callback: [Callback](unsigned Cnt, Stmt *Loop) {
260 Stmt *Body = nullptr;
261 if (auto *For = dyn_cast<ForStmt>(Val: Loop)) {
262 Body = For->getBody();
263 } else {
264 assert(isa<CXXForRangeStmt>(Loop) &&
265 "Expected canonical for or range-based for loops.");
266 Body = cast<CXXForRangeStmt>(Val: Loop)->getBody();
267 }
268 if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(Val: Body))
269 Body = CanonLoop->getLoopStmt();
270 Callback(Cnt, Loop, Body);
271 return false;
272 });
273 assert(Res && "Expected only loops");
274 (void)Res;
275}
276
277Stmt *OMPLoopDirective::getBody() {
278 // This relies on the loop form is already checked by Sema.
279 Stmt *Body = nullptr;
280 OMPLoopBasedDirective::doForAllLoopsBodies(
281 CurStmt: Data->getRawStmt(), /*TryImperfectlyNestedLoops=*/true,
282 NumLoops: NumAssociatedLoops,
283 Callback: [&Body](unsigned, Stmt *, Stmt *BodyStmt) { Body = BodyStmt; });
284 return Body;
285}
286
287void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) {
288 assert(A.size() == getLoopsNumber() &&
289 "Number of loop counters is not the same as the collapsed number");
290 llvm::copy(Range&: A, Out: getCounters().begin());
291}
292
293void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) {
294 assert(A.size() == getLoopsNumber() && "Number of loop private counters "
295 "is not the same as the collapsed "
296 "number");
297 llvm::copy(Range&: A, Out: getPrivateCounters().begin());
298}
299
300void OMPLoopDirective::setInits(ArrayRef<Expr *> A) {
301 assert(A.size() == getLoopsNumber() &&
302 "Number of counter inits is not the same as the collapsed number");
303 llvm::copy(Range&: A, Out: getInits().begin());
304}
305
306void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) {
307 assert(A.size() == getLoopsNumber() &&
308 "Number of counter updates is not the same as the collapsed number");
309 llvm::copy(Range&: A, Out: getUpdates().begin());
310}
311
312void OMPLoopDirective::setFinals(ArrayRef<Expr *> A) {
313 assert(A.size() == getLoopsNumber() &&
314 "Number of counter finals is not the same as the collapsed number");
315 llvm::copy(Range&: A, Out: getFinals().begin());
316}
317
318void OMPLoopDirective::setDependentCounters(ArrayRef<Expr *> A) {
319 assert(
320 A.size() == getLoopsNumber() &&
321 "Number of dependent counters is not the same as the collapsed number");
322 llvm::copy(Range&: A, Out: getDependentCounters().begin());
323}
324
325void OMPLoopDirective::setDependentInits(ArrayRef<Expr *> A) {
326 assert(A.size() == getLoopsNumber() &&
327 "Number of dependent inits is not the same as the collapsed number");
328 llvm::copy(Range&: A, Out: getDependentInits().begin());
329}
330
331void OMPLoopDirective::setFinalsConditions(ArrayRef<Expr *> A) {
332 assert(A.size() == getLoopsNumber() &&
333 "Number of finals conditions is not the same as the collapsed number");
334 llvm::copy(Range&: A, Out: getFinalsConditions().begin());
335}
336
337void OMPLoopDirective::setHelperExprs(const HelperExprs &Exprs) {
338 setIterationVariable(Exprs.IterationVarRef);
339 setLastIteration(Exprs.LastIteration);
340 setCalcLastIteration(Exprs.CalcLastIteration);
341 setPreCond(Exprs.PreCond);
342 setCond(Exprs.Cond);
343 setInit(Exprs.Init);
344 setInc(Exprs.Inc);
345 setCounters(Exprs.Counters);
346 setPrivateCounters(Exprs.PrivateCounters);
347 setInits(Exprs.Inits);
348 setUpdates(Exprs.Updates);
349 setFinals(Exprs.Finals);
350 setDependentCounters(Exprs.DependentCounters);
351 setDependentInits(Exprs.DependentInits);
352 setFinalsConditions(Exprs.FinalsConditions);
353 setPreInits(Exprs.PreInits);
354
355 const unsigned ArraysOffset = getArraysOffset(Kind: getDirectiveKind());
356 // Simd directives have no worksharing helpers.
357 if (ArraysOffset == DefaultEnd)
358 return;
359 setIsLastIterVariable(Exprs.IL);
360 setLowerBoundVariable(Exprs.LB);
361 setUpperBoundVariable(Exprs.UB);
362 setStrideVariable(Exprs.ST);
363 setEnsureUpperBound(Exprs.EUB);
364 setNextLowerBound(Exprs.NLB);
365 setNextUpperBound(Exprs.NUB);
366 setNumIterations(Exprs.NumIterations);
367
368 if (ArraysOffset == WorksharingEnd)
369 return;
370 setPrevLowerBoundVariable(Exprs.PrevLB);
371 setPrevUpperBoundVariable(Exprs.PrevUB);
372 setDistInc(Exprs.DistInc);
373 setPrevEnsureUpperBound(Exprs.PrevEUB);
374 setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
375 setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
376 setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
377 setCombinedInit(Exprs.DistCombinedFields.Init);
378 setCombinedCond(Exprs.DistCombinedFields.Cond);
379 setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
380 setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
381 setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
382 setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
383}
384
385OMPMetaDirective *OMPMetaDirective::allocate(const ASTContext &C,
386 unsigned NumVariants,
387 SourceLocation StartLoc,
388 SourceLocation EndLoc) {
389 void *Mem =
390 C.Allocate(Size: sizeof(OMPMetaDirective) + getTraitInfosOffset(NumVariants) +
391 NumVariants * sizeof(OMPTraitInfo *),
392 Align: alignof(OMPMetaDirective));
393 auto *Data = OMPChildren::CreateEmpty(
394 Mem: reinterpret_cast<OMPMetaDirective *>(Mem) + 1, /*NumClauses=*/0,
395 /*HasAssociatedStmt=*/false, NumChildren: 2 * NumVariants);
396 auto *Dir = new (Mem) OMPMetaDirective(StartLoc, EndLoc);
397 Dir->Data = Data;
398 return Dir;
399}
400
401OMPMetaDirective *OMPMetaDirective::Create(
402 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
403 ArrayRef<Stmt *> Variants, ArrayRef<Expr *> Conditions,
404 ArrayRef<OMPTraitInfo *> TraitInfos, bool HasImplicitOtherwise) {
405 assert(Variants.size() == Conditions.size() &&
406 Variants.size() == TraitInfos.size() &&
407 "Expected one condition and one trait info per variant");
408 OMPMetaDirective *Dir = allocate(C, NumVariants: Variants.size(), StartLoc, EndLoc);
409 llvm::copy(Range&: Variants, Out: Dir->getTrailingVariants().begin());
410 llvm::copy(Range&: Conditions, Out: Dir->getTrailingConditions().begin());
411 llvm::copy(Range&: TraitInfos, Out: Dir->getTrailingTraitInfos().begin());
412 Dir->setHasImplicitOtherwise(HasImplicitOtherwise);
413 return Dir;
414}
415
416OMPMetaDirective *OMPMetaDirective::CreateEmpty(const ASTContext &C,
417 unsigned NumVariants,
418 EmptyShell) {
419 return allocate(C, NumVariants, StartLoc: SourceLocation(), EndLoc: SourceLocation());
420}
421
422OMPParallelDirective *OMPParallelDirective::Create(
423 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
424 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
425 bool HasCancel) {
426 auto *Dir = createDirective<OMPParallelDirective>(
427 C, Clauses, AssociatedStmt, /*NumChildren=*/1, P&: StartLoc, P&: EndLoc);
428 Dir->setTaskReductionRefExpr(TaskRedRef);
429 Dir->setHasCancel(HasCancel);
430 return Dir;
431}
432
433OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C,
434 unsigned NumClauses,
435 EmptyShell) {
436 return createEmptyDirective<OMPParallelDirective>(C, NumClauses,
437 /*HasAssociatedStmt=*/true,
438 /*NumChildren=*/1);
439}
440
441OMPSimdDirective *
442OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
443 SourceLocation EndLoc, unsigned CollapsedNum,
444 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
445 const HelperExprs &Exprs) {
446 auto *Dir = createDirective<OMPSimdDirective>(
447 C, Clauses, AssociatedStmt, NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_simd),
448 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
449 Dir->setHelperExprs(Exprs);
450 return Dir;
451}
452
453OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C,
454 unsigned NumClauses,
455 unsigned CollapsedNum,
456 EmptyShell) {
457 return createEmptyDirective<OMPSimdDirective>(
458 C, NumClauses, /*HasAssociatedStmt=*/true,
459 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_simd), P&: CollapsedNum);
460}
461
462OMPForDirective *OMPForDirective::Create(
463 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
464 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
465 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
466 auto *Dir = createDirective<OMPForDirective>(
467 C, Clauses, AssociatedStmt, NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_for) + 1,
468 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
469 Dir->setHelperExprs(Exprs);
470 Dir->setTaskReductionRefExpr(TaskRedRef);
471 Dir->setHasCancel(HasCancel);
472 return Dir;
473}
474
475Stmt *OMPLoopTransformationDirective::getTransformedStmt() const {
476 if (auto *D = dyn_cast<OMPCanonicalLoopNestTransformationDirective>(Val: S))
477 return D->getTransformedStmt();
478 if (auto *D = dyn_cast<OMPCanonicalLoopSequenceTransformationDirective>(Val: S))
479 return D->getTransformedStmt();
480 llvm_unreachable("unexpected object type");
481}
482
483Stmt *OMPLoopTransformationDirective::getPreInits() const {
484 if (auto *D = dyn_cast<OMPCanonicalLoopNestTransformationDirective>(Val: S))
485 return D->getPreInits();
486 if (auto *D = dyn_cast<OMPCanonicalLoopSequenceTransformationDirective>(Val: S))
487 return D->getPreInits();
488 llvm_unreachable("unexpected object type");
489}
490
491Stmt *OMPLoopTransformationDirective::getFinals() const {
492 if (auto *D = dyn_cast<OMPCanonicalLoopNestTransformationDirective>(Val: S))
493 return D->getFinals();
494 if (auto *D = dyn_cast<OMPCanonicalLoopSequenceTransformationDirective>(Val: S))
495 return D->getFinals();
496 llvm_unreachable("unexpected object type");
497}
498
499Stmt *OMPCanonicalLoopNestTransformationDirective::getTransformedStmt() const {
500 switch (getStmtClass()) {
501#define STMT(CLASS, PARENT)
502#define ABSTRACT_STMT(CLASS)
503#define OMPCANONICALLOOPNESTTRANSFORMATIONDIRECTIVE(CLASS, PARENT) \
504 case Stmt::CLASS##Class: \
505 return static_cast<const CLASS *>(this)->getTransformedStmt();
506#include "clang/AST/StmtNodes.inc"
507 default:
508 llvm_unreachable("Not a loop transformation for canonical loop nests");
509 }
510}
511
512Stmt *OMPCanonicalLoopNestTransformationDirective::getPreInits() const {
513 switch (getStmtClass()) {
514#define STMT(CLASS, PARENT)
515#define ABSTRACT_STMT(CLASS)
516#define OMPCANONICALLOOPNESTTRANSFORMATIONDIRECTIVE(CLASS, PARENT) \
517 case Stmt::CLASS##Class: \
518 return static_cast<const CLASS *>(this)->getPreInits();
519#include "clang/AST/StmtNodes.inc"
520 default:
521 llvm_unreachable("Not a loop transformation for canonical loop nests");
522 }
523}
524
525Stmt *OMPCanonicalLoopNestTransformationDirective::getFinals() const {
526 switch (getStmtClass()) {
527#define STMT(CLASS, PARENT)
528#define ABSTRACT_STMT(CLASS)
529#define OMPCANONICALLOOPNESTTRANSFORMATIONDIRECTIVE(CLASS, PARENT) \
530 case Stmt::CLASS##Class: \
531 return static_cast<const CLASS *>(this)->getFinals();
532#include "clang/AST/StmtNodes.inc"
533 default:
534 llvm_unreachable("Not a loop transformation for canonical loop nests");
535 }
536}
537
538Stmt *
539OMPCanonicalLoopSequenceTransformationDirective::getTransformedStmt() const {
540 switch (getStmtClass()) {
541#define STMT(CLASS, PARENT)
542#define ABSTRACT_STMT(CLASS)
543#define OMPCANONICALLOOPSEQUENCETRANSFORMATIONDIRECTIVE(CLASS, PARENT) \
544 case Stmt::CLASS##Class: \
545 return static_cast<const CLASS *>(this)->getTransformedStmt();
546#include "clang/AST/StmtNodes.inc"
547 default:
548 llvm_unreachable("Not a loop transformation for canonical loop sequences");
549 }
550}
551
552Stmt *OMPCanonicalLoopSequenceTransformationDirective::getPreInits() const {
553 switch (getStmtClass()) {
554#define STMT(CLASS, PARENT)
555#define ABSTRACT_STMT(CLASS)
556#define OMPCANONICALLOOPSEQUENCETRANSFORMATIONDIRECTIVE(CLASS, PARENT) \
557 case Stmt::CLASS##Class: \
558 return static_cast<const CLASS *>(this)->getPreInits();
559#include "clang/AST/StmtNodes.inc"
560 default:
561 llvm_unreachable("Not a loop transformation for canonical loop sequences");
562 }
563}
564
565Stmt *OMPCanonicalLoopSequenceTransformationDirective::getFinals() const {
566 switch (getStmtClass()) {
567#define STMT(CLASS, PARENT)
568#define ABSTRACT_STMT(CLASS)
569#define OMPCANONICALLOOPSEQUENCETRANSFORMATIONDIRECTIVE(CLASS, PARENT) \
570 case Stmt::CLASS##Class: \
571 return static_cast<const CLASS *>(this)->getFinals();
572#include "clang/AST/StmtNodes.inc"
573 default:
574 llvm_unreachable("Not a loop transformation for canonical loop sequences");
575 }
576}
577
578OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C,
579 unsigned NumClauses,
580 unsigned CollapsedNum,
581 EmptyShell) {
582 return createEmptyDirective<OMPForDirective>(
583 C, NumClauses, /*HasAssociatedStmt=*/true,
584 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_for) + 1, P&: CollapsedNum);
585}
586
587OMPTileDirective *
588OMPTileDirective::Create(const ASTContext &C, SourceLocation StartLoc,
589 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
590 unsigned NumLoops, Stmt *AssociatedStmt,
591 Stmt *TransformedStmt, Stmt *PreInits, Stmt *Finals) {
592 OMPTileDirective *Dir = createDirective<OMPTileDirective>(
593 C, Clauses, AssociatedStmt, NumChildren: FinalsOffset + 1, P&: StartLoc, P&: EndLoc, P&: NumLoops);
594 Dir->setTransformedStmt(TransformedStmt);
595 Dir->setPreInits(PreInits);
596 Dir->setFinals(Finals);
597 return Dir;
598}
599
600OMPTileDirective *OMPTileDirective::CreateEmpty(const ASTContext &C,
601 unsigned NumClauses,
602 unsigned NumLoops) {
603 return createEmptyDirective<OMPTileDirective>(
604 C, NumClauses, /*HasAssociatedStmt=*/true, NumChildren: FinalsOffset + 1,
605 P: SourceLocation(), P: SourceLocation(), P&: NumLoops);
606}
607
608OMPStripeDirective *OMPStripeDirective::Create(
609 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
610 ArrayRef<OMPClause *> Clauses, unsigned NumLoops, Stmt *AssociatedStmt,
611 Stmt *TransformedStmt, Stmt *PreInits, Stmt *Finals) {
612 OMPStripeDirective *Dir = createDirective<OMPStripeDirective>(
613 C, Clauses, AssociatedStmt, NumChildren: FinalsOffset + 1, P&: StartLoc, P&: EndLoc, P&: NumLoops);
614 Dir->setTransformedStmt(TransformedStmt);
615 Dir->setPreInits(PreInits);
616 Dir->setFinals(Finals);
617 return Dir;
618}
619
620OMPStripeDirective *OMPStripeDirective::CreateEmpty(const ASTContext &C,
621 unsigned NumClauses,
622 unsigned NumLoops) {
623 return createEmptyDirective<OMPStripeDirective>(
624 C, NumClauses, /*HasAssociatedStmt=*/true, NumChildren: FinalsOffset + 1,
625 P: SourceLocation(), P: SourceLocation(), P&: NumLoops);
626}
627
628OMPUnrollDirective *OMPUnrollDirective::Create(
629 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
630 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
631 unsigned NumGeneratedTopLevelLoops, Stmt *TransformedStmt, Stmt *PreInits,
632 Stmt *Finals) {
633 assert(NumGeneratedTopLevelLoops <= 1 &&
634 "Unrolling generates at most one loop");
635
636 auto *Dir = createDirective<OMPUnrollDirective>(
637 C, Clauses, AssociatedStmt, NumChildren: FinalsOffset + 1, P&: StartLoc, P&: EndLoc);
638 Dir->setNumGeneratedTopLevelLoops(NumGeneratedTopLevelLoops);
639 Dir->setTransformedStmt(TransformedStmt);
640 Dir->setPreInits(PreInits);
641 Dir->setFinals(Finals);
642 return Dir;
643}
644
645OMPUnrollDirective *OMPUnrollDirective::CreateEmpty(const ASTContext &C,
646 unsigned NumClauses) {
647 return createEmptyDirective<OMPUnrollDirective>(
648 C, NumClauses, /*HasAssociatedStmt=*/true, NumChildren: FinalsOffset + 1,
649 P: SourceLocation(), P: SourceLocation());
650}
651
652OMPReverseDirective *
653OMPReverseDirective::Create(const ASTContext &C, SourceLocation StartLoc,
654 SourceLocation EndLoc, Stmt *AssociatedStmt,
655 unsigned NumLoops, Stmt *TransformedStmt,
656 Stmt *PreInits, Stmt *Finals) {
657 OMPReverseDirective *Dir = createDirective<OMPReverseDirective>(
658 C, Clauses: {}, AssociatedStmt, NumChildren: FinalsOffset + 1, P&: StartLoc, P&: EndLoc, P&: NumLoops);
659 Dir->setTransformedStmt(TransformedStmt);
660 Dir->setPreInits(PreInits);
661 Dir->setFinals(Finals);
662 return Dir;
663}
664
665OMPReverseDirective *OMPReverseDirective::CreateEmpty(const ASTContext &C,
666 unsigned NumLoops) {
667 return createEmptyDirective<OMPReverseDirective>(
668 C, /*NumClauses=*/0, /*HasAssociatedStmt=*/true, NumChildren: FinalsOffset + 1,
669 P: SourceLocation(), P: SourceLocation(), P&: NumLoops);
670}
671
672OMPInterchangeDirective *OMPInterchangeDirective::Create(
673 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
674 ArrayRef<OMPClause *> Clauses, unsigned NumLoops, Stmt *AssociatedStmt,
675 Stmt *TransformedStmt, Stmt *PreInits, Stmt *Finals) {
676 OMPInterchangeDirective *Dir = createDirective<OMPInterchangeDirective>(
677 C, Clauses, AssociatedStmt, NumChildren: FinalsOffset + 1, P&: StartLoc, P&: EndLoc, P&: NumLoops);
678 Dir->setTransformedStmt(TransformedStmt);
679 Dir->setPreInits(PreInits);
680 Dir->setFinals(Finals);
681 return Dir;
682}
683
684OMPInterchangeDirective *
685OMPInterchangeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
686 unsigned NumLoops) {
687 return createEmptyDirective<OMPInterchangeDirective>(
688 C, NumClauses, /*HasAssociatedStmt=*/true, NumChildren: FinalsOffset + 1,
689 P: SourceLocation(), P: SourceLocation(), P&: NumLoops);
690}
691
692OMPFlattenDirective *OMPFlattenDirective::Create(
693 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
694 ArrayRef<OMPClause *> Clauses, unsigned NumLoops, Stmt *AssociatedStmt,
695 Stmt *TransformedStmt, Stmt *PreInits, Stmt *Finals) {
696 OMPFlattenDirective *Dir = createDirective<OMPFlattenDirective>(
697 C, Clauses, AssociatedStmt, NumChildren: FinalsOffset + 1, P&: StartLoc, P&: EndLoc, P&: NumLoops);
698 Dir->setTransformedStmt(TransformedStmt);
699 Dir->setPreInits(PreInits);
700 Dir->setFinals(Finals);
701 return Dir;
702}
703
704OMPFlattenDirective *OMPFlattenDirective::CreateEmpty(const ASTContext &C,
705 unsigned NumClauses,
706 unsigned NumLoops) {
707 return createEmptyDirective<OMPFlattenDirective>(
708 C, NumClauses, /*HasAssociatedStmt=*/true, NumChildren: FinalsOffset + 1,
709 P: SourceLocation(), P: SourceLocation(), P&: NumLoops);
710}
711
712OMPSplitDirective *
713OMPSplitDirective::Create(const ASTContext &C, SourceLocation StartLoc,
714 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
715 unsigned NumLoops, Stmt *AssociatedStmt,
716 Stmt *TransformedStmt, Stmt *PreInits, Stmt *Finals) {
717 OMPSplitDirective *Dir = createDirective<OMPSplitDirective>(
718 C, Clauses, AssociatedStmt, NumChildren: FinalsOffset + 1, P&: StartLoc, P&: EndLoc, P&: NumLoops);
719 Dir->setTransformedStmt(TransformedStmt);
720 Dir->setPreInits(PreInits);
721 Dir->setFinals(Finals);
722 return Dir;
723}
724
725OMPSplitDirective *OMPSplitDirective::CreateEmpty(const ASTContext &C,
726 unsigned NumClauses,
727 unsigned NumLoops) {
728 return createEmptyDirective<OMPSplitDirective>(
729 C, NumClauses, /*HasAssociatedStmt=*/true, NumChildren: FinalsOffset + 1,
730 P: SourceLocation(), P: SourceLocation(), P&: NumLoops);
731}
732
733OMPFuseDirective *OMPFuseDirective::Create(
734 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
735 ArrayRef<OMPClause *> Clauses, unsigned NumGeneratedTopLevelLoops,
736 Stmt *AssociatedStmt, Stmt *TransformedStmt, Stmt *PreInits, Stmt *Finals) {
737
738 OMPFuseDirective *Dir = createDirective<OMPFuseDirective>(
739 C, Clauses, AssociatedStmt, NumChildren: FinalsOffset + 1, P&: StartLoc, P&: EndLoc);
740 Dir->setTransformedStmt(TransformedStmt);
741 Dir->setPreInits(PreInits);
742 Dir->setFinals(Finals);
743 Dir->setNumGeneratedTopLevelLoops(NumGeneratedTopLevelLoops);
744 return Dir;
745}
746
747OMPFuseDirective *OMPFuseDirective::CreateEmpty(const ASTContext &C,
748 unsigned NumClauses) {
749 OMPFuseDirective *Dir = createEmptyDirective<OMPFuseDirective>(
750 C, NumClauses, /*HasAssociatedStmt=*/true, NumChildren: FinalsOffset + 1,
751 P: SourceLocation(), P: SourceLocation());
752 return Dir;
753}
754
755OMPForSimdDirective *
756OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
757 SourceLocation EndLoc, unsigned CollapsedNum,
758 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
759 const HelperExprs &Exprs) {
760 auto *Dir = createDirective<OMPForSimdDirective>(
761 C, Clauses, AssociatedStmt, NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_for_simd),
762 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
763 Dir->setHelperExprs(Exprs);
764 return Dir;
765}
766
767OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C,
768 unsigned NumClauses,
769 unsigned CollapsedNum,
770 EmptyShell) {
771 return createEmptyDirective<OMPForSimdDirective>(
772 C, NumClauses, /*HasAssociatedStmt=*/true,
773 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_for_simd), P&: CollapsedNum);
774}
775
776OMPSectionsDirective *OMPSectionsDirective::Create(
777 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
778 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
779 bool HasCancel) {
780 auto *Dir = createDirective<OMPSectionsDirective>(C, Clauses, AssociatedStmt,
781 /*NumChildren=*/1, P&: StartLoc,
782 P&: EndLoc);
783 Dir->setTaskReductionRefExpr(TaskRedRef);
784 Dir->setHasCancel(HasCancel);
785 return Dir;
786}
787
788OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C,
789 unsigned NumClauses,
790 EmptyShell) {
791 return createEmptyDirective<OMPSectionsDirective>(C, NumClauses,
792 /*HasAssociatedStmt=*/true,
793 /*NumChildren=*/1);
794}
795
796OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C,
797 SourceLocation StartLoc,
798 SourceLocation EndLoc,
799 Stmt *AssociatedStmt,
800 bool HasCancel) {
801 auto *Dir =
802 createDirective<OMPSectionDirective>(C, Clauses: {}, AssociatedStmt,
803 /*NumChildren=*/0, P&: StartLoc, P&: EndLoc);
804 Dir->setHasCancel(HasCancel);
805 return Dir;
806}
807
808OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,
809 EmptyShell) {
810 return createEmptyDirective<OMPSectionDirective>(C, /*NumClauses=*/0,
811 /*HasAssociatedStmt=*/true);
812}
813
814OMPScopeDirective *OMPScopeDirective::Create(const ASTContext &C,
815 SourceLocation StartLoc,
816 SourceLocation EndLoc,
817 ArrayRef<OMPClause *> Clauses,
818 Stmt *AssociatedStmt) {
819 return createDirective<OMPScopeDirective>(C, Clauses, AssociatedStmt,
820 /*NumChildren=*/0, P&: StartLoc,
821 P&: EndLoc);
822}
823
824OMPScopeDirective *OMPScopeDirective::CreateEmpty(const ASTContext &C,
825 unsigned NumClauses,
826 EmptyShell) {
827 return createEmptyDirective<OMPScopeDirective>(C, NumClauses,
828 /*HasAssociatedStmt=*/true);
829}
830
831OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,
832 SourceLocation StartLoc,
833 SourceLocation EndLoc,
834 ArrayRef<OMPClause *> Clauses,
835 Stmt *AssociatedStmt) {
836 return createDirective<OMPSingleDirective>(C, Clauses, AssociatedStmt,
837 /*NumChildren=*/0, P&: StartLoc,
838 P&: EndLoc);
839}
840
841OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,
842 unsigned NumClauses,
843 EmptyShell) {
844 return createEmptyDirective<OMPSingleDirective>(C, NumClauses,
845 /*HasAssociatedStmt=*/true);
846}
847
848OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C,
849 SourceLocation StartLoc,
850 SourceLocation EndLoc,
851 Stmt *AssociatedStmt) {
852 return createDirective<OMPMasterDirective>(C, Clauses: {}, AssociatedStmt,
853 /*NumChildren=*/0, P&: StartLoc,
854 P&: EndLoc);
855}
856
857OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C,
858 EmptyShell) {
859 return createEmptyDirective<OMPMasterDirective>(C, /*NumClauses=*/0,
860 /*HasAssociatedStmt=*/true);
861}
862
863OMPCriticalDirective *OMPCriticalDirective::Create(
864 const ASTContext &C, const DeclarationNameInfo &Name,
865 SourceLocation StartLoc, SourceLocation EndLoc,
866 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
867 return createDirective<OMPCriticalDirective>(C, Clauses, AssociatedStmt,
868 /*NumChildren=*/0, P: Name,
869 P&: StartLoc, P&: EndLoc);
870}
871
872OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C,
873 unsigned NumClauses,
874 EmptyShell) {
875 return createEmptyDirective<OMPCriticalDirective>(C, NumClauses,
876 /*HasAssociatedStmt=*/true);
877}
878
879OMPParallelForDirective *OMPParallelForDirective::Create(
880 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
881 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
882 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
883 auto *Dir = createDirective<OMPParallelForDirective>(
884 C, Clauses, AssociatedStmt,
885 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_for) + 1, P&: StartLoc, P&: EndLoc,
886 P&: CollapsedNum);
887 Dir->setHelperExprs(Exprs);
888 Dir->setTaskReductionRefExpr(TaskRedRef);
889 Dir->setHasCancel(HasCancel);
890 return Dir;
891}
892
893OMPParallelForDirective *
894OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
895 unsigned CollapsedNum, EmptyShell) {
896 return createEmptyDirective<OMPParallelForDirective>(
897 C, NumClauses, /*HasAssociatedStmt=*/true,
898 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_for) + 1, P&: CollapsedNum);
899}
900
901OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create(
902 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
903 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
904 const HelperExprs &Exprs) {
905 auto *Dir = createDirective<OMPParallelForSimdDirective>(
906 C, Clauses, AssociatedStmt,
907 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_for_simd), P&: StartLoc, P&: EndLoc,
908 P&: CollapsedNum);
909 Dir->setHelperExprs(Exprs);
910 return Dir;
911}
912
913OMPParallelForSimdDirective *
914OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C,
915 unsigned NumClauses,
916 unsigned CollapsedNum, EmptyShell) {
917 return createEmptyDirective<OMPParallelForSimdDirective>(
918 C, NumClauses, /*HasAssociatedStmt=*/true,
919 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_for_simd), P&: CollapsedNum);
920}
921
922OMPParallelMasterDirective *OMPParallelMasterDirective::Create(
923 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
924 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef) {
925 auto *Dir = createDirective<OMPParallelMasterDirective>(
926 C, Clauses, AssociatedStmt, /*NumChildren=*/1, P&: StartLoc, P&: EndLoc);
927 Dir->setTaskReductionRefExpr(TaskRedRef);
928 return Dir;
929}
930
931OMPParallelMasterDirective *
932OMPParallelMasterDirective::CreateEmpty(const ASTContext &C,
933 unsigned NumClauses, EmptyShell) {
934 return createEmptyDirective<OMPParallelMasterDirective>(
935 C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
936}
937
938OMPParallelMaskedDirective *OMPParallelMaskedDirective::Create(
939 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
940 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef) {
941 auto *Dir = createDirective<OMPParallelMaskedDirective>(
942 C, Clauses, AssociatedStmt, /*NumChildren=*/1, P&: StartLoc, P&: EndLoc);
943 Dir->setTaskReductionRefExpr(TaskRedRef);
944 return Dir;
945}
946
947OMPParallelMaskedDirective *
948OMPParallelMaskedDirective::CreateEmpty(const ASTContext &C,
949 unsigned NumClauses, EmptyShell) {
950 return createEmptyDirective<OMPParallelMaskedDirective>(
951 C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
952}
953
954OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(
955 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
956 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
957 bool HasCancel) {
958 auto *Dir = createDirective<OMPParallelSectionsDirective>(
959 C, Clauses, AssociatedStmt, /*NumChildren=*/1, P&: StartLoc, P&: EndLoc);
960 Dir->setTaskReductionRefExpr(TaskRedRef);
961 Dir->setHasCancel(HasCancel);
962 return Dir;
963}
964
965OMPParallelSectionsDirective *
966OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,
967 unsigned NumClauses, EmptyShell) {
968 return createEmptyDirective<OMPParallelSectionsDirective>(
969 C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
970}
971
972OMPTaskDirective *
973OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc,
974 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
975 Stmt *AssociatedStmt, bool HasCancel) {
976 auto *Dir = createDirective<OMPTaskDirective>(
977 C, Clauses, AssociatedStmt, /*NumChildren=*/0, P&: StartLoc, P&: EndLoc);
978 Dir->setHasCancel(HasCancel);
979 return Dir;
980}
981
982OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C,
983 unsigned NumClauses,
984 EmptyShell) {
985 return createEmptyDirective<OMPTaskDirective>(C, NumClauses,
986 /*HasAssociatedStmt=*/true);
987}
988
989OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C,
990 SourceLocation StartLoc,
991 SourceLocation EndLoc) {
992 return new (C) OMPTaskyieldDirective(StartLoc, EndLoc);
993}
994
995OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C,
996 EmptyShell) {
997 return new (C) OMPTaskyieldDirective();
998}
999
1000OMPAssumeDirective *OMPAssumeDirective::Create(const ASTContext &C,
1001 SourceLocation StartLoc,
1002 SourceLocation EndLoc,
1003 ArrayRef<OMPClause *> Clauses,
1004 Stmt *AStmt) {
1005 return createDirective<OMPAssumeDirective>(C, Clauses, AssociatedStmt: AStmt,
1006 /*NumChildren=*/0, P&: StartLoc,
1007 P&: EndLoc);
1008}
1009
1010OMPAssumeDirective *OMPAssumeDirective::CreateEmpty(const ASTContext &C,
1011 unsigned NumClauses,
1012 EmptyShell) {
1013 return createEmptyDirective<OMPAssumeDirective>(C, NumClauses,
1014 /*HasAssociatedStmt=*/true);
1015}
1016
1017OMPErrorDirective *OMPErrorDirective::Create(const ASTContext &C,
1018 SourceLocation StartLoc,
1019 SourceLocation EndLoc,
1020 ArrayRef<OMPClause *> Clauses) {
1021 return createDirective<OMPErrorDirective>(
1022 C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, P&: StartLoc,
1023 P&: EndLoc);
1024}
1025
1026OMPErrorDirective *OMPErrorDirective::CreateEmpty(const ASTContext &C,
1027 unsigned NumClauses,
1028 EmptyShell) {
1029 return createEmptyDirective<OMPErrorDirective>(C, NumClauses);
1030}
1031
1032OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,
1033 SourceLocation StartLoc,
1034 SourceLocation EndLoc) {
1035 return new (C) OMPBarrierDirective(StartLoc, EndLoc);
1036}
1037
1038OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,
1039 EmptyShell) {
1040 return new (C) OMPBarrierDirective();
1041}
1042
1043OMPTaskwaitDirective *
1044OMPTaskwaitDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1045 SourceLocation EndLoc,
1046 ArrayRef<OMPClause *> Clauses) {
1047 return createDirective<OMPTaskwaitDirective>(
1048 C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, P&: StartLoc,
1049 P&: EndLoc);
1050}
1051
1052OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,
1053 unsigned NumClauses,
1054 EmptyShell) {
1055 return createEmptyDirective<OMPTaskwaitDirective>(C, NumClauses);
1056}
1057
1058OMPTaskgroupDirective *OMPTaskgroupDirective::Create(
1059 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1060 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) {
1061 auto *Dir = createDirective<OMPTaskgroupDirective>(
1062 C, Clauses, AssociatedStmt, /*NumChildren=*/1, P&: StartLoc, P&: EndLoc);
1063 Dir->setReductionRef(ReductionRef);
1064 return Dir;
1065}
1066
1067OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C,
1068 unsigned NumClauses,
1069 EmptyShell) {
1070 return createEmptyDirective<OMPTaskgroupDirective>(
1071 C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
1072}
1073
1074OMPCancellationPointDirective *OMPCancellationPointDirective::Create(
1075 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1076 OpenMPDirectiveKind CancelRegion) {
1077 auto *Dir = new (C) OMPCancellationPointDirective(StartLoc, EndLoc);
1078 Dir->setCancelRegion(CancelRegion);
1079 return Dir;
1080}
1081
1082OMPCancellationPointDirective *
1083OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) {
1084 return new (C) OMPCancellationPointDirective();
1085}
1086
1087OMPCancelDirective *
1088OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1089 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
1090 OpenMPDirectiveKind CancelRegion) {
1091 auto *Dir = createDirective<OMPCancelDirective>(
1092 C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, P&: StartLoc,
1093 P&: EndLoc);
1094 Dir->setCancelRegion(CancelRegion);
1095 return Dir;
1096}
1097
1098OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C,
1099 unsigned NumClauses,
1100 EmptyShell) {
1101 return createEmptyDirective<OMPCancelDirective>(C, NumClauses);
1102}
1103
1104OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C,
1105 SourceLocation StartLoc,
1106 SourceLocation EndLoc,
1107 ArrayRef<OMPClause *> Clauses) {
1108 return createDirective<OMPFlushDirective>(
1109 C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, P&: StartLoc,
1110 P&: EndLoc);
1111}
1112
1113OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C,
1114 unsigned NumClauses,
1115 EmptyShell) {
1116 return createEmptyDirective<OMPFlushDirective>(C, NumClauses);
1117}
1118
1119OMPDepobjDirective *OMPDepobjDirective::Create(const ASTContext &C,
1120 SourceLocation StartLoc,
1121 SourceLocation EndLoc,
1122 ArrayRef<OMPClause *> Clauses) {
1123 return createDirective<OMPDepobjDirective>(
1124 C, Clauses, /*AssociatedStmt=*/nullptr,
1125 /*NumChildren=*/0, P&: StartLoc, P&: EndLoc);
1126}
1127
1128OMPDepobjDirective *OMPDepobjDirective::CreateEmpty(const ASTContext &C,
1129 unsigned NumClauses,
1130 EmptyShell) {
1131 return createEmptyDirective<OMPDepobjDirective>(C, NumClauses);
1132}
1133
1134OMPScanDirective *OMPScanDirective::Create(const ASTContext &C,
1135 SourceLocation StartLoc,
1136 SourceLocation EndLoc,
1137 ArrayRef<OMPClause *> Clauses) {
1138 return createDirective<OMPScanDirective>(C, Clauses,
1139 /*AssociatedStmt=*/nullptr,
1140 /*NumChildren=*/0, P&: StartLoc, P&: EndLoc);
1141}
1142
1143OMPScanDirective *OMPScanDirective::CreateEmpty(const ASTContext &C,
1144 unsigned NumClauses,
1145 EmptyShell) {
1146 return createEmptyDirective<OMPScanDirective>(C, NumClauses);
1147}
1148
1149OMPOrderedStandaloneDirective *OMPOrderedStandaloneDirective::Create(
1150 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1151 ArrayRef<OMPClause *> Clauses) {
1152 return createDirective<OMPOrderedStandaloneDirective>(
1153 C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, P&: StartLoc,
1154 P&: EndLoc);
1155}
1156
1157OMPOrderedStandaloneDirective *
1158OMPOrderedStandaloneDirective::CreateEmpty(const ASTContext &C,
1159 unsigned NumClauses, EmptyShell) {
1160 return createEmptyDirective<OMPOrderedStandaloneDirective>(C, NumClauses);
1161}
1162
1163OMPOrderedBlockAssocDirective *OMPOrderedBlockAssocDirective::Create(
1164 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1165 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1166 return createDirective<OMPOrderedBlockAssocDirective>(
1167 C, Clauses, AssociatedStmt: cast<CapturedStmt>(Val: AssociatedStmt), /*NumChildren=*/0,
1168 P&: StartLoc, P&: EndLoc);
1169}
1170
1171OMPOrderedBlockAssocDirective *
1172OMPOrderedBlockAssocDirective::CreateEmpty(const ASTContext &C,
1173 unsigned NumClauses, EmptyShell) {
1174 return createEmptyDirective<OMPOrderedBlockAssocDirective>(
1175 C, NumClauses, /*HasAssociatedStmt=*/true);
1176}
1177
1178OMPAtomicDirective *
1179OMPAtomicDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1180 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
1181 Stmt *AssociatedStmt, Expressions Exprs) {
1182 auto *Dir = createDirective<OMPAtomicDirective>(
1183 C, Clauses, AssociatedStmt, /*NumChildren=*/7, P&: StartLoc, P&: EndLoc);
1184 Dir->setX(Exprs.X);
1185 Dir->setV(Exprs.V);
1186 Dir->setR(Exprs.R);
1187 Dir->setExpr(Exprs.E);
1188 Dir->setUpdateExpr(Exprs.UE);
1189 Dir->setD(Exprs.D);
1190 Dir->setCond(Exprs.Cond);
1191 Dir->Flags.IsXLHSInRHSPart = Exprs.IsXLHSInRHSPart ? 1 : 0;
1192 Dir->Flags.IsPostfixUpdate = Exprs.IsPostfixUpdate ? 1 : 0;
1193 Dir->Flags.IsFailOnly = Exprs.IsFailOnly ? 1 : 0;
1194 return Dir;
1195}
1196
1197OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,
1198 unsigned NumClauses,
1199 EmptyShell) {
1200 return createEmptyDirective<OMPAtomicDirective>(
1201 C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/7);
1202}
1203
1204OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,
1205 SourceLocation StartLoc,
1206 SourceLocation EndLoc,
1207 ArrayRef<OMPClause *> Clauses,
1208 Stmt *AssociatedStmt) {
1209 return createDirective<OMPTargetDirective>(
1210 C, Clauses, AssociatedStmt, /*NumChildren=*/0, P&: StartLoc, P&: EndLoc);
1211}
1212
1213OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,
1214 unsigned NumClauses,
1215 EmptyShell) {
1216 return createEmptyDirective<OMPTargetDirective>(C, NumClauses,
1217 /*HasAssociatedStmt=*/true);
1218}
1219
1220OMPTargetParallelDirective *OMPTargetParallelDirective::Create(
1221 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1222 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
1223 bool HasCancel) {
1224 auto *Dir = createDirective<OMPTargetParallelDirective>(
1225 C, Clauses, AssociatedStmt, /*NumChildren=*/1, P&: StartLoc, P&: EndLoc);
1226 Dir->setTaskReductionRefExpr(TaskRedRef);
1227 Dir->setHasCancel(HasCancel);
1228 return Dir;
1229}
1230
1231OMPTargetParallelDirective *
1232OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,
1233 unsigned NumClauses, EmptyShell) {
1234 return createEmptyDirective<OMPTargetParallelDirective>(
1235 C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
1236}
1237
1238OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(
1239 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1240 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1241 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
1242 auto *Dir = createDirective<OMPTargetParallelForDirective>(
1243 C, Clauses, AssociatedStmt,
1244 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_parallel_for) + 1, P&: StartLoc,
1245 P&: EndLoc, P&: CollapsedNum);
1246 Dir->setHelperExprs(Exprs);
1247 Dir->setTaskReductionRefExpr(TaskRedRef);
1248 Dir->setHasCancel(HasCancel);
1249 return Dir;
1250}
1251
1252OMPTargetParallelForDirective *
1253OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,
1254 unsigned NumClauses,
1255 unsigned CollapsedNum, EmptyShell) {
1256 return createEmptyDirective<OMPTargetParallelForDirective>(
1257 C, NumClauses, /*HasAssociatedStmt=*/true,
1258 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_parallel_for) + 1,
1259 P&: CollapsedNum);
1260}
1261
1262OMPTargetDataDirective *OMPTargetDataDirective::Create(
1263 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1264 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1265 return createDirective<OMPTargetDataDirective>(
1266 C, Clauses, AssociatedStmt, /*NumChildren=*/0, P&: StartLoc, P&: EndLoc);
1267}
1268
1269OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,
1270 unsigned N,
1271 EmptyShell) {
1272 return createEmptyDirective<OMPTargetDataDirective>(
1273 C, NumClauses: N, /*HasAssociatedStmt=*/true);
1274}
1275
1276OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(
1277 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1278 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1279 return createDirective<OMPTargetEnterDataDirective>(
1280 C, Clauses, AssociatedStmt, /*NumChildren=*/0, P&: StartLoc, P&: EndLoc);
1281}
1282
1283OMPTargetEnterDataDirective *
1284OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
1285 EmptyShell) {
1286 return createEmptyDirective<OMPTargetEnterDataDirective>(
1287 C, NumClauses: N, /*HasAssociatedStmt=*/true);
1288}
1289
1290OMPTargetExitDataDirective *OMPTargetExitDataDirective::Create(
1291 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1292 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1293 return createDirective<OMPTargetExitDataDirective>(
1294 C, Clauses, AssociatedStmt, /*NumChildren=*/0, P&: StartLoc, P&: EndLoc);
1295}
1296
1297OMPTargetExitDataDirective *
1298OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
1299 EmptyShell) {
1300 return createEmptyDirective<OMPTargetExitDataDirective>(
1301 C, NumClauses: N, /*HasAssociatedStmt=*/true);
1302}
1303
1304OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
1305 SourceLocation StartLoc,
1306 SourceLocation EndLoc,
1307 ArrayRef<OMPClause *> Clauses,
1308 Stmt *AssociatedStmt) {
1309 return createDirective<OMPTeamsDirective>(
1310 C, Clauses, AssociatedStmt, /*NumChildren=*/0, P&: StartLoc, P&: EndLoc);
1311}
1312
1313OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
1314 unsigned NumClauses,
1315 EmptyShell) {
1316 return createEmptyDirective<OMPTeamsDirective>(C, NumClauses,
1317 /*HasAssociatedStmt=*/true);
1318}
1319
1320OMPTaskLoopDirective *OMPTaskLoopDirective::Create(
1321 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1322 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1323 const HelperExprs &Exprs, bool HasCancel) {
1324 auto *Dir = createDirective<OMPTaskLoopDirective>(
1325 C, Clauses, AssociatedStmt, NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_taskloop),
1326 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
1327 Dir->setHelperExprs(Exprs);
1328 Dir->setHasCancel(HasCancel);
1329 return Dir;
1330}
1331
1332OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,
1333 unsigned NumClauses,
1334 unsigned CollapsedNum,
1335 EmptyShell) {
1336 return createEmptyDirective<OMPTaskLoopDirective>(
1337 C, NumClauses, /*HasAssociatedStmt=*/true,
1338 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_taskloop), P&: CollapsedNum);
1339}
1340
1341OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(
1342 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1343 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1344 const HelperExprs &Exprs) {
1345 auto *Dir = createDirective<OMPTaskLoopSimdDirective>(
1346 C, Clauses, AssociatedStmt,
1347 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_taskloop_simd), P&: StartLoc, P&: EndLoc,
1348 P&: CollapsedNum);
1349 Dir->setHelperExprs(Exprs);
1350 return Dir;
1351}
1352
1353OMPTaskLoopSimdDirective *
1354OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1355 unsigned CollapsedNum, EmptyShell) {
1356 return createEmptyDirective<OMPTaskLoopSimdDirective>(
1357 C, NumClauses, /*HasAssociatedStmt=*/true,
1358 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_taskloop_simd), P&: CollapsedNum);
1359}
1360
1361OMPMasterTaskLoopDirective *OMPMasterTaskLoopDirective::Create(
1362 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1363 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1364 const HelperExprs &Exprs, bool HasCancel) {
1365 auto *Dir = createDirective<OMPMasterTaskLoopDirective>(
1366 C, Clauses, AssociatedStmt,
1367 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_master_taskloop), P&: StartLoc, P&: EndLoc,
1368 P&: CollapsedNum);
1369 Dir->setHelperExprs(Exprs);
1370 Dir->setHasCancel(HasCancel);
1371 return Dir;
1372}
1373
1374OMPMasterTaskLoopDirective *
1375OMPMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
1376 unsigned NumClauses,
1377 unsigned CollapsedNum, EmptyShell) {
1378 return createEmptyDirective<OMPMasterTaskLoopDirective>(
1379 C, NumClauses, /*HasAssociatedStmt=*/true,
1380 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_master_taskloop), P&: CollapsedNum);
1381}
1382
1383OMPMaskedTaskLoopDirective *OMPMaskedTaskLoopDirective::Create(
1384 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1385 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1386 const HelperExprs &Exprs, bool HasCancel) {
1387 auto *Dir = createDirective<OMPMaskedTaskLoopDirective>(
1388 C, Clauses, AssociatedStmt,
1389 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_masked_taskloop), P&: StartLoc, P&: EndLoc,
1390 P&: CollapsedNum);
1391 Dir->setHelperExprs(Exprs);
1392 Dir->setHasCancel(HasCancel);
1393 return Dir;
1394}
1395
1396OMPMaskedTaskLoopDirective *
1397OMPMaskedTaskLoopDirective::CreateEmpty(const ASTContext &C,
1398 unsigned NumClauses,
1399 unsigned CollapsedNum, EmptyShell) {
1400 return createEmptyDirective<OMPMaskedTaskLoopDirective>(
1401 C, NumClauses, /*HasAssociatedStmt=*/true,
1402 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_masked_taskloop), P&: CollapsedNum);
1403}
1404
1405OMPMasterTaskLoopSimdDirective *OMPMasterTaskLoopSimdDirective::Create(
1406 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1407 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1408 const HelperExprs &Exprs) {
1409 auto *Dir = createDirective<OMPMasterTaskLoopSimdDirective>(
1410 C, Clauses, AssociatedStmt,
1411 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_master_taskloop_simd), P&: StartLoc,
1412 P&: EndLoc, P&: CollapsedNum);
1413 Dir->setHelperExprs(Exprs);
1414 return Dir;
1415}
1416
1417OMPMasterTaskLoopSimdDirective *
1418OMPMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1419 unsigned NumClauses,
1420 unsigned CollapsedNum, EmptyShell) {
1421 return createEmptyDirective<OMPMasterTaskLoopSimdDirective>(
1422 C, NumClauses, /*HasAssociatedStmt=*/true,
1423 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_master_taskloop_simd), P&: CollapsedNum);
1424}
1425
1426OMPMaskedTaskLoopSimdDirective *OMPMaskedTaskLoopSimdDirective::Create(
1427 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1428 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1429 const HelperExprs &Exprs) {
1430 auto *Dir = createDirective<OMPMaskedTaskLoopSimdDirective>(
1431 C, Clauses, AssociatedStmt,
1432 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_masked_taskloop_simd), P&: StartLoc,
1433 P&: EndLoc, P&: CollapsedNum);
1434 Dir->setHelperExprs(Exprs);
1435 return Dir;
1436}
1437
1438OMPMaskedTaskLoopSimdDirective *
1439OMPMaskedTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1440 unsigned NumClauses,
1441 unsigned CollapsedNum, EmptyShell) {
1442 return createEmptyDirective<OMPMaskedTaskLoopSimdDirective>(
1443 C, NumClauses, /*HasAssociatedStmt=*/true,
1444 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_masked_taskloop_simd), P&: CollapsedNum);
1445}
1446
1447OMPParallelMasterTaskLoopDirective *OMPParallelMasterTaskLoopDirective::Create(
1448 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1449 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1450 const HelperExprs &Exprs, bool HasCancel) {
1451 auto *Dir = createDirective<OMPParallelMasterTaskLoopDirective>(
1452 C, Clauses, AssociatedStmt,
1453 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_master_taskloop), P&: StartLoc,
1454 P&: EndLoc, P&: CollapsedNum);
1455 Dir->setHelperExprs(Exprs);
1456 Dir->setHasCancel(HasCancel);
1457 return Dir;
1458}
1459
1460OMPParallelMasterTaskLoopDirective *
1461OMPParallelMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
1462 unsigned NumClauses,
1463 unsigned CollapsedNum,
1464 EmptyShell) {
1465 return createEmptyDirective<OMPParallelMasterTaskLoopDirective>(
1466 C, NumClauses, /*HasAssociatedStmt=*/true,
1467 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_master_taskloop),
1468 P&: CollapsedNum);
1469}
1470
1471OMPParallelMaskedTaskLoopDirective *OMPParallelMaskedTaskLoopDirective::Create(
1472 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1473 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1474 const HelperExprs &Exprs, bool HasCancel) {
1475 auto *Dir = createDirective<OMPParallelMaskedTaskLoopDirective>(
1476 C, Clauses, AssociatedStmt,
1477 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_masked_taskloop), P&: StartLoc,
1478 P&: EndLoc, P&: CollapsedNum);
1479 Dir->setHelperExprs(Exprs);
1480 Dir->setHasCancel(HasCancel);
1481 return Dir;
1482}
1483
1484OMPParallelMaskedTaskLoopDirective *
1485OMPParallelMaskedTaskLoopDirective::CreateEmpty(const ASTContext &C,
1486 unsigned NumClauses,
1487 unsigned CollapsedNum,
1488 EmptyShell) {
1489 return createEmptyDirective<OMPParallelMaskedTaskLoopDirective>(
1490 C, NumClauses, /*HasAssociatedStmt=*/true,
1491 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_masked_taskloop),
1492 P&: CollapsedNum);
1493}
1494
1495OMPParallelMasterTaskLoopSimdDirective *
1496OMPParallelMasterTaskLoopSimdDirective::Create(
1497 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1498 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1499 const HelperExprs &Exprs) {
1500 auto *Dir = createDirective<OMPParallelMasterTaskLoopSimdDirective>(
1501 C, Clauses, AssociatedStmt,
1502 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_master_taskloop_simd),
1503 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
1504 Dir->setHelperExprs(Exprs);
1505 return Dir;
1506}
1507
1508OMPParallelMasterTaskLoopSimdDirective *
1509OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1510 unsigned NumClauses,
1511 unsigned CollapsedNum,
1512 EmptyShell) {
1513 return createEmptyDirective<OMPParallelMasterTaskLoopSimdDirective>(
1514 C, NumClauses, /*HasAssociatedStmt=*/true,
1515 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_master_taskloop_simd),
1516 P&: CollapsedNum);
1517}
1518
1519OMPParallelMaskedTaskLoopSimdDirective *
1520OMPParallelMaskedTaskLoopSimdDirective::Create(
1521 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1522 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1523 const HelperExprs &Exprs) {
1524 auto *Dir = createDirective<OMPParallelMaskedTaskLoopSimdDirective>(
1525 C, Clauses, AssociatedStmt,
1526 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_masked_taskloop_simd),
1527 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
1528 Dir->setHelperExprs(Exprs);
1529 return Dir;
1530}
1531
1532OMPParallelMaskedTaskLoopSimdDirective *
1533OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1534 unsigned NumClauses,
1535 unsigned CollapsedNum,
1536 EmptyShell) {
1537 return createEmptyDirective<OMPParallelMaskedTaskLoopSimdDirective>(
1538 C, NumClauses, /*HasAssociatedStmt=*/true,
1539 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_masked_taskloop_simd),
1540 P&: CollapsedNum);
1541}
1542
1543OMPDistributeDirective *
1544OMPDistributeDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1545 SourceLocation EndLoc, unsigned CollapsedNum,
1546 ArrayRef<OMPClause *> Clauses,
1547 Stmt *AssociatedStmt, const HelperExprs &Exprs) {
1548 auto *Dir = createDirective<OMPDistributeDirective>(
1549 C, Clauses, AssociatedStmt,
1550 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_distribute), P&: StartLoc, P&: EndLoc,
1551 P&: CollapsedNum);
1552 Dir->setHelperExprs(Exprs);
1553 return Dir;
1554}
1555
1556OMPDistributeDirective *
1557OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1558 unsigned CollapsedNum, EmptyShell) {
1559 return createEmptyDirective<OMPDistributeDirective>(
1560 C, NumClauses, /*HasAssociatedStmt=*/true,
1561 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_distribute), P&: CollapsedNum);
1562}
1563
1564OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(
1565 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1566 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1567 return createDirective<OMPTargetUpdateDirective>(C, Clauses, AssociatedStmt,
1568 /*NumChildren=*/0, P&: StartLoc,
1569 P&: EndLoc);
1570}
1571
1572OMPTargetUpdateDirective *
1573OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1574 EmptyShell) {
1575 return createEmptyDirective<OMPTargetUpdateDirective>(
1576 C, NumClauses, /*HasAssociatedStmt=*/true);
1577}
1578
1579OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
1580 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1581 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1582 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
1583 auto *Dir = createDirective<OMPDistributeParallelForDirective>(
1584 C, Clauses, AssociatedStmt,
1585 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_distribute_parallel_for) + 1, P&: StartLoc,
1586 P&: EndLoc, P&: CollapsedNum);
1587 Dir->setHelperExprs(Exprs);
1588 Dir->setTaskReductionRefExpr(TaskRedRef);
1589 Dir->HasCancel = HasCancel;
1590 return Dir;
1591}
1592
1593OMPDistributeParallelForDirective *
1594OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1595 unsigned NumClauses,
1596 unsigned CollapsedNum,
1597 EmptyShell) {
1598 return createEmptyDirective<OMPDistributeParallelForDirective>(
1599 C, NumClauses, /*HasAssociatedStmt=*/true,
1600 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_distribute_parallel_for) + 1,
1601 P&: CollapsedNum);
1602}
1603
1604OMPDistributeParallelForSimdDirective *
1605OMPDistributeParallelForSimdDirective::Create(
1606 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1607 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1608 const HelperExprs &Exprs) {
1609 auto *Dir = createDirective<OMPDistributeParallelForSimdDirective>(
1610 C, Clauses, AssociatedStmt,
1611 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_distribute_parallel_for_simd),
1612 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
1613 Dir->setHelperExprs(Exprs);
1614 return Dir;
1615}
1616
1617OMPDistributeParallelForSimdDirective *
1618OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1619 unsigned NumClauses,
1620 unsigned CollapsedNum,
1621 EmptyShell) {
1622 return createEmptyDirective<OMPDistributeParallelForSimdDirective>(
1623 C, NumClauses, /*HasAssociatedStmt=*/true,
1624 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_distribute_parallel_for_simd),
1625 P&: CollapsedNum);
1626}
1627
1628OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
1629 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1630 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1631 const HelperExprs &Exprs) {
1632 auto *Dir = createDirective<OMPDistributeSimdDirective>(
1633 C, Clauses, AssociatedStmt,
1634 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_distribute_simd), P&: StartLoc, P&: EndLoc,
1635 P&: CollapsedNum);
1636 Dir->setHelperExprs(Exprs);
1637 return Dir;
1638}
1639
1640OMPDistributeSimdDirective *
1641OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1642 unsigned NumClauses,
1643 unsigned CollapsedNum, EmptyShell) {
1644 return createEmptyDirective<OMPDistributeSimdDirective>(
1645 C, NumClauses, /*HasAssociatedStmt=*/true,
1646 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_distribute_simd), P&: CollapsedNum);
1647}
1648
1649OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
1650 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1651 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1652 const HelperExprs &Exprs) {
1653 auto *Dir = createDirective<OMPTargetParallelForSimdDirective>(
1654 C, Clauses, AssociatedStmt,
1655 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_parallel_for_simd), P&: StartLoc,
1656 P&: EndLoc, P&: CollapsedNum);
1657 Dir->setHelperExprs(Exprs);
1658 return Dir;
1659}
1660
1661OMPTargetParallelForSimdDirective *
1662OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1663 unsigned NumClauses,
1664 unsigned CollapsedNum,
1665 EmptyShell) {
1666 return createEmptyDirective<OMPTargetParallelForSimdDirective>(
1667 C, NumClauses, /*HasAssociatedStmt=*/true,
1668 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_parallel_for_simd),
1669 P&: CollapsedNum);
1670}
1671
1672OMPTargetSimdDirective *
1673OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1674 SourceLocation EndLoc, unsigned CollapsedNum,
1675 ArrayRef<OMPClause *> Clauses,
1676 Stmt *AssociatedStmt, const HelperExprs &Exprs) {
1677 auto *Dir = createDirective<OMPTargetSimdDirective>(
1678 C, Clauses, AssociatedStmt,
1679 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_simd), P&: StartLoc, P&: EndLoc,
1680 P&: CollapsedNum);
1681 Dir->setHelperExprs(Exprs);
1682 return Dir;
1683}
1684
1685OMPTargetSimdDirective *
1686OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1687 unsigned CollapsedNum, EmptyShell) {
1688 return createEmptyDirective<OMPTargetSimdDirective>(
1689 C, NumClauses, /*HasAssociatedStmt=*/true,
1690 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_simd), P&: CollapsedNum);
1691}
1692
1693OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
1694 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1695 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1696 const HelperExprs &Exprs) {
1697 auto *Dir = createDirective<OMPTeamsDistributeDirective>(
1698 C, Clauses, AssociatedStmt,
1699 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_teams_distribute), P&: StartLoc, P&: EndLoc,
1700 P&: CollapsedNum);
1701 Dir->setHelperExprs(Exprs);
1702 return Dir;
1703}
1704
1705OMPTeamsDistributeDirective *
1706OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1707 unsigned NumClauses,
1708 unsigned CollapsedNum, EmptyShell) {
1709 return createEmptyDirective<OMPTeamsDistributeDirective>(
1710 C, NumClauses, /*HasAssociatedStmt=*/true,
1711 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_teams_distribute), P&: CollapsedNum);
1712}
1713
1714OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
1715 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1716 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1717 const HelperExprs &Exprs) {
1718 auto *Dir = createDirective<OMPTeamsDistributeSimdDirective>(
1719 C, Clauses, AssociatedStmt,
1720 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_teams_distribute_simd), P&: StartLoc,
1721 P&: EndLoc, P&: CollapsedNum);
1722 Dir->setHelperExprs(Exprs);
1723 return Dir;
1724}
1725
1726OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
1727 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1728 EmptyShell) {
1729 return createEmptyDirective<OMPTeamsDistributeSimdDirective>(
1730 C, NumClauses, /*HasAssociatedStmt=*/true,
1731 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_teams_distribute_simd), P&: CollapsedNum);
1732}
1733
1734OMPTeamsDistributeParallelForSimdDirective *
1735OMPTeamsDistributeParallelForSimdDirective::Create(
1736 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1737 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1738 const HelperExprs &Exprs) {
1739 auto *Dir = createDirective<OMPTeamsDistributeParallelForSimdDirective>(
1740 C, Clauses, AssociatedStmt,
1741 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_teams_distribute_parallel_for_simd),
1742 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
1743 Dir->setHelperExprs(Exprs);
1744 return Dir;
1745}
1746
1747OMPTeamsDistributeParallelForSimdDirective *
1748OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1749 unsigned NumClauses,
1750 unsigned CollapsedNum,
1751 EmptyShell) {
1752 return createEmptyDirective<OMPTeamsDistributeParallelForSimdDirective>(
1753 C, NumClauses, /*HasAssociatedStmt=*/true,
1754 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_teams_distribute_parallel_for_simd),
1755 P&: CollapsedNum);
1756}
1757
1758OMPTeamsDistributeParallelForDirective *
1759OMPTeamsDistributeParallelForDirective::Create(
1760 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1761 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1762 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
1763 auto *Dir = createDirective<OMPTeamsDistributeParallelForDirective>(
1764 C, Clauses, AssociatedStmt,
1765 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_teams_distribute_parallel_for) + 1,
1766 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
1767 Dir->setHelperExprs(Exprs);
1768 Dir->setTaskReductionRefExpr(TaskRedRef);
1769 Dir->HasCancel = HasCancel;
1770 return Dir;
1771}
1772
1773OMPTeamsDistributeParallelForDirective *
1774OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1775 unsigned NumClauses,
1776 unsigned CollapsedNum,
1777 EmptyShell) {
1778 return createEmptyDirective<OMPTeamsDistributeParallelForDirective>(
1779 C, NumClauses, /*HasAssociatedStmt=*/true,
1780 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_teams_distribute_parallel_for) + 1,
1781 P&: CollapsedNum);
1782}
1783
1784OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
1785 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1786 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1787 return createDirective<OMPTargetTeamsDirective>(C, Clauses, AssociatedStmt,
1788 /*NumChildren=*/0, P&: StartLoc,
1789 P&: EndLoc);
1790}
1791
1792OMPTargetTeamsDirective *
1793OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1794 EmptyShell) {
1795 return createEmptyDirective<OMPTargetTeamsDirective>(
1796 C, NumClauses, /*HasAssociatedStmt=*/true);
1797}
1798
1799OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
1800 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1801 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1802 const HelperExprs &Exprs) {
1803 auto *Dir = createDirective<OMPTargetTeamsDistributeDirective>(
1804 C, Clauses, AssociatedStmt,
1805 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_teams_distribute), P&: StartLoc,
1806 P&: EndLoc, P&: CollapsedNum);
1807 Dir->setHelperExprs(Exprs);
1808 return Dir;
1809}
1810
1811OMPTargetTeamsDistributeDirective *
1812OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1813 unsigned NumClauses,
1814 unsigned CollapsedNum,
1815 EmptyShell) {
1816 return createEmptyDirective<OMPTargetTeamsDistributeDirective>(
1817 C, NumClauses, /*HasAssociatedStmt=*/true,
1818 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_teams_distribute),
1819 P&: CollapsedNum);
1820}
1821
1822OMPTargetTeamsDistributeParallelForDirective *
1823OMPTargetTeamsDistributeParallelForDirective::Create(
1824 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1825 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1826 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
1827 auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForDirective>(
1828 C, Clauses, AssociatedStmt,
1829 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_teams_distribute_parallel_for) +
1830 1,
1831 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
1832 Dir->setHelperExprs(Exprs);
1833 Dir->setTaskReductionRefExpr(TaskRedRef);
1834 Dir->HasCancel = HasCancel;
1835 return Dir;
1836}
1837
1838OMPTargetTeamsDistributeParallelForDirective *
1839OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1840 unsigned NumClauses,
1841 unsigned CollapsedNum,
1842 EmptyShell) {
1843 return createEmptyDirective<OMPTargetTeamsDistributeParallelForDirective>(
1844 C, NumClauses, /*HasAssociatedStmt=*/true,
1845 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_teams_distribute_parallel_for) +
1846 1,
1847 P&: CollapsedNum);
1848}
1849
1850OMPTargetTeamsDistributeParallelForSimdDirective *
1851OMPTargetTeamsDistributeParallelForSimdDirective::Create(
1852 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1853 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1854 const HelperExprs &Exprs) {
1855 auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForSimdDirective>(
1856 C, Clauses, AssociatedStmt,
1857 NumChildren: numLoopChildren(CollapsedNum,
1858 Kind: OMPD_target_teams_distribute_parallel_for_simd),
1859 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
1860 Dir->setHelperExprs(Exprs);
1861 return Dir;
1862}
1863
1864OMPTargetTeamsDistributeParallelForSimdDirective *
1865OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
1866 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1867 EmptyShell) {
1868 return createEmptyDirective<OMPTargetTeamsDistributeParallelForSimdDirective>(
1869 C, NumClauses, /*HasAssociatedStmt=*/true,
1870 NumChildren: numLoopChildren(CollapsedNum,
1871 Kind: OMPD_target_teams_distribute_parallel_for_simd),
1872 P&: CollapsedNum);
1873}
1874
1875OMPTargetTeamsDistributeSimdDirective *
1876OMPTargetTeamsDistributeSimdDirective::Create(
1877 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1878 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1879 const HelperExprs &Exprs) {
1880 auto *Dir = createDirective<OMPTargetTeamsDistributeSimdDirective>(
1881 C, Clauses, AssociatedStmt,
1882 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_teams_distribute_simd),
1883 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
1884 Dir->setHelperExprs(Exprs);
1885 return Dir;
1886}
1887
1888OMPTargetTeamsDistributeSimdDirective *
1889OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1890 unsigned NumClauses,
1891 unsigned CollapsedNum,
1892 EmptyShell) {
1893 return createEmptyDirective<OMPTargetTeamsDistributeSimdDirective>(
1894 C, NumClauses, /*HasAssociatedStmt=*/true,
1895 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_teams_distribute_simd),
1896 P&: CollapsedNum);
1897}
1898
1899OMPInteropDirective *
1900OMPInteropDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1901 SourceLocation EndLoc,
1902 ArrayRef<OMPClause *> Clauses) {
1903 return createDirective<OMPInteropDirective>(
1904 C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, P&: StartLoc,
1905 P&: EndLoc);
1906}
1907
1908OMPInteropDirective *OMPInteropDirective::CreateEmpty(const ASTContext &C,
1909 unsigned NumClauses,
1910 EmptyShell) {
1911 return createEmptyDirective<OMPInteropDirective>(C, NumClauses);
1912}
1913
1914OMPDispatchDirective *OMPDispatchDirective::Create(
1915 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1916 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1917 SourceLocation TargetCallLoc) {
1918 auto *Dir = createDirective<OMPDispatchDirective>(
1919 C, Clauses, AssociatedStmt, /*NumChildren=*/0, P&: StartLoc, P&: EndLoc);
1920 Dir->setTargetCallLoc(TargetCallLoc);
1921 return Dir;
1922}
1923
1924OMPDispatchDirective *OMPDispatchDirective::CreateEmpty(const ASTContext &C,
1925 unsigned NumClauses,
1926 EmptyShell) {
1927 return createEmptyDirective<OMPDispatchDirective>(C, NumClauses,
1928 /*HasAssociatedStmt=*/true,
1929 /*NumChildren=*/0);
1930}
1931
1932OMPMaskedDirective *OMPMaskedDirective::Create(const ASTContext &C,
1933 SourceLocation StartLoc,
1934 SourceLocation EndLoc,
1935 ArrayRef<OMPClause *> Clauses,
1936 Stmt *AssociatedStmt) {
1937 return createDirective<OMPMaskedDirective>(C, Clauses, AssociatedStmt,
1938 /*NumChildren=*/0, P&: StartLoc,
1939 P&: EndLoc);
1940}
1941
1942OMPMaskedDirective *OMPMaskedDirective::CreateEmpty(const ASTContext &C,
1943 unsigned NumClauses,
1944 EmptyShell) {
1945 return createEmptyDirective<OMPMaskedDirective>(C, NumClauses,
1946 /*HasAssociatedStmt=*/true);
1947}
1948
1949OMPGenericLoopDirective *OMPGenericLoopDirective::Create(
1950 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1951 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1952 const HelperExprs &Exprs) {
1953 auto *Dir = createDirective<OMPGenericLoopDirective>(
1954 C, Clauses, AssociatedStmt, NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_loop),
1955 P&: StartLoc, P&: EndLoc, P&: CollapsedNum);
1956 Dir->setHelperExprs(Exprs);
1957 return Dir;
1958}
1959
1960OMPGenericLoopDirective *
1961OMPGenericLoopDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1962 unsigned CollapsedNum, EmptyShell) {
1963 return createEmptyDirective<OMPGenericLoopDirective>(
1964 C, NumClauses, /*HasAssociatedStmt=*/true,
1965 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_loop), P&: CollapsedNum);
1966}
1967
1968OMPTeamsGenericLoopDirective *OMPTeamsGenericLoopDirective::Create(
1969 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1970 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1971 const HelperExprs &Exprs) {
1972 auto *Dir = createDirective<OMPTeamsGenericLoopDirective>(
1973 C, Clauses, AssociatedStmt,
1974 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_teams_loop), P&: StartLoc, P&: EndLoc,
1975 P&: CollapsedNum);
1976 Dir->setHelperExprs(Exprs);
1977 return Dir;
1978}
1979
1980OMPTeamsGenericLoopDirective *
1981OMPTeamsGenericLoopDirective::CreateEmpty(const ASTContext &C,
1982 unsigned NumClauses,
1983 unsigned CollapsedNum, EmptyShell) {
1984 return createEmptyDirective<OMPTeamsGenericLoopDirective>(
1985 C, NumClauses, /*HasAssociatedStmt=*/true,
1986 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_teams_loop), P&: CollapsedNum);
1987}
1988
1989OMPTargetTeamsGenericLoopDirective *OMPTargetTeamsGenericLoopDirective::Create(
1990 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1991 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1992 const HelperExprs &Exprs, bool CanBeParallelFor) {
1993 auto *Dir = createDirective<OMPTargetTeamsGenericLoopDirective>(
1994 C, Clauses, AssociatedStmt,
1995 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_teams_loop), P&: StartLoc, P&: EndLoc,
1996 P&: CollapsedNum);
1997 Dir->setHelperExprs(Exprs);
1998 Dir->setCanBeParallelFor(CanBeParallelFor);
1999 return Dir;
2000}
2001
2002OMPTargetTeamsGenericLoopDirective *
2003OMPTargetTeamsGenericLoopDirective::CreateEmpty(const ASTContext &C,
2004 unsigned NumClauses,
2005 unsigned CollapsedNum,
2006 EmptyShell) {
2007 return createEmptyDirective<OMPTargetTeamsGenericLoopDirective>(
2008 C, NumClauses, /*HasAssociatedStmt=*/true,
2009 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_teams_loop), P&: CollapsedNum);
2010}
2011
2012OMPParallelGenericLoopDirective *OMPParallelGenericLoopDirective::Create(
2013 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2014 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2015 const HelperExprs &Exprs) {
2016 auto *Dir = createDirective<OMPParallelGenericLoopDirective>(
2017 C, Clauses, AssociatedStmt,
2018 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_loop), P&: StartLoc, P&: EndLoc,
2019 P&: CollapsedNum);
2020 Dir->setHelperExprs(Exprs);
2021 return Dir;
2022}
2023
2024OMPParallelGenericLoopDirective *OMPParallelGenericLoopDirective::CreateEmpty(
2025 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
2026 EmptyShell) {
2027 return createEmptyDirective<OMPParallelGenericLoopDirective>(
2028 C, NumClauses, /*HasAssociatedStmt=*/true,
2029 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_parallel_loop), P&: CollapsedNum);
2030}
2031
2032OMPTargetParallelGenericLoopDirective *
2033OMPTargetParallelGenericLoopDirective::Create(
2034 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2035 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2036 const HelperExprs &Exprs) {
2037 auto *Dir = createDirective<OMPTargetParallelGenericLoopDirective>(
2038 C, Clauses, AssociatedStmt,
2039 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_parallel_loop), P&: StartLoc,
2040 P&: EndLoc, P&: CollapsedNum);
2041 Dir->setHelperExprs(Exprs);
2042 return Dir;
2043}
2044
2045OMPTargetParallelGenericLoopDirective *
2046OMPTargetParallelGenericLoopDirective::CreateEmpty(const ASTContext &C,
2047 unsigned NumClauses,
2048 unsigned CollapsedNum,
2049 EmptyShell) {
2050 return createEmptyDirective<OMPTargetParallelGenericLoopDirective>(
2051 C, NumClauses, /*HasAssociatedStmt=*/true,
2052 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_parallel_loop), P&: CollapsedNum);
2053}
2054
2055OMPTargetGenericLoopDirective *OMPTargetGenericLoopDirective::Create(
2056 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2057 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2058 const HelperExprs &Exprs) {
2059 auto *Dir = createDirective<OMPTargetGenericLoopDirective>(
2060 C, Clauses, AssociatedStmt,
2061 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_loop), P&: StartLoc, P&: EndLoc,
2062 P&: CollapsedNum);
2063 Dir->setHelperExprs(Exprs);
2064 return Dir;
2065}
2066
2067OMPTargetGenericLoopDirective *
2068OMPTargetGenericLoopDirective::CreateEmpty(const ASTContext &C,
2069 unsigned NumClauses,
2070 unsigned CollapsedNum, EmptyShell) {
2071 return createEmptyDirective<OMPTargetGenericLoopDirective>(
2072 C, NumClauses, /*HasAssociatedStmt=*/true,
2073 NumChildren: numLoopChildren(CollapsedNum, Kind: OMPD_target_loop), P&: CollapsedNum);
2074}
2075