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 /// \brief This represents '#pragma omp taskgroup' directive.
1901 /// #pragma omp taskgroup
1904 class OMPTaskgroupDirective : public OMPExecutableDirective {
1905 friend class ASTStmtReader;
1906 /// \brief 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.
1911 OMPTaskgroupDirective(SourceLocation StartLoc, SourceLocation EndLoc)
1912 : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, OMPD_taskgroup,
1913 StartLoc, EndLoc, 0, 1) {}
1915 /// \brief Build an empty directive.
1917 explicit OMPTaskgroupDirective()
1918 : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, OMPD_taskgroup,
1919 SourceLocation(), SourceLocation(), 0, 1) {}
1922 /// \brief Creates directive.
1924 /// \param C AST context.
1925 /// \param StartLoc Starting location of the directive kind.
1926 /// \param EndLoc Ending Location of the directive.
1927 /// \param AssociatedStmt Statement, associated with the directive.
1929 static OMPTaskgroupDirective *Create(const ASTContext &C,
1930 SourceLocation StartLoc,
1931 SourceLocation EndLoc,
1932 Stmt *AssociatedStmt);
1934 /// \brief Creates an empty directive.
1936 /// \param C AST context.
1938 static OMPTaskgroupDirective *CreateEmpty(const ASTContext &C, EmptyShell);
1940 static bool classof(const Stmt *T) {
1941 return T->getStmtClass() == OMPTaskgroupDirectiveClass;
1945 /// \brief This represents '#pragma omp flush' directive.
1948 /// #pragma omp flush(a,b)
1950 /// In this example directive '#pragma omp flush' has 2 arguments- variables 'a'
1952 /// 'omp flush' directive does not have clauses but have an optional list of
1953 /// variables to flush. This list of variables is stored within some fake clause
1955 class OMPFlushDirective : public OMPExecutableDirective {
1956 friend class ASTStmtReader;
1957 /// \brief Build directive with the given start and end location.
1959 /// \param StartLoc Starting location of the directive kind.
1960 /// \param EndLoc Ending location of the directive.
1961 /// \param NumClauses Number of clauses.
1963 OMPFlushDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1964 unsigned NumClauses)
1965 : OMPExecutableDirective(this, OMPFlushDirectiveClass, OMPD_flush,
1966 StartLoc, EndLoc, NumClauses, 0) {}
1968 /// \brief Build an empty directive.
1970 /// \param NumClauses Number of clauses.
1972 explicit OMPFlushDirective(unsigned NumClauses)
1973 : OMPExecutableDirective(this, OMPFlushDirectiveClass, OMPD_flush,
1974 SourceLocation(), SourceLocation(), NumClauses,
1978 /// \brief Creates directive with a list of \a Clauses.
1980 /// \param C AST context.
1981 /// \param StartLoc Starting location of the directive kind.
1982 /// \param EndLoc Ending Location of the directive.
1983 /// \param Clauses List of clauses (only single OMPFlushClause clause is
1986 static OMPFlushDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1987 SourceLocation EndLoc,
1988 ArrayRef<OMPClause *> Clauses);
1990 /// \brief Creates an empty directive with the place for \a NumClauses
1993 /// \param C AST context.
1994 /// \param NumClauses Number of clauses.
1996 static OMPFlushDirective *CreateEmpty(const ASTContext &C,
1997 unsigned NumClauses, EmptyShell);
1999 static bool classof(const Stmt *T) {
2000 return T->getStmtClass() == OMPFlushDirectiveClass;
2004 /// \brief This represents '#pragma omp ordered' directive.
2007 /// #pragma omp ordered
2010 class OMPOrderedDirective : public OMPExecutableDirective {
2011 friend class ASTStmtReader;
2012 /// \brief Build directive with the given start and end location.
2014 /// \param StartLoc Starting location of the directive kind.
2015 /// \param EndLoc Ending location of the directive.
2016 /// \param NumClauses Number of clauses.
2018 OMPOrderedDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2019 unsigned NumClauses)
2020 : OMPExecutableDirective(this, OMPOrderedDirectiveClass, OMPD_ordered,
2021 StartLoc, EndLoc, NumClauses, 1) {}
2023 /// \brief Build an empty directive.
2025 /// \param NumClauses Number of clauses.
2027 explicit OMPOrderedDirective(unsigned NumClauses)
2028 : OMPExecutableDirective(this, OMPOrderedDirectiveClass, OMPD_ordered,
2029 SourceLocation(), SourceLocation(), NumClauses,
2033 /// \brief Creates directive.
2035 /// \param C AST context.
2036 /// \param StartLoc Starting location of the directive kind.
2037 /// \param EndLoc Ending Location of the directive.
2038 /// \param Clauses List of clauses.
2039 /// \param AssociatedStmt Statement, associated with the directive.
2041 static OMPOrderedDirective *
2042 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2043 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2045 /// \brief Creates an empty directive.
2047 /// \param C AST context.
2048 /// \param NumClauses Number of clauses.
2050 static OMPOrderedDirective *CreateEmpty(const ASTContext &C,
2051 unsigned NumClauses, EmptyShell);
2053 static bool classof(const Stmt *T) {
2054 return T->getStmtClass() == OMPOrderedDirectiveClass;
2058 /// \brief This represents '#pragma omp atomic' directive.
2061 /// #pragma omp atomic capture
2063 /// In this example directive '#pragma omp atomic' has clause 'capture'.
2065 class OMPAtomicDirective : public OMPExecutableDirective {
2066 friend class ASTStmtReader;
2067 /// \brief Used for 'atomic update' or 'atomic capture' constructs. They may
2068 /// have atomic expressions of forms
2070 /// x = x binop expr;
2071 /// x = expr binop x;
2073 /// This field is true for the first form of the expression and false for the
2074 /// second. Required for correct codegen of non-associative operations (like
2076 bool IsXLHSInRHSPart;
2077 /// \brief Used for 'atomic update' or 'atomic capture' constructs. They may
2078 /// have atomic expressions of forms
2080 /// v = x; <update x>;
2081 /// <update x>; v = x;
2083 /// This field is true for the first(postfix) form of the expression and false
2085 bool IsPostfixUpdate;
2087 /// \brief Build directive with the given start and end location.
2089 /// \param StartLoc Starting location of the directive kind.
2090 /// \param EndLoc Ending location of the directive.
2091 /// \param NumClauses Number of clauses.
2093 OMPAtomicDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2094 unsigned NumClauses)
2095 : OMPExecutableDirective(this, OMPAtomicDirectiveClass, OMPD_atomic,
2096 StartLoc, EndLoc, NumClauses, 5),
2097 IsXLHSInRHSPart(false), IsPostfixUpdate(false) {}
2099 /// \brief Build an empty directive.
2101 /// \param NumClauses Number of clauses.
2103 explicit OMPAtomicDirective(unsigned NumClauses)
2104 : OMPExecutableDirective(this, OMPAtomicDirectiveClass, OMPD_atomic,
2105 SourceLocation(), SourceLocation(), NumClauses,
2107 IsXLHSInRHSPart(false), IsPostfixUpdate(false) {}
2109 /// \brief Set 'x' part of the associated expression/statement.
2110 void setX(Expr *X) { *std::next(child_begin()) = X; }
2111 /// \brief Set helper expression of the form
2112 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2113 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2114 void setUpdateExpr(Expr *UE) { *std::next(child_begin(), 2) = UE; }
2115 /// \brief Set 'v' part of the associated expression/statement.
2116 void setV(Expr *V) { *std::next(child_begin(), 3) = V; }
2117 /// \brief Set 'expr' part of the associated expression/statement.
2118 void setExpr(Expr *E) { *std::next(child_begin(), 4) = E; }
2121 /// \brief Creates directive with a list of \a Clauses and 'x', 'v' and 'expr'
2122 /// parts of the atomic construct (see Section 2.12.6, atomic Construct, for
2123 /// detailed description of 'x', 'v' and 'expr').
2125 /// \param C AST context.
2126 /// \param StartLoc Starting location of the directive kind.
2127 /// \param EndLoc Ending Location of the directive.
2128 /// \param Clauses List of clauses.
2129 /// \param AssociatedStmt Statement, associated with the directive.
2130 /// \param X 'x' part of the associated expression/statement.
2131 /// \param V 'v' part of the associated expression/statement.
2132 /// \param E 'expr' part of the associated expression/statement.
2133 /// \param UE Helper expression of the form
2134 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2135 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2136 /// \param IsXLHSInRHSPart true if \a UE has the first form and false if the
2138 /// \param IsPostfixUpdate true if original value of 'x' must be stored in
2139 /// 'v', not an updated one.
2140 static OMPAtomicDirective *
2141 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2142 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
2143 Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate);
2145 /// \brief Creates an empty directive with the place for \a NumClauses
2148 /// \param C AST context.
2149 /// \param NumClauses Number of clauses.
2151 static OMPAtomicDirective *CreateEmpty(const ASTContext &C,
2152 unsigned NumClauses, EmptyShell);
2154 /// \brief Get 'x' part of the associated expression/statement.
2155 Expr *getX() { return cast_or_null<Expr>(*std::next(child_begin())); }
2156 const Expr *getX() const {
2157 return cast_or_null<Expr>(*std::next(child_begin()));
2159 /// \brief Get helper expression of the form
2160 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2161 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2162 Expr *getUpdateExpr() {
2163 return cast_or_null<Expr>(*std::next(child_begin(), 2));
2165 const Expr *getUpdateExpr() const {
2166 return cast_or_null<Expr>(*std::next(child_begin(), 2));
2168 /// \brief Return true if helper update expression has form
2169 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and false if it has form
2170 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2171 bool isXLHSInRHSPart() const { return IsXLHSInRHSPart; }
2172 /// \brief Return true if 'v' expression must be updated to original value of
2173 /// 'x', false if 'v' must be updated to the new value of 'x'.
2174 bool isPostfixUpdate() const { return IsPostfixUpdate; }
2175 /// \brief Get 'v' part of the associated expression/statement.
2176 Expr *getV() { return cast_or_null<Expr>(*std::next(child_begin(), 3)); }
2177 const Expr *getV() const {
2178 return cast_or_null<Expr>(*std::next(child_begin(), 3));
2180 /// \brief Get 'expr' part of the associated expression/statement.
2181 Expr *getExpr() { return cast_or_null<Expr>(*std::next(child_begin(), 4)); }
2182 const Expr *getExpr() const {
2183 return cast_or_null<Expr>(*std::next(child_begin(), 4));
2186 static bool classof(const Stmt *T) {
2187 return T->getStmtClass() == OMPAtomicDirectiveClass;
2191 /// \brief This represents '#pragma omp target' directive.
2194 /// #pragma omp target if(a)
2196 /// In this example directive '#pragma omp target' has clause 'if' with
2199 class OMPTargetDirective : public OMPExecutableDirective {
2200 friend class ASTStmtReader;
2201 /// \brief Build directive with the given start and end location.
2203 /// \param StartLoc Starting location of the directive kind.
2204 /// \param EndLoc Ending location of the directive.
2205 /// \param NumClauses Number of clauses.
2207 OMPTargetDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2208 unsigned NumClauses)
2209 : OMPExecutableDirective(this, OMPTargetDirectiveClass, OMPD_target,
2210 StartLoc, EndLoc, NumClauses, 1) {}
2212 /// \brief Build an empty directive.
2214 /// \param NumClauses Number of clauses.
2216 explicit OMPTargetDirective(unsigned NumClauses)
2217 : OMPExecutableDirective(this, OMPTargetDirectiveClass, OMPD_target,
2218 SourceLocation(), SourceLocation(), NumClauses,
2222 /// \brief Creates directive with a list of \a Clauses.
2224 /// \param C AST context.
2225 /// \param StartLoc Starting location of the directive kind.
2226 /// \param EndLoc Ending Location of the directive.
2227 /// \param Clauses List of clauses.
2228 /// \param AssociatedStmt Statement, associated with the directive.
2230 static OMPTargetDirective *
2231 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2232 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2234 /// \brief Creates an empty directive with the place for \a NumClauses
2237 /// \param C AST context.
2238 /// \param NumClauses Number of clauses.
2240 static OMPTargetDirective *CreateEmpty(const ASTContext &C,
2241 unsigned NumClauses, EmptyShell);
2243 static bool classof(const Stmt *T) {
2244 return T->getStmtClass() == OMPTargetDirectiveClass;
2248 /// \brief This represents '#pragma omp target data' directive.
2251 /// #pragma omp target data device(0) if(a) map(b[:])
2253 /// In this example directive '#pragma omp target data' has clauses 'device'
2254 /// with the value '0', 'if' with condition 'a' and 'map' with array
2257 class OMPTargetDataDirective : public OMPExecutableDirective {
2258 friend class ASTStmtReader;
2259 /// \brief Build directive with the given start and end location.
2261 /// \param StartLoc Starting location of the directive kind.
2262 /// \param EndLoc Ending Location of the directive.
2263 /// \param NumClauses The number of clauses.
2265 OMPTargetDataDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2266 unsigned NumClauses)
2267 : OMPExecutableDirective(this, OMPTargetDataDirectiveClass,
2268 OMPD_target_data, StartLoc, EndLoc, NumClauses,
2271 /// \brief Build an empty directive.
2273 /// \param NumClauses Number of clauses.
2275 explicit OMPTargetDataDirective(unsigned NumClauses)
2276 : OMPExecutableDirective(this, OMPTargetDataDirectiveClass,
2277 OMPD_target_data, SourceLocation(),
2278 SourceLocation(), NumClauses, 1) {}
2281 /// \brief Creates directive with a list of \a Clauses.
2283 /// \param C AST context.
2284 /// \param StartLoc Starting location of the directive kind.
2285 /// \param EndLoc Ending Location of the directive.
2286 /// \param Clauses List of clauses.
2287 /// \param AssociatedStmt Statement, associated with the directive.
2289 static OMPTargetDataDirective *
2290 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2291 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2293 /// \brief Creates an empty directive with the place for \a N clauses.
2295 /// \param C AST context.
2296 /// \param N The number of clauses.
2298 static OMPTargetDataDirective *CreateEmpty(const ASTContext &C, unsigned N,
2301 static bool classof(const Stmt *T) {
2302 return T->getStmtClass() == OMPTargetDataDirectiveClass;
2306 /// \brief This represents '#pragma omp target enter data' directive.
2309 /// #pragma omp target enter data device(0) if(a) map(b[:])
2311 /// In this example directive '#pragma omp target enter data' has clauses
2312 /// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
2315 class OMPTargetEnterDataDirective : public OMPExecutableDirective {
2316 friend class ASTStmtReader;
2317 /// \brief Build directive with the given start and end location.
2319 /// \param StartLoc Starting location of the directive kind.
2320 /// \param EndLoc Ending Location of the directive.
2321 /// \param NumClauses The number of clauses.
2323 OMPTargetEnterDataDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2324 unsigned NumClauses)
2325 : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
2326 OMPD_target_enter_data, StartLoc, EndLoc,
2327 NumClauses, /*NumChildren=*/0) {}
2329 /// \brief Build an empty directive.
2331 /// \param NumClauses Number of clauses.
2333 explicit OMPTargetEnterDataDirective(unsigned NumClauses)
2334 : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
2335 OMPD_target_enter_data, SourceLocation(),
2336 SourceLocation(), NumClauses,
2337 /*NumChildren=*/0) {}
2340 /// \brief Creates directive with a list of \a Clauses.
2342 /// \param C AST context.
2343 /// \param StartLoc Starting location of the directive kind.
2344 /// \param EndLoc Ending Location of the directive.
2345 /// \param Clauses List of clauses.
2347 static OMPTargetEnterDataDirective *Create(const ASTContext &C,
2348 SourceLocation StartLoc,
2349 SourceLocation EndLoc,
2350 ArrayRef<OMPClause *> Clauses);
2352 /// \brief Creates an empty directive with the place for \a N clauses.
2354 /// \param C AST context.
2355 /// \param N The number of clauses.
2357 static OMPTargetEnterDataDirective *CreateEmpty(const ASTContext &C,
2358 unsigned N, EmptyShell);
2360 static bool classof(const Stmt *T) {
2361 return T->getStmtClass() == OMPTargetEnterDataDirectiveClass;
2365 /// \brief This represents '#pragma omp target exit data' directive.
2368 /// #pragma omp target exit data device(0) if(a) map(b[:])
2370 /// In this example directive '#pragma omp target exit data' has clauses
2371 /// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
2374 class OMPTargetExitDataDirective : public OMPExecutableDirective {
2375 friend class ASTStmtReader;
2376 /// \brief Build directive with the given start and end location.
2378 /// \param StartLoc Starting location of the directive kind.
2379 /// \param EndLoc Ending Location of the directive.
2380 /// \param NumClauses The number of clauses.
2382 OMPTargetExitDataDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2383 unsigned NumClauses)
2384 : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
2385 OMPD_target_exit_data, StartLoc, EndLoc,
2386 NumClauses, /*NumChildren=*/0) {}
2388 /// \brief Build an empty directive.
2390 /// \param NumClauses Number of clauses.
2392 explicit OMPTargetExitDataDirective(unsigned NumClauses)
2393 : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
2394 OMPD_target_exit_data, SourceLocation(),
2395 SourceLocation(), NumClauses,
2396 /*NumChildren=*/0) {}
2399 /// \brief Creates directive with a list of \a Clauses.
2401 /// \param C AST context.
2402 /// \param StartLoc Starting location of the directive kind.
2403 /// \param EndLoc Ending Location of the directive.
2404 /// \param Clauses List of clauses.
2406 static OMPTargetExitDataDirective *Create(const ASTContext &C,
2407 SourceLocation StartLoc,
2408 SourceLocation EndLoc,
2409 ArrayRef<OMPClause *> Clauses);
2411 /// \brief Creates an empty directive with the place for \a N clauses.
2413 /// \param C AST context.
2414 /// \param N The number of clauses.
2416 static OMPTargetExitDataDirective *CreateEmpty(const ASTContext &C,
2417 unsigned N, EmptyShell);
2419 static bool classof(const Stmt *T) {
2420 return T->getStmtClass() == OMPTargetExitDataDirectiveClass;
2424 /// \brief This represents '#pragma omp target parallel' directive.
2427 /// #pragma omp target parallel if(a)
2429 /// In this example directive '#pragma omp target parallel' has clause 'if' with
2432 class OMPTargetParallelDirective : public OMPExecutableDirective {
2433 friend class ASTStmtReader;
2434 /// \brief Build directive with the given start and end location.
2436 /// \param StartLoc Starting location of the directive kind.
2437 /// \param EndLoc Ending location of the directive.
2438 /// \param NumClauses Number of clauses.
2440 OMPTargetParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2441 unsigned NumClauses)
2442 : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass,
2443 OMPD_target_parallel, StartLoc, EndLoc,
2444 NumClauses, /*NumChildren=*/1) {}
2446 /// \brief Build an empty directive.
2448 /// \param NumClauses Number of clauses.
2450 explicit OMPTargetParallelDirective(unsigned NumClauses)
2451 : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass,
2452 OMPD_target_parallel, SourceLocation(),
2453 SourceLocation(), NumClauses,
2454 /*NumChildren=*/1) {}
2457 /// \brief Creates directive with a list of \a Clauses.
2459 /// \param C AST context.
2460 /// \param StartLoc Starting location of the directive kind.
2461 /// \param EndLoc Ending Location of the directive.
2462 /// \param Clauses List of clauses.
2463 /// \param AssociatedStmt Statement, associated with the directive.
2465 static OMPTargetParallelDirective *
2466 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2467 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2469 /// \brief Creates an empty directive with the place for \a NumClauses
2472 /// \param C AST context.
2473 /// \param NumClauses Number of clauses.
2475 static OMPTargetParallelDirective *
2476 CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
2478 static bool classof(const Stmt *T) {
2479 return T->getStmtClass() == OMPTargetParallelDirectiveClass;
2483 /// \brief This represents '#pragma omp target parallel for' directive.
2486 /// #pragma omp target parallel for private(a,b) reduction(+:c,d)
2488 /// In this example directive '#pragma omp target parallel for' has clauses
2489 /// 'private' with the variables 'a' and 'b' and 'reduction' with operator '+'
2490 /// and variables 'c' and 'd'.
2492 class OMPTargetParallelForDirective : public OMPLoopDirective {
2493 friend class ASTStmtReader;
2495 /// \brief true if current region has inner cancel directive.
2498 /// \brief Build directive with the given start and end location.
2500 /// \param StartLoc Starting location of the directive kind.
2501 /// \param EndLoc Ending location of the directive.
2502 /// \param CollapsedNum Number of collapsed nested loops.
2503 /// \param NumClauses Number of clauses.
2505 OMPTargetParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2506 unsigned CollapsedNum, unsigned NumClauses)
2507 : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass,
2508 OMPD_target_parallel_for, StartLoc, EndLoc,
2509 CollapsedNum, NumClauses),
2512 /// \brief Build an empty directive.
2514 /// \param CollapsedNum Number of collapsed nested loops.
2515 /// \param NumClauses Number of clauses.
2517 explicit OMPTargetParallelForDirective(unsigned CollapsedNum,
2518 unsigned NumClauses)
2519 : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass,
2520 OMPD_target_parallel_for, SourceLocation(),
2521 SourceLocation(), CollapsedNum, NumClauses),
2524 /// \brief Set cancel state.
2525 void setHasCancel(bool Has) { HasCancel = Has; }
2528 /// \brief Creates directive with a list of \a Clauses.
2530 /// \param C AST context.
2531 /// \param StartLoc Starting location of the directive kind.
2532 /// \param EndLoc Ending Location of the directive.
2533 /// \param CollapsedNum Number of collapsed loops.
2534 /// \param Clauses List of clauses.
2535 /// \param AssociatedStmt Statement, associated with the directive.
2536 /// \param Exprs Helper expressions for CodeGen.
2537 /// \param HasCancel true if current directive has inner cancel directive.
2539 static OMPTargetParallelForDirective *
2540 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2541 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2542 Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
2544 /// \brief Creates an empty directive with the place
2545 /// for \a NumClauses clauses.
2547 /// \param C AST context.
2548 /// \param CollapsedNum Number of collapsed nested loops.
2549 /// \param NumClauses Number of clauses.
2551 static OMPTargetParallelForDirective *CreateEmpty(const ASTContext &C,
2552 unsigned NumClauses,
2553 unsigned CollapsedNum,
2556 /// \brief Return true if current directive has inner cancel directive.
2557 bool hasCancel() const { return HasCancel; }
2559 static bool classof(const Stmt *T) {
2560 return T->getStmtClass() == OMPTargetParallelForDirectiveClass;
2564 /// \brief This represents '#pragma omp teams' directive.
2567 /// #pragma omp teams if(a)
2569 /// In this example directive '#pragma omp teams' has clause 'if' with
2572 class OMPTeamsDirective : public OMPExecutableDirective {
2573 friend class ASTStmtReader;
2574 /// \brief Build directive with the given start and end location.
2576 /// \param StartLoc Starting location of the directive kind.
2577 /// \param EndLoc Ending location of the directive.
2578 /// \param NumClauses Number of clauses.
2580 OMPTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2581 unsigned NumClauses)
2582 : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
2583 StartLoc, EndLoc, NumClauses, 1) {}
2585 /// \brief Build an empty directive.
2587 /// \param NumClauses Number of clauses.
2589 explicit OMPTeamsDirective(unsigned NumClauses)
2590 : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
2591 SourceLocation(), SourceLocation(), NumClauses,
2595 /// \brief Creates directive with a list of \a Clauses.
2597 /// \param C AST context.
2598 /// \param StartLoc Starting location of the directive kind.
2599 /// \param EndLoc Ending Location of the directive.
2600 /// \param Clauses List of clauses.
2601 /// \param AssociatedStmt Statement, associated with the directive.
2603 static OMPTeamsDirective *Create(const ASTContext &C, SourceLocation StartLoc,
2604 SourceLocation EndLoc,
2605 ArrayRef<OMPClause *> Clauses,
2606 Stmt *AssociatedStmt);
2608 /// \brief Creates an empty directive with the place for \a NumClauses
2611 /// \param C AST context.
2612 /// \param NumClauses Number of clauses.
2614 static OMPTeamsDirective *CreateEmpty(const ASTContext &C,
2615 unsigned NumClauses, EmptyShell);
2617 static bool classof(const Stmt *T) {
2618 return T->getStmtClass() == OMPTeamsDirectiveClass;
2622 /// \brief This represents '#pragma omp cancellation point' directive.
2625 /// #pragma omp cancellation point for
2628 /// In this example a cancellation point is created for innermost 'for' region.
2629 class OMPCancellationPointDirective : public OMPExecutableDirective {
2630 friend class ASTStmtReader;
2631 OpenMPDirectiveKind CancelRegion;
2632 /// \brief Build directive with the given start and end location.
2634 /// \param StartLoc Starting location of the directive kind.
2635 /// \param EndLoc Ending location of the directive.
2637 OMPCancellationPointDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2638 : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass,
2639 OMPD_cancellation_point, StartLoc, EndLoc, 0, 0),
2640 CancelRegion(OMPD_unknown) {}
2642 /// \brief Build an empty directive.
2644 explicit OMPCancellationPointDirective()
2645 : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass,
2646 OMPD_cancellation_point, SourceLocation(),
2647 SourceLocation(), 0, 0),
2648 CancelRegion(OMPD_unknown) {}
2650 /// \brief Set cancel region for current cancellation point.
2651 /// \param CR Cancellation region.
2652 void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; }
2655 /// \brief Creates directive.
2657 /// \param C AST context.
2658 /// \param StartLoc Starting location of the directive kind.
2659 /// \param EndLoc Ending Location of the directive.
2661 static OMPCancellationPointDirective *
2662 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2663 OpenMPDirectiveKind CancelRegion);
2665 /// \brief Creates an empty directive.
2667 /// \param C AST context.
2669 static OMPCancellationPointDirective *CreateEmpty(const ASTContext &C,
2672 /// \brief Get cancellation region for the current cancellation point.
2673 OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; }
2675 static bool classof(const Stmt *T) {
2676 return T->getStmtClass() == OMPCancellationPointDirectiveClass;
2680 /// \brief This represents '#pragma omp cancel' directive.
2683 /// #pragma omp cancel for
2686 /// In this example a cancel is created for innermost 'for' region.
2687 class OMPCancelDirective : public OMPExecutableDirective {
2688 friend class ASTStmtReader;
2689 OpenMPDirectiveKind CancelRegion;
2690 /// \brief Build directive with the given start and end location.
2692 /// \param StartLoc Starting location of the directive kind.
2693 /// \param EndLoc Ending location of the directive.
2694 /// \param NumClauses Number of clauses.
2696 OMPCancelDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2697 unsigned NumClauses)
2698 : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
2699 StartLoc, EndLoc, NumClauses, 0),
2700 CancelRegion(OMPD_unknown) {}
2702 /// \brief Build an empty directive.
2704 /// \param NumClauses Number of clauses.
2705 explicit OMPCancelDirective(unsigned NumClauses)
2706 : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
2707 SourceLocation(), SourceLocation(), NumClauses,
2709 CancelRegion(OMPD_unknown) {}
2711 /// \brief Set cancel region for current cancellation point.
2712 /// \param CR Cancellation region.
2713 void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; }
2716 /// \brief Creates directive.
2718 /// \param C AST context.
2719 /// \param StartLoc Starting location of the directive kind.
2720 /// \param EndLoc Ending Location of the directive.
2721 /// \param Clauses List of clauses.
2723 static OMPCancelDirective *
2724 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2725 ArrayRef<OMPClause *> Clauses, OpenMPDirectiveKind CancelRegion);
2727 /// \brief Creates an empty directive.
2729 /// \param C AST context.
2730 /// \param NumClauses Number of clauses.
2732 static OMPCancelDirective *CreateEmpty(const ASTContext &C,
2733 unsigned NumClauses, EmptyShell);
2735 /// \brief Get cancellation region for the current cancellation point.
2736 OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; }
2738 static bool classof(const Stmt *T) {
2739 return T->getStmtClass() == OMPCancelDirectiveClass;
2743 /// \brief This represents '#pragma omp taskloop' directive.
2746 /// #pragma omp taskloop private(a,b) grainsize(val) num_tasks(num)
2748 /// In this example directive '#pragma omp taskloop' has clauses 'private'
2749 /// with the variables 'a' and 'b', 'grainsize' with expression 'val' and
2750 /// 'num_tasks' with expression 'num'.
2752 class OMPTaskLoopDirective : public OMPLoopDirective {
2753 friend class ASTStmtReader;
2754 /// \brief Build directive with the given start and end location.
2756 /// \param StartLoc Starting location of the directive kind.
2757 /// \param EndLoc Ending location of the directive.
2758 /// \param CollapsedNum Number of collapsed nested loops.
2759 /// \param NumClauses Number of clauses.
2761 OMPTaskLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2762 unsigned CollapsedNum, unsigned NumClauses)
2763 : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, OMPD_taskloop,
2764 StartLoc, EndLoc, CollapsedNum, NumClauses) {}
2766 /// \brief Build an empty directive.
2768 /// \param CollapsedNum Number of collapsed nested loops.
2769 /// \param NumClauses Number of clauses.
2771 explicit OMPTaskLoopDirective(unsigned CollapsedNum, unsigned NumClauses)
2772 : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, OMPD_taskloop,
2773 SourceLocation(), SourceLocation(), CollapsedNum,
2777 /// \brief Creates directive with a list of \a Clauses.
2779 /// \param C AST context.
2780 /// \param StartLoc Starting location of the directive kind.
2781 /// \param EndLoc Ending Location of the directive.
2782 /// \param CollapsedNum Number of collapsed loops.
2783 /// \param Clauses List of clauses.
2784 /// \param AssociatedStmt Statement, associated with the directive.
2785 /// \param Exprs Helper expressions for CodeGen.
2787 static OMPTaskLoopDirective *
2788 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2789 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2790 Stmt *AssociatedStmt, const HelperExprs &Exprs);
2792 /// \brief Creates an empty directive with the place
2793 /// for \a NumClauses clauses.
2795 /// \param C AST context.
2796 /// \param CollapsedNum Number of collapsed nested loops.
2797 /// \param NumClauses Number of clauses.
2799 static OMPTaskLoopDirective *CreateEmpty(const ASTContext &C,
2800 unsigned NumClauses,
2801 unsigned CollapsedNum, EmptyShell);
2803 static bool classof(const Stmt *T) {
2804 return T->getStmtClass() == OMPTaskLoopDirectiveClass;
2808 /// \brief This represents '#pragma omp taskloop simd' directive.
2811 /// #pragma omp taskloop simd private(a,b) grainsize(val) num_tasks(num)
2813 /// In this example directive '#pragma omp taskloop simd' has clauses 'private'
2814 /// with the variables 'a' and 'b', 'grainsize' with expression 'val' and
2815 /// 'num_tasks' with expression 'num'.
2817 class OMPTaskLoopSimdDirective : public OMPLoopDirective {
2818 friend class ASTStmtReader;
2819 /// \brief Build directive with the given start and end location.
2821 /// \param StartLoc Starting location of the directive kind.
2822 /// \param EndLoc Ending location of the directive.
2823 /// \param CollapsedNum Number of collapsed nested loops.
2824 /// \param NumClauses Number of clauses.
2826 OMPTaskLoopSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2827 unsigned CollapsedNum, unsigned NumClauses)
2828 : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass,
2829 OMPD_taskloop_simd, StartLoc, EndLoc, CollapsedNum,
2832 /// \brief Build an empty directive.
2834 /// \param CollapsedNum Number of collapsed nested loops.
2835 /// \param NumClauses Number of clauses.
2837 explicit OMPTaskLoopSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
2838 : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass,
2839 OMPD_taskloop_simd, SourceLocation(), SourceLocation(),
2840 CollapsedNum, NumClauses) {}
2843 /// \brief Creates directive with a list of \a Clauses.
2845 /// \param C AST context.
2846 /// \param StartLoc Starting location of the directive kind.
2847 /// \param EndLoc Ending Location of the directive.
2848 /// \param CollapsedNum Number of collapsed loops.
2849 /// \param Clauses List of clauses.
2850 /// \param AssociatedStmt Statement, associated with the directive.
2851 /// \param Exprs Helper expressions for CodeGen.
2853 static OMPTaskLoopSimdDirective *
2854 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2855 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2856 Stmt *AssociatedStmt, const HelperExprs &Exprs);
2858 /// \brief Creates an empty directive with the place
2859 /// for \a NumClauses clauses.
2861 /// \param C AST context.
2862 /// \param CollapsedNum Number of collapsed nested loops.
2863 /// \param NumClauses Number of clauses.
2865 static OMPTaskLoopSimdDirective *CreateEmpty(const ASTContext &C,
2866 unsigned NumClauses,
2867 unsigned CollapsedNum,
2870 static bool classof(const Stmt *T) {
2871 return T->getStmtClass() == OMPTaskLoopSimdDirectiveClass;
2875 /// \brief This represents '#pragma omp distribute' directive.
2878 /// #pragma omp distribute private(a,b)
2880 /// In this example directive '#pragma omp distribute' has clauses 'private'
2881 /// with the variables 'a' and 'b'
2883 class OMPDistributeDirective : public OMPLoopDirective {
2884 friend class ASTStmtReader;
2886 /// \brief Build directive with the given start and end location.
2888 /// \param StartLoc Starting location of the directive kind.
2889 /// \param EndLoc Ending location of the directive.
2890 /// \param CollapsedNum Number of collapsed nested loops.
2891 /// \param NumClauses Number of clauses.
2893 OMPDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2894 unsigned CollapsedNum, unsigned NumClauses)
2895 : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,
2896 StartLoc, EndLoc, CollapsedNum, NumClauses)
2899 /// \brief Build an empty directive.
2901 /// \param CollapsedNum Number of collapsed nested loops.
2902 /// \param NumClauses Number of clauses.
2904 explicit OMPDistributeDirective(unsigned CollapsedNum, unsigned NumClauses)
2905 : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,
2906 SourceLocation(), SourceLocation(), CollapsedNum,
2911 /// \brief Creates directive with a list of \a Clauses.
2913 /// \param C AST context.
2914 /// \param StartLoc Starting location of the directive kind.
2915 /// \param EndLoc Ending Location of the directive.
2916 /// \param CollapsedNum Number of collapsed loops.
2917 /// \param Clauses List of clauses.
2918 /// \param AssociatedStmt Statement, associated with the directive.
2919 /// \param Exprs Helper expressions for CodeGen.
2921 static OMPDistributeDirective *
2922 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2923 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2924 Stmt *AssociatedStmt, const HelperExprs &Exprs);
2926 /// \brief Creates an empty directive with the place
2927 /// for \a NumClauses clauses.
2929 /// \param C AST context.
2930 /// \param CollapsedNum Number of collapsed nested loops.
2931 /// \param NumClauses Number of clauses.
2933 static OMPDistributeDirective *CreateEmpty(const ASTContext &C,
2934 unsigned NumClauses,
2935 unsigned CollapsedNum, EmptyShell);
2937 static bool classof(const Stmt *T) {
2938 return T->getStmtClass() == OMPDistributeDirectiveClass;
2942 /// \brief This represents '#pragma omp target update' directive.
2945 /// #pragma omp target update to(a) from(b) device(1)
2947 /// In this example directive '#pragma omp target update' has clause 'to' with
2948 /// argument 'a', clause 'from' with argument 'b' and clause 'device' with
2951 class OMPTargetUpdateDirective : public OMPExecutableDirective {
2952 friend class ASTStmtReader;
2953 /// \brief Build directive with the given start and end location.
2955 /// \param StartLoc Starting location of the directive kind.
2956 /// \param EndLoc Ending Location of the directive.
2957 /// \param NumClauses The number of clauses.
2959 OMPTargetUpdateDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2960 unsigned NumClauses)
2961 : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass,
2962 OMPD_target_update, StartLoc, EndLoc, NumClauses,
2965 /// \brief Build an empty directive.
2967 /// \param NumClauses Number of clauses.
2969 explicit OMPTargetUpdateDirective(unsigned NumClauses)
2970 : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass,
2971 OMPD_target_update, SourceLocation(),
2972 SourceLocation(), NumClauses, 0) {}
2975 /// \brief Creates directive with a list of \a Clauses.
2977 /// \param C AST context.
2978 /// \param StartLoc Starting location of the directive kind.
2979 /// \param EndLoc Ending Location of the directive.
2980 /// \param Clauses List of clauses.
2982 static OMPTargetUpdateDirective *Create(const ASTContext &C,
2983 SourceLocation StartLoc,
2984 SourceLocation EndLoc,
2985 ArrayRef<OMPClause *> Clauses);
2987 /// \brief Creates an empty directive with the place for \a NumClauses
2990 /// \param C AST context.
2991 /// \param NumClauses The number of clauses.
2993 static OMPTargetUpdateDirective *CreateEmpty(const ASTContext &C,
2994 unsigned NumClauses, EmptyShell);
2996 static bool classof(const Stmt *T) {
2997 return T->getStmtClass() == OMPTargetUpdateDirectiveClass;
3001 /// \brief This represents '#pragma omp distribute parallel for' composite
3005 /// #pragma omp distribute parallel for private(a,b)
3007 /// In this example directive '#pragma omp distribute parallel for' has clause
3008 /// 'private' with the variables 'a' and 'b'
3010 class OMPDistributeParallelForDirective : public OMPLoopDirective {
3011 friend class ASTStmtReader;
3013 /// \brief Build directive with the given start and end location.
3015 /// \param StartLoc Starting location of the directive kind.
3016 /// \param EndLoc Ending location of the directive.
3017 /// \param CollapsedNum Number of collapsed nested loops.
3018 /// \param NumClauses Number of clauses.
3020 OMPDistributeParallelForDirective(SourceLocation StartLoc,
3021 SourceLocation EndLoc,
3022 unsigned CollapsedNum, unsigned NumClauses)
3023 : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
3024 OMPD_distribute_parallel_for, StartLoc, EndLoc,
3025 CollapsedNum, NumClauses) {}
3027 /// \brief Build an empty directive.
3029 /// \param CollapsedNum Number of collapsed nested loops.
3030 /// \param NumClauses Number of clauses.
3032 explicit OMPDistributeParallelForDirective(unsigned CollapsedNum,
3033 unsigned NumClauses)
3034 : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
3035 OMPD_distribute_parallel_for, SourceLocation(),
3036 SourceLocation(), CollapsedNum, NumClauses) {}
3039 /// \brief Creates directive with a list of \a Clauses.
3041 /// \param C AST context.
3042 /// \param StartLoc Starting location of the directive kind.
3043 /// \param EndLoc Ending Location of the directive.
3044 /// \param CollapsedNum Number of collapsed loops.
3045 /// \param Clauses List of clauses.
3046 /// \param AssociatedStmt Statement, associated with the directive.
3047 /// \param Exprs Helper expressions for CodeGen.
3049 static OMPDistributeParallelForDirective *
3050 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3051 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3052 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3054 /// \brief Creates an empty directive with the place
3055 /// for \a NumClauses clauses.
3057 /// \param C AST context.
3058 /// \param CollapsedNum Number of collapsed nested loops.
3059 /// \param NumClauses Number of clauses.
3061 static OMPDistributeParallelForDirective *CreateEmpty(const ASTContext &C,
3062 unsigned NumClauses,
3063 unsigned CollapsedNum,
3066 static bool classof(const Stmt *T) {
3067 return T->getStmtClass() == OMPDistributeParallelForDirectiveClass;
3071 /// This represents '#pragma omp distribute parallel for simd' composite
3075 /// #pragma omp distribute parallel for simd private(x)
3077 /// In this example directive '#pragma omp distribute parallel for simd' has
3078 /// clause 'private' with the variables 'x'
3080 class OMPDistributeParallelForSimdDirective final : public OMPLoopDirective {
3081 friend class ASTStmtReader;
3083 /// Build directive with the given start and end location.
3085 /// \param StartLoc Starting location of the directive kind.
3086 /// \param EndLoc Ending location of the directive.
3087 /// \param CollapsedNum Number of collapsed nested loops.
3088 /// \param NumClauses Number of clauses.
3090 OMPDistributeParallelForSimdDirective(SourceLocation StartLoc,
3091 SourceLocation EndLoc,
3092 unsigned CollapsedNum,
3093 unsigned NumClauses)
3094 : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass,
3095 OMPD_distribute_parallel_for_simd, StartLoc,
3096 EndLoc, CollapsedNum, NumClauses) {}
3098 /// Build an empty directive.
3100 /// \param CollapsedNum Number of collapsed nested loops.
3101 /// \param NumClauses Number of clauses.
3103 explicit OMPDistributeParallelForSimdDirective(unsigned CollapsedNum,
3104 unsigned NumClauses)
3105 : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass,
3106 OMPD_distribute_parallel_for_simd,
3107 SourceLocation(), SourceLocation(), CollapsedNum,
3111 /// Creates directive with a list of \a Clauses.
3113 /// \param C AST context.
3114 /// \param StartLoc Starting location of the directive kind.
3115 /// \param EndLoc Ending Location of the directive.
3116 /// \param CollapsedNum Number of collapsed loops.
3117 /// \param Clauses List of clauses.
3118 /// \param AssociatedStmt Statement, associated with the directive.
3119 /// \param Exprs Helper expressions for CodeGen.
3121 static OMPDistributeParallelForSimdDirective *Create(
3122 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3123 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3124 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3126 /// Creates an empty directive with the place for \a NumClauses clauses.
3128 /// \param C AST context.
3129 /// \param CollapsedNum Number of collapsed nested loops.
3130 /// \param NumClauses Number of clauses.
3132 static OMPDistributeParallelForSimdDirective *CreateEmpty(
3133 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3136 static bool classof(const Stmt *T) {
3137 return T->getStmtClass() == OMPDistributeParallelForSimdDirectiveClass;
3141 /// This represents '#pragma omp distribute simd' composite directive.
3144 /// #pragma omp distribute simd private(x)
3146 /// In this example directive '#pragma omp distribute simd' has clause
3147 /// 'private' with the variables 'x'
3149 class OMPDistributeSimdDirective final : public OMPLoopDirective {
3150 friend class ASTStmtReader;
3152 /// Build directive with the given start and end location.
3154 /// \param StartLoc Starting location of the directive kind.
3155 /// \param EndLoc Ending location of the directive.
3156 /// \param CollapsedNum Number of collapsed nested loops.
3157 /// \param NumClauses Number of clauses.
3159 OMPDistributeSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3160 unsigned CollapsedNum, unsigned NumClauses)
3161 : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass,
3162 OMPD_distribute_simd, StartLoc, EndLoc, CollapsedNum,
3165 /// Build an empty directive.
3167 /// \param CollapsedNum Number of collapsed nested loops.
3168 /// \param NumClauses Number of clauses.
3170 explicit OMPDistributeSimdDirective(unsigned CollapsedNum,
3171 unsigned NumClauses)
3172 : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass,
3173 OMPD_distribute_simd, SourceLocation(),
3174 SourceLocation(), CollapsedNum, NumClauses) {}
3177 /// Creates directive with a list of \a Clauses.
3179 /// \param C AST context.
3180 /// \param StartLoc Starting location of the directive kind.
3181 /// \param EndLoc Ending Location of the directive.
3182 /// \param CollapsedNum Number of collapsed loops.
3183 /// \param Clauses List of clauses.
3184 /// \param AssociatedStmt Statement, associated with the directive.
3185 /// \param Exprs Helper expressions for CodeGen.
3187 static OMPDistributeSimdDirective *
3188 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3189 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3190 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3192 /// Creates an empty directive with the place for \a NumClauses clauses.
3194 /// \param C AST context.
3195 /// \param CollapsedNum Number of collapsed nested loops.
3196 /// \param NumClauses Number of clauses.
3198 static OMPDistributeSimdDirective *CreateEmpty(const ASTContext &C,
3199 unsigned NumClauses,
3200 unsigned CollapsedNum,
3203 static bool classof(const Stmt *T) {
3204 return T->getStmtClass() == OMPDistributeSimdDirectiveClass;
3208 /// This represents '#pragma omp target parallel for simd' directive.
3211 /// #pragma omp target parallel for simd private(a) map(b) safelen(c)
3213 /// In this example directive '#pragma omp target parallel for simd' has clauses
3214 /// 'private' with the variable 'a', 'map' with the variable 'b' and 'safelen'
3215 /// with the variable 'c'.
3217 class OMPTargetParallelForSimdDirective final : public OMPLoopDirective {
3218 friend class ASTStmtReader;
3220 /// Build directive with the given start and end location.
3222 /// \param StartLoc Starting location of the directive kind.
3223 /// \param EndLoc Ending location of the directive.
3224 /// \param CollapsedNum Number of collapsed nested loops.
3225 /// \param NumClauses Number of clauses.
3227 OMPTargetParallelForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3228 unsigned CollapsedNum, unsigned NumClauses)
3229 : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass,
3230 OMPD_target_parallel_for_simd, StartLoc, EndLoc,
3231 CollapsedNum, NumClauses) {}
3233 /// Build an empty directive.
3235 /// \param CollapsedNum Number of collapsed nested loops.
3236 /// \param NumClauses Number of clauses.
3238 explicit OMPTargetParallelForSimdDirective(unsigned CollapsedNum,
3239 unsigned NumClauses)
3240 : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass,
3241 OMPD_target_parallel_for_simd, SourceLocation(),
3242 SourceLocation(), CollapsedNum, NumClauses) {}
3245 /// Creates directive with a list of \a Clauses.
3247 /// \param C AST context.
3248 /// \param StartLoc Starting location of the directive kind.
3249 /// \param EndLoc Ending Location of the directive.
3250 /// \param CollapsedNum Number of collapsed loops.
3251 /// \param Clauses List of clauses.
3252 /// \param AssociatedStmt Statement, associated with the directive.
3253 /// \param Exprs Helper expressions for CodeGen.
3255 static OMPTargetParallelForSimdDirective *
3256 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3257 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3258 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3260 /// Creates an empty directive with the place for \a NumClauses clauses.
3262 /// \param C AST context.
3263 /// \param CollapsedNum Number of collapsed nested loops.
3264 /// \param NumClauses Number of clauses.
3266 static OMPTargetParallelForSimdDirective *CreateEmpty(const ASTContext &C,
3267 unsigned NumClauses,
3268 unsigned CollapsedNum,
3271 static bool classof(const Stmt *T) {
3272 return T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass;
3276 /// This represents '#pragma omp target simd' directive.
3279 /// #pragma omp target simd private(a) map(b) safelen(c)
3281 /// In this example directive '#pragma omp target simd' has clauses 'private'
3282 /// with the variable 'a', 'map' with the variable 'b' and 'safelen' with
3283 /// the variable 'c'.
3285 class OMPTargetSimdDirective final : public OMPLoopDirective {
3286 friend class ASTStmtReader;
3288 /// Build directive with the given start and end location.
3290 /// \param StartLoc Starting location of the directive kind.
3291 /// \param EndLoc Ending location of the directive.
3292 /// \param CollapsedNum Number of collapsed nested loops.
3293 /// \param NumClauses Number of clauses.
3295 OMPTargetSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3296 unsigned CollapsedNum, unsigned NumClauses)
3297 : OMPLoopDirective(this, OMPTargetSimdDirectiveClass,
3298 OMPD_target_simd, StartLoc, EndLoc, CollapsedNum,
3301 /// Build an empty directive.
3303 /// \param CollapsedNum Number of collapsed nested loops.
3304 /// \param NumClauses Number of clauses.
3306 explicit OMPTargetSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
3307 : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, OMPD_target_simd,
3308 SourceLocation(),SourceLocation(), CollapsedNum,
3312 /// Creates directive with a list of \a Clauses.
3314 /// \param C AST context.
3315 /// \param StartLoc Starting location of the directive kind.
3316 /// \param EndLoc Ending Location of the directive.
3317 /// \param CollapsedNum Number of collapsed loops.
3318 /// \param Clauses List of clauses.
3319 /// \param AssociatedStmt Statement, associated with the directive.
3320 /// \param Exprs Helper expressions for CodeGen.
3322 static OMPTargetSimdDirective *
3323 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3324 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3325 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3327 /// Creates an empty directive with the place for \a NumClauses clauses.
3329 /// \param C AST context.
3330 /// \param CollapsedNum Number of collapsed nested loops.
3331 /// \param NumClauses Number of clauses.
3333 static OMPTargetSimdDirective *CreateEmpty(const ASTContext &C,
3334 unsigned NumClauses,
3335 unsigned CollapsedNum,
3338 static bool classof(const Stmt *T) {
3339 return T->getStmtClass() == OMPTargetSimdDirectiveClass;
3343 /// This represents '#pragma omp teams distribute' directive.
3346 /// #pragma omp teams distribute private(a,b)
3348 /// In this example directive '#pragma omp teams distribute' has clauses
3349 /// 'private' with the variables 'a' and 'b'
3351 class OMPTeamsDistributeDirective final : public OMPLoopDirective {
3352 friend class ASTStmtReader;
3354 /// Build directive with the given start and end location.
3356 /// \param StartLoc Starting location of the directive kind.
3357 /// \param EndLoc Ending location of the directive.
3358 /// \param CollapsedNum Number of collapsed nested loops.
3359 /// \param NumClauses Number of clauses.
3361 OMPTeamsDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3362 unsigned CollapsedNum, unsigned NumClauses)
3363 : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass,
3364 OMPD_teams_distribute, StartLoc, EndLoc,
3365 CollapsedNum, NumClauses) {}
3367 /// Build an empty directive.
3369 /// \param CollapsedNum Number of collapsed nested loops.
3370 /// \param NumClauses Number of clauses.
3372 explicit OMPTeamsDistributeDirective(unsigned CollapsedNum,
3373 unsigned NumClauses)
3374 : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass,
3375 OMPD_teams_distribute, SourceLocation(),
3376 SourceLocation(), CollapsedNum, NumClauses) {}
3379 /// Creates directive with a list of \a Clauses.
3381 /// \param C AST context.
3382 /// \param StartLoc Starting location of the directive kind.
3383 /// \param EndLoc Ending Location of the directive.
3384 /// \param CollapsedNum Number of collapsed loops.
3385 /// \param Clauses List of clauses.
3386 /// \param AssociatedStmt Statement, associated with the directive.
3387 /// \param Exprs Helper expressions for CodeGen.
3389 static OMPTeamsDistributeDirective *
3390 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3391 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3392 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3394 /// Creates an empty directive with the place for \a NumClauses clauses.
3396 /// \param C AST context.
3397 /// \param CollapsedNum Number of collapsed nested loops.
3398 /// \param NumClauses Number of clauses.
3400 static OMPTeamsDistributeDirective *CreateEmpty(const ASTContext &C,
3401 unsigned NumClauses,
3402 unsigned CollapsedNum,
3405 static bool classof(const Stmt *T) {
3406 return T->getStmtClass() == OMPTeamsDistributeDirectiveClass;
3410 /// This represents '#pragma omp teams distribute simd'
3411 /// combined directive.
3414 /// #pragma omp teams distribute simd private(a,b)
3416 /// In this example directive '#pragma omp teams distribute simd'
3417 /// has clause 'private' with the variables 'a' and 'b'
3419 class OMPTeamsDistributeSimdDirective final : public OMPLoopDirective {
3420 friend class ASTStmtReader;
3422 /// Build directive with the given start and end location.
3424 /// \param StartLoc Starting location of the directive kind.
3425 /// \param EndLoc Ending location of the directive.
3426 /// \param CollapsedNum Number of collapsed nested loops.
3427 /// \param NumClauses Number of clauses.
3429 OMPTeamsDistributeSimdDirective(SourceLocation StartLoc,
3430 SourceLocation EndLoc, unsigned CollapsedNum,
3431 unsigned NumClauses)
3432 : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass,
3433 OMPD_teams_distribute_simd, StartLoc, EndLoc,
3434 CollapsedNum, NumClauses) {}
3436 /// Build an empty directive.
3438 /// \param CollapsedNum Number of collapsed nested loops.
3439 /// \param NumClauses Number of clauses.
3441 explicit OMPTeamsDistributeSimdDirective(unsigned CollapsedNum,
3442 unsigned NumClauses)
3443 : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass,
3444 OMPD_teams_distribute_simd, SourceLocation(),
3445 SourceLocation(), CollapsedNum, NumClauses) {}
3448 /// Creates directive with a list of \a Clauses.
3450 /// \param C AST context.
3451 /// \param StartLoc Starting location of the directive kind.
3452 /// \param EndLoc Ending Location of the directive.
3453 /// \param CollapsedNum Number of collapsed loops.
3454 /// \param Clauses List of clauses.
3455 /// \param AssociatedStmt Statement, associated with the directive.
3456 /// \param Exprs Helper expressions for CodeGen.
3458 static OMPTeamsDistributeSimdDirective *
3459 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3460 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3461 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3463 /// Creates an empty directive with the place
3464 /// for \a NumClauses clauses.
3466 /// \param C AST context.
3467 /// \param CollapsedNum Number of collapsed nested loops.
3468 /// \param NumClauses Number of clauses.
3470 static OMPTeamsDistributeSimdDirective *CreateEmpty(const ASTContext &C,
3471 unsigned NumClauses,
3472 unsigned CollapsedNum,
3475 static bool classof(const Stmt *T) {
3476 return T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass;
3480 /// This represents '#pragma omp teams distribute parallel for simd' composite
3484 /// #pragma omp teams distribute parallel for simd private(x)
3486 /// In this example directive '#pragma omp teams distribute parallel for simd'
3487 /// has clause 'private' with the variables 'x'
3489 class OMPTeamsDistributeParallelForSimdDirective final
3490 : public OMPLoopDirective {
3491 friend class ASTStmtReader;
3493 /// Build directive with the given start and end location.
3495 /// \param StartLoc Starting location of the directive kind.
3496 /// \param EndLoc Ending location of the directive.
3497 /// \param CollapsedNum Number of collapsed nested loops.
3498 /// \param NumClauses Number of clauses.
3500 OMPTeamsDistributeParallelForSimdDirective(SourceLocation StartLoc,
3501 SourceLocation EndLoc,
3502 unsigned CollapsedNum,
3503 unsigned NumClauses)
3504 : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass,
3505 OMPD_teams_distribute_parallel_for_simd, StartLoc,
3506 EndLoc, CollapsedNum, NumClauses) {}
3508 /// Build an empty directive.
3510 /// \param CollapsedNum Number of collapsed nested loops.
3511 /// \param NumClauses Number of clauses.
3513 explicit OMPTeamsDistributeParallelForSimdDirective(unsigned CollapsedNum,
3514 unsigned NumClauses)
3515 : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass,
3516 OMPD_teams_distribute_parallel_for_simd,
3517 SourceLocation(), SourceLocation(), CollapsedNum,
3521 /// Creates directive with a list of \a Clauses.
3523 /// \param C AST context.
3524 /// \param StartLoc Starting location of the directive kind.
3525 /// \param EndLoc Ending Location of the directive.
3526 /// \param CollapsedNum Number of collapsed loops.
3527 /// \param Clauses List of clauses.
3528 /// \param AssociatedStmt Statement, associated with the directive.
3529 /// \param Exprs Helper expressions for CodeGen.
3531 static OMPTeamsDistributeParallelForSimdDirective *
3532 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3533 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3534 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3536 /// Creates an empty directive with the place for \a NumClauses clauses.
3538 /// \param C AST context.
3539 /// \param CollapsedNum Number of collapsed nested loops.
3540 /// \param NumClauses Number of clauses.
3542 static OMPTeamsDistributeParallelForSimdDirective *
3543 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3546 static bool classof(const Stmt *T) {
3547 return T->getStmtClass() == OMPTeamsDistributeParallelForSimdDirectiveClass;
3551 /// This represents '#pragma omp teams distribute parallel for' composite
3555 /// #pragma omp teams distribute parallel for private(x)
3557 /// In this example directive '#pragma omp teams distribute parallel for'
3558 /// has clause 'private' with the variables 'x'
3560 class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective {
3561 friend class ASTStmtReader;
3563 /// Build directive with the given start and end location.
3565 /// \param StartLoc Starting location of the directive kind.
3566 /// \param EndLoc Ending location of the directive.
3567 /// \param CollapsedNum Number of collapsed nested loops.
3568 /// \param NumClauses Number of clauses.
3570 OMPTeamsDistributeParallelForDirective(SourceLocation StartLoc,
3571 SourceLocation EndLoc,
3572 unsigned CollapsedNum,
3573 unsigned NumClauses)
3574 : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
3575 OMPD_teams_distribute_parallel_for, StartLoc, EndLoc,
3576 CollapsedNum, NumClauses) {}
3578 /// Build an empty directive.
3580 /// \param CollapsedNum Number of collapsed nested loops.
3581 /// \param NumClauses Number of clauses.
3583 explicit OMPTeamsDistributeParallelForDirective(unsigned CollapsedNum,
3584 unsigned NumClauses)
3585 : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
3586 OMPD_teams_distribute_parallel_for, SourceLocation(),
3587 SourceLocation(), CollapsedNum, NumClauses) {}
3590 /// Creates directive with a list of \a Clauses.
3592 /// \param C AST context.
3593 /// \param StartLoc Starting location of the directive kind.
3594 /// \param EndLoc Ending Location of the directive.
3595 /// \param CollapsedNum Number of collapsed loops.
3596 /// \param Clauses List of clauses.
3597 /// \param AssociatedStmt Statement, associated with the directive.
3598 /// \param Exprs Helper expressions for CodeGen.
3600 static OMPTeamsDistributeParallelForDirective *
3601 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3602 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3603 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3605 /// Creates an empty directive with the place for \a NumClauses clauses.
3607 /// \param C AST context.
3608 /// \param CollapsedNum Number of collapsed nested loops.
3609 /// \param NumClauses Number of clauses.
3611 static OMPTeamsDistributeParallelForDirective *
3612 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3615 static bool classof(const Stmt *T) {
3616 return T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass;
3620 /// This represents '#pragma omp target teams' directive.
3623 /// #pragma omp target teams if(a>0)
3625 /// In this example directive '#pragma omp target teams' has clause 'if' with
3626 /// condition 'a>0'.
3628 class OMPTargetTeamsDirective final : public OMPExecutableDirective {
3629 friend class ASTStmtReader;
3630 /// Build directive with the given start and end location.
3632 /// \param StartLoc Starting location of the directive kind.
3633 /// \param EndLoc Ending location of the directive.
3634 /// \param NumClauses Number of clauses.
3636 OMPTargetTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3637 unsigned NumClauses)
3638 : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass,
3639 OMPD_target_teams, StartLoc, EndLoc, NumClauses,
3642 /// Build an empty directive.
3644 /// \param NumClauses Number of clauses.
3646 explicit OMPTargetTeamsDirective(unsigned NumClauses)
3647 : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass,
3648 OMPD_target_teams, SourceLocation(),
3649 SourceLocation(), NumClauses, 1) {}
3652 /// Creates directive with a list of \a Clauses.
3654 /// \param C AST context.
3655 /// \param StartLoc Starting location of the directive kind.
3656 /// \param EndLoc Ending Location of the directive.
3657 /// \param Clauses List of clauses.
3658 /// \param AssociatedStmt Statement, associated with the directive.
3660 static OMPTargetTeamsDirective *Create(const ASTContext &C,
3661 SourceLocation StartLoc,
3662 SourceLocation EndLoc,
3663 ArrayRef<OMPClause *> Clauses,
3664 Stmt *AssociatedStmt);
3666 /// Creates an empty directive with the place for \a NumClauses clauses.
3668 /// \param C AST context.
3669 /// \param NumClauses Number of clauses.
3671 static OMPTargetTeamsDirective *CreateEmpty(const ASTContext &C,
3672 unsigned NumClauses, EmptyShell);
3674 static bool classof(const Stmt *T) {
3675 return T->getStmtClass() == OMPTargetTeamsDirectiveClass;
3679 /// This represents '#pragma omp target teams distribute' combined directive.
3682 /// #pragma omp target teams distribute private(x)
3684 /// In this example directive '#pragma omp target teams distribute' has clause
3685 /// 'private' with the variables 'x'
3687 class OMPTargetTeamsDistributeDirective final : public OMPLoopDirective {
3688 friend class ASTStmtReader;
3690 /// Build directive with the given start and end location.
3692 /// \param StartLoc Starting location of the directive kind.
3693 /// \param EndLoc Ending location of the directive.
3694 /// \param CollapsedNum Number of collapsed nested loops.
3695 /// \param NumClauses Number of clauses.
3697 OMPTargetTeamsDistributeDirective(SourceLocation StartLoc,
3698 SourceLocation EndLoc,
3699 unsigned CollapsedNum, unsigned NumClauses)
3700 : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass,
3701 OMPD_target_teams_distribute, StartLoc, EndLoc,
3702 CollapsedNum, NumClauses) {}
3704 /// Build an empty directive.
3706 /// \param CollapsedNum Number of collapsed nested loops.
3707 /// \param NumClauses Number of clauses.
3709 explicit OMPTargetTeamsDistributeDirective(unsigned CollapsedNum,
3710 unsigned NumClauses)
3711 : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass,
3712 OMPD_target_teams_distribute, SourceLocation(),
3713 SourceLocation(), CollapsedNum, NumClauses) {}
3716 /// Creates directive with a list of \a Clauses.
3718 /// \param C AST context.
3719 /// \param StartLoc Starting location of the directive kind.
3720 /// \param EndLoc Ending Location of the directive.
3721 /// \param CollapsedNum Number of collapsed loops.
3722 /// \param Clauses List of clauses.
3723 /// \param AssociatedStmt Statement, associated with the directive.
3724 /// \param Exprs Helper expressions for CodeGen.
3726 static OMPTargetTeamsDistributeDirective *
3727 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3728 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3729 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3731 /// Creates an empty directive with the place for \a NumClauses clauses.
3733 /// \param C AST context.
3734 /// \param CollapsedNum Number of collapsed nested loops.
3735 /// \param NumClauses Number of clauses.
3737 static OMPTargetTeamsDistributeDirective *
3738 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3741 static bool classof(const Stmt *T) {
3742 return T->getStmtClass() == OMPTargetTeamsDistributeDirectiveClass;
3746 /// This represents '#pragma omp target teams distribute parallel for' combined
3750 /// #pragma omp target teams distribute parallel for private(x)
3752 /// In this example directive '#pragma omp target teams distribute parallel
3753 /// for' has clause 'private' with the variables 'x'
3755 class OMPTargetTeamsDistributeParallelForDirective final
3756 : public OMPLoopDirective {
3757 friend class ASTStmtReader;
3759 /// Build directive with the given start and end location.
3761 /// \param StartLoc Starting location of the directive kind.
3762 /// \param EndLoc Ending location of the directive.
3763 /// \param CollapsedNum Number of collapsed nested loops.
3764 /// \param NumClauses Number of clauses.
3766 OMPTargetTeamsDistributeParallelForDirective(SourceLocation StartLoc,
3767 SourceLocation EndLoc,
3768 unsigned CollapsedNum,
3769 unsigned NumClauses)
3770 : OMPLoopDirective(this,
3771 OMPTargetTeamsDistributeParallelForDirectiveClass,
3772 OMPD_target_teams_distribute_parallel_for, StartLoc,
3773 EndLoc, CollapsedNum, NumClauses) {}
3775 /// Build an empty directive.
3777 /// \param CollapsedNum Number of collapsed nested loops.
3778 /// \param NumClauses Number of clauses.
3780 explicit OMPTargetTeamsDistributeParallelForDirective(unsigned CollapsedNum,
3781 unsigned NumClauses)
3783 this, OMPTargetTeamsDistributeParallelForDirectiveClass,
3784 OMPD_target_teams_distribute_parallel_for, SourceLocation(),
3785 SourceLocation(), CollapsedNum, NumClauses) {}
3788 /// Creates directive with a list of \a Clauses.
3790 /// \param C AST context.
3791 /// \param StartLoc Starting location of the directive kind.
3792 /// \param EndLoc Ending Location of the directive.
3793 /// \param CollapsedNum Number of collapsed loops.
3794 /// \param Clauses List of clauses.
3795 /// \param AssociatedStmt Statement, associated with the directive.
3796 /// \param Exprs Helper expressions for CodeGen.
3798 static OMPTargetTeamsDistributeParallelForDirective *
3799 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3800 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3801 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3803 /// Creates an empty directive with the place for \a NumClauses clauses.
3805 /// \param C AST context.
3806 /// \param CollapsedNum Number of collapsed nested loops.
3807 /// \param NumClauses Number of clauses.
3809 static OMPTargetTeamsDistributeParallelForDirective *
3810 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3813 static bool classof(const Stmt *T) {
3814 return T->getStmtClass() ==
3815 OMPTargetTeamsDistributeParallelForDirectiveClass;
3819 /// This represents '#pragma omp target teams distribute parallel for simd'
3820 /// combined directive.
3823 /// #pragma omp target teams distribute parallel for simd private(x)
3825 /// In this example directive '#pragma omp target teams distribute parallel
3826 /// for simd' has clause 'private' with the variables 'x'
3828 class OMPTargetTeamsDistributeParallelForSimdDirective final
3829 : public OMPLoopDirective {
3830 friend class ASTStmtReader;
3832 /// Build directive with the given start and end location.
3834 /// \param StartLoc Starting location of the directive kind.
3835 /// \param EndLoc Ending location of the directive.
3836 /// \param CollapsedNum Number of collapsed nested loops.
3837 /// \param NumClauses Number of clauses.
3839 OMPTargetTeamsDistributeParallelForSimdDirective(SourceLocation StartLoc,
3840 SourceLocation EndLoc,
3841 unsigned CollapsedNum,
3842 unsigned NumClauses)
3843 : OMPLoopDirective(this,
3844 OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
3845 OMPD_target_teams_distribute_parallel_for_simd,
3846 StartLoc, EndLoc, CollapsedNum, NumClauses) {}
3848 /// Build an empty directive.
3850 /// \param CollapsedNum Number of collapsed nested loops.
3851 /// \param NumClauses Number of clauses.
3853 explicit OMPTargetTeamsDistributeParallelForSimdDirective(
3854 unsigned CollapsedNum, unsigned NumClauses)
3856 this, OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
3857 OMPD_target_teams_distribute_parallel_for_simd, SourceLocation(),
3858 SourceLocation(), CollapsedNum, NumClauses) {}
3861 /// Creates directive with a list of \a Clauses.
3863 /// \param C AST context.
3864 /// \param StartLoc Starting location of the directive kind.
3865 /// \param EndLoc Ending Location of the directive.
3866 /// \param CollapsedNum Number of collapsed loops.
3867 /// \param Clauses List of clauses.
3868 /// \param AssociatedStmt Statement, associated with the directive.
3869 /// \param Exprs Helper expressions for CodeGen.
3871 static OMPTargetTeamsDistributeParallelForSimdDirective *
3872 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3873 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3874 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3876 /// Creates an empty directive with the place for \a NumClauses clauses.
3878 /// \param C AST context.
3879 /// \param CollapsedNum Number of collapsed nested loops.
3880 /// \param NumClauses Number of clauses.
3882 static OMPTargetTeamsDistributeParallelForSimdDirective *
3883 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3886 static bool classof(const Stmt *T) {
3887 return T->getStmtClass() ==
3888 OMPTargetTeamsDistributeParallelForSimdDirectiveClass;
3892 /// This represents '#pragma omp target teams distribute simd' combined
3896 /// #pragma omp target teams distribute simd private(x)
3898 /// In this example directive '#pragma omp target teams distribute simd'
3899 /// has clause 'private' with the variables 'x'
3901 class OMPTargetTeamsDistributeSimdDirective final : public OMPLoopDirective {
3902 friend class ASTStmtReader;
3904 /// Build directive with the given start and end location.
3906 /// \param StartLoc Starting location of the directive kind.
3907 /// \param EndLoc Ending location of the directive.
3908 /// \param CollapsedNum Number of collapsed nested loops.
3909 /// \param NumClauses Number of clauses.
3911 OMPTargetTeamsDistributeSimdDirective(SourceLocation StartLoc,
3912 SourceLocation EndLoc,
3913 unsigned CollapsedNum,
3914 unsigned NumClauses)
3915 : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
3916 OMPD_target_teams_distribute_simd, StartLoc, EndLoc,
3917 CollapsedNum, NumClauses) {}
3919 /// Build an empty directive.
3921 /// \param CollapsedNum Number of collapsed nested loops.
3922 /// \param NumClauses Number of clauses.
3924 explicit OMPTargetTeamsDistributeSimdDirective(unsigned CollapsedNum,
3925 unsigned NumClauses)
3926 : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
3927 OMPD_target_teams_distribute_simd, SourceLocation(),
3928 SourceLocation(), CollapsedNum, NumClauses) {}
3931 /// Creates directive with a list of \a Clauses.
3933 /// \param C AST context.
3934 /// \param StartLoc Starting location of the directive kind.
3935 /// \param EndLoc Ending Location of the directive.
3936 /// \param CollapsedNum Number of collapsed loops.
3937 /// \param Clauses List of clauses.
3938 /// \param AssociatedStmt Statement, associated with the directive.
3939 /// \param Exprs Helper expressions for CodeGen.
3941 static OMPTargetTeamsDistributeSimdDirective *
3942 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3943 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3944 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3946 /// Creates an empty directive with the place for \a NumClauses clauses.
3948 /// \param C AST context.
3949 /// \param CollapsedNum Number of collapsed nested loops.
3950 /// \param NumClauses Number of clauses.
3952 static OMPTargetTeamsDistributeSimdDirective *
3953 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3956 static bool classof(const Stmt *T) {
3957 return T->getStmtClass() == OMPTargetTeamsDistributeSimdDirectiveClass;
3961 } // end namespace clang