1 //===- StmtOpenMP.h - Classes for OpenMP directives ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// \brief This file defines OpenMP AST classes for executable directives and
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_AST_STMTOPENMP_H
16 #define LLVM_CLANG_AST_STMTOPENMP_H
18 #include "clang/AST/Expr.h"
19 #include "clang/AST/OpenMPClause.h"
20 #include "clang/AST/Stmt.h"
21 #include "clang/Basic/OpenMPKinds.h"
22 #include "clang/Basic/SourceLocation.h"
26 //===----------------------------------------------------------------------===//
27 // AST classes for directives.
28 //===----------------------------------------------------------------------===//
30 /// \brief This is a basic class for representing single OpenMP executable
33 class OMPExecutableDirective : public Stmt {
34 friend class ASTStmtReader;
35 /// \brief Kind of the directive.
36 OpenMPDirectiveKind Kind;
37 /// \brief Starting location of the directive (directive keyword).
38 SourceLocation StartLoc;
39 /// \brief Ending location of the directive.
40 SourceLocation EndLoc;
41 /// \brief Numbers of clauses.
42 const unsigned NumClauses;
43 /// \brief Number of child expressions/stmts.
44 const unsigned NumChildren;
45 /// \brief Offset from this to the start of clauses.
46 /// There are NumClauses pointers to clauses, they are followed by
47 /// NumChildren pointers to child stmts/exprs (if the directive type
48 /// requires an associated stmt, then it has to be the first of them).
49 const unsigned ClausesOffset;
51 /// \brief Get the clauses storage.
52 MutableArrayRef<OMPClause *> getClauses() {
53 OMPClause **ClauseStorage = reinterpret_cast<OMPClause **>(
54 reinterpret_cast<char *>(this) + ClausesOffset);
55 return MutableArrayRef<OMPClause *>(ClauseStorage, NumClauses);
59 /// \brief Build instance of directive of class \a K.
61 /// \param SC Statement class.
62 /// \param K Kind of OpenMP directive.
63 /// \param StartLoc Starting location of the directive (directive keyword).
64 /// \param EndLoc Ending location of the directive.
67 OMPExecutableDirective(const T *, StmtClass SC, OpenMPDirectiveKind K,
68 SourceLocation StartLoc, SourceLocation EndLoc,
69 unsigned NumClauses, unsigned NumChildren)
70 : Stmt(SC), Kind(K), StartLoc(std::move(StartLoc)),
71 EndLoc(std::move(EndLoc)), NumClauses(NumClauses),
72 NumChildren(NumChildren),
73 ClausesOffset(llvm::alignTo(sizeof(T), alignof(OMPClause *))) {}
75 /// \brief Sets the list of variables for this clause.
77 /// \param Clauses The list of clauses for the directive.
79 void setClauses(ArrayRef<OMPClause *> Clauses);
81 /// \brief Set the associated statement for the directive.
83 /// /param S Associated statement.
85 void setAssociatedStmt(Stmt *S) {
86 assert(hasAssociatedStmt() && "no associated statement.");
91 /// \brief Iterates over a filtered subrange of clauses applied to a
94 /// This iterator visits only clauses of type SpecificClause.
95 template <typename SpecificClause>
96 class specific_clause_iterator
97 : public llvm::iterator_adaptor_base<
98 specific_clause_iterator<SpecificClause>,
99 ArrayRef<OMPClause *>::const_iterator, std::forward_iterator_tag,
100 const SpecificClause *, ptrdiff_t, const SpecificClause *,
101 const SpecificClause *> {
102 ArrayRef<OMPClause *>::const_iterator End;
104 void SkipToNextClause() {
105 while (this->I != End && !isa<SpecificClause>(*this->I))
110 explicit specific_clause_iterator(ArrayRef<OMPClause *> Clauses)
111 : specific_clause_iterator::iterator_adaptor_base(Clauses.begin()),
116 const SpecificClause *operator*() const {
117 return cast<SpecificClause>(*this->I);
119 const SpecificClause *operator->() const { return **this; }
121 specific_clause_iterator &operator++() {
128 template <typename SpecificClause>
129 static llvm::iterator_range<specific_clause_iterator<SpecificClause>>
130 getClausesOfKind(ArrayRef<OMPClause *> Clauses) {
131 return {specific_clause_iterator<SpecificClause>(Clauses),
132 specific_clause_iterator<SpecificClause>(
133 llvm::makeArrayRef(Clauses.end(), 0))};
136 template <typename SpecificClause>
137 llvm::iterator_range<specific_clause_iterator<SpecificClause>>
138 getClausesOfKind() const {
139 return getClausesOfKind<SpecificClause>(clauses());
142 /// Gets a single clause of the specified kind associated with the
143 /// current directive iff there is only one clause of this kind (and assertion
144 /// is fired if there is more than one clause is associated with the
145 /// directive). Returns nullptr if no clause of this kind is associated with
147 template <typename SpecificClause>
148 const SpecificClause *getSingleClause() const {
149 auto Clauses = getClausesOfKind<SpecificClause>();
151 if (Clauses.begin() != Clauses.end()) {
152 assert(std::next(Clauses.begin()) == Clauses.end() &&
153 "There are at least 2 clauses of the specified kind");
154 return *Clauses.begin();
159 /// Returns true if the current directive has one or more clauses of a
161 template <typename SpecificClause>
162 bool hasClausesOfKind() const {
163 auto Clauses = getClausesOfKind<SpecificClause>();
164 return Clauses.begin() != Clauses.end();
167 /// \brief Returns starting location of directive kind.
168 SourceLocation getLocStart() const { return StartLoc; }
169 /// \brief Returns ending location of directive.
170 SourceLocation getLocEnd() const { return EndLoc; }
172 /// \brief Set starting location of directive kind.
174 /// \param Loc New starting location of directive.
176 void setLocStart(SourceLocation Loc) { StartLoc = Loc; }
177 /// \brief Set ending location of directive.
179 /// \param Loc New ending location of directive.
181 void setLocEnd(SourceLocation Loc) { EndLoc = Loc; }
183 /// \brief Get number of clauses.
184 unsigned getNumClauses() const { return NumClauses; }
186 /// \brief Returns specified clause.
188 /// \param i Number of clause.
190 OMPClause *getClause(unsigned i) const { return clauses()[i]; }
192 /// \brief Returns true if directive has associated statement.
193 bool hasAssociatedStmt() const { return NumChildren > 0; }
195 /// \brief Returns statement associated with the directive.
196 Stmt *getAssociatedStmt() const {
197 assert(hasAssociatedStmt() && "no associated statement.");
198 return const_cast<Stmt *>(*child_begin());
201 /// \brief Returns the captured statement associated with the
202 /// component region within the (combined) directive.
204 // \param RegionKind Component region kind.
205 CapturedStmt *getCapturedStmt(OpenMPDirectiveKind RegionKind) const {
206 SmallVector<OpenMPDirectiveKind, 4> CaptureRegions;
207 getOpenMPCaptureRegions(CaptureRegions, getDirectiveKind());
209 CaptureRegions.begin(), CaptureRegions.end(),
210 [=](const OpenMPDirectiveKind K) { return K == RegionKind; }) &&
211 "RegionKind not found in OpenMP CaptureRegions.");
212 auto *CS = cast<CapturedStmt>(getAssociatedStmt());
213 for (auto ThisCaptureRegion : CaptureRegions) {
214 if (ThisCaptureRegion == RegionKind)
216 CS = cast<CapturedStmt>(CS->getCapturedStmt());
218 llvm_unreachable("Incorrect RegionKind specified for directive.");
221 OpenMPDirectiveKind getDirectiveKind() const { return Kind; }
223 static bool classof(const Stmt *S) {
224 return S->getStmtClass() >= firstOMPExecutableDirectiveConstant &&
225 S->getStmtClass() <= lastOMPExecutableDirectiveConstant;
228 child_range children() {
229 if (!hasAssociatedStmt())
230 return child_range(child_iterator(), child_iterator());
231 Stmt **ChildStorage = reinterpret_cast<Stmt **>(getClauses().end());
232 return child_range(ChildStorage, ChildStorage + NumChildren);
235 ArrayRef<OMPClause *> clauses() { return getClauses(); }
237 ArrayRef<OMPClause *> clauses() const {
238 return const_cast<OMPExecutableDirective *>(this)->getClauses();
242 /// \brief This represents '#pragma omp parallel' directive.
245 /// #pragma omp parallel private(a,b) reduction(+: c,d)
247 /// In this example directive '#pragma omp parallel' has clauses 'private'
248 /// with the variables 'a' and 'b' and 'reduction' with operator '+' and
249 /// variables 'c' and 'd'.
251 class OMPParallelDirective : public OMPExecutableDirective {
252 friend class ASTStmtReader;
253 /// \brief true if the construct has inner cancel directive.
256 /// \brief Build directive with the given start and end location.
258 /// \param StartLoc Starting location of the directive (directive keyword).
259 /// \param EndLoc Ending Location of the directive.
261 OMPParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc,
263 : OMPExecutableDirective(this, OMPParallelDirectiveClass, OMPD_parallel,
264 StartLoc, EndLoc, NumClauses, 1),
267 /// \brief Build an empty directive.
269 /// \param NumClauses Number of clauses.
271 explicit OMPParallelDirective(unsigned NumClauses)
272 : OMPExecutableDirective(this, OMPParallelDirectiveClass, OMPD_parallel,
273 SourceLocation(), SourceLocation(), NumClauses,
277 /// \brief Set cancel state.
278 void setHasCancel(bool Has) { HasCancel = Has; }
281 /// \brief Creates directive with a list of \a Clauses.
283 /// \param C AST context.
284 /// \param StartLoc Starting location of the directive kind.
285 /// \param EndLoc Ending Location of the directive.
286 /// \param Clauses List of clauses.
287 /// \param AssociatedStmt Statement associated with the directive.
288 /// \param HasCancel true if this directive has inner cancel directive.
290 static OMPParallelDirective *
291 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
292 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel);
294 /// \brief Creates an empty directive with the place for \a N clauses.
296 /// \param C AST context.
297 /// \param NumClauses Number of clauses.
299 static OMPParallelDirective *CreateEmpty(const ASTContext &C,
300 unsigned NumClauses, EmptyShell);
302 /// \brief Return true if current directive has inner cancel directive.
303 bool hasCancel() const { return HasCancel; }
305 static bool classof(const Stmt *T) {
306 return T->getStmtClass() == OMPParallelDirectiveClass;
310 /// \brief This is a common base class for loop directives ('omp simd', 'omp
311 /// for', 'omp for simd' etc.). It is responsible for the loop code generation.
313 class OMPLoopDirective : public OMPExecutableDirective {
314 friend class ASTStmtReader;
315 /// \brief Number of collapsed loops as specified by 'collapse' clause.
316 unsigned CollapsedNum;
318 /// \brief Offsets to the stored exprs.
319 /// This enumeration contains offsets to all the pointers to children
320 /// expressions stored in OMPLoopDirective.
321 /// The first 9 children are necessary for all the loop directives,
322 /// the next 8 are specific to the worksharing ones, and the next 11 are
323 /// used for combined constructs containing two pragmas associated to loops.
324 /// After the fixed children, three arrays of length CollapsedNum are
325 /// allocated: loop counters, their updates and final values.
326 /// PrevLowerBound and PrevUpperBound are used to communicate blocking
327 /// information in composite constructs which require loop blocking
328 /// DistInc is used to generate the increment expression for the distribute
329 /// loop when combined with a further nested loop
330 /// PrevEnsureUpperBound is used as the EnsureUpperBound expression for the
331 /// for loop when combined with a previous distribute loop in the same pragma
332 /// (e.g. 'distribute parallel for')
335 AssociatedStmtOffset = 0,
336 IterationVariableOffset = 1,
337 LastIterationOffset = 2,
338 CalcLastIterationOffset = 3,
339 PreConditionOffset = 4,
344 // The '...End' enumerators do not correspond to child expressions - they
345 // specify the offset to the end (and start of the following counters/
346 // updates/finals arrays).
348 // The following 8 exprs are used by worksharing and distribute loops only.
349 IsLastIterVariableOffset = 9,
350 LowerBoundVariableOffset = 10,
351 UpperBoundVariableOffset = 11,
352 StrideVariableOffset = 12,
353 EnsureUpperBoundOffset = 13,
354 NextLowerBoundOffset = 14,
355 NextUpperBoundOffset = 15,
356 NumIterationsOffset = 16,
357 // Offset to the end for worksharing loop directives.
359 PrevLowerBoundVariableOffset = 17,
360 PrevUpperBoundVariableOffset = 18,
362 PrevEnsureUpperBoundOffset = 20,
363 CombinedLowerBoundVariableOffset = 21,
364 CombinedUpperBoundVariableOffset = 22,
365 CombinedEnsureUpperBoundOffset = 23,
366 CombinedInitOffset = 24,
367 CombinedConditionOffset = 25,
368 CombinedNextLowerBoundOffset = 26,
369 CombinedNextUpperBoundOffset = 27,
370 // Offset to the end (and start of the following counters/updates/finals
371 // arrays) for combined distribute loop directives.
372 CombinedDistributeEnd = 28,
375 /// \brief Get the counters storage.
376 MutableArrayRef<Expr *> getCounters() {
377 Expr **Storage = reinterpret_cast<Expr **>(
378 &(*(std::next(child_begin(), getArraysOffset(getDirectiveKind())))));
379 return MutableArrayRef<Expr *>(Storage, CollapsedNum);
382 /// \brief Get the private counters storage.
383 MutableArrayRef<Expr *> getPrivateCounters() {
384 Expr **Storage = reinterpret_cast<Expr **>(&*std::next(
385 child_begin(), getArraysOffset(getDirectiveKind()) + CollapsedNum));
386 return MutableArrayRef<Expr *>(Storage, CollapsedNum);
389 /// \brief Get the updates storage.
390 MutableArrayRef<Expr *> getInits() {
391 Expr **Storage = reinterpret_cast<Expr **>(
392 &*std::next(child_begin(),
393 getArraysOffset(getDirectiveKind()) + 2 * CollapsedNum));
394 return MutableArrayRef<Expr *>(Storage, CollapsedNum);
397 /// \brief Get the updates storage.
398 MutableArrayRef<Expr *> getUpdates() {
399 Expr **Storage = reinterpret_cast<Expr **>(
400 &*std::next(child_begin(),
401 getArraysOffset(getDirectiveKind()) + 3 * CollapsedNum));
402 return MutableArrayRef<Expr *>(Storage, CollapsedNum);
405 /// \brief Get the final counter updates storage.
406 MutableArrayRef<Expr *> getFinals() {
407 Expr **Storage = reinterpret_cast<Expr **>(
408 &*std::next(child_begin(),
409 getArraysOffset(getDirectiveKind()) + 4 * CollapsedNum));
410 return MutableArrayRef<Expr *>(Storage, CollapsedNum);
414 /// \brief Build instance of loop directive of class \a Kind.
416 /// \param SC Statement class.
417 /// \param Kind Kind of OpenMP directive.
418 /// \param StartLoc Starting location of the directive (directive keyword).
419 /// \param EndLoc Ending location of the directive.
420 /// \param CollapsedNum Number of collapsed loops from 'collapse' clause.
421 /// \param NumClauses Number of clauses.
422 /// \param NumSpecialChildren Number of additional directive-specific stmts.
424 template <typename T>
425 OMPLoopDirective(const T *That, StmtClass SC, OpenMPDirectiveKind Kind,
426 SourceLocation StartLoc, SourceLocation EndLoc,
427 unsigned CollapsedNum, unsigned NumClauses,
428 unsigned NumSpecialChildren = 0)
429 : OMPExecutableDirective(That, SC, Kind, StartLoc, EndLoc, NumClauses,
430 numLoopChildren(CollapsedNum, Kind) +
432 CollapsedNum(CollapsedNum) {}
434 /// \brief Offset to the start of children expression arrays.
435 static unsigned getArraysOffset(OpenMPDirectiveKind Kind) {
436 if (isOpenMPLoopBoundSharingDirective(Kind))
437 return CombinedDistributeEnd;
438 if (isOpenMPWorksharingDirective(Kind) || isOpenMPTaskLoopDirective(Kind) ||
439 isOpenMPDistributeDirective(Kind))
440 return WorksharingEnd;
444 /// \brief Children number.
445 static unsigned numLoopChildren(unsigned CollapsedNum,
446 OpenMPDirectiveKind Kind) {
447 return getArraysOffset(Kind) + 5 * CollapsedNum; // Counters,
448 // PrivateCounters, Inits,
449 // Updates and Finals
452 void setIterationVariable(Expr *IV) {
453 *std::next(child_begin(), IterationVariableOffset) = IV;
455 void setLastIteration(Expr *LI) {
456 *std::next(child_begin(), LastIterationOffset) = LI;
458 void setCalcLastIteration(Expr *CLI) {
459 *std::next(child_begin(), CalcLastIterationOffset) = CLI;
461 void setPreCond(Expr *PC) {
462 *std::next(child_begin(), PreConditionOffset) = PC;
464 void setCond(Expr *Cond) {
465 *std::next(child_begin(), CondOffset) = Cond;
467 void setInit(Expr *Init) { *std::next(child_begin(), InitOffset) = Init; }
468 void setInc(Expr *Inc) { *std::next(child_begin(), IncOffset) = Inc; }
469 void setPreInits(Stmt *PreInits) {
470 *std::next(child_begin(), PreInitsOffset) = PreInits;
472 void setIsLastIterVariable(Expr *IL) {
473 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
474 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
475 isOpenMPDistributeDirective(getDirectiveKind())) &&
476 "expected worksharing loop directive");
477 *std::next(child_begin(), IsLastIterVariableOffset) = IL;
479 void setLowerBoundVariable(Expr *LB) {
480 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
481 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
482 isOpenMPDistributeDirective(getDirectiveKind())) &&
483 "expected worksharing loop directive");
484 *std::next(child_begin(), LowerBoundVariableOffset) = LB;
486 void setUpperBoundVariable(Expr *UB) {
487 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
488 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
489 isOpenMPDistributeDirective(getDirectiveKind())) &&
490 "expected worksharing loop directive");
491 *std::next(child_begin(), UpperBoundVariableOffset) = UB;
493 void setStrideVariable(Expr *ST) {
494 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
495 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
496 isOpenMPDistributeDirective(getDirectiveKind())) &&
497 "expected worksharing loop directive");
498 *std::next(child_begin(), StrideVariableOffset) = ST;
500 void setEnsureUpperBound(Expr *EUB) {
501 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
502 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
503 isOpenMPDistributeDirective(getDirectiveKind())) &&
504 "expected worksharing loop directive");
505 *std::next(child_begin(), EnsureUpperBoundOffset) = EUB;
507 void setNextLowerBound(Expr *NLB) {
508 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
509 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
510 isOpenMPDistributeDirective(getDirectiveKind())) &&
511 "expected worksharing loop directive");
512 *std::next(child_begin(), NextLowerBoundOffset) = NLB;
514 void setNextUpperBound(Expr *NUB) {
515 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
516 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
517 isOpenMPDistributeDirective(getDirectiveKind())) &&
518 "expected worksharing loop directive");
519 *std::next(child_begin(), NextUpperBoundOffset) = NUB;
521 void setNumIterations(Expr *NI) {
522 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
523 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
524 isOpenMPDistributeDirective(getDirectiveKind())) &&
525 "expected worksharing loop directive");
526 *std::next(child_begin(), NumIterationsOffset) = NI;
528 void setPrevLowerBoundVariable(Expr *PrevLB) {
529 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
530 "expected loop bound sharing directive");
531 *std::next(child_begin(), PrevLowerBoundVariableOffset) = PrevLB;
533 void setPrevUpperBoundVariable(Expr *PrevUB) {
534 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
535 "expected loop bound sharing directive");
536 *std::next(child_begin(), PrevUpperBoundVariableOffset) = PrevUB;
538 void setDistInc(Expr *DistInc) {
539 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
540 "expected loop bound sharing directive");
541 *std::next(child_begin(), DistIncOffset) = DistInc;
543 void setPrevEnsureUpperBound(Expr *PrevEUB) {
544 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
545 "expected loop bound sharing directive");
546 *std::next(child_begin(), PrevEnsureUpperBoundOffset) = PrevEUB;
548 void setCombinedLowerBoundVariable(Expr *CombLB) {
549 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
550 "expected loop bound sharing directive");
551 *std::next(child_begin(), CombinedLowerBoundVariableOffset) = CombLB;
553 void setCombinedUpperBoundVariable(Expr *CombUB) {
554 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
555 "expected loop bound sharing directive");
556 *std::next(child_begin(), CombinedUpperBoundVariableOffset) = CombUB;
558 void setCombinedEnsureUpperBound(Expr *CombEUB) {
559 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
560 "expected loop bound sharing directive");
561 *std::next(child_begin(), CombinedEnsureUpperBoundOffset) = CombEUB;
563 void setCombinedInit(Expr *CombInit) {
564 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
565 "expected loop bound sharing directive");
566 *std::next(child_begin(), CombinedInitOffset) = CombInit;
568 void setCombinedCond(Expr *CombCond) {
569 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
570 "expected loop bound sharing directive");
571 *std::next(child_begin(), CombinedConditionOffset) = CombCond;
573 void setCombinedNextLowerBound(Expr *CombNLB) {
574 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
575 "expected loop bound sharing directive");
576 *std::next(child_begin(), CombinedNextLowerBoundOffset) = CombNLB;
578 void setCombinedNextUpperBound(Expr *CombNUB) {
579 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
580 "expected loop bound sharing directive");
581 *std::next(child_begin(), CombinedNextUpperBoundOffset) = CombNUB;
583 void setCounters(ArrayRef<Expr *> A);
584 void setPrivateCounters(ArrayRef<Expr *> A);
585 void setInits(ArrayRef<Expr *> A);
586 void setUpdates(ArrayRef<Expr *> A);
587 void setFinals(ArrayRef<Expr *> A);
590 /// The expressions built to support OpenMP loops in combined/composite
591 /// pragmas (e.g. pragma omp distribute parallel for)
592 struct DistCombinedHelperExprs {
593 /// DistributeLowerBound - used when composing 'omp distribute' with
594 /// 'omp for' in a same construct.
596 /// DistributeUpperBound - used when composing 'omp distribute' with
597 /// 'omp for' in a same construct.
599 /// DistributeEnsureUpperBound - used when composing 'omp distribute'
600 /// with 'omp for' in a same construct, EUB depends on DistUB
602 /// Distribute loop iteration variable init used when composing 'omp
604 /// with 'omp for' in a same construct
606 /// Distribute Loop condition used when composing 'omp distribute'
607 /// with 'omp for' in a same construct
609 /// Update of LowerBound for statically sheduled omp loops for
610 /// outer loop in combined constructs (e.g. 'distribute parallel for')
612 /// Update of UpperBound for statically sheduled omp loops for
613 /// outer loop in combined constructs (e.g. 'distribute parallel for')
617 /// \brief The expressions built for the OpenMP loop CodeGen for the
618 /// whole collapsed loop nest.
620 /// \brief Loop iteration variable.
621 Expr *IterationVarRef;
622 /// \brief Loop last iteration number.
624 /// \brief Loop number of iterations.
626 /// \brief Calculation of last iteration.
627 Expr *CalcLastIteration;
628 /// \brief Loop pre-condition.
630 /// \brief Loop condition.
632 /// \brief Loop iteration variable init.
634 /// \brief Loop increment.
636 /// \brief IsLastIteration - local flag variable passed to runtime.
638 /// \brief LowerBound - local variable passed to runtime.
640 /// \brief UpperBound - local variable passed to runtime.
642 /// \brief Stride - local variable passed to runtime.
644 /// \brief EnsureUpperBound -- expression UB = min(UB, NumIterations).
646 /// \brief Update of LowerBound for statically sheduled 'omp for' loops.
648 /// \brief Update of UpperBound for statically sheduled 'omp for' loops.
650 /// \brief PreviousLowerBound - local variable passed to runtime in the
651 /// enclosing schedule or null if that does not apply.
653 /// \brief PreviousUpperBound - local variable passed to runtime in the
654 /// enclosing schedule or null if that does not apply.
656 /// \brief DistInc - increment expression for distribute loop when found
657 /// combined with a further loop level (e.g. in 'distribute parallel for')
658 /// expression IV = IV + ST
660 /// \brief PrevEUB - expression similar to EUB but to be used when loop
661 /// scheduling uses PrevLB and PrevUB (e.g. in 'distribute parallel for'
662 /// when ensuring that the UB is either the calculated UB by the runtime or
663 /// the end of the assigned distribute chunk)
664 /// expression UB = min (UB, PrevUB)
666 /// \brief Counters Loop counters.
667 SmallVector<Expr *, 4> Counters;
668 /// \brief PrivateCounters Loop counters.
669 SmallVector<Expr *, 4> PrivateCounters;
670 /// \brief Expressions for loop counters inits for CodeGen.
671 SmallVector<Expr *, 4> Inits;
672 /// \brief Expressions for loop counters update for CodeGen.
673 SmallVector<Expr *, 4> Updates;
674 /// \brief Final loop counter values for GodeGen.
675 SmallVector<Expr *, 4> Finals;
676 /// Init statement for all captured expressions.
679 /// Expressions used when combining OpenMP loop pragmas
680 DistCombinedHelperExprs DistCombinedFields;
682 /// \brief Check if all the expressions are built (does not check the
683 /// worksharing ones).
685 return IterationVarRef != nullptr && LastIteration != nullptr &&
686 NumIterations != nullptr && PreCond != nullptr &&
687 Cond != nullptr && Init != nullptr && Inc != nullptr;
690 /// \brief Initialize all the fields to null.
691 /// \param Size Number of elements in the counters/finals/updates arrays.
692 void clear(unsigned Size) {
693 IterationVarRef = nullptr;
694 LastIteration = nullptr;
695 CalcLastIteration = nullptr;
707 NumIterations = nullptr;
712 Counters.resize(Size);
713 PrivateCounters.resize(Size);
715 Updates.resize(Size);
717 for (unsigned i = 0; i < Size; ++i) {
718 Counters[i] = nullptr;
719 PrivateCounters[i] = nullptr;
721 Updates[i] = nullptr;
725 DistCombinedFields.LB = nullptr;
726 DistCombinedFields.UB = nullptr;
727 DistCombinedFields.EUB = nullptr;
728 DistCombinedFields.Init = nullptr;
729 DistCombinedFields.Cond = nullptr;
730 DistCombinedFields.NLB = nullptr;
731 DistCombinedFields.NUB = nullptr;
735 /// \brief Get number of collapsed loops.
736 unsigned getCollapsedNumber() const { return CollapsedNum; }
738 Expr *getIterationVariable() const {
739 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
740 *std::next(child_begin(), IterationVariableOffset)));
742 Expr *getLastIteration() const {
743 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
744 *std::next(child_begin(), LastIterationOffset)));
746 Expr *getCalcLastIteration() const {
747 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
748 *std::next(child_begin(), CalcLastIterationOffset)));
750 Expr *getPreCond() const {
751 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
752 *std::next(child_begin(), PreConditionOffset)));
754 Expr *getCond() const {
755 return const_cast<Expr *>(
756 reinterpret_cast<const Expr *>(*std::next(child_begin(), CondOffset)));
758 Expr *getInit() const {
759 return const_cast<Expr *>(
760 reinterpret_cast<const Expr *>(*std::next(child_begin(), InitOffset)));
762 Expr *getInc() const {
763 return const_cast<Expr *>(
764 reinterpret_cast<const Expr *>(*std::next(child_begin(), IncOffset)));
766 const Stmt *getPreInits() const {
767 return *std::next(child_begin(), PreInitsOffset);
769 Stmt *getPreInits() { return *std::next(child_begin(), PreInitsOffset); }
770 Expr *getIsLastIterVariable() const {
771 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
772 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
773 isOpenMPDistributeDirective(getDirectiveKind())) &&
774 "expected worksharing loop directive");
775 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
776 *std::next(child_begin(), IsLastIterVariableOffset)));
778 Expr *getLowerBoundVariable() const {
779 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
780 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
781 isOpenMPDistributeDirective(getDirectiveKind())) &&
782 "expected worksharing loop directive");
783 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
784 *std::next(child_begin(), LowerBoundVariableOffset)));
786 Expr *getUpperBoundVariable() const {
787 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
788 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
789 isOpenMPDistributeDirective(getDirectiveKind())) &&
790 "expected worksharing loop directive");
791 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
792 *std::next(child_begin(), UpperBoundVariableOffset)));
794 Expr *getStrideVariable() const {
795 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
796 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
797 isOpenMPDistributeDirective(getDirectiveKind())) &&
798 "expected worksharing loop directive");
799 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
800 *std::next(child_begin(), StrideVariableOffset)));
802 Expr *getEnsureUpperBound() const {
803 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
804 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
805 isOpenMPDistributeDirective(getDirectiveKind())) &&
806 "expected worksharing loop directive");
807 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
808 *std::next(child_begin(), EnsureUpperBoundOffset)));
810 Expr *getNextLowerBound() const {
811 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
812 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
813 isOpenMPDistributeDirective(getDirectiveKind())) &&
814 "expected worksharing loop directive");
815 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
816 *std::next(child_begin(), NextLowerBoundOffset)));
818 Expr *getNextUpperBound() const {
819 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
820 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
821 isOpenMPDistributeDirective(getDirectiveKind())) &&
822 "expected worksharing loop directive");
823 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
824 *std::next(child_begin(), NextUpperBoundOffset)));
826 Expr *getNumIterations() const {
827 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
828 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
829 isOpenMPDistributeDirective(getDirectiveKind())) &&
830 "expected worksharing loop directive");
831 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
832 *std::next(child_begin(), NumIterationsOffset)));
834 Expr *getPrevLowerBoundVariable() const {
835 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
836 "expected loop bound sharing directive");
837 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
838 *std::next(child_begin(), PrevLowerBoundVariableOffset)));
840 Expr *getPrevUpperBoundVariable() const {
841 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
842 "expected loop bound sharing directive");
843 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
844 *std::next(child_begin(), PrevUpperBoundVariableOffset)));
846 Expr *getDistInc() const {
847 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
848 "expected loop bound sharing directive");
849 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
850 *std::next(child_begin(), DistIncOffset)));
852 Expr *getPrevEnsureUpperBound() const {
853 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
854 "expected loop bound sharing directive");
855 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
856 *std::next(child_begin(), PrevEnsureUpperBoundOffset)));
858 Expr *getCombinedLowerBoundVariable() const {
859 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
860 "expected loop bound sharing directive");
861 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
862 *std::next(child_begin(), CombinedLowerBoundVariableOffset)));
864 Expr *getCombinedUpperBoundVariable() const {
865 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
866 "expected loop bound sharing directive");
867 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
868 *std::next(child_begin(), CombinedUpperBoundVariableOffset)));
870 Expr *getCombinedEnsureUpperBound() const {
871 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
872 "expected loop bound sharing directive");
873 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
874 *std::next(child_begin(), CombinedEnsureUpperBoundOffset)));
876 Expr *getCombinedInit() const {
877 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
878 "expected loop bound sharing directive");
879 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
880 *std::next(child_begin(), CombinedInitOffset)));
882 Expr *getCombinedCond() const {
883 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
884 "expected loop bound sharing directive");
885 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
886 *std::next(child_begin(), CombinedConditionOffset)));
888 Expr *getCombinedNextLowerBound() const {
889 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
890 "expected loop bound sharing directive");
891 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
892 *std::next(child_begin(), CombinedNextLowerBoundOffset)));
894 Expr *getCombinedNextUpperBound() const {
895 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
896 "expected loop bound sharing directive");
897 return const_cast<Expr *>(reinterpret_cast<const Expr *>(
898 *std::next(child_begin(), CombinedNextUpperBoundOffset)));
900 const Stmt *getBody() const {
901 // This relies on the loop form is already checked by Sema.
902 Stmt *Body = getAssociatedStmt()->IgnoreContainers(true);
903 Body = cast<ForStmt>(Body)->getBody();
904 for (unsigned Cnt = 1; Cnt < CollapsedNum; ++Cnt) {
905 Body = Body->IgnoreContainers();
906 Body = cast<ForStmt>(Body)->getBody();
911 ArrayRef<Expr *> counters() { return getCounters(); }
913 ArrayRef<Expr *> counters() const {
914 return const_cast<OMPLoopDirective *>(this)->getCounters();
917 ArrayRef<Expr *> private_counters() { return getPrivateCounters(); }
919 ArrayRef<Expr *> private_counters() const {
920 return const_cast<OMPLoopDirective *>(this)->getPrivateCounters();
923 ArrayRef<Expr *> inits() { return getInits(); }
925 ArrayRef<Expr *> inits() const {
926 return const_cast<OMPLoopDirective *>(this)->getInits();
929 ArrayRef<Expr *> updates() { return getUpdates(); }
931 ArrayRef<Expr *> updates() const {
932 return const_cast<OMPLoopDirective *>(this)->getUpdates();
935 ArrayRef<Expr *> finals() { return getFinals(); }
937 ArrayRef<Expr *> finals() const {
938 return const_cast<OMPLoopDirective *>(this)->getFinals();
941 static bool classof(const Stmt *T) {
942 return T->getStmtClass() == OMPSimdDirectiveClass ||
943 T->getStmtClass() == OMPForDirectiveClass ||
944 T->getStmtClass() == OMPForSimdDirectiveClass ||
945 T->getStmtClass() == OMPParallelForDirectiveClass ||
946 T->getStmtClass() == OMPParallelForSimdDirectiveClass ||
947 T->getStmtClass() == OMPTaskLoopDirectiveClass ||
948 T->getStmtClass() == OMPTaskLoopSimdDirectiveClass ||
949 T->getStmtClass() == OMPDistributeDirectiveClass ||
950 T->getStmtClass() == OMPTargetParallelForDirectiveClass ||
951 T->getStmtClass() == OMPDistributeParallelForDirectiveClass ||
952 T->getStmtClass() == OMPDistributeParallelForSimdDirectiveClass ||
953 T->getStmtClass() == OMPDistributeSimdDirectiveClass ||
954 T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass ||
955 T->getStmtClass() == OMPTargetSimdDirectiveClass ||
956 T->getStmtClass() == OMPTeamsDistributeDirectiveClass ||
957 T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass ||
958 T->getStmtClass() == OMPTeamsDistributeParallelForSimdDirectiveClass ||
959 T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass;
963 /// \brief This represents '#pragma omp simd' directive.
966 /// #pragma omp simd private(a,b) linear(i,j:s) reduction(+:c,d)
968 /// In this example directive '#pragma omp simd' has clauses 'private'
969 /// with the variables 'a' and 'b', 'linear' with variables 'i', 'j' and
970 /// linear step 's', 'reduction' with operator '+' and variables 'c' and 'd'.
972 class OMPSimdDirective : public OMPLoopDirective {
973 friend class ASTStmtReader;
974 /// \brief Build directive with the given start and end location.
976 /// \param StartLoc Starting location of the directive kind.
977 /// \param EndLoc Ending location of the directive.
978 /// \param CollapsedNum Number of collapsed nested loops.
979 /// \param NumClauses Number of clauses.
981 OMPSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
982 unsigned CollapsedNum, unsigned NumClauses)
983 : OMPLoopDirective(this, OMPSimdDirectiveClass, OMPD_simd, StartLoc,
984 EndLoc, CollapsedNum, NumClauses) {}
986 /// \brief Build an empty directive.
988 /// \param CollapsedNum Number of collapsed nested loops.
989 /// \param NumClauses Number of clauses.
991 explicit OMPSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
992 : OMPLoopDirective(this, OMPSimdDirectiveClass, OMPD_simd,
993 SourceLocation(), SourceLocation(), CollapsedNum,
997 /// \brief Creates directive with a list of \a Clauses.
999 /// \param C AST context.
1000 /// \param StartLoc Starting location of the directive kind.
1001 /// \param EndLoc Ending Location of the directive.
1002 /// \param CollapsedNum Number of collapsed loops.
1003 /// \param Clauses List of clauses.
1004 /// \param AssociatedStmt Statement, associated with the directive.
1005 /// \param Exprs Helper expressions for CodeGen.
1007 static OMPSimdDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1008 SourceLocation EndLoc, unsigned CollapsedNum,
1009 ArrayRef<OMPClause *> Clauses,
1010 Stmt *AssociatedStmt,
1011 const HelperExprs &Exprs);
1013 /// \brief Creates an empty directive with the place
1014 /// for \a NumClauses clauses.
1016 /// \param C AST context.
1017 /// \param CollapsedNum Number of collapsed nested loops.
1018 /// \param NumClauses Number of clauses.
1020 static OMPSimdDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
1021 unsigned CollapsedNum, EmptyShell);
1023 static bool classof(const Stmt *T) {
1024 return T->getStmtClass() == OMPSimdDirectiveClass;
1028 /// \brief This represents '#pragma omp for' directive.
1031 /// #pragma omp for private(a,b) reduction(+:c,d)
1033 /// In this example directive '#pragma omp for' has clauses 'private' with the
1034 /// variables 'a' and 'b' and 'reduction' with operator '+' and variables 'c'
1037 class OMPForDirective : public OMPLoopDirective {
1038 friend class ASTStmtReader;
1040 /// \brief true if current directive has inner cancel directive.
1043 /// \brief Build directive with the given start and end location.
1045 /// \param StartLoc Starting location of the directive kind.
1046 /// \param EndLoc Ending location of the directive.
1047 /// \param CollapsedNum Number of collapsed nested loops.
1048 /// \param NumClauses Number of clauses.
1050 OMPForDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1051 unsigned CollapsedNum, unsigned NumClauses)
1052 : OMPLoopDirective(this, OMPForDirectiveClass, OMPD_for, StartLoc, EndLoc,
1053 CollapsedNum, NumClauses),
1056 /// \brief Build an empty directive.
1058 /// \param CollapsedNum Number of collapsed nested loops.
1059 /// \param NumClauses Number of clauses.
1061 explicit OMPForDirective(unsigned CollapsedNum, unsigned NumClauses)
1062 : OMPLoopDirective(this, OMPForDirectiveClass, OMPD_for, SourceLocation(),
1063 SourceLocation(), CollapsedNum, NumClauses),
1066 /// \brief Set cancel state.
1067 void setHasCancel(bool Has) { HasCancel = Has; }
1070 /// \brief Creates directive with a list of \a Clauses.
1072 /// \param C AST context.
1073 /// \param StartLoc Starting location of the directive kind.
1074 /// \param EndLoc Ending Location of the directive.
1075 /// \param CollapsedNum Number of collapsed loops.
1076 /// \param Clauses List of clauses.
1077 /// \param AssociatedStmt Statement, associated with the directive.
1078 /// \param Exprs Helper expressions for CodeGen.
1079 /// \param HasCancel true if current directive has inner cancel directive.
1081 static OMPForDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1082 SourceLocation EndLoc, unsigned CollapsedNum,
1083 ArrayRef<OMPClause *> Clauses,
1084 Stmt *AssociatedStmt, const HelperExprs &Exprs,
1087 /// \brief Creates an empty directive with the place
1088 /// for \a NumClauses clauses.
1090 /// \param C AST context.
1091 /// \param CollapsedNum Number of collapsed nested loops.
1092 /// \param NumClauses Number of clauses.
1094 static OMPForDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
1095 unsigned CollapsedNum, EmptyShell);
1097 /// \brief Return true if current directive has inner cancel directive.
1098 bool hasCancel() const { return HasCancel; }
1100 static bool classof(const Stmt *T) {
1101 return T->getStmtClass() == OMPForDirectiveClass;
1105 /// \brief This represents '#pragma omp for simd' directive.
1108 /// #pragma omp for simd private(a,b) linear(i,j:s) reduction(+:c,d)
1110 /// In this example directive '#pragma omp for simd' has clauses 'private'
1111 /// with the variables 'a' and 'b', 'linear' with variables 'i', 'j' and
1112 /// linear step 's', 'reduction' with operator '+' and variables 'c' and 'd'.
1114 class OMPForSimdDirective : public OMPLoopDirective {
1115 friend class ASTStmtReader;
1116 /// \brief Build directive with the given start and end location.
1118 /// \param StartLoc Starting location of the directive kind.
1119 /// \param EndLoc Ending location of the directive.
1120 /// \param CollapsedNum Number of collapsed nested loops.
1121 /// \param NumClauses Number of clauses.
1123 OMPForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1124 unsigned CollapsedNum, unsigned NumClauses)
1125 : OMPLoopDirective(this, OMPForSimdDirectiveClass, OMPD_for_simd,
1126 StartLoc, EndLoc, CollapsedNum, NumClauses) {}
1128 /// \brief Build an empty directive.
1130 /// \param CollapsedNum Number of collapsed nested loops.
1131 /// \param NumClauses Number of clauses.
1133 explicit OMPForSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
1134 : OMPLoopDirective(this, OMPForSimdDirectiveClass, OMPD_for_simd,
1135 SourceLocation(), SourceLocation(), CollapsedNum,
1139 /// \brief Creates directive with a list of \a Clauses.
1141 /// \param C AST context.
1142 /// \param StartLoc Starting location of the directive kind.
1143 /// \param EndLoc Ending Location of the directive.
1144 /// \param CollapsedNum Number of collapsed loops.
1145 /// \param Clauses List of clauses.
1146 /// \param AssociatedStmt Statement, associated with the directive.
1147 /// \param Exprs Helper expressions for CodeGen.
1149 static OMPForSimdDirective *
1150 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1151 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
1152 Stmt *AssociatedStmt, const HelperExprs &Exprs);
1154 /// \brief Creates an empty directive with the place
1155 /// for \a NumClauses clauses.
1157 /// \param C AST context.
1158 /// \param CollapsedNum Number of collapsed nested loops.
1159 /// \param NumClauses Number of clauses.
1161 static OMPForSimdDirective *CreateEmpty(const ASTContext &C,
1162 unsigned NumClauses,
1163 unsigned CollapsedNum, EmptyShell);
1165 static bool classof(const Stmt *T) {
1166 return T->getStmtClass() == OMPForSimdDirectiveClass;
1170 /// \brief This represents '#pragma omp sections' directive.
1173 /// #pragma omp sections private(a,b) reduction(+:c,d)
1175 /// In this example directive '#pragma omp sections' has clauses 'private' with
1176 /// the variables 'a' and 'b' and 'reduction' with operator '+' and variables
1179 class OMPSectionsDirective : public OMPExecutableDirective {
1180 friend class ASTStmtReader;
1182 /// \brief true if current directive has inner cancel directive.
1185 /// \brief Build directive with the given start and end location.
1187 /// \param StartLoc Starting location of the directive kind.
1188 /// \param EndLoc Ending location of the directive.
1189 /// \param NumClauses Number of clauses.
1191 OMPSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1192 unsigned NumClauses)
1193 : OMPExecutableDirective(this, OMPSectionsDirectiveClass, OMPD_sections,
1194 StartLoc, EndLoc, NumClauses, 1),
1197 /// \brief Build an empty directive.
1199 /// \param NumClauses Number of clauses.
1201 explicit OMPSectionsDirective(unsigned NumClauses)
1202 : OMPExecutableDirective(this, OMPSectionsDirectiveClass, OMPD_sections,
1203 SourceLocation(), SourceLocation(), NumClauses,
1207 /// \brief Set cancel state.
1208 void setHasCancel(bool Has) { HasCancel = Has; }
1211 /// \brief Creates directive with a list of \a Clauses.
1213 /// \param C AST context.
1214 /// \param StartLoc Starting location of the directive kind.
1215 /// \param EndLoc Ending Location of the directive.
1216 /// \param Clauses List of clauses.
1217 /// \param AssociatedStmt Statement, associated with the directive.
1218 /// \param HasCancel true if current directive has inner directive.
1220 static OMPSectionsDirective *
1221 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1222 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel);
1224 /// \brief Creates an empty directive with the place for \a NumClauses
1227 /// \param C AST context.
1228 /// \param NumClauses Number of clauses.
1230 static OMPSectionsDirective *CreateEmpty(const ASTContext &C,
1231 unsigned NumClauses, EmptyShell);
1233 /// \brief Return true if current directive has inner cancel directive.
1234 bool hasCancel() const { return HasCancel; }
1236 static bool classof(const Stmt *T) {
1237 return T->getStmtClass() == OMPSectionsDirectiveClass;
1241 /// \brief This represents '#pragma omp section' directive.
1244 /// #pragma omp section
1247 class OMPSectionDirective : public OMPExecutableDirective {
1248 friend class ASTStmtReader;
1250 /// \brief true if current directive has inner cancel directive.
1253 /// \brief Build directive with the given start and end location.
1255 /// \param StartLoc Starting location of the directive kind.
1256 /// \param EndLoc Ending location of the directive.
1258 OMPSectionDirective(SourceLocation StartLoc, SourceLocation EndLoc)
1259 : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,
1260 StartLoc, EndLoc, 0, 1),
1263 /// \brief Build an empty directive.
1265 explicit OMPSectionDirective()
1266 : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,
1267 SourceLocation(), SourceLocation(), 0, 1),
1271 /// \brief Creates directive.
1273 /// \param C AST context.
1274 /// \param StartLoc Starting location of the directive kind.
1275 /// \param EndLoc Ending Location of the directive.
1276 /// \param AssociatedStmt Statement, associated with the directive.
1277 /// \param HasCancel true if current directive has inner directive.
1279 static OMPSectionDirective *Create(const ASTContext &C,
1280 SourceLocation StartLoc,
1281 SourceLocation EndLoc,
1282 Stmt *AssociatedStmt, bool HasCancel);
1284 /// \brief Creates an empty directive.
1286 /// \param C AST context.
1288 static OMPSectionDirective *CreateEmpty(const ASTContext &C, EmptyShell);
1290 /// \brief Set cancel state.
1291 void setHasCancel(bool Has) { HasCancel = Has; }
1293 /// \brief Return true if current directive has inner cancel directive.
1294 bool hasCancel() const { return HasCancel; }
1296 static bool classof(const Stmt *T) {
1297 return T->getStmtClass() == OMPSectionDirectiveClass;
1301 /// \brief This represents '#pragma omp single' directive.
1304 /// #pragma omp single private(a,b) copyprivate(c,d)
1306 /// In this example directive '#pragma omp single' has clauses 'private' with
1307 /// the variables 'a' and 'b' and 'copyprivate' with variables 'c' and 'd'.
1309 class OMPSingleDirective : public OMPExecutableDirective {
1310 friend class ASTStmtReader;
1311 /// \brief Build directive with the given start and end location.
1313 /// \param StartLoc Starting location of the directive kind.
1314 /// \param EndLoc Ending location of the directive.
1315 /// \param NumClauses Number of clauses.
1317 OMPSingleDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1318 unsigned NumClauses)
1319 : OMPExecutableDirective(this, OMPSingleDirectiveClass, OMPD_single,
1320 StartLoc, EndLoc, NumClauses, 1) {}
1322 /// \brief Build an empty directive.
1324 /// \param NumClauses Number of clauses.
1326 explicit OMPSingleDirective(unsigned NumClauses)
1327 : OMPExecutableDirective(this, OMPSingleDirectiveClass, OMPD_single,
1328 SourceLocation(), SourceLocation(), NumClauses,
1332 /// \brief Creates directive with a list of \a Clauses.
1334 /// \param C AST context.
1335 /// \param StartLoc Starting location of the directive kind.
1336 /// \param EndLoc Ending Location of the directive.
1337 /// \param Clauses List of clauses.
1338 /// \param AssociatedStmt Statement, associated with the directive.
1340 static OMPSingleDirective *
1341 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1342 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
1344 /// \brief Creates an empty directive with the place for \a NumClauses
1347 /// \param C AST context.
1348 /// \param NumClauses Number of clauses.
1350 static OMPSingleDirective *CreateEmpty(const ASTContext &C,
1351 unsigned NumClauses, EmptyShell);
1353 static bool classof(const Stmt *T) {
1354 return T->getStmtClass() == OMPSingleDirectiveClass;
1358 /// \brief This represents '#pragma omp master' directive.
1361 /// #pragma omp master
1364 class OMPMasterDirective : public OMPExecutableDirective {
1365 friend class ASTStmtReader;
1366 /// \brief Build directive with the given start and end location.
1368 /// \param StartLoc Starting location of the directive kind.
1369 /// \param EndLoc Ending location of the directive.
1371 OMPMasterDirective(SourceLocation StartLoc, SourceLocation EndLoc)
1372 : OMPExecutableDirective(this, OMPMasterDirectiveClass, OMPD_master,
1373 StartLoc, EndLoc, 0, 1) {}
1375 /// \brief Build an empty directive.
1377 explicit OMPMasterDirective()
1378 : OMPExecutableDirective(this, OMPMasterDirectiveClass, OMPD_master,
1379 SourceLocation(), SourceLocation(), 0, 1) {}
1382 /// \brief Creates directive.
1384 /// \param C AST context.
1385 /// \param StartLoc Starting location of the directive kind.
1386 /// \param EndLoc Ending Location of the directive.
1387 /// \param AssociatedStmt Statement, associated with the directive.
1389 static OMPMasterDirective *Create(const ASTContext &C,
1390 SourceLocation StartLoc,
1391 SourceLocation EndLoc,
1392 Stmt *AssociatedStmt);
1394 /// \brief Creates an empty directive.
1396 /// \param C AST context.
1398 static OMPMasterDirective *CreateEmpty(const ASTContext &C, EmptyShell);
1400 static bool classof(const Stmt *T) {
1401 return T->getStmtClass() == OMPMasterDirectiveClass;
1405 /// \brief This represents '#pragma omp critical' directive.
1408 /// #pragma omp critical
1411 class OMPCriticalDirective : public OMPExecutableDirective {
1412 friend class ASTStmtReader;
1413 /// \brief Name of the directive.
1414 DeclarationNameInfo DirName;
1415 /// \brief Build directive with the given start and end location.
1417 /// \param Name Name of the directive.
1418 /// \param StartLoc Starting location of the directive kind.
1419 /// \param EndLoc Ending location of the directive.
1420 /// \param NumClauses Number of clauses.
1422 OMPCriticalDirective(const DeclarationNameInfo &Name, SourceLocation StartLoc,
1423 SourceLocation EndLoc, unsigned NumClauses)
1424 : OMPExecutableDirective(this, OMPCriticalDirectiveClass, OMPD_critical,
1425 StartLoc, EndLoc, NumClauses, 1),
1428 /// \brief Build an empty directive.
1430 /// \param NumClauses Number of clauses.
1432 explicit OMPCriticalDirective(unsigned NumClauses)
1433 : OMPExecutableDirective(this, OMPCriticalDirectiveClass, OMPD_critical,
1434 SourceLocation(), SourceLocation(), NumClauses,
1438 /// \brief Set name of the directive.
1440 /// \param Name Name of the directive.
1442 void setDirectiveName(const DeclarationNameInfo &Name) { DirName = Name; }
1445 /// \brief Creates directive.
1447 /// \param C AST context.
1448 /// \param Name Name of the directive.
1449 /// \param StartLoc Starting location of the directive kind.
1450 /// \param EndLoc Ending Location of the directive.
1451 /// \param Clauses List of clauses.
1452 /// \param AssociatedStmt Statement, associated with the directive.
1454 static OMPCriticalDirective *
1455 Create(const ASTContext &C, const DeclarationNameInfo &Name,
1456 SourceLocation StartLoc, SourceLocation EndLoc,
1457 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
1459 /// \brief Creates an empty directive.
1461 /// \param C AST context.
1462 /// \param NumClauses Number of clauses.
1464 static OMPCriticalDirective *CreateEmpty(const ASTContext &C,
1465 unsigned NumClauses, EmptyShell);
1467 /// \brief Return name of the directive.
1469 DeclarationNameInfo getDirectiveName() const { return DirName; }
1471 static bool classof(const Stmt *T) {
1472 return T->getStmtClass() == OMPCriticalDirectiveClass;
1476 /// \brief This represents '#pragma omp parallel for' directive.
1479 /// #pragma omp parallel for private(a,b) reduction(+:c,d)
1481 /// In this example directive '#pragma omp parallel for' has clauses 'private'
1482 /// with the variables 'a' and 'b' and 'reduction' with operator '+' and
1483 /// variables 'c' and 'd'.
1485 class OMPParallelForDirective : public OMPLoopDirective {
1486 friend class ASTStmtReader;
1488 /// \brief true if current region has inner cancel directive.
1491 /// \brief Build directive with the given start and end location.
1493 /// \param StartLoc Starting location of the directive kind.
1494 /// \param EndLoc Ending location of the directive.
1495 /// \param CollapsedNum Number of collapsed nested loops.
1496 /// \param NumClauses Number of clauses.
1498 OMPParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1499 unsigned CollapsedNum, unsigned NumClauses)
1500 : OMPLoopDirective(this, OMPParallelForDirectiveClass, OMPD_parallel_for,
1501 StartLoc, EndLoc, CollapsedNum, NumClauses),
1504 /// \brief Build an empty directive.
1506 /// \param CollapsedNum Number of collapsed nested loops.
1507 /// \param NumClauses Number of clauses.
1509 explicit OMPParallelForDirective(unsigned CollapsedNum, unsigned NumClauses)
1510 : OMPLoopDirective(this, OMPParallelForDirectiveClass, OMPD_parallel_for,
1511 SourceLocation(), SourceLocation(), CollapsedNum,
1515 /// \brief Set cancel state.
1516 void setHasCancel(bool Has) { HasCancel = Has; }
1519 /// \brief Creates directive with a list of \a Clauses.
1521 /// \param C AST context.
1522 /// \param StartLoc Starting location of the directive kind.
1523 /// \param EndLoc Ending Location of the directive.
1524 /// \param CollapsedNum Number of collapsed loops.
1525 /// \param Clauses List of clauses.
1526 /// \param AssociatedStmt Statement, associated with the directive.
1527 /// \param Exprs Helper expressions for CodeGen.
1528 /// \param HasCancel true if current directive has inner cancel directive.
1530 static OMPParallelForDirective *
1531 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1532 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
1533 Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
1535 /// \brief Creates an empty directive with the place
1536 /// for \a NumClauses clauses.
1538 /// \param C AST context.
1539 /// \param CollapsedNum Number of collapsed nested loops.
1540 /// \param NumClauses Number of clauses.
1542 static OMPParallelForDirective *CreateEmpty(const ASTContext &C,
1543 unsigned NumClauses,
1544 unsigned CollapsedNum,
1547 /// \brief Return true if current directive has inner cancel directive.
1548 bool hasCancel() const { return HasCancel; }
1550 static bool classof(const Stmt *T) {
1551 return T->getStmtClass() == OMPParallelForDirectiveClass;
1555 /// \brief This represents '#pragma omp parallel for simd' directive.
1558 /// #pragma omp parallel for simd private(a,b) linear(i,j:s) reduction(+:c,d)
1560 /// In this example directive '#pragma omp parallel for simd' has clauses
1561 /// 'private' with the variables 'a' and 'b', 'linear' with variables 'i', 'j'
1562 /// and linear step 's', 'reduction' with operator '+' and variables 'c' and
1565 class OMPParallelForSimdDirective : public OMPLoopDirective {
1566 friend class ASTStmtReader;
1567 /// \brief Build directive with the given start and end location.
1569 /// \param StartLoc Starting location of the directive kind.
1570 /// \param EndLoc Ending location of the directive.
1571 /// \param CollapsedNum Number of collapsed nested loops.
1572 /// \param NumClauses Number of clauses.
1574 OMPParallelForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1575 unsigned CollapsedNum, unsigned NumClauses)
1576 : OMPLoopDirective(this, OMPParallelForSimdDirectiveClass,
1577 OMPD_parallel_for_simd, StartLoc, EndLoc, CollapsedNum,
1580 /// \brief Build an empty directive.
1582 /// \param CollapsedNum Number of collapsed nested loops.
1583 /// \param NumClauses Number of clauses.
1585 explicit OMPParallelForSimdDirective(unsigned CollapsedNum,
1586 unsigned NumClauses)
1587 : OMPLoopDirective(this, OMPParallelForSimdDirectiveClass,
1588 OMPD_parallel_for_simd, SourceLocation(),
1589 SourceLocation(), CollapsedNum, NumClauses) {}
1592 /// \brief Creates directive with a list of \a Clauses.
1594 /// \param C AST context.
1595 /// \param StartLoc Starting location of the directive kind.
1596 /// \param EndLoc Ending Location of the directive.
1597 /// \param CollapsedNum Number of collapsed loops.
1598 /// \param Clauses List of clauses.
1599 /// \param AssociatedStmt Statement, associated with the directive.
1600 /// \param Exprs Helper expressions for CodeGen.
1602 static OMPParallelForSimdDirective *
1603 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1604 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
1605 Stmt *AssociatedStmt, const HelperExprs &Exprs);
1607 /// \brief Creates an empty directive with the place
1608 /// for \a NumClauses clauses.
1610 /// \param C AST context.
1611 /// \param CollapsedNum Number of collapsed nested loops.
1612 /// \param NumClauses Number of clauses.
1614 static OMPParallelForSimdDirective *CreateEmpty(const ASTContext &C,
1615 unsigned NumClauses,
1616 unsigned CollapsedNum,
1619 static bool classof(const Stmt *T) {
1620 return T->getStmtClass() == OMPParallelForSimdDirectiveClass;
1624 /// \brief This represents '#pragma omp parallel sections' directive.
1627 /// #pragma omp parallel sections private(a,b) reduction(+:c,d)
1629 /// In this example directive '#pragma omp parallel sections' has clauses
1630 /// 'private' with the variables 'a' and 'b' and 'reduction' with operator '+'
1631 /// and variables 'c' and 'd'.
1633 class OMPParallelSectionsDirective : public OMPExecutableDirective {
1634 friend class ASTStmtReader;
1636 /// \brief true if current directive has inner cancel directive.
1639 /// \brief Build directive with the given start and end location.
1641 /// \param StartLoc Starting location of the directive kind.
1642 /// \param EndLoc Ending location of the directive.
1643 /// \param NumClauses Number of clauses.
1645 OMPParallelSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1646 unsigned NumClauses)
1647 : OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass,
1648 OMPD_parallel_sections, StartLoc, EndLoc,
1652 /// \brief Build an empty directive.
1654 /// \param NumClauses Number of clauses.
1656 explicit OMPParallelSectionsDirective(unsigned NumClauses)
1657 : OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass,
1658 OMPD_parallel_sections, SourceLocation(),
1659 SourceLocation(), NumClauses, 1),
1662 /// \brief Set cancel state.
1663 void setHasCancel(bool Has) { HasCancel = Has; }
1666 /// \brief Creates directive with a list of \a Clauses.
1668 /// \param C AST context.
1669 /// \param StartLoc Starting location of the directive kind.
1670 /// \param EndLoc Ending Location of the directive.
1671 /// \param Clauses List of clauses.
1672 /// \param AssociatedStmt Statement, associated with the directive.
1673 /// \param HasCancel true if current directive has inner cancel directive.
1675 static OMPParallelSectionsDirective *
1676 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1677 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel);
1679 /// \brief Creates an empty directive with the place for \a NumClauses
1682 /// \param C AST context.
1683 /// \param NumClauses Number of clauses.
1685 static OMPParallelSectionsDirective *
1686 CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
1688 /// \brief Return true if current directive has inner cancel directive.
1689 bool hasCancel() const { return HasCancel; }
1691 static bool classof(const Stmt *T) {
1692 return T->getStmtClass() == OMPParallelSectionsDirectiveClass;
1696 /// \brief This represents '#pragma omp task' directive.
1699 /// #pragma omp task private(a,b) final(d)
1701 /// In this example directive '#pragma omp task' has clauses 'private' with the
1702 /// variables 'a' and 'b' and 'final' with condition 'd'.
1704 class OMPTaskDirective : public OMPExecutableDirective {
1705 friend class ASTStmtReader;
1706 /// \brief true if this directive has inner cancel directive.
1709 /// \brief Build directive with the given start and end location.
1711 /// \param StartLoc Starting location of the directive kind.
1712 /// \param EndLoc Ending location of the directive.
1713 /// \param NumClauses Number of clauses.
1715 OMPTaskDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1716 unsigned NumClauses)
1717 : OMPExecutableDirective(this, OMPTaskDirectiveClass, OMPD_task, StartLoc,
1718 EndLoc, NumClauses, 1),
1721 /// \brief Build an empty directive.
1723 /// \param NumClauses Number of clauses.
1725 explicit OMPTaskDirective(unsigned NumClauses)
1726 : OMPExecutableDirective(this, OMPTaskDirectiveClass, OMPD_task,
1727 SourceLocation(), SourceLocation(), NumClauses,
1731 /// \brief Set cancel state.
1732 void setHasCancel(bool Has) { HasCancel = Has; }
1735 /// \brief Creates directive with a list of \a Clauses.
1737 /// \param C AST context.
1738 /// \param StartLoc Starting location of the directive kind.
1739 /// \param EndLoc Ending Location of the directive.
1740 /// \param Clauses List of clauses.
1741 /// \param AssociatedStmt Statement, associated with the directive.
1742 /// \param HasCancel true, if current directive has inner cancel directive.
1744 static OMPTaskDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1745 SourceLocation EndLoc,
1746 ArrayRef<OMPClause *> Clauses,
1747 Stmt *AssociatedStmt, bool HasCancel);
1749 /// \brief Creates an empty directive with the place for \a NumClauses
1752 /// \param C AST context.
1753 /// \param NumClauses Number of clauses.
1755 static OMPTaskDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
1758 /// \brief Return true if current directive has inner cancel directive.
1759 bool hasCancel() const { return HasCancel; }
1761 static bool classof(const Stmt *T) {
1762 return T->getStmtClass() == OMPTaskDirectiveClass;
1766 /// \brief This represents '#pragma omp taskyield' directive.
1769 /// #pragma omp taskyield
1772 class OMPTaskyieldDirective : public OMPExecutableDirective {
1773 friend class ASTStmtReader;
1774 /// \brief Build directive with the given start and end location.
1776 /// \param StartLoc Starting location of the directive kind.
1777 /// \param EndLoc Ending location of the directive.
1779 OMPTaskyieldDirective(SourceLocation StartLoc, SourceLocation EndLoc)
1780 : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass, OMPD_taskyield,
1781 StartLoc, EndLoc, 0, 0) {}
1783 /// \brief Build an empty directive.
1785 explicit OMPTaskyieldDirective()
1786 : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass, OMPD_taskyield,
1787 SourceLocation(), SourceLocation(), 0, 0) {}
1790 /// \brief Creates directive.
1792 /// \param C AST context.
1793 /// \param StartLoc Starting location of the directive kind.
1794 /// \param EndLoc Ending Location of the directive.
1796 static OMPTaskyieldDirective *
1797 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
1799 /// \brief Creates an empty directive.
1801 /// \param C AST context.
1803 static OMPTaskyieldDirective *CreateEmpty(const ASTContext &C, EmptyShell);
1805 static bool classof(const Stmt *T) {
1806 return T->getStmtClass() == OMPTaskyieldDirectiveClass;
1810 /// \brief This represents '#pragma omp barrier' directive.
1813 /// #pragma omp barrier
1816 class OMPBarrierDirective : public OMPExecutableDirective {
1817 friend class ASTStmtReader;
1818 /// \brief Build directive with the given start and end location.
1820 /// \param StartLoc Starting location of the directive kind.
1821 /// \param EndLoc Ending location of the directive.
1823 OMPBarrierDirective(SourceLocation StartLoc, SourceLocation EndLoc)
1824 : OMPExecutableDirective(this, OMPBarrierDirectiveClass, OMPD_barrier,
1825 StartLoc, EndLoc, 0, 0) {}
1827 /// \brief Build an empty directive.
1829 explicit OMPBarrierDirective()
1830 : OMPExecutableDirective(this, OMPBarrierDirectiveClass, OMPD_barrier,
1831 SourceLocation(), SourceLocation(), 0, 0) {}
1834 /// \brief Creates directive.
1836 /// \param C AST context.
1837 /// \param StartLoc Starting location of the directive kind.
1838 /// \param EndLoc Ending Location of the directive.
1840 static OMPBarrierDirective *
1841 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
1843 /// \brief Creates an empty directive.
1845 /// \param C AST context.
1847 static OMPBarrierDirective *CreateEmpty(const ASTContext &C, EmptyShell);
1849 static bool classof(const Stmt *T) {
1850 return T->getStmtClass() == OMPBarrierDirectiveClass;
1854 /// \brief This represents '#pragma omp taskwait' directive.
1857 /// #pragma omp taskwait
1860 class OMPTaskwaitDirective : public OMPExecutableDirective {
1861 friend class ASTStmtReader;
1862 /// \brief Build directive with the given start and end location.
1864 /// \param StartLoc Starting location of the directive kind.
1865 /// \param EndLoc Ending location of the directive.
1867 OMPTaskwaitDirective(SourceLocation StartLoc, SourceLocation EndLoc)
1868 : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass, OMPD_taskwait,
1869 StartLoc, EndLoc, 0, 0) {}
1871 /// \brief Build an empty directive.
1873 explicit OMPTaskwaitDirective()
1874 : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass, OMPD_taskwait,
1875 SourceLocation(), SourceLocation(), 0, 0) {}
1878 /// \brief Creates directive.
1880 /// \param C AST context.
1881 /// \param StartLoc Starting location of the directive kind.
1882 /// \param EndLoc Ending Location of the directive.
1884 static OMPTaskwaitDirective *
1885 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
1887 /// \brief Creates an empty directive.
1889 /// \param C AST context.
1891 static OMPTaskwaitDirective *CreateEmpty(const ASTContext &C, EmptyShell);
1893 static bool classof(const Stmt *T) {
1894 return T->getStmtClass() == OMPTaskwaitDirectiveClass;
1898 /// This represents '#pragma omp taskgroup' directive.
1901 /// #pragma omp taskgroup
1904 class OMPTaskgroupDirective : public OMPExecutableDirective {
1905 friend class ASTStmtReader;
1906 /// Build directive with the given start and end location.
1908 /// \param StartLoc Starting location of the directive kind.
1909 /// \param EndLoc Ending location of the directive.
1910 /// \param NumClauses Number of clauses.
1912 OMPTaskgroupDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1913 unsigned NumClauses)
1914 : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, OMPD_taskgroup,
1915 StartLoc, EndLoc, NumClauses, 1) {}
1917 /// Build an empty directive.
1918 /// \param NumClauses Number of clauses.
1920 explicit OMPTaskgroupDirective(unsigned NumClauses)
1921 : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, OMPD_taskgroup,
1922 SourceLocation(), SourceLocation(), NumClauses,
1926 /// Creates directive.
1928 /// \param C AST context.
1929 /// \param StartLoc Starting location of the directive kind.
1930 /// \param EndLoc Ending Location of the directive.
1931 /// \param Clauses List of clauses.
1932 /// \param AssociatedStmt Statement, associated with the directive.
1934 static OMPTaskgroupDirective *
1935 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1936 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
1938 /// Creates an empty directive.
1940 /// \param C AST context.
1941 /// \param NumClauses Number of clauses.
1943 static OMPTaskgroupDirective *CreateEmpty(const ASTContext &C,
1944 unsigned NumClauses, EmptyShell);
1946 static bool classof(const Stmt *T) {
1947 return T->getStmtClass() == OMPTaskgroupDirectiveClass;
1951 /// \brief This represents '#pragma omp flush' directive.
1954 /// #pragma omp flush(a,b)
1956 /// In this example directive '#pragma omp flush' has 2 arguments- variables 'a'
1958 /// 'omp flush' directive does not have clauses but have an optional list of
1959 /// variables to flush. This list of variables is stored within some fake clause
1961 class OMPFlushDirective : public OMPExecutableDirective {
1962 friend class ASTStmtReader;
1963 /// \brief Build directive with the given start and end location.
1965 /// \param StartLoc Starting location of the directive kind.
1966 /// \param EndLoc Ending location of the directive.
1967 /// \param NumClauses Number of clauses.
1969 OMPFlushDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1970 unsigned NumClauses)
1971 : OMPExecutableDirective(this, OMPFlushDirectiveClass, OMPD_flush,
1972 StartLoc, EndLoc, NumClauses, 0) {}
1974 /// \brief Build an empty directive.
1976 /// \param NumClauses Number of clauses.
1978 explicit OMPFlushDirective(unsigned NumClauses)
1979 : OMPExecutableDirective(this, OMPFlushDirectiveClass, OMPD_flush,
1980 SourceLocation(), SourceLocation(), NumClauses,
1984 /// \brief Creates directive with a list of \a Clauses.
1986 /// \param C AST context.
1987 /// \param StartLoc Starting location of the directive kind.
1988 /// \param EndLoc Ending Location of the directive.
1989 /// \param Clauses List of clauses (only single OMPFlushClause clause is
1992 static OMPFlushDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1993 SourceLocation EndLoc,
1994 ArrayRef<OMPClause *> Clauses);
1996 /// \brief Creates an empty directive with the place for \a NumClauses
1999 /// \param C AST context.
2000 /// \param NumClauses Number of clauses.
2002 static OMPFlushDirective *CreateEmpty(const ASTContext &C,
2003 unsigned NumClauses, EmptyShell);
2005 static bool classof(const Stmt *T) {
2006 return T->getStmtClass() == OMPFlushDirectiveClass;
2010 /// \brief This represents '#pragma omp ordered' directive.
2013 /// #pragma omp ordered
2016 class OMPOrderedDirective : public OMPExecutableDirective {
2017 friend class ASTStmtReader;
2018 /// \brief Build directive with the given start and end location.
2020 /// \param StartLoc Starting location of the directive kind.
2021 /// \param EndLoc Ending location of the directive.
2022 /// \param NumClauses Number of clauses.
2024 OMPOrderedDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2025 unsigned NumClauses)
2026 : OMPExecutableDirective(this, OMPOrderedDirectiveClass, OMPD_ordered,
2027 StartLoc, EndLoc, NumClauses, 1) {}
2029 /// \brief Build an empty directive.
2031 /// \param NumClauses Number of clauses.
2033 explicit OMPOrderedDirective(unsigned NumClauses)
2034 : OMPExecutableDirective(this, OMPOrderedDirectiveClass, OMPD_ordered,
2035 SourceLocation(), SourceLocation(), NumClauses,
2039 /// \brief Creates directive.
2041 /// \param C AST context.
2042 /// \param StartLoc Starting location of the directive kind.
2043 /// \param EndLoc Ending Location of the directive.
2044 /// \param Clauses List of clauses.
2045 /// \param AssociatedStmt Statement, associated with the directive.
2047 static OMPOrderedDirective *
2048 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2049 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2051 /// \brief Creates an empty directive.
2053 /// \param C AST context.
2054 /// \param NumClauses Number of clauses.
2056 static OMPOrderedDirective *CreateEmpty(const ASTContext &C,
2057 unsigned NumClauses, EmptyShell);
2059 static bool classof(const Stmt *T) {
2060 return T->getStmtClass() == OMPOrderedDirectiveClass;
2064 /// \brief This represents '#pragma omp atomic' directive.
2067 /// #pragma omp atomic capture
2069 /// In this example directive '#pragma omp atomic' has clause 'capture'.
2071 class OMPAtomicDirective : public OMPExecutableDirective {
2072 friend class ASTStmtReader;
2073 /// \brief Used for 'atomic update' or 'atomic capture' constructs. They may
2074 /// have atomic expressions of forms
2076 /// x = x binop expr;
2077 /// x = expr binop x;
2079 /// This field is true for the first form of the expression and false for the
2080 /// second. Required for correct codegen of non-associative operations (like
2082 bool IsXLHSInRHSPart;
2083 /// \brief Used for 'atomic update' or 'atomic capture' constructs. They may
2084 /// have atomic expressions of forms
2086 /// v = x; <update x>;
2087 /// <update x>; v = x;
2089 /// This field is true for the first(postfix) form of the expression and false
2091 bool IsPostfixUpdate;
2093 /// \brief Build directive with the given start and end location.
2095 /// \param StartLoc Starting location of the directive kind.
2096 /// \param EndLoc Ending location of the directive.
2097 /// \param NumClauses Number of clauses.
2099 OMPAtomicDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2100 unsigned NumClauses)
2101 : OMPExecutableDirective(this, OMPAtomicDirectiveClass, OMPD_atomic,
2102 StartLoc, EndLoc, NumClauses, 5),
2103 IsXLHSInRHSPart(false), IsPostfixUpdate(false) {}
2105 /// \brief Build an empty directive.
2107 /// \param NumClauses Number of clauses.
2109 explicit OMPAtomicDirective(unsigned NumClauses)
2110 : OMPExecutableDirective(this, OMPAtomicDirectiveClass, OMPD_atomic,
2111 SourceLocation(), SourceLocation(), NumClauses,
2113 IsXLHSInRHSPart(false), IsPostfixUpdate(false) {}
2115 /// \brief Set 'x' part of the associated expression/statement.
2116 void setX(Expr *X) { *std::next(child_begin()) = X; }
2117 /// \brief Set helper expression of the form
2118 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2119 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2120 void setUpdateExpr(Expr *UE) { *std::next(child_begin(), 2) = UE; }
2121 /// \brief Set 'v' part of the associated expression/statement.
2122 void setV(Expr *V) { *std::next(child_begin(), 3) = V; }
2123 /// \brief Set 'expr' part of the associated expression/statement.
2124 void setExpr(Expr *E) { *std::next(child_begin(), 4) = E; }
2127 /// \brief Creates directive with a list of \a Clauses and 'x', 'v' and 'expr'
2128 /// parts of the atomic construct (see Section 2.12.6, atomic Construct, for
2129 /// detailed description of 'x', 'v' and 'expr').
2131 /// \param C AST context.
2132 /// \param StartLoc Starting location of the directive kind.
2133 /// \param EndLoc Ending Location of the directive.
2134 /// \param Clauses List of clauses.
2135 /// \param AssociatedStmt Statement, associated with the directive.
2136 /// \param X 'x' part of the associated expression/statement.
2137 /// \param V 'v' part of the associated expression/statement.
2138 /// \param E 'expr' part of the associated expression/statement.
2139 /// \param UE Helper expression of the form
2140 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2141 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2142 /// \param IsXLHSInRHSPart true if \a UE has the first form and false if the
2144 /// \param IsPostfixUpdate true if original value of 'x' must be stored in
2145 /// 'v', not an updated one.
2146 static OMPAtomicDirective *
2147 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2148 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
2149 Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate);
2151 /// \brief Creates an empty directive with the place for \a NumClauses
2154 /// \param C AST context.
2155 /// \param NumClauses Number of clauses.
2157 static OMPAtomicDirective *CreateEmpty(const ASTContext &C,
2158 unsigned NumClauses, EmptyShell);
2160 /// \brief Get 'x' part of the associated expression/statement.
2161 Expr *getX() { return cast_or_null<Expr>(*std::next(child_begin())); }
2162 const Expr *getX() const {
2163 return cast_or_null<Expr>(*std::next(child_begin()));
2165 /// \brief Get helper expression of the form
2166 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2167 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2168 Expr *getUpdateExpr() {
2169 return cast_or_null<Expr>(*std::next(child_begin(), 2));
2171 const Expr *getUpdateExpr() const {
2172 return cast_or_null<Expr>(*std::next(child_begin(), 2));
2174 /// \brief Return true if helper update expression has form
2175 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and false if it has form
2176 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2177 bool isXLHSInRHSPart() const { return IsXLHSInRHSPart; }
2178 /// \brief Return true if 'v' expression must be updated to original value of
2179 /// 'x', false if 'v' must be updated to the new value of 'x'.
2180 bool isPostfixUpdate() const { return IsPostfixUpdate; }
2181 /// \brief Get 'v' part of the associated expression/statement.
2182 Expr *getV() { return cast_or_null<Expr>(*std::next(child_begin(), 3)); }
2183 const Expr *getV() const {
2184 return cast_or_null<Expr>(*std::next(child_begin(), 3));
2186 /// \brief Get 'expr' part of the associated expression/statement.
2187 Expr *getExpr() { return cast_or_null<Expr>(*std::next(child_begin(), 4)); }
2188 const Expr *getExpr() const {
2189 return cast_or_null<Expr>(*std::next(child_begin(), 4));
2192 static bool classof(const Stmt *T) {
2193 return T->getStmtClass() == OMPAtomicDirectiveClass;
2197 /// \brief This represents '#pragma omp target' directive.
2200 /// #pragma omp target if(a)
2202 /// In this example directive '#pragma omp target' has clause 'if' with
2205 class OMPTargetDirective : public OMPExecutableDirective {
2206 friend class ASTStmtReader;
2207 /// \brief Build directive with the given start and end location.
2209 /// \param StartLoc Starting location of the directive kind.
2210 /// \param EndLoc Ending location of the directive.
2211 /// \param NumClauses Number of clauses.
2213 OMPTargetDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2214 unsigned NumClauses)
2215 : OMPExecutableDirective(this, OMPTargetDirectiveClass, OMPD_target,
2216 StartLoc, EndLoc, NumClauses, 1) {}
2218 /// \brief Build an empty directive.
2220 /// \param NumClauses Number of clauses.
2222 explicit OMPTargetDirective(unsigned NumClauses)
2223 : OMPExecutableDirective(this, OMPTargetDirectiveClass, OMPD_target,
2224 SourceLocation(), SourceLocation(), NumClauses,
2228 /// \brief Creates directive with a list of \a Clauses.
2230 /// \param C AST context.
2231 /// \param StartLoc Starting location of the directive kind.
2232 /// \param EndLoc Ending Location of the directive.
2233 /// \param Clauses List of clauses.
2234 /// \param AssociatedStmt Statement, associated with the directive.
2236 static OMPTargetDirective *
2237 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2238 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2240 /// \brief Creates an empty directive with the place for \a NumClauses
2243 /// \param C AST context.
2244 /// \param NumClauses Number of clauses.
2246 static OMPTargetDirective *CreateEmpty(const ASTContext &C,
2247 unsigned NumClauses, EmptyShell);
2249 static bool classof(const Stmt *T) {
2250 return T->getStmtClass() == OMPTargetDirectiveClass;
2254 /// \brief This represents '#pragma omp target data' directive.
2257 /// #pragma omp target data device(0) if(a) map(b[:])
2259 /// In this example directive '#pragma omp target data' has clauses 'device'
2260 /// with the value '0', 'if' with condition 'a' and 'map' with array
2263 class OMPTargetDataDirective : public OMPExecutableDirective {
2264 friend class ASTStmtReader;
2265 /// \brief Build directive with the given start and end location.
2267 /// \param StartLoc Starting location of the directive kind.
2268 /// \param EndLoc Ending Location of the directive.
2269 /// \param NumClauses The number of clauses.
2271 OMPTargetDataDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2272 unsigned NumClauses)
2273 : OMPExecutableDirective(this, OMPTargetDataDirectiveClass,
2274 OMPD_target_data, StartLoc, EndLoc, NumClauses,
2277 /// \brief Build an empty directive.
2279 /// \param NumClauses Number of clauses.
2281 explicit OMPTargetDataDirective(unsigned NumClauses)
2282 : OMPExecutableDirective(this, OMPTargetDataDirectiveClass,
2283 OMPD_target_data, SourceLocation(),
2284 SourceLocation(), NumClauses, 1) {}
2287 /// \brief Creates directive with a list of \a Clauses.
2289 /// \param C AST context.
2290 /// \param StartLoc Starting location of the directive kind.
2291 /// \param EndLoc Ending Location of the directive.
2292 /// \param Clauses List of clauses.
2293 /// \param AssociatedStmt Statement, associated with the directive.
2295 static OMPTargetDataDirective *
2296 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2297 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2299 /// \brief Creates an empty directive with the place for \a N clauses.
2301 /// \param C AST context.
2302 /// \param N The number of clauses.
2304 static OMPTargetDataDirective *CreateEmpty(const ASTContext &C, unsigned N,
2307 static bool classof(const Stmt *T) {
2308 return T->getStmtClass() == OMPTargetDataDirectiveClass;
2312 /// \brief This represents '#pragma omp target enter data' directive.
2315 /// #pragma omp target enter data device(0) if(a) map(b[:])
2317 /// In this example directive '#pragma omp target enter data' has clauses
2318 /// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
2321 class OMPTargetEnterDataDirective : public OMPExecutableDirective {
2322 friend class ASTStmtReader;
2323 /// \brief Build directive with the given start and end location.
2325 /// \param StartLoc Starting location of the directive kind.
2326 /// \param EndLoc Ending Location of the directive.
2327 /// \param NumClauses The number of clauses.
2329 OMPTargetEnterDataDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2330 unsigned NumClauses)
2331 : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
2332 OMPD_target_enter_data, StartLoc, EndLoc,
2333 NumClauses, /*NumChildren=*/0) {}
2335 /// \brief Build an empty directive.
2337 /// \param NumClauses Number of clauses.
2339 explicit OMPTargetEnterDataDirective(unsigned NumClauses)
2340 : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
2341 OMPD_target_enter_data, SourceLocation(),
2342 SourceLocation(), NumClauses,
2343 /*NumChildren=*/0) {}
2346 /// \brief Creates directive with a list of \a Clauses.
2348 /// \param C AST context.
2349 /// \param StartLoc Starting location of the directive kind.
2350 /// \param EndLoc Ending Location of the directive.
2351 /// \param Clauses List of clauses.
2353 static OMPTargetEnterDataDirective *Create(const ASTContext &C,
2354 SourceLocation StartLoc,
2355 SourceLocation EndLoc,
2356 ArrayRef<OMPClause *> Clauses);
2358 /// \brief Creates an empty directive with the place for \a N clauses.
2360 /// \param C AST context.
2361 /// \param N The number of clauses.
2363 static OMPTargetEnterDataDirective *CreateEmpty(const ASTContext &C,
2364 unsigned N, EmptyShell);
2366 static bool classof(const Stmt *T) {
2367 return T->getStmtClass() == OMPTargetEnterDataDirectiveClass;
2371 /// \brief This represents '#pragma omp target exit data' directive.
2374 /// #pragma omp target exit data device(0) if(a) map(b[:])
2376 /// In this example directive '#pragma omp target exit data' has clauses
2377 /// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
2380 class OMPTargetExitDataDirective : public OMPExecutableDirective {
2381 friend class ASTStmtReader;
2382 /// \brief Build directive with the given start and end location.
2384 /// \param StartLoc Starting location of the directive kind.
2385 /// \param EndLoc Ending Location of the directive.
2386 /// \param NumClauses The number of clauses.
2388 OMPTargetExitDataDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2389 unsigned NumClauses)
2390 : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
2391 OMPD_target_exit_data, StartLoc, EndLoc,
2392 NumClauses, /*NumChildren=*/0) {}
2394 /// \brief Build an empty directive.
2396 /// \param NumClauses Number of clauses.
2398 explicit OMPTargetExitDataDirective(unsigned NumClauses)
2399 : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
2400 OMPD_target_exit_data, SourceLocation(),
2401 SourceLocation(), NumClauses,
2402 /*NumChildren=*/0) {}
2405 /// \brief Creates directive with a list of \a Clauses.
2407 /// \param C AST context.
2408 /// \param StartLoc Starting location of the directive kind.
2409 /// \param EndLoc Ending Location of the directive.
2410 /// \param Clauses List of clauses.
2412 static OMPTargetExitDataDirective *Create(const ASTContext &C,
2413 SourceLocation StartLoc,
2414 SourceLocation EndLoc,
2415 ArrayRef<OMPClause *> Clauses);
2417 /// \brief Creates an empty directive with the place for \a N clauses.
2419 /// \param C AST context.
2420 /// \param N The number of clauses.
2422 static OMPTargetExitDataDirective *CreateEmpty(const ASTContext &C,
2423 unsigned N, EmptyShell);
2425 static bool classof(const Stmt *T) {
2426 return T->getStmtClass() == OMPTargetExitDataDirectiveClass;
2430 /// \brief This represents '#pragma omp target parallel' directive.
2433 /// #pragma omp target parallel if(a)
2435 /// In this example directive '#pragma omp target parallel' has clause 'if' with
2438 class OMPTargetParallelDirective : public OMPExecutableDirective {
2439 friend class ASTStmtReader;
2440 /// \brief Build directive with the given start and end location.
2442 /// \param StartLoc Starting location of the directive kind.
2443 /// \param EndLoc Ending location of the directive.
2444 /// \param NumClauses Number of clauses.
2446 OMPTargetParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2447 unsigned NumClauses)
2448 : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass,
2449 OMPD_target_parallel, StartLoc, EndLoc,
2450 NumClauses, /*NumChildren=*/1) {}
2452 /// \brief Build an empty directive.
2454 /// \param NumClauses Number of clauses.
2456 explicit OMPTargetParallelDirective(unsigned NumClauses)
2457 : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass,
2458 OMPD_target_parallel, SourceLocation(),
2459 SourceLocation(), NumClauses,
2460 /*NumChildren=*/1) {}
2463 /// \brief Creates directive with a list of \a Clauses.
2465 /// \param C AST context.
2466 /// \param StartLoc Starting location of the directive kind.
2467 /// \param EndLoc Ending Location of the directive.
2468 /// \param Clauses List of clauses.
2469 /// \param AssociatedStmt Statement, associated with the directive.
2471 static OMPTargetParallelDirective *
2472 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2473 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2475 /// \brief Creates an empty directive with the place for \a NumClauses
2478 /// \param C AST context.
2479 /// \param NumClauses Number of clauses.
2481 static OMPTargetParallelDirective *
2482 CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
2484 static bool classof(const Stmt *T) {
2485 return T->getStmtClass() == OMPTargetParallelDirectiveClass;
2489 /// \brief This represents '#pragma omp target parallel for' directive.
2492 /// #pragma omp target parallel for private(a,b) reduction(+:c,d)
2494 /// In this example directive '#pragma omp target parallel for' has clauses
2495 /// 'private' with the variables 'a' and 'b' and 'reduction' with operator '+'
2496 /// and variables 'c' and 'd'.
2498 class OMPTargetParallelForDirective : public OMPLoopDirective {
2499 friend class ASTStmtReader;
2501 /// \brief true if current region has inner cancel directive.
2504 /// \brief Build directive with the given start and end location.
2506 /// \param StartLoc Starting location of the directive kind.
2507 /// \param EndLoc Ending location of the directive.
2508 /// \param CollapsedNum Number of collapsed nested loops.
2509 /// \param NumClauses Number of clauses.
2511 OMPTargetParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2512 unsigned CollapsedNum, unsigned NumClauses)
2513 : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass,
2514 OMPD_target_parallel_for, StartLoc, EndLoc,
2515 CollapsedNum, NumClauses),
2518 /// \brief Build an empty directive.
2520 /// \param CollapsedNum Number of collapsed nested loops.
2521 /// \param NumClauses Number of clauses.
2523 explicit OMPTargetParallelForDirective(unsigned CollapsedNum,
2524 unsigned NumClauses)
2525 : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass,
2526 OMPD_target_parallel_for, SourceLocation(),
2527 SourceLocation(), CollapsedNum, NumClauses),
2530 /// \brief Set cancel state.
2531 void setHasCancel(bool Has) { HasCancel = Has; }
2534 /// \brief Creates directive with a list of \a Clauses.
2536 /// \param C AST context.
2537 /// \param StartLoc Starting location of the directive kind.
2538 /// \param EndLoc Ending Location of the directive.
2539 /// \param CollapsedNum Number of collapsed loops.
2540 /// \param Clauses List of clauses.
2541 /// \param AssociatedStmt Statement, associated with the directive.
2542 /// \param Exprs Helper expressions for CodeGen.
2543 /// \param HasCancel true if current directive has inner cancel directive.
2545 static OMPTargetParallelForDirective *
2546 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2547 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2548 Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
2550 /// \brief Creates an empty directive with the place
2551 /// for \a NumClauses clauses.
2553 /// \param C AST context.
2554 /// \param CollapsedNum Number of collapsed nested loops.
2555 /// \param NumClauses Number of clauses.
2557 static OMPTargetParallelForDirective *CreateEmpty(const ASTContext &C,
2558 unsigned NumClauses,
2559 unsigned CollapsedNum,
2562 /// \brief Return true if current directive has inner cancel directive.
2563 bool hasCancel() const { return HasCancel; }
2565 static bool classof(const Stmt *T) {
2566 return T->getStmtClass() == OMPTargetParallelForDirectiveClass;
2570 /// \brief This represents '#pragma omp teams' directive.
2573 /// #pragma omp teams if(a)
2575 /// In this example directive '#pragma omp teams' has clause 'if' with
2578 class OMPTeamsDirective : public OMPExecutableDirective {
2579 friend class ASTStmtReader;
2580 /// \brief Build directive with the given start and end location.
2582 /// \param StartLoc Starting location of the directive kind.
2583 /// \param EndLoc Ending location of the directive.
2584 /// \param NumClauses Number of clauses.
2586 OMPTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2587 unsigned NumClauses)
2588 : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
2589 StartLoc, EndLoc, NumClauses, 1) {}
2591 /// \brief Build an empty directive.
2593 /// \param NumClauses Number of clauses.
2595 explicit OMPTeamsDirective(unsigned NumClauses)
2596 : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
2597 SourceLocation(), SourceLocation(), NumClauses,
2601 /// \brief Creates directive with a list of \a Clauses.
2603 /// \param C AST context.
2604 /// \param StartLoc Starting location of the directive kind.
2605 /// \param EndLoc Ending Location of the directive.
2606 /// \param Clauses List of clauses.
2607 /// \param AssociatedStmt Statement, associated with the directive.
2609 static OMPTeamsDirective *Create(const ASTContext &C, SourceLocation StartLoc,
2610 SourceLocation EndLoc,
2611 ArrayRef<OMPClause *> Clauses,
2612 Stmt *AssociatedStmt);
2614 /// \brief Creates an empty directive with the place for \a NumClauses
2617 /// \param C AST context.
2618 /// \param NumClauses Number of clauses.
2620 static OMPTeamsDirective *CreateEmpty(const ASTContext &C,
2621 unsigned NumClauses, EmptyShell);
2623 static bool classof(const Stmt *T) {
2624 return T->getStmtClass() == OMPTeamsDirectiveClass;
2628 /// \brief This represents '#pragma omp cancellation point' directive.
2631 /// #pragma omp cancellation point for
2634 /// In this example a cancellation point is created for innermost 'for' region.
2635 class OMPCancellationPointDirective : public OMPExecutableDirective {
2636 friend class ASTStmtReader;
2637 OpenMPDirectiveKind CancelRegion;
2638 /// \brief Build directive with the given start and end location.
2640 /// \param StartLoc Starting location of the directive kind.
2641 /// \param EndLoc Ending location of the directive.
2643 OMPCancellationPointDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2644 : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass,
2645 OMPD_cancellation_point, StartLoc, EndLoc, 0, 0),
2646 CancelRegion(OMPD_unknown) {}
2648 /// \brief Build an empty directive.
2650 explicit OMPCancellationPointDirective()
2651 : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass,
2652 OMPD_cancellation_point, SourceLocation(),
2653 SourceLocation(), 0, 0),
2654 CancelRegion(OMPD_unknown) {}
2656 /// \brief Set cancel region for current cancellation point.
2657 /// \param CR Cancellation region.
2658 void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; }
2661 /// \brief Creates directive.
2663 /// \param C AST context.
2664 /// \param StartLoc Starting location of the directive kind.
2665 /// \param EndLoc Ending Location of the directive.
2667 static OMPCancellationPointDirective *
2668 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2669 OpenMPDirectiveKind CancelRegion);
2671 /// \brief Creates an empty directive.
2673 /// \param C AST context.
2675 static OMPCancellationPointDirective *CreateEmpty(const ASTContext &C,
2678 /// \brief Get cancellation region for the current cancellation point.
2679 OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; }
2681 static bool classof(const Stmt *T) {
2682 return T->getStmtClass() == OMPCancellationPointDirectiveClass;
2686 /// \brief This represents '#pragma omp cancel' directive.
2689 /// #pragma omp cancel for
2692 /// In this example a cancel is created for innermost 'for' region.
2693 class OMPCancelDirective : public OMPExecutableDirective {
2694 friend class ASTStmtReader;
2695 OpenMPDirectiveKind CancelRegion;
2696 /// \brief Build directive with the given start and end location.
2698 /// \param StartLoc Starting location of the directive kind.
2699 /// \param EndLoc Ending location of the directive.
2700 /// \param NumClauses Number of clauses.
2702 OMPCancelDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2703 unsigned NumClauses)
2704 : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
2705 StartLoc, EndLoc, NumClauses, 0),
2706 CancelRegion(OMPD_unknown) {}
2708 /// \brief Build an empty directive.
2710 /// \param NumClauses Number of clauses.
2711 explicit OMPCancelDirective(unsigned NumClauses)
2712 : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
2713 SourceLocation(), SourceLocation(), NumClauses,
2715 CancelRegion(OMPD_unknown) {}
2717 /// \brief Set cancel region for current cancellation point.
2718 /// \param CR Cancellation region.
2719 void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; }
2722 /// \brief Creates directive.
2724 /// \param C AST context.
2725 /// \param StartLoc Starting location of the directive kind.
2726 /// \param EndLoc Ending Location of the directive.
2727 /// \param Clauses List of clauses.
2729 static OMPCancelDirective *
2730 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2731 ArrayRef<OMPClause *> Clauses, OpenMPDirectiveKind CancelRegion);
2733 /// \brief Creates an empty directive.
2735 /// \param C AST context.
2736 /// \param NumClauses Number of clauses.
2738 static OMPCancelDirective *CreateEmpty(const ASTContext &C,
2739 unsigned NumClauses, EmptyShell);
2741 /// \brief Get cancellation region for the current cancellation point.
2742 OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; }
2744 static bool classof(const Stmt *T) {
2745 return T->getStmtClass() == OMPCancelDirectiveClass;
2749 /// \brief This represents '#pragma omp taskloop' directive.
2752 /// #pragma omp taskloop private(a,b) grainsize(val) num_tasks(num)
2754 /// In this example directive '#pragma omp taskloop' has clauses 'private'
2755 /// with the variables 'a' and 'b', 'grainsize' with expression 'val' and
2756 /// 'num_tasks' with expression 'num'.
2758 class OMPTaskLoopDirective : public OMPLoopDirective {
2759 friend class ASTStmtReader;
2760 /// \brief Build directive with the given start and end location.
2762 /// \param StartLoc Starting location of the directive kind.
2763 /// \param EndLoc Ending location of the directive.
2764 /// \param CollapsedNum Number of collapsed nested loops.
2765 /// \param NumClauses Number of clauses.
2767 OMPTaskLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2768 unsigned CollapsedNum, unsigned NumClauses)
2769 : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, OMPD_taskloop,
2770 StartLoc, EndLoc, CollapsedNum, NumClauses) {}
2772 /// \brief Build an empty directive.
2774 /// \param CollapsedNum Number of collapsed nested loops.
2775 /// \param NumClauses Number of clauses.
2777 explicit OMPTaskLoopDirective(unsigned CollapsedNum, unsigned NumClauses)
2778 : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, OMPD_taskloop,
2779 SourceLocation(), SourceLocation(), CollapsedNum,
2783 /// \brief Creates directive with a list of \a Clauses.
2785 /// \param C AST context.
2786 /// \param StartLoc Starting location of the directive kind.
2787 /// \param EndLoc Ending Location of the directive.
2788 /// \param CollapsedNum Number of collapsed loops.
2789 /// \param Clauses List of clauses.
2790 /// \param AssociatedStmt Statement, associated with the directive.
2791 /// \param Exprs Helper expressions for CodeGen.
2793 static OMPTaskLoopDirective *
2794 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2795 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2796 Stmt *AssociatedStmt, const HelperExprs &Exprs);
2798 /// \brief Creates an empty directive with the place
2799 /// for \a NumClauses clauses.
2801 /// \param C AST context.
2802 /// \param CollapsedNum Number of collapsed nested loops.
2803 /// \param NumClauses Number of clauses.
2805 static OMPTaskLoopDirective *CreateEmpty(const ASTContext &C,
2806 unsigned NumClauses,
2807 unsigned CollapsedNum, EmptyShell);
2809 static bool classof(const Stmt *T) {
2810 return T->getStmtClass() == OMPTaskLoopDirectiveClass;
2814 /// \brief This represents '#pragma omp taskloop simd' directive.
2817 /// #pragma omp taskloop simd private(a,b) grainsize(val) num_tasks(num)
2819 /// In this example directive '#pragma omp taskloop simd' has clauses 'private'
2820 /// with the variables 'a' and 'b', 'grainsize' with expression 'val' and
2821 /// 'num_tasks' with expression 'num'.
2823 class OMPTaskLoopSimdDirective : public OMPLoopDirective {
2824 friend class ASTStmtReader;
2825 /// \brief Build directive with the given start and end location.
2827 /// \param StartLoc Starting location of the directive kind.
2828 /// \param EndLoc Ending location of the directive.
2829 /// \param CollapsedNum Number of collapsed nested loops.
2830 /// \param NumClauses Number of clauses.
2832 OMPTaskLoopSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2833 unsigned CollapsedNum, unsigned NumClauses)
2834 : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass,
2835 OMPD_taskloop_simd, StartLoc, EndLoc, CollapsedNum,
2838 /// \brief Build an empty directive.
2840 /// \param CollapsedNum Number of collapsed nested loops.
2841 /// \param NumClauses Number of clauses.
2843 explicit OMPTaskLoopSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
2844 : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass,
2845 OMPD_taskloop_simd, SourceLocation(), SourceLocation(),
2846 CollapsedNum, NumClauses) {}
2849 /// \brief Creates directive with a list of \a Clauses.
2851 /// \param C AST context.
2852 /// \param StartLoc Starting location of the directive kind.
2853 /// \param EndLoc Ending Location of the directive.
2854 /// \param CollapsedNum Number of collapsed loops.
2855 /// \param Clauses List of clauses.
2856 /// \param AssociatedStmt Statement, associated with the directive.
2857 /// \param Exprs Helper expressions for CodeGen.
2859 static OMPTaskLoopSimdDirective *
2860 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2861 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2862 Stmt *AssociatedStmt, const HelperExprs &Exprs);
2864 /// \brief Creates an empty directive with the place
2865 /// for \a NumClauses clauses.
2867 /// \param C AST context.
2868 /// \param CollapsedNum Number of collapsed nested loops.
2869 /// \param NumClauses Number of clauses.
2871 static OMPTaskLoopSimdDirective *CreateEmpty(const ASTContext &C,
2872 unsigned NumClauses,
2873 unsigned CollapsedNum,
2876 static bool classof(const Stmt *T) {
2877 return T->getStmtClass() == OMPTaskLoopSimdDirectiveClass;
2881 /// \brief This represents '#pragma omp distribute' directive.
2884 /// #pragma omp distribute private(a,b)
2886 /// In this example directive '#pragma omp distribute' has clauses 'private'
2887 /// with the variables 'a' and 'b'
2889 class OMPDistributeDirective : public OMPLoopDirective {
2890 friend class ASTStmtReader;
2892 /// \brief Build directive with the given start and end location.
2894 /// \param StartLoc Starting location of the directive kind.
2895 /// \param EndLoc Ending location of the directive.
2896 /// \param CollapsedNum Number of collapsed nested loops.
2897 /// \param NumClauses Number of clauses.
2899 OMPDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2900 unsigned CollapsedNum, unsigned NumClauses)
2901 : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,
2902 StartLoc, EndLoc, CollapsedNum, NumClauses)
2905 /// \brief Build an empty directive.
2907 /// \param CollapsedNum Number of collapsed nested loops.
2908 /// \param NumClauses Number of clauses.
2910 explicit OMPDistributeDirective(unsigned CollapsedNum, unsigned NumClauses)
2911 : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,
2912 SourceLocation(), SourceLocation(), CollapsedNum,
2917 /// \brief Creates directive with a list of \a Clauses.
2919 /// \param C AST context.
2920 /// \param StartLoc Starting location of the directive kind.
2921 /// \param EndLoc Ending Location of the directive.
2922 /// \param CollapsedNum Number of collapsed loops.
2923 /// \param Clauses List of clauses.
2924 /// \param AssociatedStmt Statement, associated with the directive.
2925 /// \param Exprs Helper expressions for CodeGen.
2927 static OMPDistributeDirective *
2928 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2929 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2930 Stmt *AssociatedStmt, const HelperExprs &Exprs);
2932 /// \brief Creates an empty directive with the place
2933 /// for \a NumClauses clauses.
2935 /// \param C AST context.
2936 /// \param CollapsedNum Number of collapsed nested loops.
2937 /// \param NumClauses Number of clauses.
2939 static OMPDistributeDirective *CreateEmpty(const ASTContext &C,
2940 unsigned NumClauses,
2941 unsigned CollapsedNum, EmptyShell);
2943 static bool classof(const Stmt *T) {
2944 return T->getStmtClass() == OMPDistributeDirectiveClass;
2948 /// \brief This represents '#pragma omp target update' directive.
2951 /// #pragma omp target update to(a) from(b) device(1)
2953 /// In this example directive '#pragma omp target update' has clause 'to' with
2954 /// argument 'a', clause 'from' with argument 'b' and clause 'device' with
2957 class OMPTargetUpdateDirective : public OMPExecutableDirective {
2958 friend class ASTStmtReader;
2959 /// \brief Build directive with the given start and end location.
2961 /// \param StartLoc Starting location of the directive kind.
2962 /// \param EndLoc Ending Location of the directive.
2963 /// \param NumClauses The number of clauses.
2965 OMPTargetUpdateDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2966 unsigned NumClauses)
2967 : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass,
2968 OMPD_target_update, StartLoc, EndLoc, NumClauses,
2971 /// \brief Build an empty directive.
2973 /// \param NumClauses Number of clauses.
2975 explicit OMPTargetUpdateDirective(unsigned NumClauses)
2976 : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass,
2977 OMPD_target_update, SourceLocation(),
2978 SourceLocation(), NumClauses, 0) {}
2981 /// \brief Creates directive with a list of \a Clauses.
2983 /// \param C AST context.
2984 /// \param StartLoc Starting location of the directive kind.
2985 /// \param EndLoc Ending Location of the directive.
2986 /// \param Clauses List of clauses.
2988 static OMPTargetUpdateDirective *Create(const ASTContext &C,
2989 SourceLocation StartLoc,
2990 SourceLocation EndLoc,
2991 ArrayRef<OMPClause *> Clauses);
2993 /// \brief Creates an empty directive with the place for \a NumClauses
2996 /// \param C AST context.
2997 /// \param NumClauses The number of clauses.
2999 static OMPTargetUpdateDirective *CreateEmpty(const ASTContext &C,
3000 unsigned NumClauses, EmptyShell);
3002 static bool classof(const Stmt *T) {
3003 return T->getStmtClass() == OMPTargetUpdateDirectiveClass;
3007 /// \brief This represents '#pragma omp distribute parallel for' composite
3011 /// #pragma omp distribute parallel for private(a,b)
3013 /// In this example directive '#pragma omp distribute parallel for' has clause
3014 /// 'private' with the variables 'a' and 'b'
3016 class OMPDistributeParallelForDirective : public OMPLoopDirective {
3017 friend class ASTStmtReader;
3019 /// \brief Build directive with the given start and end location.
3021 /// \param StartLoc Starting location of the directive kind.
3022 /// \param EndLoc Ending location of the directive.
3023 /// \param CollapsedNum Number of collapsed nested loops.
3024 /// \param NumClauses Number of clauses.
3026 OMPDistributeParallelForDirective(SourceLocation StartLoc,
3027 SourceLocation EndLoc,
3028 unsigned CollapsedNum, unsigned NumClauses)
3029 : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
3030 OMPD_distribute_parallel_for, StartLoc, EndLoc,
3031 CollapsedNum, NumClauses) {}
3033 /// \brief Build an empty directive.
3035 /// \param CollapsedNum Number of collapsed nested loops.
3036 /// \param NumClauses Number of clauses.
3038 explicit OMPDistributeParallelForDirective(unsigned CollapsedNum,
3039 unsigned NumClauses)
3040 : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
3041 OMPD_distribute_parallel_for, SourceLocation(),
3042 SourceLocation(), CollapsedNum, NumClauses) {}
3045 /// \brief Creates directive with a list of \a Clauses.
3047 /// \param C AST context.
3048 /// \param StartLoc Starting location of the directive kind.
3049 /// \param EndLoc Ending Location of the directive.
3050 /// \param CollapsedNum Number of collapsed loops.
3051 /// \param Clauses List of clauses.
3052 /// \param AssociatedStmt Statement, associated with the directive.
3053 /// \param Exprs Helper expressions for CodeGen.
3055 static OMPDistributeParallelForDirective *
3056 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3057 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3058 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3060 /// \brief Creates an empty directive with the place
3061 /// for \a NumClauses clauses.
3063 /// \param C AST context.
3064 /// \param CollapsedNum Number of collapsed nested loops.
3065 /// \param NumClauses Number of clauses.
3067 static OMPDistributeParallelForDirective *CreateEmpty(const ASTContext &C,
3068 unsigned NumClauses,
3069 unsigned CollapsedNum,
3072 static bool classof(const Stmt *T) {
3073 return T->getStmtClass() == OMPDistributeParallelForDirectiveClass;
3077 /// This represents '#pragma omp distribute parallel for simd' composite
3081 /// #pragma omp distribute parallel for simd private(x)
3083 /// In this example directive '#pragma omp distribute parallel for simd' has
3084 /// clause 'private' with the variables 'x'
3086 class OMPDistributeParallelForSimdDirective final : public OMPLoopDirective {
3087 friend class ASTStmtReader;
3089 /// Build directive with the given start and end location.
3091 /// \param StartLoc Starting location of the directive kind.
3092 /// \param EndLoc Ending location of the directive.
3093 /// \param CollapsedNum Number of collapsed nested loops.
3094 /// \param NumClauses Number of clauses.
3096 OMPDistributeParallelForSimdDirective(SourceLocation StartLoc,
3097 SourceLocation EndLoc,
3098 unsigned CollapsedNum,
3099 unsigned NumClauses)
3100 : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass,
3101 OMPD_distribute_parallel_for_simd, StartLoc,
3102 EndLoc, CollapsedNum, NumClauses) {}
3104 /// Build an empty directive.
3106 /// \param CollapsedNum Number of collapsed nested loops.
3107 /// \param NumClauses Number of clauses.
3109 explicit OMPDistributeParallelForSimdDirective(unsigned CollapsedNum,
3110 unsigned NumClauses)
3111 : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass,
3112 OMPD_distribute_parallel_for_simd,
3113 SourceLocation(), SourceLocation(), CollapsedNum,
3117 /// Creates directive with a list of \a Clauses.
3119 /// \param C AST context.
3120 /// \param StartLoc Starting location of the directive kind.
3121 /// \param EndLoc Ending Location of the directive.
3122 /// \param CollapsedNum Number of collapsed loops.
3123 /// \param Clauses List of clauses.
3124 /// \param AssociatedStmt Statement, associated with the directive.
3125 /// \param Exprs Helper expressions for CodeGen.
3127 static OMPDistributeParallelForSimdDirective *Create(
3128 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3129 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3130 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3132 /// Creates an empty directive with the place for \a NumClauses clauses.
3134 /// \param C AST context.
3135 /// \param CollapsedNum Number of collapsed nested loops.
3136 /// \param NumClauses Number of clauses.
3138 static OMPDistributeParallelForSimdDirective *CreateEmpty(
3139 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3142 static bool classof(const Stmt *T) {
3143 return T->getStmtClass() == OMPDistributeParallelForSimdDirectiveClass;
3147 /// This represents '#pragma omp distribute simd' composite directive.
3150 /// #pragma omp distribute simd private(x)
3152 /// In this example directive '#pragma omp distribute simd' has clause
3153 /// 'private' with the variables 'x'
3155 class OMPDistributeSimdDirective final : public OMPLoopDirective {
3156 friend class ASTStmtReader;
3158 /// Build directive with the given start and end location.
3160 /// \param StartLoc Starting location of the directive kind.
3161 /// \param EndLoc Ending location of the directive.
3162 /// \param CollapsedNum Number of collapsed nested loops.
3163 /// \param NumClauses Number of clauses.
3165 OMPDistributeSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3166 unsigned CollapsedNum, unsigned NumClauses)
3167 : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass,
3168 OMPD_distribute_simd, StartLoc, EndLoc, CollapsedNum,
3171 /// Build an empty directive.
3173 /// \param CollapsedNum Number of collapsed nested loops.
3174 /// \param NumClauses Number of clauses.
3176 explicit OMPDistributeSimdDirective(unsigned CollapsedNum,
3177 unsigned NumClauses)
3178 : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass,
3179 OMPD_distribute_simd, SourceLocation(),
3180 SourceLocation(), CollapsedNum, NumClauses) {}
3183 /// Creates directive with a list of \a Clauses.
3185 /// \param C AST context.
3186 /// \param StartLoc Starting location of the directive kind.
3187 /// \param EndLoc Ending Location of the directive.
3188 /// \param CollapsedNum Number of collapsed loops.
3189 /// \param Clauses List of clauses.
3190 /// \param AssociatedStmt Statement, associated with the directive.
3191 /// \param Exprs Helper expressions for CodeGen.
3193 static OMPDistributeSimdDirective *
3194 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3195 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3196 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3198 /// Creates an empty directive with the place for \a NumClauses clauses.
3200 /// \param C AST context.
3201 /// \param CollapsedNum Number of collapsed nested loops.
3202 /// \param NumClauses Number of clauses.
3204 static OMPDistributeSimdDirective *CreateEmpty(const ASTContext &C,
3205 unsigned NumClauses,
3206 unsigned CollapsedNum,
3209 static bool classof(const Stmt *T) {
3210 return T->getStmtClass() == OMPDistributeSimdDirectiveClass;
3214 /// This represents '#pragma omp target parallel for simd' directive.
3217 /// #pragma omp target parallel for simd private(a) map(b) safelen(c)
3219 /// In this example directive '#pragma omp target parallel for simd' has clauses
3220 /// 'private' with the variable 'a', 'map' with the variable 'b' and 'safelen'
3221 /// with the variable 'c'.
3223 class OMPTargetParallelForSimdDirective final : public OMPLoopDirective {
3224 friend class ASTStmtReader;
3226 /// Build directive with the given start and end location.
3228 /// \param StartLoc Starting location of the directive kind.
3229 /// \param EndLoc Ending location of the directive.
3230 /// \param CollapsedNum Number of collapsed nested loops.
3231 /// \param NumClauses Number of clauses.
3233 OMPTargetParallelForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3234 unsigned CollapsedNum, unsigned NumClauses)
3235 : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass,
3236 OMPD_target_parallel_for_simd, StartLoc, EndLoc,
3237 CollapsedNum, NumClauses) {}
3239 /// Build an empty directive.
3241 /// \param CollapsedNum Number of collapsed nested loops.
3242 /// \param NumClauses Number of clauses.
3244 explicit OMPTargetParallelForSimdDirective(unsigned CollapsedNum,
3245 unsigned NumClauses)
3246 : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass,
3247 OMPD_target_parallel_for_simd, SourceLocation(),
3248 SourceLocation(), CollapsedNum, NumClauses) {}
3251 /// Creates directive with a list of \a Clauses.
3253 /// \param C AST context.
3254 /// \param StartLoc Starting location of the directive kind.
3255 /// \param EndLoc Ending Location of the directive.
3256 /// \param CollapsedNum Number of collapsed loops.
3257 /// \param Clauses List of clauses.
3258 /// \param AssociatedStmt Statement, associated with the directive.
3259 /// \param Exprs Helper expressions for CodeGen.
3261 static OMPTargetParallelForSimdDirective *
3262 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3263 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3264 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3266 /// Creates an empty directive with the place for \a NumClauses clauses.
3268 /// \param C AST context.
3269 /// \param CollapsedNum Number of collapsed nested loops.
3270 /// \param NumClauses Number of clauses.
3272 static OMPTargetParallelForSimdDirective *CreateEmpty(const ASTContext &C,
3273 unsigned NumClauses,
3274 unsigned CollapsedNum,
3277 static bool classof(const Stmt *T) {
3278 return T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass;
3282 /// This represents '#pragma omp target simd' directive.
3285 /// #pragma omp target simd private(a) map(b) safelen(c)
3287 /// In this example directive '#pragma omp target simd' has clauses 'private'
3288 /// with the variable 'a', 'map' with the variable 'b' and 'safelen' with
3289 /// the variable 'c'.
3291 class OMPTargetSimdDirective final : public OMPLoopDirective {
3292 friend class ASTStmtReader;
3294 /// Build directive with the given start and end location.
3296 /// \param StartLoc Starting location of the directive kind.
3297 /// \param EndLoc Ending location of the directive.
3298 /// \param CollapsedNum Number of collapsed nested loops.
3299 /// \param NumClauses Number of clauses.
3301 OMPTargetSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3302 unsigned CollapsedNum, unsigned NumClauses)
3303 : OMPLoopDirective(this, OMPTargetSimdDirectiveClass,
3304 OMPD_target_simd, StartLoc, EndLoc, CollapsedNum,
3307 /// Build an empty directive.
3309 /// \param CollapsedNum Number of collapsed nested loops.
3310 /// \param NumClauses Number of clauses.
3312 explicit OMPTargetSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
3313 : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, OMPD_target_simd,
3314 SourceLocation(),SourceLocation(), CollapsedNum,
3318 /// Creates directive with a list of \a Clauses.
3320 /// \param C AST context.
3321 /// \param StartLoc Starting location of the directive kind.
3322 /// \param EndLoc Ending Location of the directive.
3323 /// \param CollapsedNum Number of collapsed loops.
3324 /// \param Clauses List of clauses.
3325 /// \param AssociatedStmt Statement, associated with the directive.
3326 /// \param Exprs Helper expressions for CodeGen.
3328 static OMPTargetSimdDirective *
3329 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3330 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3331 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3333 /// Creates an empty directive with the place for \a NumClauses clauses.
3335 /// \param C AST context.
3336 /// \param CollapsedNum Number of collapsed nested loops.
3337 /// \param NumClauses Number of clauses.
3339 static OMPTargetSimdDirective *CreateEmpty(const ASTContext &C,
3340 unsigned NumClauses,
3341 unsigned CollapsedNum,
3344 static bool classof(const Stmt *T) {
3345 return T->getStmtClass() == OMPTargetSimdDirectiveClass;
3349 /// This represents '#pragma omp teams distribute' directive.
3352 /// #pragma omp teams distribute private(a,b)
3354 /// In this example directive '#pragma omp teams distribute' has clauses
3355 /// 'private' with the variables 'a' and 'b'
3357 class OMPTeamsDistributeDirective final : public OMPLoopDirective {
3358 friend class ASTStmtReader;
3360 /// Build directive with the given start and end location.
3362 /// \param StartLoc Starting location of the directive kind.
3363 /// \param EndLoc Ending location of the directive.
3364 /// \param CollapsedNum Number of collapsed nested loops.
3365 /// \param NumClauses Number of clauses.
3367 OMPTeamsDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3368 unsigned CollapsedNum, unsigned NumClauses)
3369 : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass,
3370 OMPD_teams_distribute, StartLoc, EndLoc,
3371 CollapsedNum, NumClauses) {}
3373 /// Build an empty directive.
3375 /// \param CollapsedNum Number of collapsed nested loops.
3376 /// \param NumClauses Number of clauses.
3378 explicit OMPTeamsDistributeDirective(unsigned CollapsedNum,
3379 unsigned NumClauses)
3380 : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass,
3381 OMPD_teams_distribute, SourceLocation(),
3382 SourceLocation(), CollapsedNum, NumClauses) {}
3385 /// Creates directive with a list of \a Clauses.
3387 /// \param C AST context.
3388 /// \param StartLoc Starting location of the directive kind.
3389 /// \param EndLoc Ending Location of the directive.
3390 /// \param CollapsedNum Number of collapsed loops.
3391 /// \param Clauses List of clauses.
3392 /// \param AssociatedStmt Statement, associated with the directive.
3393 /// \param Exprs Helper expressions for CodeGen.
3395 static OMPTeamsDistributeDirective *
3396 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3397 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3398 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3400 /// Creates an empty directive with the place for \a NumClauses clauses.
3402 /// \param C AST context.
3403 /// \param CollapsedNum Number of collapsed nested loops.
3404 /// \param NumClauses Number of clauses.
3406 static OMPTeamsDistributeDirective *CreateEmpty(const ASTContext &C,
3407 unsigned NumClauses,
3408 unsigned CollapsedNum,
3411 static bool classof(const Stmt *T) {
3412 return T->getStmtClass() == OMPTeamsDistributeDirectiveClass;
3416 /// This represents '#pragma omp teams distribute simd'
3417 /// combined directive.
3420 /// #pragma omp teams distribute simd private(a,b)
3422 /// In this example directive '#pragma omp teams distribute simd'
3423 /// has clause 'private' with the variables 'a' and 'b'
3425 class OMPTeamsDistributeSimdDirective final : public OMPLoopDirective {
3426 friend class ASTStmtReader;
3428 /// Build directive with the given start and end location.
3430 /// \param StartLoc Starting location of the directive kind.
3431 /// \param EndLoc Ending location of the directive.
3432 /// \param CollapsedNum Number of collapsed nested loops.
3433 /// \param NumClauses Number of clauses.
3435 OMPTeamsDistributeSimdDirective(SourceLocation StartLoc,
3436 SourceLocation EndLoc, unsigned CollapsedNum,
3437 unsigned NumClauses)
3438 : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass,
3439 OMPD_teams_distribute_simd, StartLoc, EndLoc,
3440 CollapsedNum, NumClauses) {}
3442 /// Build an empty directive.
3444 /// \param CollapsedNum Number of collapsed nested loops.
3445 /// \param NumClauses Number of clauses.
3447 explicit OMPTeamsDistributeSimdDirective(unsigned CollapsedNum,
3448 unsigned NumClauses)
3449 : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass,
3450 OMPD_teams_distribute_simd, SourceLocation(),
3451 SourceLocation(), CollapsedNum, NumClauses) {}
3454 /// Creates directive with a list of \a Clauses.
3456 /// \param C AST context.
3457 /// \param StartLoc Starting location of the directive kind.
3458 /// \param EndLoc Ending Location of the directive.
3459 /// \param CollapsedNum Number of collapsed loops.
3460 /// \param Clauses List of clauses.
3461 /// \param AssociatedStmt Statement, associated with the directive.
3462 /// \param Exprs Helper expressions for CodeGen.
3464 static OMPTeamsDistributeSimdDirective *
3465 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3466 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3467 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3469 /// Creates an empty directive with the place
3470 /// for \a NumClauses clauses.
3472 /// \param C AST context.
3473 /// \param CollapsedNum Number of collapsed nested loops.
3474 /// \param NumClauses Number of clauses.
3476 static OMPTeamsDistributeSimdDirective *CreateEmpty(const ASTContext &C,
3477 unsigned NumClauses,
3478 unsigned CollapsedNum,
3481 static bool classof(const Stmt *T) {
3482 return T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass;
3486 /// This represents '#pragma omp teams distribute parallel for simd' composite
3490 /// #pragma omp teams distribute parallel for simd private(x)
3492 /// In this example directive '#pragma omp teams distribute parallel for simd'
3493 /// has clause 'private' with the variables 'x'
3495 class OMPTeamsDistributeParallelForSimdDirective final
3496 : public OMPLoopDirective {
3497 friend class ASTStmtReader;
3499 /// Build directive with the given start and end location.
3501 /// \param StartLoc Starting location of the directive kind.
3502 /// \param EndLoc Ending location of the directive.
3503 /// \param CollapsedNum Number of collapsed nested loops.
3504 /// \param NumClauses Number of clauses.
3506 OMPTeamsDistributeParallelForSimdDirective(SourceLocation StartLoc,
3507 SourceLocation EndLoc,
3508 unsigned CollapsedNum,
3509 unsigned NumClauses)
3510 : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass,
3511 OMPD_teams_distribute_parallel_for_simd, StartLoc,
3512 EndLoc, CollapsedNum, NumClauses) {}
3514 /// Build an empty directive.
3516 /// \param CollapsedNum Number of collapsed nested loops.
3517 /// \param NumClauses Number of clauses.
3519 explicit OMPTeamsDistributeParallelForSimdDirective(unsigned CollapsedNum,
3520 unsigned NumClauses)
3521 : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass,
3522 OMPD_teams_distribute_parallel_for_simd,
3523 SourceLocation(), SourceLocation(), CollapsedNum,
3527 /// Creates directive with a list of \a Clauses.
3529 /// \param C AST context.
3530 /// \param StartLoc Starting location of the directive kind.
3531 /// \param EndLoc Ending Location of the directive.
3532 /// \param CollapsedNum Number of collapsed loops.
3533 /// \param Clauses List of clauses.
3534 /// \param AssociatedStmt Statement, associated with the directive.
3535 /// \param Exprs Helper expressions for CodeGen.
3537 static OMPTeamsDistributeParallelForSimdDirective *
3538 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3539 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3540 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3542 /// Creates an empty directive with the place for \a NumClauses clauses.
3544 /// \param C AST context.
3545 /// \param CollapsedNum Number of collapsed nested loops.
3546 /// \param NumClauses Number of clauses.
3548 static OMPTeamsDistributeParallelForSimdDirective *
3549 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3552 static bool classof(const Stmt *T) {
3553 return T->getStmtClass() == OMPTeamsDistributeParallelForSimdDirectiveClass;
3557 /// This represents '#pragma omp teams distribute parallel for' composite
3561 /// #pragma omp teams distribute parallel for private(x)
3563 /// In this example directive '#pragma omp teams distribute parallel for'
3564 /// has clause 'private' with the variables 'x'
3566 class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective {
3567 friend class ASTStmtReader;
3569 /// Build directive with the given start and end location.
3571 /// \param StartLoc Starting location of the directive kind.
3572 /// \param EndLoc Ending location of the directive.
3573 /// \param CollapsedNum Number of collapsed nested loops.
3574 /// \param NumClauses Number of clauses.
3576 OMPTeamsDistributeParallelForDirective(SourceLocation StartLoc,
3577 SourceLocation EndLoc,
3578 unsigned CollapsedNum,
3579 unsigned NumClauses)
3580 : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
3581 OMPD_teams_distribute_parallel_for, StartLoc, EndLoc,
3582 CollapsedNum, NumClauses) {}
3584 /// Build an empty directive.
3586 /// \param CollapsedNum Number of collapsed nested loops.
3587 /// \param NumClauses Number of clauses.
3589 explicit OMPTeamsDistributeParallelForDirective(unsigned CollapsedNum,
3590 unsigned NumClauses)
3591 : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
3592 OMPD_teams_distribute_parallel_for, SourceLocation(),
3593 SourceLocation(), CollapsedNum, NumClauses) {}
3596 /// Creates directive with a list of \a Clauses.
3598 /// \param C AST context.
3599 /// \param StartLoc Starting location of the directive kind.
3600 /// \param EndLoc Ending Location of the directive.
3601 /// \param CollapsedNum Number of collapsed loops.
3602 /// \param Clauses List of clauses.
3603 /// \param AssociatedStmt Statement, associated with the directive.
3604 /// \param Exprs Helper expressions for CodeGen.
3606 static OMPTeamsDistributeParallelForDirective *
3607 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3608 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3609 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3611 /// Creates an empty directive with the place for \a NumClauses clauses.
3613 /// \param C AST context.
3614 /// \param CollapsedNum Number of collapsed nested loops.
3615 /// \param NumClauses Number of clauses.
3617 static OMPTeamsDistributeParallelForDirective *
3618 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3621 static bool classof(const Stmt *T) {
3622 return T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass;
3626 /// This represents '#pragma omp target teams' directive.
3629 /// #pragma omp target teams if(a>0)
3631 /// In this example directive '#pragma omp target teams' has clause 'if' with
3632 /// condition 'a>0'.
3634 class OMPTargetTeamsDirective final : public OMPExecutableDirective {
3635 friend class ASTStmtReader;
3636 /// Build directive with the given start and end location.
3638 /// \param StartLoc Starting location of the directive kind.
3639 /// \param EndLoc Ending location of the directive.
3640 /// \param NumClauses Number of clauses.
3642 OMPTargetTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3643 unsigned NumClauses)
3644 : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass,
3645 OMPD_target_teams, StartLoc, EndLoc, NumClauses,
3648 /// Build an empty directive.
3650 /// \param NumClauses Number of clauses.
3652 explicit OMPTargetTeamsDirective(unsigned NumClauses)
3653 : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass,
3654 OMPD_target_teams, SourceLocation(),
3655 SourceLocation(), NumClauses, 1) {}
3658 /// Creates directive with a list of \a Clauses.
3660 /// \param C AST context.
3661 /// \param StartLoc Starting location of the directive kind.
3662 /// \param EndLoc Ending Location of the directive.
3663 /// \param Clauses List of clauses.
3664 /// \param AssociatedStmt Statement, associated with the directive.
3666 static OMPTargetTeamsDirective *Create(const ASTContext &C,
3667 SourceLocation StartLoc,
3668 SourceLocation EndLoc,
3669 ArrayRef<OMPClause *> Clauses,
3670 Stmt *AssociatedStmt);
3672 /// Creates an empty directive with the place for \a NumClauses clauses.
3674 /// \param C AST context.
3675 /// \param NumClauses Number of clauses.
3677 static OMPTargetTeamsDirective *CreateEmpty(const ASTContext &C,
3678 unsigned NumClauses, EmptyShell);
3680 static bool classof(const Stmt *T) {
3681 return T->getStmtClass() == OMPTargetTeamsDirectiveClass;
3685 /// This represents '#pragma omp target teams distribute' combined directive.
3688 /// #pragma omp target teams distribute private(x)
3690 /// In this example directive '#pragma omp target teams distribute' has clause
3691 /// 'private' with the variables 'x'
3693 class OMPTargetTeamsDistributeDirective final : public OMPLoopDirective {
3694 friend class ASTStmtReader;
3696 /// Build directive with the given start and end location.
3698 /// \param StartLoc Starting location of the directive kind.
3699 /// \param EndLoc Ending location of the directive.
3700 /// \param CollapsedNum Number of collapsed nested loops.
3701 /// \param NumClauses Number of clauses.
3703 OMPTargetTeamsDistributeDirective(SourceLocation StartLoc,
3704 SourceLocation EndLoc,
3705 unsigned CollapsedNum, unsigned NumClauses)
3706 : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass,
3707 OMPD_target_teams_distribute, StartLoc, EndLoc,
3708 CollapsedNum, NumClauses) {}
3710 /// Build an empty directive.
3712 /// \param CollapsedNum Number of collapsed nested loops.
3713 /// \param NumClauses Number of clauses.
3715 explicit OMPTargetTeamsDistributeDirective(unsigned CollapsedNum,
3716 unsigned NumClauses)
3717 : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass,
3718 OMPD_target_teams_distribute, SourceLocation(),
3719 SourceLocation(), CollapsedNum, NumClauses) {}
3722 /// Creates directive with a list of \a Clauses.
3724 /// \param C AST context.
3725 /// \param StartLoc Starting location of the directive kind.
3726 /// \param EndLoc Ending Location of the directive.
3727 /// \param CollapsedNum Number of collapsed loops.
3728 /// \param Clauses List of clauses.
3729 /// \param AssociatedStmt Statement, associated with the directive.
3730 /// \param Exprs Helper expressions for CodeGen.
3732 static OMPTargetTeamsDistributeDirective *
3733 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3734 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3735 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3737 /// Creates an empty directive with the place for \a NumClauses clauses.
3739 /// \param C AST context.
3740 /// \param CollapsedNum Number of collapsed nested loops.
3741 /// \param NumClauses Number of clauses.
3743 static OMPTargetTeamsDistributeDirective *
3744 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3747 static bool classof(const Stmt *T) {
3748 return T->getStmtClass() == OMPTargetTeamsDistributeDirectiveClass;
3752 /// This represents '#pragma omp target teams distribute parallel for' combined
3756 /// #pragma omp target teams distribute parallel for private(x)
3758 /// In this example directive '#pragma omp target teams distribute parallel
3759 /// for' has clause 'private' with the variables 'x'
3761 class OMPTargetTeamsDistributeParallelForDirective final
3762 : public OMPLoopDirective {
3763 friend class ASTStmtReader;
3765 /// Build directive with the given start and end location.
3767 /// \param StartLoc Starting location of the directive kind.
3768 /// \param EndLoc Ending location of the directive.
3769 /// \param CollapsedNum Number of collapsed nested loops.
3770 /// \param NumClauses Number of clauses.
3772 OMPTargetTeamsDistributeParallelForDirective(SourceLocation StartLoc,
3773 SourceLocation EndLoc,
3774 unsigned CollapsedNum,
3775 unsigned NumClauses)
3776 : OMPLoopDirective(this,
3777 OMPTargetTeamsDistributeParallelForDirectiveClass,
3778 OMPD_target_teams_distribute_parallel_for, StartLoc,
3779 EndLoc, CollapsedNum, NumClauses) {}
3781 /// Build an empty directive.
3783 /// \param CollapsedNum Number of collapsed nested loops.
3784 /// \param NumClauses Number of clauses.
3786 explicit OMPTargetTeamsDistributeParallelForDirective(unsigned CollapsedNum,
3787 unsigned NumClauses)
3789 this, OMPTargetTeamsDistributeParallelForDirectiveClass,
3790 OMPD_target_teams_distribute_parallel_for, SourceLocation(),
3791 SourceLocation(), CollapsedNum, NumClauses) {}
3794 /// Creates directive with a list of \a Clauses.
3796 /// \param C AST context.
3797 /// \param StartLoc Starting location of the directive kind.
3798 /// \param EndLoc Ending Location of the directive.
3799 /// \param CollapsedNum Number of collapsed loops.
3800 /// \param Clauses List of clauses.
3801 /// \param AssociatedStmt Statement, associated with the directive.
3802 /// \param Exprs Helper expressions for CodeGen.
3804 static OMPTargetTeamsDistributeParallelForDirective *
3805 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3806 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3807 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3809 /// Creates an empty directive with the place for \a NumClauses clauses.
3811 /// \param C AST context.
3812 /// \param CollapsedNum Number of collapsed nested loops.
3813 /// \param NumClauses Number of clauses.
3815 static OMPTargetTeamsDistributeParallelForDirective *
3816 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3819 static bool classof(const Stmt *T) {
3820 return T->getStmtClass() ==
3821 OMPTargetTeamsDistributeParallelForDirectiveClass;
3825 /// This represents '#pragma omp target teams distribute parallel for simd'
3826 /// combined directive.
3829 /// #pragma omp target teams distribute parallel for simd private(x)
3831 /// In this example directive '#pragma omp target teams distribute parallel
3832 /// for simd' has clause 'private' with the variables 'x'
3834 class OMPTargetTeamsDistributeParallelForSimdDirective final
3835 : public OMPLoopDirective {
3836 friend class ASTStmtReader;
3838 /// Build directive with the given start and end location.
3840 /// \param StartLoc Starting location of the directive kind.
3841 /// \param EndLoc Ending location of the directive.
3842 /// \param CollapsedNum Number of collapsed nested loops.
3843 /// \param NumClauses Number of clauses.
3845 OMPTargetTeamsDistributeParallelForSimdDirective(SourceLocation StartLoc,
3846 SourceLocation EndLoc,
3847 unsigned CollapsedNum,
3848 unsigned NumClauses)
3849 : OMPLoopDirective(this,
3850 OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
3851 OMPD_target_teams_distribute_parallel_for_simd,
3852 StartLoc, EndLoc, CollapsedNum, NumClauses) {}
3854 /// Build an empty directive.
3856 /// \param CollapsedNum Number of collapsed nested loops.
3857 /// \param NumClauses Number of clauses.
3859 explicit OMPTargetTeamsDistributeParallelForSimdDirective(
3860 unsigned CollapsedNum, unsigned NumClauses)
3862 this, OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
3863 OMPD_target_teams_distribute_parallel_for_simd, SourceLocation(),
3864 SourceLocation(), CollapsedNum, NumClauses) {}
3867 /// Creates directive with a list of \a Clauses.
3869 /// \param C AST context.
3870 /// \param StartLoc Starting location of the directive kind.
3871 /// \param EndLoc Ending Location of the directive.
3872 /// \param CollapsedNum Number of collapsed loops.
3873 /// \param Clauses List of clauses.
3874 /// \param AssociatedStmt Statement, associated with the directive.
3875 /// \param Exprs Helper expressions for CodeGen.
3877 static OMPTargetTeamsDistributeParallelForSimdDirective *
3878 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3879 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3880 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3882 /// Creates an empty directive with the place for \a NumClauses clauses.
3884 /// \param C AST context.
3885 /// \param CollapsedNum Number of collapsed nested loops.
3886 /// \param NumClauses Number of clauses.
3888 static OMPTargetTeamsDistributeParallelForSimdDirective *
3889 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3892 static bool classof(const Stmt *T) {
3893 return T->getStmtClass() ==
3894 OMPTargetTeamsDistributeParallelForSimdDirectiveClass;
3898 /// This represents '#pragma omp target teams distribute simd' combined
3902 /// #pragma omp target teams distribute simd private(x)
3904 /// In this example directive '#pragma omp target teams distribute simd'
3905 /// has clause 'private' with the variables 'x'
3907 class OMPTargetTeamsDistributeSimdDirective final : public OMPLoopDirective {
3908 friend class ASTStmtReader;
3910 /// Build directive with the given start and end location.
3912 /// \param StartLoc Starting location of the directive kind.
3913 /// \param EndLoc Ending location of the directive.
3914 /// \param CollapsedNum Number of collapsed nested loops.
3915 /// \param NumClauses Number of clauses.
3917 OMPTargetTeamsDistributeSimdDirective(SourceLocation StartLoc,
3918 SourceLocation EndLoc,
3919 unsigned CollapsedNum,
3920 unsigned NumClauses)
3921 : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
3922 OMPD_target_teams_distribute_simd, StartLoc, EndLoc,
3923 CollapsedNum, NumClauses) {}
3925 /// Build an empty directive.
3927 /// \param CollapsedNum Number of collapsed nested loops.
3928 /// \param NumClauses Number of clauses.
3930 explicit OMPTargetTeamsDistributeSimdDirective(unsigned CollapsedNum,
3931 unsigned NumClauses)
3932 : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
3933 OMPD_target_teams_distribute_simd, SourceLocation(),
3934 SourceLocation(), CollapsedNum, NumClauses) {}
3937 /// Creates directive with a list of \a Clauses.
3939 /// \param C AST context.
3940 /// \param StartLoc Starting location of the directive kind.
3941 /// \param EndLoc Ending Location of the directive.
3942 /// \param CollapsedNum Number of collapsed loops.
3943 /// \param Clauses List of clauses.
3944 /// \param AssociatedStmt Statement, associated with the directive.
3945 /// \param Exprs Helper expressions for CodeGen.
3947 static OMPTargetTeamsDistributeSimdDirective *
3948 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3949 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3950 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3952 /// Creates an empty directive with the place for \a NumClauses clauses.
3954 /// \param C AST context.
3955 /// \param CollapsedNum Number of collapsed nested loops.
3956 /// \param NumClauses Number of clauses.
3958 static OMPTargetTeamsDistributeSimdDirective *
3959 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3962 static bool classof(const Stmt *T) {
3963 return T->getStmtClass() == OMPTargetTeamsDistributeSimdDirectiveClass;
3967 } // end namespace clang