clang  8.0.0svn
StmtOpenMP.h
Go to the documentation of this file.
1 //===- StmtOpenMP.h - Classes for OpenMP directives ------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 /// This file defines OpenMP AST classes for executable directives and
11 /// clauses.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_AST_STMTOPENMP_H
16 #define LLVM_CLANG_AST_STMTOPENMP_H
17 
18 #include "clang/AST/Expr.h"
19 #include "clang/AST/OpenMPClause.h"
20 #include "clang/AST/Stmt.h"
23 
24 namespace clang {
25 
26 //===----------------------------------------------------------------------===//
27 // AST classes for directives.
28 //===----------------------------------------------------------------------===//
29 
30 /// This is a basic class for representing single OpenMP executable
31 /// directive.
32 ///
33 class OMPExecutableDirective : public Stmt {
34  friend class ASTStmtReader;
35  /// Kind of the directive.
37  /// Starting location of the directive (directive keyword).
38  SourceLocation StartLoc;
39  /// Ending location of the directive.
40  SourceLocation EndLoc;
41  /// Numbers of clauses.
42  const unsigned NumClauses;
43  /// Number of child expressions/stmts.
44  const unsigned NumChildren;
45  /// 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;
50 
51  /// 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);
56  }
57 
58 protected:
59  /// Build instance of directive of class \a K.
60  ///
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.
65  ///
66  template <typename T>
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 *))) {}
74 
75  /// Sets the list of variables for this clause.
76  ///
77  /// \param Clauses The list of clauses for the directive.
78  ///
79  void setClauses(ArrayRef<OMPClause *> Clauses);
80 
81  /// Set the associated statement for the directive.
82  ///
83  /// /param S Associated statement.
84  ///
86  assert(hasAssociatedStmt() && "no associated statement.");
87  *child_begin() = S;
88  }
89 
90 public:
91  /// Iterates over a filtered subrange of clauses applied to a
92  /// directive.
93  ///
94  /// This iterator visits only clauses of type SpecificClause.
95  template <typename SpecificClause>
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 *> {
103 
104  void SkipToNextClause() {
105  while (this->I != End && !isa<SpecificClause>(*this->I))
106  ++this->I;
107  }
108 
109  public:
111  : specific_clause_iterator::iterator_adaptor_base(Clauses.begin()),
112  End(Clauses.end()) {
113  SkipToNextClause();
114  }
115 
116  const SpecificClause *operator*() const {
117  return cast<SpecificClause>(*this->I);
118  }
119  const SpecificClause *operator->() const { return **this; }
120 
122  ++this->I;
123  SkipToNextClause();
124  return *this;
125  }
126  };
127 
128  template <typename SpecificClause>
129  static llvm::iterator_range<specific_clause_iterator<SpecificClause>>
133  llvm::makeArrayRef(Clauses.end(), 0))};
134  }
135 
136  template <typename SpecificClause>
137  llvm::iterator_range<specific_clause_iterator<SpecificClause>>
139  return getClausesOfKind<SpecificClause>(clauses());
140  }
141 
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
146  /// the directive.
147  template <typename SpecificClause>
148  const SpecificClause *getSingleClause() const {
149  auto Clauses = getClausesOfKind<SpecificClause>();
150 
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();
155  }
156  return nullptr;
157  }
158 
159  /// Returns true if the current directive has one or more clauses of a
160  /// specific kind.
161  template <typename SpecificClause>
162  bool hasClausesOfKind() const {
163  auto Clauses = getClausesOfKind<SpecificClause>();
164  return Clauses.begin() != Clauses.end();
165  }
166 
167  /// Returns starting location of directive kind.
168  LLVM_ATTRIBUTE_DEPRECATED(SourceLocation getLocStart() const LLVM_READONLY,
169  "Use getBeginLoc instead") {
170  return getBeginLoc();
171  }
172  SourceLocation getBeginLoc() const { return StartLoc; }
173  /// Returns ending location of directive.
174  LLVM_ATTRIBUTE_DEPRECATED(SourceLocation getLocEnd() const LLVM_READONLY,
175  "Use getEndLoc instead") {
176  return getEndLoc();
177  }
178  SourceLocation getEndLoc() const { return EndLoc; }
179 
180  /// Set starting location of directive kind.
181  ///
182  /// \param Loc New starting location of directive.
183  ///
184  void setLocStart(SourceLocation Loc) { StartLoc = Loc; }
185  /// Set ending location of directive.
186  ///
187  /// \param Loc New ending location of directive.
188  ///
189  void setLocEnd(SourceLocation Loc) { EndLoc = Loc; }
190 
191  /// Get number of clauses.
192  unsigned getNumClauses() const { return NumClauses; }
193 
194  /// Returns specified clause.
195  ///
196  /// \param i Number of clause.
197  ///
198  OMPClause *getClause(unsigned i) const { return clauses()[i]; }
199 
200  /// Returns true if directive has associated statement.
201  bool hasAssociatedStmt() const { return NumChildren > 0; }
202 
203  /// Returns statement associated with the directive.
204  const Stmt *getAssociatedStmt() const {
205  assert(hasAssociatedStmt() && "no associated statement.");
206  return *child_begin();
207  }
209  assert(hasAssociatedStmt() && "no associated statement.");
210  return *child_begin();
211  }
212 
213  /// Returns the captured statement associated with the
214  /// component region within the (combined) directive.
215  //
216  // \param RegionKind Component region kind.
219  getOpenMPCaptureRegions(CaptureRegions, getDirectiveKind());
220  assert(std::any_of(
221  CaptureRegions.begin(), CaptureRegions.end(),
222  [=](const OpenMPDirectiveKind K) { return K == RegionKind; }) &&
223  "RegionKind not found in OpenMP CaptureRegions.");
224  auto *CS = cast<CapturedStmt>(getAssociatedStmt());
225  for (auto ThisCaptureRegion : CaptureRegions) {
226  if (ThisCaptureRegion == RegionKind)
227  return CS;
228  CS = cast<CapturedStmt>(CS->getCapturedStmt());
229  }
230  llvm_unreachable("Incorrect RegionKind specified for directive.");
231  }
232 
233  /// Get innermost captured statement for the construct.
235  assert(hasAssociatedStmt() && getAssociatedStmt() &&
236  "Must have associated statement.");
238  getOpenMPCaptureRegions(CaptureRegions, getDirectiveKind());
239  assert(!CaptureRegions.empty() &&
240  "At least one captured statement must be provided.");
241  auto *CS = cast<CapturedStmt>(getAssociatedStmt());
242  for (unsigned Level = CaptureRegions.size(); Level > 1; --Level)
243  CS = cast<CapturedStmt>(CS->getCapturedStmt());
244  return CS;
245  }
246 
248  return const_cast<OMPExecutableDirective *>(this)
250  }
251 
252  OpenMPDirectiveKind getDirectiveKind() const { return Kind; }
253 
254  static bool classof(const Stmt *S) {
255  return S->getStmtClass() >= firstOMPExecutableDirectiveConstant &&
256  S->getStmtClass() <= lastOMPExecutableDirectiveConstant;
257  }
258 
260  if (!hasAssociatedStmt())
262  Stmt **ChildStorage = reinterpret_cast<Stmt **>(getClauses().end());
263  /// Do not mark all the special expression/statements as children, except
264  /// for the associated statement.
265  return child_range(ChildStorage, ChildStorage + 1);
266  }
267 
268  ArrayRef<OMPClause *> clauses() { return getClauses(); }
269 
271  return const_cast<OMPExecutableDirective *>(this)->getClauses();
272  }
273 };
274 
275 /// This represents '#pragma omp parallel' directive.
276 ///
277 /// \code
278 /// #pragma omp parallel private(a,b) reduction(+: c,d)
279 /// \endcode
280 /// In this example directive '#pragma omp parallel' has clauses 'private'
281 /// with the variables 'a' and 'b' and 'reduction' with operator '+' and
282 /// variables 'c' and 'd'.
283 ///
285  friend class ASTStmtReader;
286  /// true if the construct has inner cancel directive.
287  bool HasCancel;
288 
289  /// Build directive with the given start and end location.
290  ///
291  /// \param StartLoc Starting location of the directive (directive keyword).
292  /// \param EndLoc Ending Location of the directive.
293  ///
295  unsigned NumClauses)
296  : OMPExecutableDirective(this, OMPParallelDirectiveClass, OMPD_parallel,
297  StartLoc, EndLoc, NumClauses, 1),
298  HasCancel(false) {}
299 
300  /// Build an empty directive.
301  ///
302  /// \param NumClauses Number of clauses.
303  ///
304  explicit OMPParallelDirective(unsigned NumClauses)
305  : OMPExecutableDirective(this, OMPParallelDirectiveClass, OMPD_parallel,
306  SourceLocation(), SourceLocation(), NumClauses,
307  1),
308  HasCancel(false) {}
309 
310  /// Set cancel state.
311  void setHasCancel(bool Has) { HasCancel = Has; }
312 
313 public:
314  /// Creates directive with a list of \a Clauses.
315  ///
316  /// \param C AST context.
317  /// \param StartLoc Starting location of the directive kind.
318  /// \param EndLoc Ending Location of the directive.
319  /// \param Clauses List of clauses.
320  /// \param AssociatedStmt Statement associated with the directive.
321  /// \param HasCancel true if this directive has inner cancel directive.
322  ///
323  static OMPParallelDirective *
324  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
325  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel);
326 
327  /// Creates an empty directive with the place for \a N clauses.
328  ///
329  /// \param C AST context.
330  /// \param NumClauses Number of clauses.
331  ///
333  unsigned NumClauses, EmptyShell);
334 
335  /// Return true if current directive has inner cancel directive.
336  bool hasCancel() const { return HasCancel; }
337 
338  static bool classof(const Stmt *T) {
339  return T->getStmtClass() == OMPParallelDirectiveClass;
340  }
341 };
342 
343 /// This is a common base class for loop directives ('omp simd', 'omp
344 /// for', 'omp for simd' etc.). It is responsible for the loop code generation.
345 ///
347  friend class ASTStmtReader;
348  /// Number of collapsed loops as specified by 'collapse' clause.
349  unsigned CollapsedNum;
350 
351  /// Offsets to the stored exprs.
352  /// This enumeration contains offsets to all the pointers to children
353  /// expressions stored in OMPLoopDirective.
354  /// The first 9 children are necessary for all the loop directives,
355  /// the next 8 are specific to the worksharing ones, and the next 11 are
356  /// used for combined constructs containing two pragmas associated to loops.
357  /// After the fixed children, three arrays of length CollapsedNum are
358  /// allocated: loop counters, their updates and final values.
359  /// PrevLowerBound and PrevUpperBound are used to communicate blocking
360  /// information in composite constructs which require loop blocking
361  /// DistInc is used to generate the increment expression for the distribute
362  /// loop when combined with a further nested loop
363  /// PrevEnsureUpperBound is used as the EnsureUpperBound expression for the
364  /// for loop when combined with a previous distribute loop in the same pragma
365  /// (e.g. 'distribute parallel for')
366  ///
367  enum {
368  AssociatedStmtOffset = 0,
369  IterationVariableOffset = 1,
370  LastIterationOffset = 2,
371  CalcLastIterationOffset = 3,
372  PreConditionOffset = 4,
373  CondOffset = 5,
374  InitOffset = 6,
375  IncOffset = 7,
376  PreInitsOffset = 8,
377  // The '...End' enumerators do not correspond to child expressions - they
378  // specify the offset to the end (and start of the following counters/
379  // updates/finals arrays).
380  DefaultEnd = 9,
381  // The following 8 exprs are used by worksharing and distribute loops only.
382  IsLastIterVariableOffset = 9,
383  LowerBoundVariableOffset = 10,
384  UpperBoundVariableOffset = 11,
385  StrideVariableOffset = 12,
386  EnsureUpperBoundOffset = 13,
387  NextLowerBoundOffset = 14,
388  NextUpperBoundOffset = 15,
389  NumIterationsOffset = 16,
390  // Offset to the end for worksharing loop directives.
391  WorksharingEnd = 17,
392  PrevLowerBoundVariableOffset = 17,
393  PrevUpperBoundVariableOffset = 18,
394  DistIncOffset = 19,
395  PrevEnsureUpperBoundOffset = 20,
396  CombinedLowerBoundVariableOffset = 21,
397  CombinedUpperBoundVariableOffset = 22,
398  CombinedEnsureUpperBoundOffset = 23,
399  CombinedInitOffset = 24,
400  CombinedConditionOffset = 25,
401  CombinedNextLowerBoundOffset = 26,
402  CombinedNextUpperBoundOffset = 27,
403  // Offset to the end (and start of the following counters/updates/finals
404  // arrays) for combined distribute loop directives.
405  CombinedDistributeEnd = 28,
406  };
407 
408  /// Get the counters storage.
409  MutableArrayRef<Expr *> getCounters() {
410  Expr **Storage = reinterpret_cast<Expr **>(
411  &(*(std::next(child_begin(), getArraysOffset(getDirectiveKind())))));
412  return MutableArrayRef<Expr *>(Storage, CollapsedNum);
413  }
414 
415  /// Get the private counters storage.
416  MutableArrayRef<Expr *> getPrivateCounters() {
417  Expr **Storage = reinterpret_cast<Expr **>(&*std::next(
418  child_begin(), getArraysOffset(getDirectiveKind()) + CollapsedNum));
419  return MutableArrayRef<Expr *>(Storage, CollapsedNum);
420  }
421 
422  /// Get the updates storage.
424  Expr **Storage = reinterpret_cast<Expr **>(
425  &*std::next(child_begin(),
426  getArraysOffset(getDirectiveKind()) + 2 * CollapsedNum));
427  return MutableArrayRef<Expr *>(Storage, CollapsedNum);
428  }
429 
430  /// Get the updates storage.
432  Expr **Storage = reinterpret_cast<Expr **>(
433  &*std::next(child_begin(),
434  getArraysOffset(getDirectiveKind()) + 3 * CollapsedNum));
435  return MutableArrayRef<Expr *>(Storage, CollapsedNum);
436  }
437 
438  /// Get the final counter updates storage.
440  Expr **Storage = reinterpret_cast<Expr **>(
441  &*std::next(child_begin(),
442  getArraysOffset(getDirectiveKind()) + 4 * CollapsedNum));
443  return MutableArrayRef<Expr *>(Storage, CollapsedNum);
444  }
445 
446 protected:
447  /// Build instance of loop directive of class \a Kind.
448  ///
449  /// \param SC Statement class.
450  /// \param Kind Kind of OpenMP directive.
451  /// \param StartLoc Starting location of the directive (directive keyword).
452  /// \param EndLoc Ending location of the directive.
453  /// \param CollapsedNum Number of collapsed loops from 'collapse' clause.
454  /// \param NumClauses Number of clauses.
455  /// \param NumSpecialChildren Number of additional directive-specific stmts.
456  ///
457  template <typename T>
459  SourceLocation StartLoc, SourceLocation EndLoc,
460  unsigned CollapsedNum, unsigned NumClauses,
461  unsigned NumSpecialChildren = 0)
462  : OMPExecutableDirective(That, SC, Kind, StartLoc, EndLoc, NumClauses,
463  numLoopChildren(CollapsedNum, Kind) +
464  NumSpecialChildren),
465  CollapsedNum(CollapsedNum) {}
466 
467  /// Offset to the start of children expression arrays.
468  static unsigned getArraysOffset(OpenMPDirectiveKind Kind) {
470  return CombinedDistributeEnd;
473  return WorksharingEnd;
474  return DefaultEnd;
475  }
476 
477  /// Children number.
478  static unsigned numLoopChildren(unsigned CollapsedNum,
479  OpenMPDirectiveKind Kind) {
480  return getArraysOffset(Kind) + 5 * CollapsedNum; // Counters,
481  // PrivateCounters, Inits,
482  // Updates and Finals
483  }
484 
486  *std::next(child_begin(), IterationVariableOffset) = IV;
487  }
488  void setLastIteration(Expr *LI) {
489  *std::next(child_begin(), LastIterationOffset) = LI;
490  }
492  *std::next(child_begin(), CalcLastIterationOffset) = CLI;
493  }
494  void setPreCond(Expr *PC) {
495  *std::next(child_begin(), PreConditionOffset) = PC;
496  }
497  void setCond(Expr *Cond) {
498  *std::next(child_begin(), CondOffset) = Cond;
499  }
500  void setInit(Expr *Init) { *std::next(child_begin(), InitOffset) = Init; }
501  void setInc(Expr *Inc) { *std::next(child_begin(), IncOffset) = Inc; }
502  void setPreInits(Stmt *PreInits) {
503  *std::next(child_begin(), PreInitsOffset) = PreInits;
504  }
509  "expected worksharing loop directive");
510  *std::next(child_begin(), IsLastIterVariableOffset) = IL;
511  }
516  "expected worksharing loop directive");
517  *std::next(child_begin(), LowerBoundVariableOffset) = LB;
518  }
523  "expected worksharing loop directive");
524  *std::next(child_begin(), UpperBoundVariableOffset) = UB;
525  }
530  "expected worksharing loop directive");
531  *std::next(child_begin(), StrideVariableOffset) = ST;
532  }
537  "expected worksharing loop directive");
538  *std::next(child_begin(), EnsureUpperBoundOffset) = EUB;
539  }
540  void setNextLowerBound(Expr *NLB) {
544  "expected worksharing loop directive");
545  *std::next(child_begin(), NextLowerBoundOffset) = NLB;
546  }
547  void setNextUpperBound(Expr *NUB) {
551  "expected worksharing loop directive");
552  *std::next(child_begin(), NextUpperBoundOffset) = NUB;
553  }
554  void setNumIterations(Expr *NI) {
558  "expected worksharing loop directive");
559  *std::next(child_begin(), NumIterationsOffset) = NI;
560  }
563  "expected loop bound sharing directive");
564  *std::next(child_begin(), PrevLowerBoundVariableOffset) = PrevLB;
565  }
568  "expected loop bound sharing directive");
569  *std::next(child_begin(), PrevUpperBoundVariableOffset) = PrevUB;
570  }
571  void setDistInc(Expr *DistInc) {
573  "expected loop bound sharing directive");
574  *std::next(child_begin(), DistIncOffset) = DistInc;
575  }
576  void setPrevEnsureUpperBound(Expr *PrevEUB) {
578  "expected loop bound sharing directive");
579  *std::next(child_begin(), PrevEnsureUpperBoundOffset) = PrevEUB;
580  }
583  "expected loop bound sharing directive");
584  *std::next(child_begin(), CombinedLowerBoundVariableOffset) = CombLB;
585  }
588  "expected loop bound sharing directive");
589  *std::next(child_begin(), CombinedUpperBoundVariableOffset) = CombUB;
590  }
593  "expected loop bound sharing directive");
594  *std::next(child_begin(), CombinedEnsureUpperBoundOffset) = CombEUB;
595  }
596  void setCombinedInit(Expr *CombInit) {
598  "expected loop bound sharing directive");
599  *std::next(child_begin(), CombinedInitOffset) = CombInit;
600  }
601  void setCombinedCond(Expr *CombCond) {
603  "expected loop bound sharing directive");
604  *std::next(child_begin(), CombinedConditionOffset) = CombCond;
605  }
608  "expected loop bound sharing directive");
609  *std::next(child_begin(), CombinedNextLowerBoundOffset) = CombNLB;
610  }
613  "expected loop bound sharing directive");
614  *std::next(child_begin(), CombinedNextUpperBoundOffset) = CombNUB;
615  }
616  void setCounters(ArrayRef<Expr *> A);
617  void setPrivateCounters(ArrayRef<Expr *> A);
618  void setInits(ArrayRef<Expr *> A);
620  void setFinals(ArrayRef<Expr *> A);
621 
622 public:
623  /// The expressions built to support OpenMP loops in combined/composite
624  /// pragmas (e.g. pragma omp distribute parallel for)
626  /// DistributeLowerBound - used when composing 'omp distribute' with
627  /// 'omp for' in a same construct.
629  /// DistributeUpperBound - used when composing 'omp distribute' with
630  /// 'omp for' in a same construct.
632  /// DistributeEnsureUpperBound - used when composing 'omp distribute'
633  /// with 'omp for' in a same construct, EUB depends on DistUB
635  /// Distribute loop iteration variable init used when composing 'omp
636  /// distribute'
637  /// with 'omp for' in a same construct
639  /// Distribute Loop condition used when composing 'omp distribute'
640  /// with 'omp for' in a same construct
642  /// Update of LowerBound for statically scheduled omp loops for
643  /// outer loop in combined constructs (e.g. 'distribute parallel for')
645  /// Update of UpperBound for statically scheduled omp loops for
646  /// outer loop in combined constructs (e.g. 'distribute parallel for')
648  };
649 
650  /// The expressions built for the OpenMP loop CodeGen for the
651  /// whole collapsed loop nest.
652  struct HelperExprs {
653  /// Loop iteration variable.
655  /// Loop last iteration number.
657  /// Loop number of iterations.
659  /// Calculation of last iteration.
661  /// Loop pre-condition.
663  /// Loop condition.
665  /// Loop iteration variable init.
667  /// Loop increment.
669  /// IsLastIteration - local flag variable passed to runtime.
671  /// LowerBound - local variable passed to runtime.
673  /// UpperBound - local variable passed to runtime.
675  /// Stride - local variable passed to runtime.
677  /// EnsureUpperBound -- expression UB = min(UB, NumIterations).
679  /// Update of LowerBound for statically scheduled 'omp for' loops.
681  /// Update of UpperBound for statically scheduled 'omp for' loops.
683  /// PreviousLowerBound - local variable passed to runtime in the
684  /// enclosing schedule or null if that does not apply.
686  /// PreviousUpperBound - local variable passed to runtime in the
687  /// enclosing schedule or null if that does not apply.
689  /// DistInc - increment expression for distribute loop when found
690  /// combined with a further loop level (e.g. in 'distribute parallel for')
691  /// expression IV = IV + ST
693  /// PrevEUB - expression similar to EUB but to be used when loop
694  /// scheduling uses PrevLB and PrevUB (e.g. in 'distribute parallel for'
695  /// when ensuring that the UB is either the calculated UB by the runtime or
696  /// the end of the assigned distribute chunk)
697  /// expression UB = min (UB, PrevUB)
699  /// Counters Loop counters.
701  /// PrivateCounters Loop counters.
703  /// Expressions for loop counters inits for CodeGen.
705  /// Expressions for loop counters update for CodeGen.
707  /// Final loop counter values for GodeGen.
709  /// Init statement for all captured expressions.
711 
712  /// Expressions used when combining OpenMP loop pragmas
714 
715  /// Check if all the expressions are built (does not check the
716  /// worksharing ones).
717  bool builtAll() {
718  return IterationVarRef != nullptr && LastIteration != nullptr &&
719  NumIterations != nullptr && PreCond != nullptr &&
720  Cond != nullptr && Init != nullptr && Inc != nullptr;
721  }
722 
723  /// Initialize all the fields to null.
724  /// \param Size Number of elements in the counters/finals/updates arrays.
725  void clear(unsigned Size) {
726  IterationVarRef = nullptr;
727  LastIteration = nullptr;
728  CalcLastIteration = nullptr;
729  PreCond = nullptr;
730  Cond = nullptr;
731  Init = nullptr;
732  Inc = nullptr;
733  IL = nullptr;
734  LB = nullptr;
735  UB = nullptr;
736  ST = nullptr;
737  EUB = nullptr;
738  NLB = nullptr;
739  NUB = nullptr;
740  NumIterations = nullptr;
741  PrevLB = nullptr;
742  PrevUB = nullptr;
743  DistInc = nullptr;
744  PrevEUB = nullptr;
745  Counters.resize(Size);
746  PrivateCounters.resize(Size);
747  Inits.resize(Size);
748  Updates.resize(Size);
749  Finals.resize(Size);
750  for (unsigned i = 0; i < Size; ++i) {
751  Counters[i] = nullptr;
752  PrivateCounters[i] = nullptr;
753  Inits[i] = nullptr;
754  Updates[i] = nullptr;
755  Finals[i] = nullptr;
756  }
757  PreInits = nullptr;
758  DistCombinedFields.LB = nullptr;
759  DistCombinedFields.UB = nullptr;
760  DistCombinedFields.EUB = nullptr;
761  DistCombinedFields.Init = nullptr;
762  DistCombinedFields.Cond = nullptr;
763  DistCombinedFields.NLB = nullptr;
764  DistCombinedFields.NUB = nullptr;
765  }
766  };
767 
768  /// Get number of collapsed loops.
769  unsigned getCollapsedNumber() const { return CollapsedNum; }
770 
772  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
773  *std::next(child_begin(), IterationVariableOffset)));
774  }
776  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
777  *std::next(child_begin(), LastIterationOffset)));
778  }
780  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
781  *std::next(child_begin(), CalcLastIterationOffset)));
782  }
783  Expr *getPreCond() const {
784  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
785  *std::next(child_begin(), PreConditionOffset)));
786  }
787  Expr *getCond() const {
788  return const_cast<Expr *>(
789  reinterpret_cast<const Expr *>(*std::next(child_begin(), CondOffset)));
790  }
791  Expr *getInit() const {
792  return const_cast<Expr *>(
793  reinterpret_cast<const Expr *>(*std::next(child_begin(), InitOffset)));
794  }
795  Expr *getInc() const {
796  return const_cast<Expr *>(
797  reinterpret_cast<const Expr *>(*std::next(child_begin(), IncOffset)));
798  }
799  const Stmt *getPreInits() const {
800  return *std::next(child_begin(), PreInitsOffset);
801  }
802  Stmt *getPreInits() { return *std::next(child_begin(), PreInitsOffset); }
807  "expected worksharing loop directive");
808  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
809  *std::next(child_begin(), IsLastIterVariableOffset)));
810  }
815  "expected worksharing loop directive");
816  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
817  *std::next(child_begin(), LowerBoundVariableOffset)));
818  }
823  "expected worksharing loop directive");
824  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
825  *std::next(child_begin(), UpperBoundVariableOffset)));
826  }
831  "expected worksharing loop directive");
832  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
833  *std::next(child_begin(), StrideVariableOffset)));
834  }
839  "expected worksharing loop directive");
840  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
841  *std::next(child_begin(), EnsureUpperBoundOffset)));
842  }
847  "expected worksharing loop directive");
848  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
849  *std::next(child_begin(), NextLowerBoundOffset)));
850  }
855  "expected worksharing loop directive");
856  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
857  *std::next(child_begin(), NextUpperBoundOffset)));
858  }
863  "expected worksharing loop directive");
864  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
865  *std::next(child_begin(), NumIterationsOffset)));
866  }
869  "expected loop bound sharing directive");
870  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
871  *std::next(child_begin(), PrevLowerBoundVariableOffset)));
872  }
875  "expected loop bound sharing directive");
876  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
877  *std::next(child_begin(), PrevUpperBoundVariableOffset)));
878  }
879  Expr *getDistInc() const {
881  "expected loop bound sharing directive");
882  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
883  *std::next(child_begin(), DistIncOffset)));
884  }
887  "expected loop bound sharing directive");
888  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
889  *std::next(child_begin(), PrevEnsureUpperBoundOffset)));
890  }
893  "expected loop bound sharing directive");
894  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
895  *std::next(child_begin(), CombinedLowerBoundVariableOffset)));
896  }
899  "expected loop bound sharing directive");
900  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
901  *std::next(child_begin(), CombinedUpperBoundVariableOffset)));
902  }
905  "expected loop bound sharing directive");
906  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
907  *std::next(child_begin(), CombinedEnsureUpperBoundOffset)));
908  }
911  "expected loop bound sharing directive");
912  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
913  *std::next(child_begin(), CombinedInitOffset)));
914  }
917  "expected loop bound sharing directive");
918  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
919  *std::next(child_begin(), CombinedConditionOffset)));
920  }
923  "expected loop bound sharing directive");
924  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
925  *std::next(child_begin(), CombinedNextLowerBoundOffset)));
926  }
929  "expected loop bound sharing directive");
930  return const_cast<Expr *>(reinterpret_cast<const Expr *>(
931  *std::next(child_begin(), CombinedNextUpperBoundOffset)));
932  }
933  const Stmt *getBody() const {
934  // This relies on the loop form is already checked by Sema.
935  const Stmt *Body =
937  Body = cast<ForStmt>(Body)->getBody();
938  for (unsigned Cnt = 1; Cnt < CollapsedNum; ++Cnt) {
939  Body = Body->IgnoreContainers();
940  Body = cast<ForStmt>(Body)->getBody();
941  }
942  return Body;
943  }
944 
945  ArrayRef<Expr *> counters() { return getCounters(); }
946 
948  return const_cast<OMPLoopDirective *>(this)->getCounters();
949  }
950 
951  ArrayRef<Expr *> private_counters() { return getPrivateCounters(); }
952 
954  return const_cast<OMPLoopDirective *>(this)->getPrivateCounters();
955  }
956 
958 
960  return const_cast<OMPLoopDirective *>(this)->getInits();
961  }
962 
964 
966  return const_cast<OMPLoopDirective *>(this)->getUpdates();
967  }
968 
970 
972  return const_cast<OMPLoopDirective *>(this)->getFinals();
973  }
974 
975  static bool classof(const Stmt *T) {
976  return T->getStmtClass() == OMPSimdDirectiveClass ||
977  T->getStmtClass() == OMPForDirectiveClass ||
978  T->getStmtClass() == OMPForSimdDirectiveClass ||
979  T->getStmtClass() == OMPParallelForDirectiveClass ||
980  T->getStmtClass() == OMPParallelForSimdDirectiveClass ||
981  T->getStmtClass() == OMPTaskLoopDirectiveClass ||
982  T->getStmtClass() == OMPTaskLoopSimdDirectiveClass ||
983  T->getStmtClass() == OMPDistributeDirectiveClass ||
984  T->getStmtClass() == OMPTargetParallelForDirectiveClass ||
985  T->getStmtClass() == OMPDistributeParallelForDirectiveClass ||
986  T->getStmtClass() == OMPDistributeParallelForSimdDirectiveClass ||
987  T->getStmtClass() == OMPDistributeSimdDirectiveClass ||
988  T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass ||
989  T->getStmtClass() == OMPTargetSimdDirectiveClass ||
990  T->getStmtClass() == OMPTeamsDistributeDirectiveClass ||
991  T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass ||
992  T->getStmtClass() ==
993  OMPTeamsDistributeParallelForSimdDirectiveClass ||
994  T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass ||
995  T->getStmtClass() ==
996  OMPTargetTeamsDistributeParallelForDirectiveClass ||
997  T->getStmtClass() ==
998  OMPTargetTeamsDistributeParallelForSimdDirectiveClass ||
999  T->getStmtClass() == OMPTargetTeamsDistributeDirectiveClass ||
1000  T->getStmtClass() == OMPTargetTeamsDistributeSimdDirectiveClass;
1001  }
1002 };
1003 
1004 /// This represents '#pragma omp simd' directive.
1005 ///
1006 /// \code
1007 /// #pragma omp simd private(a,b) linear(i,j:s) reduction(+:c,d)
1008 /// \endcode
1009 /// In this example directive '#pragma omp simd' has clauses 'private'
1010 /// with the variables 'a' and 'b', 'linear' with variables 'i', 'j' and
1011 /// linear step 's', 'reduction' with operator '+' and variables 'c' and 'd'.
1012 ///
1014  friend class ASTStmtReader;
1015  /// Build directive with the given start and end location.
1016  ///
1017  /// \param StartLoc Starting location of the directive kind.
1018  /// \param EndLoc Ending location of the directive.
1019  /// \param CollapsedNum Number of collapsed nested loops.
1020  /// \param NumClauses Number of clauses.
1021  ///
1023  unsigned CollapsedNum, unsigned NumClauses)
1024  : OMPLoopDirective(this, OMPSimdDirectiveClass, OMPD_simd, StartLoc,
1025  EndLoc, CollapsedNum, NumClauses) {}
1026 
1027  /// Build an empty directive.
1028  ///
1029  /// \param CollapsedNum Number of collapsed nested loops.
1030  /// \param NumClauses Number of clauses.
1031  ///
1032  explicit OMPSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
1033  : OMPLoopDirective(this, OMPSimdDirectiveClass, OMPD_simd,
1034  SourceLocation(), SourceLocation(), CollapsedNum,
1035  NumClauses) {}
1036 
1037 public:
1038  /// Creates directive with a list of \a Clauses.
1039  ///
1040  /// \param C AST context.
1041  /// \param StartLoc Starting location of the directive kind.
1042  /// \param EndLoc Ending Location of the directive.
1043  /// \param CollapsedNum Number of collapsed loops.
1044  /// \param Clauses List of clauses.
1045  /// \param AssociatedStmt Statement, associated with the directive.
1046  /// \param Exprs Helper expressions for CodeGen.
1047  ///
1048  static OMPSimdDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1049  SourceLocation EndLoc, unsigned CollapsedNum,
1050  ArrayRef<OMPClause *> Clauses,
1051  Stmt *AssociatedStmt,
1052  const HelperExprs &Exprs);
1053 
1054  /// Creates an empty directive with the place
1055  /// for \a NumClauses clauses.
1056  ///
1057  /// \param C AST context.
1058  /// \param CollapsedNum Number of collapsed nested loops.
1059  /// \param NumClauses Number of clauses.
1060  ///
1061  static OMPSimdDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
1062  unsigned CollapsedNum, EmptyShell);
1063 
1064  static bool classof(const Stmt *T) {
1065  return T->getStmtClass() == OMPSimdDirectiveClass;
1066  }
1067 };
1068 
1069 /// This represents '#pragma omp for' directive.
1070 ///
1071 /// \code
1072 /// #pragma omp for private(a,b) reduction(+:c,d)
1073 /// \endcode
1074 /// In this example directive '#pragma omp for' has clauses 'private' with the
1075 /// variables 'a' and 'b' and 'reduction' with operator '+' and variables 'c'
1076 /// and 'd'.
1077 ///
1079  friend class ASTStmtReader;
1080 
1081  /// true if current directive has inner cancel directive.
1082  bool HasCancel;
1083 
1084  /// Build directive with the given start and end location.
1085  ///
1086  /// \param StartLoc Starting location of the directive kind.
1087  /// \param EndLoc Ending location of the directive.
1088  /// \param CollapsedNum Number of collapsed nested loops.
1089  /// \param NumClauses Number of clauses.
1090  ///
1092  unsigned CollapsedNum, unsigned NumClauses)
1093  : OMPLoopDirective(this, OMPForDirectiveClass, OMPD_for, StartLoc, EndLoc,
1094  CollapsedNum, NumClauses),
1095  HasCancel(false) {}
1096 
1097  /// Build an empty directive.
1098  ///
1099  /// \param CollapsedNum Number of collapsed nested loops.
1100  /// \param NumClauses Number of clauses.
1101  ///
1102  explicit OMPForDirective(unsigned CollapsedNum, unsigned NumClauses)
1103  : OMPLoopDirective(this, OMPForDirectiveClass, OMPD_for, SourceLocation(),
1104  SourceLocation(), CollapsedNum, NumClauses),
1105  HasCancel(false) {}
1106 
1107  /// Set cancel state.
1108  void setHasCancel(bool Has) { HasCancel = Has; }
1109 
1110 public:
1111  /// Creates directive with a list of \a Clauses.
1112  ///
1113  /// \param C AST context.
1114  /// \param StartLoc Starting location of the directive kind.
1115  /// \param EndLoc Ending Location of the directive.
1116  /// \param CollapsedNum Number of collapsed loops.
1117  /// \param Clauses List of clauses.
1118  /// \param AssociatedStmt Statement, associated with the directive.
1119  /// \param Exprs Helper expressions for CodeGen.
1120  /// \param HasCancel true if current directive has inner cancel directive.
1121  ///
1122  static OMPForDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1123  SourceLocation EndLoc, unsigned CollapsedNum,
1124  ArrayRef<OMPClause *> Clauses,
1125  Stmt *AssociatedStmt, const HelperExprs &Exprs,
1126  bool HasCancel);
1127 
1128  /// Creates an empty directive with the place
1129  /// for \a NumClauses clauses.
1130  ///
1131  /// \param C AST context.
1132  /// \param CollapsedNum Number of collapsed nested loops.
1133  /// \param NumClauses Number of clauses.
1134  ///
1135  static OMPForDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
1136  unsigned CollapsedNum, EmptyShell);
1137 
1138  /// Return true if current directive has inner cancel directive.
1139  bool hasCancel() const { return HasCancel; }
1140 
1141  static bool classof(const Stmt *T) {
1142  return T->getStmtClass() == OMPForDirectiveClass;
1143  }
1144 };
1145 
1146 /// This represents '#pragma omp for simd' directive.
1147 ///
1148 /// \code
1149 /// #pragma omp for simd private(a,b) linear(i,j:s) reduction(+:c,d)
1150 /// \endcode
1151 /// In this example directive '#pragma omp for simd' has clauses 'private'
1152 /// with the variables 'a' and 'b', 'linear' with variables 'i', 'j' and
1153 /// linear step 's', 'reduction' with operator '+' and variables 'c' and 'd'.
1154 ///
1156  friend class ASTStmtReader;
1157  /// Build directive with the given start and end location.
1158  ///
1159  /// \param StartLoc Starting location of the directive kind.
1160  /// \param EndLoc Ending location of the directive.
1161  /// \param CollapsedNum Number of collapsed nested loops.
1162  /// \param NumClauses Number of clauses.
1163  ///
1165  unsigned CollapsedNum, unsigned NumClauses)
1166  : OMPLoopDirective(this, OMPForSimdDirectiveClass, OMPD_for_simd,
1167  StartLoc, EndLoc, CollapsedNum, NumClauses) {}
1168 
1169  /// Build an empty directive.
1170  ///
1171  /// \param CollapsedNum Number of collapsed nested loops.
1172  /// \param NumClauses Number of clauses.
1173  ///
1174  explicit OMPForSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
1175  : OMPLoopDirective(this, OMPForSimdDirectiveClass, OMPD_for_simd,
1176  SourceLocation(), SourceLocation(), CollapsedNum,
1177  NumClauses) {}
1178 
1179 public:
1180  /// Creates directive with a list of \a Clauses.
1181  ///
1182  /// \param C AST context.
1183  /// \param StartLoc Starting location of the directive kind.
1184  /// \param EndLoc Ending Location of the directive.
1185  /// \param CollapsedNum Number of collapsed loops.
1186  /// \param Clauses List of clauses.
1187  /// \param AssociatedStmt Statement, associated with the directive.
1188  /// \param Exprs Helper expressions for CodeGen.
1189  ///
1190  static OMPForSimdDirective *
1191  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1192  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
1193  Stmt *AssociatedStmt, const HelperExprs &Exprs);
1194 
1195  /// Creates an empty directive with the place
1196  /// for \a NumClauses clauses.
1197  ///
1198  /// \param C AST context.
1199  /// \param CollapsedNum Number of collapsed nested loops.
1200  /// \param NumClauses Number of clauses.
1201  ///
1203  unsigned NumClauses,
1204  unsigned CollapsedNum, EmptyShell);
1205 
1206  static bool classof(const Stmt *T) {
1207  return T->getStmtClass() == OMPForSimdDirectiveClass;
1208  }
1209 };
1210 
1211 /// This represents '#pragma omp sections' directive.
1212 ///
1213 /// \code
1214 /// #pragma omp sections private(a,b) reduction(+:c,d)
1215 /// \endcode
1216 /// In this example directive '#pragma omp sections' has clauses 'private' with
1217 /// the variables 'a' and 'b' and 'reduction' with operator '+' and variables
1218 /// 'c' and 'd'.
1219 ///
1221  friend class ASTStmtReader;
1222 
1223  /// true if current directive has inner cancel directive.
1224  bool HasCancel;
1225 
1226  /// Build directive with the given start and end location.
1227  ///
1228  /// \param StartLoc Starting location of the directive kind.
1229  /// \param EndLoc Ending location of the directive.
1230  /// \param NumClauses Number of clauses.
1231  ///
1233  unsigned NumClauses)
1234  : OMPExecutableDirective(this, OMPSectionsDirectiveClass, OMPD_sections,
1235  StartLoc, EndLoc, NumClauses, 1),
1236  HasCancel(false) {}
1237 
1238  /// Build an empty directive.
1239  ///
1240  /// \param NumClauses Number of clauses.
1241  ///
1242  explicit OMPSectionsDirective(unsigned NumClauses)
1243  : OMPExecutableDirective(this, OMPSectionsDirectiveClass, OMPD_sections,
1244  SourceLocation(), SourceLocation(), NumClauses,
1245  1),
1246  HasCancel(false) {}
1247 
1248  /// Set cancel state.
1249  void setHasCancel(bool Has) { HasCancel = Has; }
1250 
1251 public:
1252  /// Creates directive with a list of \a Clauses.
1253  ///
1254  /// \param C AST context.
1255  /// \param StartLoc Starting location of the directive kind.
1256  /// \param EndLoc Ending Location of the directive.
1257  /// \param Clauses List of clauses.
1258  /// \param AssociatedStmt Statement, associated with the directive.
1259  /// \param HasCancel true if current directive has inner directive.
1260  ///
1261  static OMPSectionsDirective *
1262  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1263  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel);
1264 
1265  /// Creates an empty directive with the place for \a NumClauses
1266  /// clauses.
1267  ///
1268  /// \param C AST context.
1269  /// \param NumClauses Number of clauses.
1270  ///
1272  unsigned NumClauses, EmptyShell);
1273 
1274  /// Return true if current directive has inner cancel directive.
1275  bool hasCancel() const { return HasCancel; }
1276 
1277  static bool classof(const Stmt *T) {
1278  return T->getStmtClass() == OMPSectionsDirectiveClass;
1279  }
1280 };
1281 
1282 /// This represents '#pragma omp section' directive.
1283 ///
1284 /// \code
1285 /// #pragma omp section
1286 /// \endcode
1287 ///
1289  friend class ASTStmtReader;
1290 
1291  /// true if current directive has inner cancel directive.
1292  bool HasCancel;
1293 
1294  /// Build directive with the given start and end location.
1295  ///
1296  /// \param StartLoc Starting location of the directive kind.
1297  /// \param EndLoc Ending location of the directive.
1298  ///
1300  : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,
1301  StartLoc, EndLoc, 0, 1),
1302  HasCancel(false) {}
1303 
1304  /// Build an empty directive.
1305  ///
1306  explicit OMPSectionDirective()
1307  : OMPExecutableDirective(this, OMPSectionDirectiveClass, OMPD_section,
1308  SourceLocation(), SourceLocation(), 0, 1),
1309  HasCancel(false) {}
1310 
1311 public:
1312  /// Creates directive.
1313  ///
1314  /// \param C AST context.
1315  /// \param StartLoc Starting location of the directive kind.
1316  /// \param EndLoc Ending Location of the directive.
1317  /// \param AssociatedStmt Statement, associated with the directive.
1318  /// \param HasCancel true if current directive has inner directive.
1319  ///
1320  static OMPSectionDirective *Create(const ASTContext &C,
1321  SourceLocation StartLoc,
1322  SourceLocation EndLoc,
1323  Stmt *AssociatedStmt, bool HasCancel);
1324 
1325  /// Creates an empty directive.
1326  ///
1327  /// \param C AST context.
1328  ///
1330 
1331  /// Set cancel state.
1332  void setHasCancel(bool Has) { HasCancel = Has; }
1333 
1334  /// Return true if current directive has inner cancel directive.
1335  bool hasCancel() const { return HasCancel; }
1336 
1337  static bool classof(const Stmt *T) {
1338  return T->getStmtClass() == OMPSectionDirectiveClass;
1339  }
1340 };
1341 
1342 /// This represents '#pragma omp single' directive.
1343 ///
1344 /// \code
1345 /// #pragma omp single private(a,b) copyprivate(c,d)
1346 /// \endcode
1347 /// In this example directive '#pragma omp single' has clauses 'private' with
1348 /// the variables 'a' and 'b' and 'copyprivate' with variables 'c' and 'd'.
1349 ///
1351  friend class ASTStmtReader;
1352  /// Build directive with the given start and end location.
1353  ///
1354  /// \param StartLoc Starting location of the directive kind.
1355  /// \param EndLoc Ending location of the directive.
1356  /// \param NumClauses Number of clauses.
1357  ///
1359  unsigned NumClauses)
1360  : OMPExecutableDirective(this, OMPSingleDirectiveClass, OMPD_single,
1361  StartLoc, EndLoc, NumClauses, 1) {}
1362 
1363  /// Build an empty directive.
1364  ///
1365  /// \param NumClauses Number of clauses.
1366  ///
1367  explicit OMPSingleDirective(unsigned NumClauses)
1368  : OMPExecutableDirective(this, OMPSingleDirectiveClass, OMPD_single,
1369  SourceLocation(), SourceLocation(), NumClauses,
1370  1) {}
1371 
1372 public:
1373  /// Creates directive with a list of \a Clauses.
1374  ///
1375  /// \param C AST context.
1376  /// \param StartLoc Starting location of the directive kind.
1377  /// \param EndLoc Ending Location of the directive.
1378  /// \param Clauses List of clauses.
1379  /// \param AssociatedStmt Statement, associated with the directive.
1380  ///
1381  static OMPSingleDirective *
1382  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1383  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
1384 
1385  /// Creates an empty directive with the place for \a NumClauses
1386  /// clauses.
1387  ///
1388  /// \param C AST context.
1389  /// \param NumClauses Number of clauses.
1390  ///
1391  static OMPSingleDirective *CreateEmpty(const ASTContext &C,
1392  unsigned NumClauses, EmptyShell);
1393 
1394  static bool classof(const Stmt *T) {
1395  return T->getStmtClass() == OMPSingleDirectiveClass;
1396  }
1397 };
1398 
1399 /// This represents '#pragma omp master' directive.
1400 ///
1401 /// \code
1402 /// #pragma omp master
1403 /// \endcode
1404 ///
1406  friend class ASTStmtReader;
1407  /// Build directive with the given start and end location.
1408  ///
1409  /// \param StartLoc Starting location of the directive kind.
1410  /// \param EndLoc Ending location of the directive.
1411  ///
1413  : OMPExecutableDirective(this, OMPMasterDirectiveClass, OMPD_master,
1414  StartLoc, EndLoc, 0, 1) {}
1415 
1416  /// Build an empty directive.
1417  ///
1418  explicit OMPMasterDirective()
1419  : OMPExecutableDirective(this, OMPMasterDirectiveClass, OMPD_master,
1420  SourceLocation(), SourceLocation(), 0, 1) {}
1421 
1422 public:
1423  /// Creates directive.
1424  ///
1425  /// \param C AST context.
1426  /// \param StartLoc Starting location of the directive kind.
1427  /// \param EndLoc Ending Location of the directive.
1428  /// \param AssociatedStmt Statement, associated with the directive.
1429  ///
1430  static OMPMasterDirective *Create(const ASTContext &C,
1431  SourceLocation StartLoc,
1432  SourceLocation EndLoc,
1433  Stmt *AssociatedStmt);
1434 
1435  /// Creates an empty directive.
1436  ///
1437  /// \param C AST context.
1438  ///
1440 
1441  static bool classof(const Stmt *T) {
1442  return T->getStmtClass() == OMPMasterDirectiveClass;
1443  }
1444 };
1445 
1446 /// This represents '#pragma omp critical' directive.
1447 ///
1448 /// \code
1449 /// #pragma omp critical
1450 /// \endcode
1451 ///
1453  friend class ASTStmtReader;
1454  /// Name of the directive.
1455  DeclarationNameInfo DirName;
1456  /// Build directive with the given start and end location.
1457  ///
1458  /// \param Name Name of the directive.
1459  /// \param StartLoc Starting location of the directive kind.
1460  /// \param EndLoc Ending location of the directive.
1461  /// \param NumClauses Number of clauses.
1462  ///
1464  SourceLocation EndLoc, unsigned NumClauses)
1465  : OMPExecutableDirective(this, OMPCriticalDirectiveClass, OMPD_critical,
1466  StartLoc, EndLoc, NumClauses, 1),
1467  DirName(Name) {}
1468 
1469  /// Build an empty directive.
1470  ///
1471  /// \param NumClauses Number of clauses.
1472  ///
1473  explicit OMPCriticalDirective(unsigned NumClauses)
1474  : OMPExecutableDirective(this, OMPCriticalDirectiveClass, OMPD_critical,
1475  SourceLocation(), SourceLocation(), NumClauses,
1476  1),
1477  DirName() {}
1478 
1479  /// Set name of the directive.
1480  ///
1481  /// \param Name Name of the directive.
1482  ///
1483  void setDirectiveName(const DeclarationNameInfo &Name) { DirName = Name; }
1484 
1485 public:
1486  /// Creates directive.
1487  ///
1488  /// \param C AST context.
1489  /// \param Name Name of the directive.
1490  /// \param StartLoc Starting location of the directive kind.
1491  /// \param EndLoc Ending Location of the directive.
1492  /// \param Clauses List of clauses.
1493  /// \param AssociatedStmt Statement, associated with the directive.
1494  ///
1495  static OMPCriticalDirective *
1496  Create(const ASTContext &C, const DeclarationNameInfo &Name,
1497  SourceLocation StartLoc, SourceLocation EndLoc,
1498  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
1499 
1500  /// Creates an empty directive.
1501  ///
1502  /// \param C AST context.
1503  /// \param NumClauses Number of clauses.
1504  ///
1506  unsigned NumClauses, EmptyShell);
1507 
1508  /// Return name of the directive.
1509  ///
1510  DeclarationNameInfo getDirectiveName() const { return DirName; }
1511 
1512  static bool classof(const Stmt *T) {
1513  return T->getStmtClass() == OMPCriticalDirectiveClass;
1514  }
1515 };
1516 
1517 /// This represents '#pragma omp parallel for' directive.
1518 ///
1519 /// \code
1520 /// #pragma omp parallel for private(a,b) reduction(+:c,d)
1521 /// \endcode
1522 /// In this example directive '#pragma omp parallel for' has clauses 'private'
1523 /// with the variables 'a' and 'b' and 'reduction' with operator '+' and
1524 /// variables 'c' and 'd'.
1525 ///
1527  friend class ASTStmtReader;
1528 
1529  /// true if current region has inner cancel directive.
1530  bool HasCancel;
1531 
1532  /// Build directive with the given start and end location.
1533  ///
1534  /// \param StartLoc Starting location of the directive kind.
1535  /// \param EndLoc Ending location of the directive.
1536  /// \param CollapsedNum Number of collapsed nested loops.
1537  /// \param NumClauses Number of clauses.
1538  ///
1540  unsigned CollapsedNum, unsigned NumClauses)
1541  : OMPLoopDirective(this, OMPParallelForDirectiveClass, OMPD_parallel_for,
1542  StartLoc, EndLoc, CollapsedNum, NumClauses),
1543  HasCancel(false) {}
1544 
1545  /// Build an empty directive.
1546  ///
1547  /// \param CollapsedNum Number of collapsed nested loops.
1548  /// \param NumClauses Number of clauses.
1549  ///
1550  explicit OMPParallelForDirective(unsigned CollapsedNum, unsigned NumClauses)
1551  : OMPLoopDirective(this, OMPParallelForDirectiveClass, OMPD_parallel_for,
1552  SourceLocation(), SourceLocation(), CollapsedNum,
1553  NumClauses),
1554  HasCancel(false) {}
1555 
1556  /// Set cancel state.
1557  void setHasCancel(bool Has) { HasCancel = Has; }
1558 
1559 public:
1560  /// Creates directive with a list of \a Clauses.
1561  ///
1562  /// \param C AST context.
1563  /// \param StartLoc Starting location of the directive kind.
1564  /// \param EndLoc Ending Location of the directive.
1565  /// \param CollapsedNum Number of collapsed loops.
1566  /// \param Clauses List of clauses.
1567  /// \param AssociatedStmt Statement, associated with the directive.
1568  /// \param Exprs Helper expressions for CodeGen.
1569  /// \param HasCancel true if current directive has inner cancel directive.
1570  ///
1571  static OMPParallelForDirective *
1572  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1573  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
1574  Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
1575 
1576  /// Creates an empty directive with the place
1577  /// for \a NumClauses clauses.
1578  ///
1579  /// \param C AST context.
1580  /// \param CollapsedNum Number of collapsed nested loops.
1581  /// \param NumClauses Number of clauses.
1582  ///
1584  unsigned NumClauses,
1585  unsigned CollapsedNum,
1586  EmptyShell);
1587 
1588  /// Return true if current directive has inner cancel directive.
1589  bool hasCancel() const { return HasCancel; }
1590 
1591  static bool classof(const Stmt *T) {
1592  return T->getStmtClass() == OMPParallelForDirectiveClass;
1593  }
1594 };
1595 
1596 /// This represents '#pragma omp parallel for simd' directive.
1597 ///
1598 /// \code
1599 /// #pragma omp parallel for simd private(a,b) linear(i,j:s) reduction(+:c,d)
1600 /// \endcode
1601 /// In this example directive '#pragma omp parallel for simd' has clauses
1602 /// 'private' with the variables 'a' and 'b', 'linear' with variables 'i', 'j'
1603 /// and linear step 's', 'reduction' with operator '+' and variables 'c' and
1604 /// 'd'.
1605 ///
1607  friend class ASTStmtReader;
1608  /// Build directive with the given start and end location.
1609  ///
1610  /// \param StartLoc Starting location of the directive kind.
1611  /// \param EndLoc Ending location of the directive.
1612  /// \param CollapsedNum Number of collapsed nested loops.
1613  /// \param NumClauses Number of clauses.
1614  ///
1616  unsigned CollapsedNum, unsigned NumClauses)
1617  : OMPLoopDirective(this, OMPParallelForSimdDirectiveClass,
1618  OMPD_parallel_for_simd, StartLoc, EndLoc, CollapsedNum,
1619  NumClauses) {}
1620 
1621  /// Build an empty directive.
1622  ///
1623  /// \param CollapsedNum Number of collapsed nested loops.
1624  /// \param NumClauses Number of clauses.
1625  ///
1626  explicit OMPParallelForSimdDirective(unsigned CollapsedNum,
1627  unsigned NumClauses)
1628  : OMPLoopDirective(this, OMPParallelForSimdDirectiveClass,
1629  OMPD_parallel_for_simd, SourceLocation(),
1630  SourceLocation(), CollapsedNum, NumClauses) {}
1631 
1632 public:
1633  /// Creates directive with a list of \a Clauses.
1634  ///
1635  /// \param C AST context.
1636  /// \param StartLoc Starting location of the directive kind.
1637  /// \param EndLoc Ending Location of the directive.
1638  /// \param CollapsedNum Number of collapsed loops.
1639  /// \param Clauses List of clauses.
1640  /// \param AssociatedStmt Statement, associated with the directive.
1641  /// \param Exprs Helper expressions for CodeGen.
1642  ///
1644  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1645  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
1646  Stmt *AssociatedStmt, const HelperExprs &Exprs);
1647 
1648  /// Creates an empty directive with the place
1649  /// for \a NumClauses clauses.
1650  ///
1651  /// \param C AST context.
1652  /// \param CollapsedNum Number of collapsed nested loops.
1653  /// \param NumClauses Number of clauses.
1654  ///
1656  unsigned NumClauses,
1657  unsigned CollapsedNum,
1658  EmptyShell);
1659 
1660  static bool classof(const Stmt *T) {
1661  return T->getStmtClass() == OMPParallelForSimdDirectiveClass;
1662  }
1663 };
1664 
1665 /// This represents '#pragma omp parallel sections' directive.
1666 ///
1667 /// \code
1668 /// #pragma omp parallel sections private(a,b) reduction(+:c,d)
1669 /// \endcode
1670 /// In this example directive '#pragma omp parallel sections' has clauses
1671 /// 'private' with the variables 'a' and 'b' and 'reduction' with operator '+'
1672 /// and variables 'c' and 'd'.
1673 ///
1675  friend class ASTStmtReader;
1676 
1677  /// true if current directive has inner cancel directive.
1678  bool HasCancel;
1679 
1680  /// Build directive with the given start and end location.
1681  ///
1682  /// \param StartLoc Starting location of the directive kind.
1683  /// \param EndLoc Ending location of the directive.
1684  /// \param NumClauses Number of clauses.
1685  ///
1687  unsigned NumClauses)
1688  : OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass,
1689  OMPD_parallel_sections, StartLoc, EndLoc,
1690  NumClauses, 1),
1691  HasCancel(false) {}
1692 
1693  /// Build an empty directive.
1694  ///
1695  /// \param NumClauses Number of clauses.
1696  ///
1697  explicit OMPParallelSectionsDirective(unsigned NumClauses)
1698  : OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass,
1699  OMPD_parallel_sections, SourceLocation(),
1700  SourceLocation(), NumClauses, 1),
1701  HasCancel(false) {}
1702 
1703  /// Set cancel state.
1704  void setHasCancel(bool Has) { HasCancel = Has; }
1705 
1706 public:
1707  /// Creates directive with a list of \a Clauses.
1708  ///
1709  /// \param C AST context.
1710  /// \param StartLoc Starting location of the directive kind.
1711  /// \param EndLoc Ending Location of the directive.
1712  /// \param Clauses List of clauses.
1713  /// \param AssociatedStmt Statement, associated with the directive.
1714  /// \param HasCancel true if current directive has inner cancel directive.
1715  ///
1717  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1718  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel);
1719 
1720  /// Creates an empty directive with the place for \a NumClauses
1721  /// clauses.
1722  ///
1723  /// \param C AST context.
1724  /// \param NumClauses Number of clauses.
1725  ///
1727  CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
1728 
1729  /// Return true if current directive has inner cancel directive.
1730  bool hasCancel() const { return HasCancel; }
1731 
1732  static bool classof(const Stmt *T) {
1733  return T->getStmtClass() == OMPParallelSectionsDirectiveClass;
1734  }
1735 };
1736 
1737 /// This represents '#pragma omp task' directive.
1738 ///
1739 /// \code
1740 /// #pragma omp task private(a,b) final(d)
1741 /// \endcode
1742 /// In this example directive '#pragma omp task' has clauses 'private' with the
1743 /// variables 'a' and 'b' and 'final' with condition 'd'.
1744 ///
1746  friend class ASTStmtReader;
1747  /// true if this directive has inner cancel directive.
1748  bool HasCancel;
1749 
1750  /// Build directive with the given start and end location.
1751  ///
1752  /// \param StartLoc Starting location of the directive kind.
1753  /// \param EndLoc Ending location of the directive.
1754  /// \param NumClauses Number of clauses.
1755  ///
1757  unsigned NumClauses)
1758  : OMPExecutableDirective(this, OMPTaskDirectiveClass, OMPD_task, StartLoc,
1759  EndLoc, NumClauses, 1),
1760  HasCancel(false) {}
1761 
1762  /// Build an empty directive.
1763  ///
1764  /// \param NumClauses Number of clauses.
1765  ///
1766  explicit OMPTaskDirective(unsigned NumClauses)
1767  : OMPExecutableDirective(this, OMPTaskDirectiveClass, OMPD_task,
1768  SourceLocation(), SourceLocation(), NumClauses,
1769  1),
1770  HasCancel(false) {}
1771 
1772  /// Set cancel state.
1773  void setHasCancel(bool Has) { HasCancel = Has; }
1774 
1775 public:
1776  /// Creates directive with a list of \a Clauses.
1777  ///
1778  /// \param C AST context.
1779  /// \param StartLoc Starting location of the directive kind.
1780  /// \param EndLoc Ending Location of the directive.
1781  /// \param Clauses List of clauses.
1782  /// \param AssociatedStmt Statement, associated with the directive.
1783  /// \param HasCancel true, if current directive has inner cancel directive.
1784  ///
1785  static OMPTaskDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1786  SourceLocation EndLoc,
1787  ArrayRef<OMPClause *> Clauses,
1788  Stmt *AssociatedStmt, bool HasCancel);
1789 
1790  /// Creates an empty directive with the place for \a NumClauses
1791  /// clauses.
1792  ///
1793  /// \param C AST context.
1794  /// \param NumClauses Number of clauses.
1795  ///
1796  static OMPTaskDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
1797  EmptyShell);
1798 
1799  /// Return true if current directive has inner cancel directive.
1800  bool hasCancel() const { return HasCancel; }
1801 
1802  static bool classof(const Stmt *T) {
1803  return T->getStmtClass() == OMPTaskDirectiveClass;
1804  }
1805 };
1806 
1807 /// This represents '#pragma omp taskyield' directive.
1808 ///
1809 /// \code
1810 /// #pragma omp taskyield
1811 /// \endcode
1812 ///
1814  friend class ASTStmtReader;
1815  /// Build directive with the given start and end location.
1816  ///
1817  /// \param StartLoc Starting location of the directive kind.
1818  /// \param EndLoc Ending location of the directive.
1819  ///
1821  : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass, OMPD_taskyield,
1822  StartLoc, EndLoc, 0, 0) {}
1823 
1824  /// Build an empty directive.
1825  ///
1826  explicit OMPTaskyieldDirective()
1827  : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass, OMPD_taskyield,
1828  SourceLocation(), SourceLocation(), 0, 0) {}
1829 
1830 public:
1831  /// Creates directive.
1832  ///
1833  /// \param C AST context.
1834  /// \param StartLoc Starting location of the directive kind.
1835  /// \param EndLoc Ending Location of the directive.
1836  ///
1837  static OMPTaskyieldDirective *
1838  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
1839 
1840  /// Creates an empty directive.
1841  ///
1842  /// \param C AST context.
1843  ///
1845 
1846  static bool classof(const Stmt *T) {
1847  return T->getStmtClass() == OMPTaskyieldDirectiveClass;
1848  }
1849 };
1850 
1851 /// This represents '#pragma omp barrier' directive.
1852 ///
1853 /// \code
1854 /// #pragma omp barrier
1855 /// \endcode
1856 ///
1858  friend class ASTStmtReader;
1859  /// Build directive with the given start and end location.
1860  ///
1861  /// \param StartLoc Starting location of the directive kind.
1862  /// \param EndLoc Ending location of the directive.
1863  ///
1865  : OMPExecutableDirective(this, OMPBarrierDirectiveClass, OMPD_barrier,
1866  StartLoc, EndLoc, 0, 0) {}
1867 
1868  /// Build an empty directive.
1869  ///
1870  explicit OMPBarrierDirective()
1871  : OMPExecutableDirective(this, OMPBarrierDirectiveClass, OMPD_barrier,
1872  SourceLocation(), SourceLocation(), 0, 0) {}
1873 
1874 public:
1875  /// Creates directive.
1876  ///
1877  /// \param C AST context.
1878  /// \param StartLoc Starting location of the directive kind.
1879  /// \param EndLoc Ending Location of the directive.
1880  ///
1881  static OMPBarrierDirective *
1882  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
1883 
1884  /// Creates an empty directive.
1885  ///
1886  /// \param C AST context.
1887  ///
1889 
1890  static bool classof(const Stmt *T) {
1891  return T->getStmtClass() == OMPBarrierDirectiveClass;
1892  }
1893 };
1894 
1895 /// This represents '#pragma omp taskwait' directive.
1896 ///
1897 /// \code
1898 /// #pragma omp taskwait
1899 /// \endcode
1900 ///
1902  friend class ASTStmtReader;
1903  /// Build directive with the given start and end location.
1904  ///
1905  /// \param StartLoc Starting location of the directive kind.
1906  /// \param EndLoc Ending location of the directive.
1907  ///
1909  : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass, OMPD_taskwait,
1910  StartLoc, EndLoc, 0, 0) {}
1911 
1912  /// Build an empty directive.
1913  ///
1914  explicit OMPTaskwaitDirective()
1915  : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass, OMPD_taskwait,
1916  SourceLocation(), SourceLocation(), 0, 0) {}
1917 
1918 public:
1919  /// Creates directive.
1920  ///
1921  /// \param C AST context.
1922  /// \param StartLoc Starting location of the directive kind.
1923  /// \param EndLoc Ending Location of the directive.
1924  ///
1925  static OMPTaskwaitDirective *
1926  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
1927 
1928  /// Creates an empty directive.
1929  ///
1930  /// \param C AST context.
1931  ///
1933 
1934  static bool classof(const Stmt *T) {
1935  return T->getStmtClass() == OMPTaskwaitDirectiveClass;
1936  }
1937 };
1938 
1939 /// This represents '#pragma omp taskgroup' directive.
1940 ///
1941 /// \code
1942 /// #pragma omp taskgroup
1943 /// \endcode
1944 ///
1946  friend class ASTStmtReader;
1947  /// Build directive with the given start and end location.
1948  ///
1949  /// \param StartLoc Starting location of the directive kind.
1950  /// \param EndLoc Ending location of the directive.
1951  /// \param NumClauses Number of clauses.
1952  ///
1954  unsigned NumClauses)
1955  : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, OMPD_taskgroup,
1956  StartLoc, EndLoc, NumClauses, 2) {}
1957 
1958  /// Build an empty directive.
1959  /// \param NumClauses Number of clauses.
1960  ///
1961  explicit OMPTaskgroupDirective(unsigned NumClauses)
1962  : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, OMPD_taskgroup,
1963  SourceLocation(), SourceLocation(), NumClauses,
1964  2) {}
1965 
1966  /// Sets the task_reduction return variable.
1967  void setReductionRef(Expr *RR) {
1968  *std::next(child_begin(), 1) = RR;
1969  }
1970 
1971 public:
1972  /// Creates directive.
1973  ///
1974  /// \param C AST context.
1975  /// \param StartLoc Starting location of the directive kind.
1976  /// \param EndLoc Ending Location of the directive.
1977  /// \param Clauses List of clauses.
1978  /// \param AssociatedStmt Statement, associated with the directive.
1979  /// \param ReductionRef Reference to the task_reduction return variable.
1980  ///
1981  static OMPTaskgroupDirective *
1982  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1983  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1984  Expr *ReductionRef);
1985 
1986  /// Creates an empty directive.
1987  ///
1988  /// \param C AST context.
1989  /// \param NumClauses Number of clauses.
1990  ///
1992  unsigned NumClauses, EmptyShell);
1993 
1994 
1995  /// Returns reference to the task_reduction return variable.
1996  const Expr *getReductionRef() const {
1997  return static_cast<const Expr *>(*std::next(child_begin(), 1));
1998  }
2000  return static_cast<Expr *>(*std::next(child_begin(), 1));
2001  }
2002 
2003  static bool classof(const Stmt *T) {
2004  return T->getStmtClass() == OMPTaskgroupDirectiveClass;
2005  }
2006 };
2007 
2008 /// This represents '#pragma omp flush' directive.
2009 ///
2010 /// \code
2011 /// #pragma omp flush(a,b)
2012 /// \endcode
2013 /// In this example directive '#pragma omp flush' has 2 arguments- variables 'a'
2014 /// and 'b'.
2015 /// 'omp flush' directive does not have clauses but have an optional list of
2016 /// variables to flush. This list of variables is stored within some fake clause
2017 /// FlushClause.
2019  friend class ASTStmtReader;
2020  /// Build directive with the given start and end location.
2021  ///
2022  /// \param StartLoc Starting location of the directive kind.
2023  /// \param EndLoc Ending location of the directive.
2024  /// \param NumClauses Number of clauses.
2025  ///
2027  unsigned NumClauses)
2028  : OMPExecutableDirective(this, OMPFlushDirectiveClass, OMPD_flush,
2029  StartLoc, EndLoc, NumClauses, 0) {}
2030 
2031  /// Build an empty directive.
2032  ///
2033  /// \param NumClauses Number of clauses.
2034  ///
2035  explicit OMPFlushDirective(unsigned NumClauses)
2036  : OMPExecutableDirective(this, OMPFlushDirectiveClass, OMPD_flush,
2037  SourceLocation(), SourceLocation(), NumClauses,
2038  0) {}
2039 
2040 public:
2041  /// Creates directive with a list of \a Clauses.
2042  ///
2043  /// \param C AST context.
2044  /// \param StartLoc Starting location of the directive kind.
2045  /// \param EndLoc Ending Location of the directive.
2046  /// \param Clauses List of clauses (only single OMPFlushClause clause is
2047  /// allowed).
2048  ///
2049  static OMPFlushDirective *Create(const ASTContext &C, SourceLocation StartLoc,
2050  SourceLocation EndLoc,
2051  ArrayRef<OMPClause *> Clauses);
2052 
2053  /// Creates an empty directive with the place for \a NumClauses
2054  /// clauses.
2055  ///
2056  /// \param C AST context.
2057  /// \param NumClauses Number of clauses.
2058  ///
2059  static OMPFlushDirective *CreateEmpty(const ASTContext &C,
2060  unsigned NumClauses, EmptyShell);
2061 
2062  static bool classof(const Stmt *T) {
2063  return T->getStmtClass() == OMPFlushDirectiveClass;
2064  }
2065 };
2066 
2067 /// This represents '#pragma omp ordered' directive.
2068 ///
2069 /// \code
2070 /// #pragma omp ordered
2071 /// \endcode
2072 ///
2074  friend class ASTStmtReader;
2075  /// Build directive with the given start and end location.
2076  ///
2077  /// \param StartLoc Starting location of the directive kind.
2078  /// \param EndLoc Ending location of the directive.
2079  /// \param NumClauses Number of clauses.
2080  ///
2082  unsigned NumClauses)
2083  : OMPExecutableDirective(this, OMPOrderedDirectiveClass, OMPD_ordered,
2084  StartLoc, EndLoc, NumClauses, 1) {}
2085 
2086  /// Build an empty directive.
2087  ///
2088  /// \param NumClauses Number of clauses.
2089  ///
2090  explicit OMPOrderedDirective(unsigned NumClauses)
2091  : OMPExecutableDirective(this, OMPOrderedDirectiveClass, OMPD_ordered,
2092  SourceLocation(), SourceLocation(), NumClauses,
2093  1) {}
2094 
2095 public:
2096  /// Creates directive.
2097  ///
2098  /// \param C AST context.
2099  /// \param StartLoc Starting location of the directive kind.
2100  /// \param EndLoc Ending Location of the directive.
2101  /// \param Clauses List of clauses.
2102  /// \param AssociatedStmt Statement, associated with the directive.
2103  ///
2104  static OMPOrderedDirective *
2105  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2106  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2107 
2108  /// Creates an empty directive.
2109  ///
2110  /// \param C AST context.
2111  /// \param NumClauses Number of clauses.
2112  ///
2114  unsigned NumClauses, EmptyShell);
2115 
2116  static bool classof(const Stmt *T) {
2117  return T->getStmtClass() == OMPOrderedDirectiveClass;
2118  }
2119 };
2120 
2121 /// This represents '#pragma omp atomic' directive.
2122 ///
2123 /// \code
2124 /// #pragma omp atomic capture
2125 /// \endcode
2126 /// In this example directive '#pragma omp atomic' has clause 'capture'.
2127 ///
2129  friend class ASTStmtReader;
2130  /// Used for 'atomic update' or 'atomic capture' constructs. They may
2131  /// have atomic expressions of forms
2132  /// \code
2133  /// x = x binop expr;
2134  /// x = expr binop x;
2135  /// \endcode
2136  /// This field is true for the first form of the expression and false for the
2137  /// second. Required for correct codegen of non-associative operations (like
2138  /// << or >>).
2139  bool IsXLHSInRHSPart;
2140  /// Used for 'atomic update' or 'atomic capture' constructs. They may
2141  /// have atomic expressions of forms
2142  /// \code
2143  /// v = x; <update x>;
2144  /// <update x>; v = x;
2145  /// \endcode
2146  /// This field is true for the first(postfix) form of the expression and false
2147  /// otherwise.
2148  bool IsPostfixUpdate;
2149 
2150  /// Build directive with the given start and end location.
2151  ///
2152  /// \param StartLoc Starting location of the directive kind.
2153  /// \param EndLoc Ending location of the directive.
2154  /// \param NumClauses Number of clauses.
2155  ///
2157  unsigned NumClauses)
2158  : OMPExecutableDirective(this, OMPAtomicDirectiveClass, OMPD_atomic,
2159  StartLoc, EndLoc, NumClauses, 5),
2160  IsXLHSInRHSPart(false), IsPostfixUpdate(false) {}
2161 
2162  /// Build an empty directive.
2163  ///
2164  /// \param NumClauses Number of clauses.
2165  ///
2166  explicit OMPAtomicDirective(unsigned NumClauses)
2167  : OMPExecutableDirective(this, OMPAtomicDirectiveClass, OMPD_atomic,
2168  SourceLocation(), SourceLocation(), NumClauses,
2169  5),
2170  IsXLHSInRHSPart(false), IsPostfixUpdate(false) {}
2171 
2172  /// Set 'x' part of the associated expression/statement.
2173  void setX(Expr *X) { *std::next(child_begin()) = X; }
2174  /// Set helper expression of the form
2175  /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2176  /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2177  void setUpdateExpr(Expr *UE) { *std::next(child_begin(), 2) = UE; }
2178  /// Set 'v' part of the associated expression/statement.
2179  void setV(Expr *V) { *std::next(child_begin(), 3) = V; }
2180  /// Set 'expr' part of the associated expression/statement.
2181  void setExpr(Expr *E) { *std::next(child_begin(), 4) = E; }
2182 
2183 public:
2184  /// Creates directive with a list of \a Clauses and 'x', 'v' and 'expr'
2185  /// parts of the atomic construct (see Section 2.12.6, atomic Construct, for
2186  /// detailed description of 'x', 'v' and 'expr').
2187  ///
2188  /// \param C AST context.
2189  /// \param StartLoc Starting location of the directive kind.
2190  /// \param EndLoc Ending Location of the directive.
2191  /// \param Clauses List of clauses.
2192  /// \param AssociatedStmt Statement, associated with the directive.
2193  /// \param X 'x' part of the associated expression/statement.
2194  /// \param V 'v' part of the associated expression/statement.
2195  /// \param E 'expr' part of the associated expression/statement.
2196  /// \param UE Helper expression of the form
2197  /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2198  /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2199  /// \param IsXLHSInRHSPart true if \a UE has the first form and false if the
2200  /// second.
2201  /// \param IsPostfixUpdate true if original value of 'x' must be stored in
2202  /// 'v', not an updated one.
2203  static OMPAtomicDirective *
2204  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2205  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
2206  Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate);
2207 
2208  /// Creates an empty directive with the place for \a NumClauses
2209  /// clauses.
2210  ///
2211  /// \param C AST context.
2212  /// \param NumClauses Number of clauses.
2213  ///
2214  static OMPAtomicDirective *CreateEmpty(const ASTContext &C,
2215  unsigned NumClauses, EmptyShell);
2216 
2217  /// Get 'x' part of the associated expression/statement.
2218  Expr *getX() { return cast_or_null<Expr>(*std::next(child_begin())); }
2219  const Expr *getX() const {
2220  return cast_or_null<Expr>(*std::next(child_begin()));
2221  }
2222  /// Get helper expression of the form
2223  /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
2224  /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2226  return cast_or_null<Expr>(*std::next(child_begin(), 2));
2227  }
2228  const Expr *getUpdateExpr() const {
2229  return cast_or_null<Expr>(*std::next(child_begin(), 2));
2230  }
2231  /// Return true if helper update expression has form
2232  /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and false if it has form
2233  /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
2234  bool isXLHSInRHSPart() const { return IsXLHSInRHSPart; }
2235  /// Return true if 'v' expression must be updated to original value of
2236  /// 'x', false if 'v' must be updated to the new value of 'x'.
2237  bool isPostfixUpdate() const { return IsPostfixUpdate; }
2238  /// Get 'v' part of the associated expression/statement.
2239  Expr *getV() { return cast_or_null<Expr>(*std::next(child_begin(), 3)); }
2240  const Expr *getV() const {
2241  return cast_or_null<Expr>(*std::next(child_begin(), 3));
2242  }
2243  /// Get 'expr' part of the associated expression/statement.
2244  Expr *getExpr() { return cast_or_null<Expr>(*std::next(child_begin(), 4)); }
2245  const Expr *getExpr() const {
2246  return cast_or_null<Expr>(*std::next(child_begin(), 4));
2247  }
2248 
2249  static bool classof(const Stmt *T) {
2250  return T->getStmtClass() == OMPAtomicDirectiveClass;
2251  }
2252 };
2253 
2254 /// This represents '#pragma omp target' directive.
2255 ///
2256 /// \code
2257 /// #pragma omp target if(a)
2258 /// \endcode
2259 /// In this example directive '#pragma omp target' has clause 'if' with
2260 /// condition 'a'.
2261 ///
2263  friend class ASTStmtReader;
2264  /// Build directive with the given start and end location.
2265  ///
2266  /// \param StartLoc Starting location of the directive kind.
2267  /// \param EndLoc Ending location of the directive.
2268  /// \param NumClauses Number of clauses.
2269  ///
2271  unsigned NumClauses)
2272  : OMPExecutableDirective(this, OMPTargetDirectiveClass, OMPD_target,
2273  StartLoc, EndLoc, NumClauses, 1) {}
2274 
2275  /// Build an empty directive.
2276  ///
2277  /// \param NumClauses Number of clauses.
2278  ///
2279  explicit OMPTargetDirective(unsigned NumClauses)
2280  : OMPExecutableDirective(this, OMPTargetDirectiveClass, OMPD_target,
2281  SourceLocation(), SourceLocation(), NumClauses,
2282  1) {}
2283 
2284 public:
2285  /// Creates directive with a list of \a Clauses.
2286  ///
2287  /// \param C AST context.
2288  /// \param StartLoc Starting location of the directive kind.
2289  /// \param EndLoc Ending Location of the directive.
2290  /// \param Clauses List of clauses.
2291  /// \param AssociatedStmt Statement, associated with the directive.
2292  ///
2293  static OMPTargetDirective *
2294  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2295  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2296 
2297  /// Creates an empty directive with the place for \a NumClauses
2298  /// clauses.
2299  ///
2300  /// \param C AST context.
2301  /// \param NumClauses Number of clauses.
2302  ///
2303  static OMPTargetDirective *CreateEmpty(const ASTContext &C,
2304  unsigned NumClauses, EmptyShell);
2305 
2306  static bool classof(const Stmt *T) {
2307  return T->getStmtClass() == OMPTargetDirectiveClass;
2308  }
2309 };
2310 
2311 /// This represents '#pragma omp target data' directive.
2312 ///
2313 /// \code
2314 /// #pragma omp target data device(0) if(a) map(b[:])
2315 /// \endcode
2316 /// In this example directive '#pragma omp target data' has clauses 'device'
2317 /// with the value '0', 'if' with condition 'a' and 'map' with array
2318 /// section 'b[:]'.
2319 ///
2321  friend class ASTStmtReader;
2322  /// Build directive with the given start and end location.
2323  ///
2324  /// \param StartLoc Starting location of the directive kind.
2325  /// \param EndLoc Ending Location of the directive.
2326  /// \param NumClauses The number of clauses.
2327  ///
2329  unsigned NumClauses)
2330  : OMPExecutableDirective(this, OMPTargetDataDirectiveClass,
2331  OMPD_target_data, StartLoc, EndLoc, NumClauses,
2332  1) {}
2333 
2334  /// Build an empty directive.
2335  ///
2336  /// \param NumClauses Number of clauses.
2337  ///
2338  explicit OMPTargetDataDirective(unsigned NumClauses)
2339  : OMPExecutableDirective(this, OMPTargetDataDirectiveClass,
2340  OMPD_target_data, SourceLocation(),
2341  SourceLocation(), NumClauses, 1) {}
2342 
2343 public:
2344  /// Creates directive with a list of \a Clauses.
2345  ///
2346  /// \param C AST context.
2347  /// \param StartLoc Starting location of the directive kind.
2348  /// \param EndLoc Ending Location of the directive.
2349  /// \param Clauses List of clauses.
2350  /// \param AssociatedStmt Statement, associated with the directive.
2351  ///
2352  static OMPTargetDataDirective *
2353  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2354  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2355 
2356  /// Creates an empty directive with the place for \a N clauses.
2357  ///
2358  /// \param C AST context.
2359  /// \param N The number of clauses.
2360  ///
2361  static OMPTargetDataDirective *CreateEmpty(const ASTContext &C, unsigned N,
2362  EmptyShell);
2363 
2364  static bool classof(const Stmt *T) {
2365  return T->getStmtClass() == OMPTargetDataDirectiveClass;
2366  }
2367 };
2368 
2369 /// This represents '#pragma omp target enter data' directive.
2370 ///
2371 /// \code
2372 /// #pragma omp target enter data device(0) if(a) map(b[:])
2373 /// \endcode
2374 /// In this example directive '#pragma omp target enter data' has clauses
2375 /// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
2376 /// section 'b[:]'.
2377 ///
2379  friend class ASTStmtReader;
2380  /// Build directive with the given start and end location.
2381  ///
2382  /// \param StartLoc Starting location of the directive kind.
2383  /// \param EndLoc Ending Location of the directive.
2384  /// \param NumClauses The number of clauses.
2385  ///
2387  unsigned NumClauses)
2388  : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
2389  OMPD_target_enter_data, StartLoc, EndLoc,
2390  NumClauses, /*NumChildren=*/1) {}
2391 
2392  /// Build an empty directive.
2393  ///
2394  /// \param NumClauses Number of clauses.
2395  ///
2396  explicit OMPTargetEnterDataDirective(unsigned NumClauses)
2397  : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
2398  OMPD_target_enter_data, SourceLocation(),
2399  SourceLocation(), NumClauses,
2400  /*NumChildren=*/1) {}
2401 
2402 public:
2403  /// Creates directive with a list of \a Clauses.
2404  ///
2405  /// \param C AST context.
2406  /// \param StartLoc Starting location of the directive kind.
2407  /// \param EndLoc Ending Location of the directive.
2408  /// \param Clauses List of clauses.
2409  /// \param AssociatedStmt Statement, associated with the directive.
2410  ///
2412  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2413  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2414 
2415  /// Creates an empty directive with the place for \a N clauses.
2416  ///
2417  /// \param C AST context.
2418  /// \param N The number of clauses.
2419  ///
2421  unsigned N, EmptyShell);
2422 
2423  static bool classof(const Stmt *T) {
2424  return T->getStmtClass() == OMPTargetEnterDataDirectiveClass;
2425  }
2426 };
2427 
2428 /// This represents '#pragma omp target exit data' directive.
2429 ///
2430 /// \code
2431 /// #pragma omp target exit data device(0) if(a) map(b[:])
2432 /// \endcode
2433 /// In this example directive '#pragma omp target exit data' has clauses
2434 /// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
2435 /// section 'b[:]'.
2436 ///
2438  friend class ASTStmtReader;
2439  /// Build directive with the given start and end location.
2440  ///
2441  /// \param StartLoc Starting location of the directive kind.
2442  /// \param EndLoc Ending Location of the directive.
2443  /// \param NumClauses The number of clauses.
2444  ///
2446  unsigned NumClauses)
2447  : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
2448  OMPD_target_exit_data, StartLoc, EndLoc,
2449  NumClauses, /*NumChildren=*/1) {}
2450 
2451  /// Build an empty directive.
2452  ///
2453  /// \param NumClauses Number of clauses.
2454  ///
2455  explicit OMPTargetExitDataDirective(unsigned NumClauses)
2456  : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
2457  OMPD_target_exit_data, SourceLocation(),
2458  SourceLocation(), NumClauses,
2459  /*NumChildren=*/1) {}
2460 
2461 public:
2462  /// Creates directive with a list of \a Clauses.
2463  ///
2464  /// \param C AST context.
2465  /// \param StartLoc Starting location of the directive kind.
2466  /// \param EndLoc Ending Location of the directive.
2467  /// \param Clauses List of clauses.
2468  /// \param AssociatedStmt Statement, associated with the directive.
2469  ///
2471  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2472  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2473 
2474  /// Creates an empty directive with the place for \a N clauses.
2475  ///
2476  /// \param C AST context.
2477  /// \param N The number of clauses.
2478  ///
2480  unsigned N, EmptyShell);
2481 
2482  static bool classof(const Stmt *T) {
2483  return T->getStmtClass() == OMPTargetExitDataDirectiveClass;
2484  }
2485 };
2486 
2487 /// This represents '#pragma omp target parallel' directive.
2488 ///
2489 /// \code
2490 /// #pragma omp target parallel if(a)
2491 /// \endcode
2492 /// In this example directive '#pragma omp target parallel' has clause 'if' with
2493 /// condition 'a'.
2494 ///
2496  friend class ASTStmtReader;
2497  /// Build directive with the given start and end location.
2498  ///
2499  /// \param StartLoc Starting location of the directive kind.
2500  /// \param EndLoc Ending location of the directive.
2501  /// \param NumClauses Number of clauses.
2502  ///
2504  unsigned NumClauses)
2505  : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass,
2506  OMPD_target_parallel, StartLoc, EndLoc,
2507  NumClauses, /*NumChildren=*/1) {}
2508 
2509  /// Build an empty directive.
2510  ///
2511  /// \param NumClauses Number of clauses.
2512  ///
2513  explicit OMPTargetParallelDirective(unsigned NumClauses)
2514  : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass,
2515  OMPD_target_parallel, SourceLocation(),
2516  SourceLocation(), NumClauses,
2517  /*NumChildren=*/1) {}
2518 
2519 public:
2520  /// Creates directive with a list of \a Clauses.
2521  ///
2522  /// \param C AST context.
2523  /// \param StartLoc Starting location of the directive kind.
2524  /// \param EndLoc Ending Location of the directive.
2525  /// \param Clauses List of clauses.
2526  /// \param AssociatedStmt Statement, associated with the directive.
2527  ///
2529  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2530  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2531 
2532  /// Creates an empty directive with the place for \a NumClauses
2533  /// clauses.
2534  ///
2535  /// \param C AST context.
2536  /// \param NumClauses Number of clauses.
2537  ///
2539  CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
2540 
2541  static bool classof(const Stmt *T) {
2542  return T->getStmtClass() == OMPTargetParallelDirectiveClass;
2543  }
2544 };
2545 
2546 /// This represents '#pragma omp target parallel for' directive.
2547 ///
2548 /// \code
2549 /// #pragma omp target parallel for private(a,b) reduction(+:c,d)
2550 /// \endcode
2551 /// In this example directive '#pragma omp target parallel for' has clauses
2552 /// 'private' with the variables 'a' and 'b' and 'reduction' with operator '+'
2553 /// and variables 'c' and 'd'.
2554 ///
2556  friend class ASTStmtReader;
2557 
2558  /// true if current region has inner cancel directive.
2559  bool HasCancel;
2560 
2561  /// Build directive with the given start and end location.
2562  ///
2563  /// \param StartLoc Starting location of the directive kind.
2564  /// \param EndLoc Ending location of the directive.
2565  /// \param CollapsedNum Number of collapsed nested loops.
2566  /// \param NumClauses Number of clauses.
2567  ///
2569  unsigned CollapsedNum, unsigned NumClauses)
2570  : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass,
2571  OMPD_target_parallel_for, StartLoc, EndLoc,
2572  CollapsedNum, NumClauses),
2573  HasCancel(false) {}
2574 
2575  /// Build an empty directive.
2576  ///
2577  /// \param CollapsedNum Number of collapsed nested loops.
2578  /// \param NumClauses Number of clauses.
2579  ///
2580  explicit OMPTargetParallelForDirective(unsigned CollapsedNum,
2581  unsigned NumClauses)
2582  : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass,
2583  OMPD_target_parallel_for, SourceLocation(),
2584  SourceLocation(), CollapsedNum, NumClauses),
2585  HasCancel(false) {}
2586 
2587  /// Set cancel state.
2588  void setHasCancel(bool Has) { HasCancel = Has; }
2589 
2590 public:
2591  /// Creates directive with a list of \a Clauses.
2592  ///
2593  /// \param C AST context.
2594  /// \param StartLoc Starting location of the directive kind.
2595  /// \param EndLoc Ending Location of the directive.
2596  /// \param CollapsedNum Number of collapsed loops.
2597  /// \param Clauses List of clauses.
2598  /// \param AssociatedStmt Statement, associated with the directive.
2599  /// \param Exprs Helper expressions for CodeGen.
2600  /// \param HasCancel true if current directive has inner cancel directive.
2601  ///
2603  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2604  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2605  Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
2606 
2607  /// Creates an empty directive with the place
2608  /// for \a NumClauses clauses.
2609  ///
2610  /// \param C AST context.
2611  /// \param CollapsedNum Number of collapsed nested loops.
2612  /// \param NumClauses Number of clauses.
2613  ///
2615  unsigned NumClauses,
2616  unsigned CollapsedNum,
2617  EmptyShell);
2618 
2619  /// Return true if current directive has inner cancel directive.
2620  bool hasCancel() const { return HasCancel; }
2621 
2622  static bool classof(const Stmt *T) {
2623  return T->getStmtClass() == OMPTargetParallelForDirectiveClass;
2624  }
2625 };
2626 
2627 /// This represents '#pragma omp teams' directive.
2628 ///
2629 /// \code
2630 /// #pragma omp teams if(a)
2631 /// \endcode
2632 /// In this example directive '#pragma omp teams' has clause 'if' with
2633 /// condition 'a'.
2634 ///
2636  friend class ASTStmtReader;
2637  /// Build directive with the given start and end location.
2638  ///
2639  /// \param StartLoc Starting location of the directive kind.
2640  /// \param EndLoc Ending location of the directive.
2641  /// \param NumClauses Number of clauses.
2642  ///
2644  unsigned NumClauses)
2645  : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
2646  StartLoc, EndLoc, NumClauses, 1) {}
2647 
2648  /// Build an empty directive.
2649  ///
2650  /// \param NumClauses Number of clauses.
2651  ///
2652  explicit OMPTeamsDirective(unsigned NumClauses)
2653  : OMPExecutableDirective(this, OMPTeamsDirectiveClass, OMPD_teams,
2654  SourceLocation(), SourceLocation(), NumClauses,
2655  1) {}
2656 
2657 public:
2658  /// Creates directive with a list of \a Clauses.
2659  ///
2660  /// \param C AST context.
2661  /// \param StartLoc Starting location of the directive kind.
2662  /// \param EndLoc Ending Location of the directive.
2663  /// \param Clauses List of clauses.
2664  /// \param AssociatedStmt Statement, associated with the directive.
2665  ///
2666  static OMPTeamsDirective *Create(const ASTContext &C, SourceLocation StartLoc,
2667  SourceLocation EndLoc,
2668  ArrayRef<OMPClause *> Clauses,
2669  Stmt *AssociatedStmt);
2670 
2671  /// Creates an empty directive with the place for \a NumClauses
2672  /// clauses.
2673  ///
2674  /// \param C AST context.
2675  /// \param NumClauses Number of clauses.
2676  ///
2677  static OMPTeamsDirective *CreateEmpty(const ASTContext &C,
2678  unsigned NumClauses, EmptyShell);
2679 
2680  static bool classof(const Stmt *T) {
2681  return T->getStmtClass() == OMPTeamsDirectiveClass;
2682  }
2683 };
2684 
2685 /// This represents '#pragma omp cancellation point' directive.
2686 ///
2687 /// \code
2688 /// #pragma omp cancellation point for
2689 /// \endcode
2690 ///
2691 /// In this example a cancellation point is created for innermost 'for' region.
2693  friend class ASTStmtReader;
2694  OpenMPDirectiveKind CancelRegion;
2695  /// Build directive with the given start and end location.
2696  ///
2697  /// \param StartLoc Starting location of the directive kind.
2698  /// \param EndLoc Ending location of the directive.
2699  ///
2701  : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass,
2702  OMPD_cancellation_point, StartLoc, EndLoc, 0, 0),
2703  CancelRegion(OMPD_unknown) {}
2704 
2705  /// Build an empty directive.
2706  ///
2708  : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass,
2709  OMPD_cancellation_point, SourceLocation(),
2710  SourceLocation(), 0, 0),
2711  CancelRegion(OMPD_unknown) {}
2712 
2713  /// Set cancel region for current cancellation point.
2714  /// \param CR Cancellation region.
2715  void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; }
2716 
2717 public:
2718  /// Creates directive.
2719  ///
2720  /// \param C AST context.
2721  /// \param StartLoc Starting location of the directive kind.
2722  /// \param EndLoc Ending Location of the directive.
2723  ///
2725  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2726  OpenMPDirectiveKind CancelRegion);
2727 
2728  /// Creates an empty directive.
2729  ///
2730  /// \param C AST context.
2731  ///
2733  EmptyShell);
2734 
2735  /// Get cancellation region for the current cancellation point.
2736  OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; }
2737 
2738  static bool classof(const Stmt *T) {
2739  return T->getStmtClass() == OMPCancellationPointDirectiveClass;
2740  }
2741 };
2742 
2743 /// This represents '#pragma omp cancel' directive.
2744 ///
2745 /// \code
2746 /// #pragma omp cancel for
2747 /// \endcode
2748 ///
2749 /// In this example a cancel is created for innermost 'for' region.
2751  friend class ASTStmtReader;
2752  OpenMPDirectiveKind CancelRegion;
2753  /// Build directive with the given start and end location.
2754  ///
2755  /// \param StartLoc Starting location of the directive kind.
2756  /// \param EndLoc Ending location of the directive.
2757  /// \param NumClauses Number of clauses.
2758  ///
2760  unsigned NumClauses)
2761  : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
2762  StartLoc, EndLoc, NumClauses, 0),
2763  CancelRegion(OMPD_unknown) {}
2764 
2765  /// Build an empty directive.
2766  ///
2767  /// \param NumClauses Number of clauses.
2768  explicit OMPCancelDirective(unsigned NumClauses)
2769  : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
2770  SourceLocation(), SourceLocation(), NumClauses,
2771  0),
2772  CancelRegion(OMPD_unknown) {}
2773 
2774  /// Set cancel region for current cancellation point.
2775  /// \param CR Cancellation region.
2776  void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; }
2777 
2778 public:
2779  /// Creates directive.
2780  ///
2781  /// \param C AST context.
2782  /// \param StartLoc Starting location of the directive kind.
2783  /// \param EndLoc Ending Location of the directive.
2784  /// \param Clauses List of clauses.
2785  ///
2786  static OMPCancelDirective *
2787  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2788  ArrayRef<OMPClause *> Clauses, OpenMPDirectiveKind CancelRegion);
2789 
2790  /// Creates an empty directive.
2791  ///
2792  /// \param C AST context.
2793  /// \param NumClauses Number of clauses.
2794  ///
2795  static OMPCancelDirective *CreateEmpty(const ASTContext &C,
2796  unsigned NumClauses, EmptyShell);
2797 
2798  /// Get cancellation region for the current cancellation point.
2799  OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; }
2800 
2801  static bool classof(const Stmt *T) {
2802  return T->getStmtClass() == OMPCancelDirectiveClass;
2803  }
2804 };
2805 
2806 /// This represents '#pragma omp taskloop' directive.
2807 ///
2808 /// \code
2809 /// #pragma omp taskloop private(a,b) grainsize(val) num_tasks(num)
2810 /// \endcode
2811 /// In this example directive '#pragma omp taskloop' has clauses 'private'
2812 /// with the variables 'a' and 'b', 'grainsize' with expression 'val' and
2813 /// 'num_tasks' with expression 'num'.
2814 ///
2816  friend class ASTStmtReader;
2817  /// Build directive with the given start and end location.
2818  ///
2819  /// \param StartLoc Starting location of the directive kind.
2820  /// \param EndLoc Ending location of the directive.
2821  /// \param CollapsedNum Number of collapsed nested loops.
2822  /// \param NumClauses Number of clauses.
2823  ///
2825  unsigned CollapsedNum, unsigned NumClauses)
2826  : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, OMPD_taskloop,
2827  StartLoc, EndLoc, CollapsedNum, NumClauses) {}
2828 
2829  /// Build an empty directive.
2830  ///
2831  /// \param CollapsedNum Number of collapsed nested loops.
2832  /// \param NumClauses Number of clauses.
2833  ///
2834  explicit OMPTaskLoopDirective(unsigned CollapsedNum, unsigned NumClauses)
2835  : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, OMPD_taskloop,
2836  SourceLocation(), SourceLocation(), CollapsedNum,
2837  NumClauses) {}
2838 
2839 public:
2840  /// Creates directive with a list of \a Clauses.
2841  ///
2842  /// \param C AST context.
2843  /// \param StartLoc Starting location of the directive kind.
2844  /// \param EndLoc Ending Location of the directive.
2845  /// \param CollapsedNum Number of collapsed loops.
2846  /// \param Clauses List of clauses.
2847  /// \param AssociatedStmt Statement, associated with the directive.
2848  /// \param Exprs Helper expressions for CodeGen.
2849  ///
2850  static OMPTaskLoopDirective *
2851  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2852  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2853  Stmt *AssociatedStmt, const HelperExprs &Exprs);
2854 
2855  /// Creates an empty directive with the place
2856  /// for \a NumClauses clauses.
2857  ///
2858  /// \param C AST context.
2859  /// \param CollapsedNum Number of collapsed nested loops.
2860  /// \param NumClauses Number of clauses.
2861  ///
2863  unsigned NumClauses,
2864  unsigned CollapsedNum, EmptyShell);
2865 
2866  static bool classof(const Stmt *T) {
2867  return T->getStmtClass() == OMPTaskLoopDirectiveClass;
2868  }
2869 };
2870 
2871 /// This represents '#pragma omp taskloop simd' directive.
2872 ///
2873 /// \code
2874 /// #pragma omp taskloop simd private(a,b) grainsize(val) num_tasks(num)
2875 /// \endcode
2876 /// In this example directive '#pragma omp taskloop simd' has clauses 'private'
2877 /// with the variables 'a' and 'b', 'grainsize' with expression 'val' and
2878 /// 'num_tasks' with expression 'num'.
2879 ///
2881  friend class ASTStmtReader;
2882  /// Build directive with the given start and end location.
2883  ///
2884  /// \param StartLoc Starting location of the directive kind.
2885  /// \param EndLoc Ending location of the directive.
2886  /// \param CollapsedNum Number of collapsed nested loops.
2887  /// \param NumClauses Number of clauses.
2888  ///
2890  unsigned CollapsedNum, unsigned NumClauses)
2891  : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass,
2892  OMPD_taskloop_simd, StartLoc, EndLoc, CollapsedNum,
2893  NumClauses) {}
2894 
2895  /// Build an empty directive.
2896  ///
2897  /// \param CollapsedNum Number of collapsed nested loops.
2898  /// \param NumClauses Number of clauses.
2899  ///
2900  explicit OMPTaskLoopSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
2901  : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass,
2902  OMPD_taskloop_simd, SourceLocation(), SourceLocation(),
2903  CollapsedNum, NumClauses) {}
2904 
2905 public:
2906  /// Creates directive with a list of \a Clauses.
2907  ///
2908  /// \param C AST context.
2909  /// \param StartLoc Starting location of the directive kind.
2910  /// \param EndLoc Ending Location of the directive.
2911  /// \param CollapsedNum Number of collapsed loops.
2912  /// \param Clauses List of clauses.
2913  /// \param AssociatedStmt Statement, associated with the directive.
2914  /// \param Exprs Helper expressions for CodeGen.
2915  ///
2916  static OMPTaskLoopSimdDirective *
2917  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2918  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2919  Stmt *AssociatedStmt, const HelperExprs &Exprs);
2920 
2921  /// Creates an empty directive with the place
2922  /// for \a NumClauses clauses.
2923  ///
2924  /// \param C AST context.
2925  /// \param CollapsedNum Number of collapsed nested loops.
2926  /// \param NumClauses Number of clauses.
2927  ///
2929  unsigned NumClauses,
2930  unsigned CollapsedNum,
2931  EmptyShell);
2932 
2933  static bool classof(const Stmt *T) {
2934  return T->getStmtClass() == OMPTaskLoopSimdDirectiveClass;
2935  }
2936 };
2937 
2938 /// This represents '#pragma omp distribute' directive.
2939 ///
2940 /// \code
2941 /// #pragma omp distribute private(a,b)
2942 /// \endcode
2943 /// In this example directive '#pragma omp distribute' has clauses 'private'
2944 /// with the variables 'a' and 'b'
2945 ///
2947  friend class ASTStmtReader;
2948 
2949  /// Build directive with the given start and end location.
2950  ///
2951  /// \param StartLoc Starting location of the directive kind.
2952  /// \param EndLoc Ending location of the directive.
2953  /// \param CollapsedNum Number of collapsed nested loops.
2954  /// \param NumClauses Number of clauses.
2955  ///
2957  unsigned CollapsedNum, unsigned NumClauses)
2958  : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,
2959  StartLoc, EndLoc, CollapsedNum, NumClauses)
2960  {}
2961 
2962  /// Build an empty directive.
2963  ///
2964  /// \param CollapsedNum Number of collapsed nested loops.
2965  /// \param NumClauses Number of clauses.
2966  ///
2967  explicit OMPDistributeDirective(unsigned CollapsedNum, unsigned NumClauses)
2968  : OMPLoopDirective(this, OMPDistributeDirectiveClass, OMPD_distribute,
2969  SourceLocation(), SourceLocation(), CollapsedNum,
2970  NumClauses)
2971  {}
2972 
2973 public:
2974  /// Creates directive with a list of \a Clauses.
2975  ///
2976  /// \param C AST context.
2977  /// \param StartLoc Starting location of the directive kind.
2978  /// \param EndLoc Ending Location of the directive.
2979  /// \param CollapsedNum Number of collapsed loops.
2980  /// \param Clauses List of clauses.
2981  /// \param AssociatedStmt Statement, associated with the directive.
2982  /// \param Exprs Helper expressions for CodeGen.
2983  ///
2984  static OMPDistributeDirective *
2985  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2986  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2987  Stmt *AssociatedStmt, const HelperExprs &Exprs);
2988 
2989  /// Creates an empty directive with the place
2990  /// for \a NumClauses clauses.
2991  ///
2992  /// \param C AST context.
2993  /// \param CollapsedNum Number of collapsed nested loops.
2994  /// \param NumClauses Number of clauses.
2995  ///
2997  unsigned NumClauses,
2998  unsigned CollapsedNum, EmptyShell);
2999 
3000  static bool classof(const Stmt *T) {
3001  return T->getStmtClass() == OMPDistributeDirectiveClass;
3002  }
3003 };
3004 
3005 /// This represents '#pragma omp target update' directive.
3006 ///
3007 /// \code
3008 /// #pragma omp target update to(a) from(b) device(1)
3009 /// \endcode
3010 /// In this example directive '#pragma omp target update' has clause 'to' with
3011 /// argument 'a', clause 'from' with argument 'b' and clause 'device' with
3012 /// argument '1'.
3013 ///
3015  friend class ASTStmtReader;
3016  /// Build directive with the given start and end location.
3017  ///
3018  /// \param StartLoc Starting location of the directive kind.
3019  /// \param EndLoc Ending Location of the directive.
3020  /// \param NumClauses The number of clauses.
3021  ///
3023  unsigned NumClauses)
3024  : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass,
3025  OMPD_target_update, StartLoc, EndLoc, NumClauses,
3026  1) {}
3027 
3028  /// Build an empty directive.
3029  ///
3030  /// \param NumClauses Number of clauses.
3031  ///
3032  explicit OMPTargetUpdateDirective(unsigned NumClauses)
3033  : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass,
3034  OMPD_target_update, SourceLocation(),
3035  SourceLocation(), NumClauses, 1) {}
3036 
3037 public:
3038  /// Creates directive with a list of \a Clauses.
3039  ///
3040  /// \param C AST context.
3041  /// \param StartLoc Starting location of the directive kind.
3042  /// \param EndLoc Ending Location of the directive.
3043  /// \param Clauses List of clauses.
3044  /// \param AssociatedStmt Statement, associated with the directive.
3045  ///
3046  static OMPTargetUpdateDirective *
3047  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3048  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
3049 
3050  /// Creates an empty directive with the place for \a NumClauses
3051  /// clauses.
3052  ///
3053  /// \param C AST context.
3054  /// \param NumClauses The number of clauses.
3055  ///
3057  unsigned NumClauses, EmptyShell);
3058 
3059  static bool classof(const Stmt *T) {
3060  return T->getStmtClass() == OMPTargetUpdateDirectiveClass;
3061  }
3062 };
3063 
3064 /// This represents '#pragma omp distribute parallel for' composite
3065 /// directive.
3066 ///
3067 /// \code
3068 /// #pragma omp distribute parallel for private(a,b)
3069 /// \endcode
3070 /// In this example directive '#pragma omp distribute parallel for' has clause
3071 /// 'private' with the variables 'a' and 'b'
3072 ///
3074  friend class ASTStmtReader;
3075  /// true if the construct has inner cancel directive.
3076  bool HasCancel = false;
3077 
3078  /// Build directive with the given start and end location.
3079  ///
3080  /// \param StartLoc Starting location of the directive kind.
3081  /// \param EndLoc Ending location of the directive.
3082  /// \param CollapsedNum Number of collapsed nested loops.
3083  /// \param NumClauses Number of clauses.
3084  ///
3086  SourceLocation EndLoc,
3087  unsigned CollapsedNum, unsigned NumClauses)
3088  : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
3089  OMPD_distribute_parallel_for, StartLoc, EndLoc,
3090  CollapsedNum, NumClauses), HasCancel(false) {}
3091 
3092  /// Build an empty directive.
3093  ///
3094  /// \param CollapsedNum Number of collapsed nested loops.
3095  /// \param NumClauses Number of clauses.
3096  ///
3097  explicit OMPDistributeParallelForDirective(unsigned CollapsedNum,
3098  unsigned NumClauses)
3099  : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
3100  OMPD_distribute_parallel_for, SourceLocation(),
3101  SourceLocation(), CollapsedNum, NumClauses),
3102  HasCancel(false) {}
3103 
3104  /// Set cancel state.
3105  void setHasCancel(bool Has) { HasCancel = Has; }
3106 
3107 public:
3108  /// Creates directive with a list of \a Clauses.
3109  ///
3110  /// \param C AST context.
3111  /// \param StartLoc Starting location of the directive kind.
3112  /// \param EndLoc Ending Location of the directive.
3113  /// \param CollapsedNum Number of collapsed loops.
3114  /// \param Clauses List of clauses.
3115  /// \param AssociatedStmt Statement, associated with the directive.
3116  /// \param Exprs Helper expressions for CodeGen.
3117  /// \param HasCancel true if this directive has inner cancel directive.
3118  ///
3120  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3121  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3122  Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
3123 
3124  /// Creates an empty directive with the place
3125  /// for \a NumClauses clauses.
3126  ///
3127  /// \param C AST context.
3128  /// \param CollapsedNum Number of collapsed nested loops.
3129  /// \param NumClauses Number of clauses.
3130  ///
3132  unsigned NumClauses,
3133  unsigned CollapsedNum,
3134  EmptyShell);
3135 
3136  /// Return true if current directive has inner cancel directive.
3137  bool hasCancel() const { return HasCancel; }
3138 
3139  static bool classof(const Stmt *T) {
3140  return T->getStmtClass() == OMPDistributeParallelForDirectiveClass;
3141  }
3142 };
3143 
3144 /// This represents '#pragma omp distribute parallel for simd' composite
3145 /// directive.
3146 ///
3147 /// \code
3148 /// #pragma omp distribute parallel for simd private(x)
3149 /// \endcode
3150 /// In this example directive '#pragma omp distribute parallel for simd' has
3151 /// clause 'private' with the variables 'x'
3152 ///
3154  friend class ASTStmtReader;
3155 
3156  /// Build directive with the given start and end location.
3157  ///
3158  /// \param StartLoc Starting location of the directive kind.
3159  /// \param EndLoc Ending location of the directive.
3160  /// \param CollapsedNum Number of collapsed nested loops.
3161  /// \param NumClauses Number of clauses.
3162  ///
3164  SourceLocation EndLoc,
3165  unsigned CollapsedNum,
3166  unsigned NumClauses)
3167  : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass,
3168  OMPD_distribute_parallel_for_simd, StartLoc,
3169  EndLoc, CollapsedNum, NumClauses) {}
3170 
3171  /// Build an empty directive.
3172  ///
3173  /// \param CollapsedNum Number of collapsed nested loops.
3174  /// \param NumClauses Number of clauses.
3175  ///
3176  explicit OMPDistributeParallelForSimdDirective(unsigned CollapsedNum,
3177  unsigned NumClauses)
3178  : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass,
3179  OMPD_distribute_parallel_for_simd,
3180  SourceLocation(), SourceLocation(), CollapsedNum,
3181  NumClauses) {}
3182 
3183 public:
3184  /// Creates directive with a list of \a Clauses.
3185  ///
3186  /// \param C AST context.
3187  /// \param StartLoc Starting location of the directive kind.
3188  /// \param EndLoc Ending Location of the directive.
3189  /// \param CollapsedNum Number of collapsed loops.
3190  /// \param Clauses List of clauses.
3191  /// \param AssociatedStmt Statement, associated with the directive.
3192  /// \param Exprs Helper expressions for CodeGen.
3193  ///
3195  const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3196  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3197  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3198 
3199  /// Creates an empty directive with the place for \a NumClauses clauses.
3200  ///
3201  /// \param C AST context.
3202  /// \param CollapsedNum Number of collapsed nested loops.
3203  /// \param NumClauses Number of clauses.
3204  ///
3206  const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3207  EmptyShell);
3208 
3209  static bool classof(const Stmt *T) {
3210  return T->getStmtClass() == OMPDistributeParallelForSimdDirectiveClass;
3211  }
3212 };
3213 
3214 /// This represents '#pragma omp distribute simd' composite directive.
3215 ///
3216 /// \code
3217 /// #pragma omp distribute simd private(x)
3218 /// \endcode
3219 /// In this example directive '#pragma omp distribute simd' has clause
3220 /// 'private' with the variables 'x'
3221 ///
3223  friend class ASTStmtReader;
3224 
3225  /// Build directive with the given start and end location.
3226  ///
3227  /// \param StartLoc Starting location of the directive kind.
3228  /// \param EndLoc Ending location of the directive.
3229  /// \param CollapsedNum Number of collapsed nested loops.
3230  /// \param NumClauses Number of clauses.
3231  ///
3233  unsigned CollapsedNum, unsigned NumClauses)
3234  : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass,
3235  OMPD_distribute_simd, StartLoc, EndLoc, CollapsedNum,
3236  NumClauses) {}
3237 
3238  /// Build an empty directive.
3239  ///
3240  /// \param CollapsedNum Number of collapsed nested loops.
3241  /// \param NumClauses Number of clauses.
3242  ///
3243  explicit OMPDistributeSimdDirective(unsigned CollapsedNum,
3244  unsigned NumClauses)
3245  : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass,
3246  OMPD_distribute_simd, SourceLocation(),
3247  SourceLocation(), CollapsedNum, NumClauses) {}
3248 
3249 public:
3250  /// Creates directive with a list of \a Clauses.
3251  ///
3252  /// \param C AST context.
3253  /// \param StartLoc Starting location of the directive kind.
3254  /// \param EndLoc Ending Location of the directive.
3255  /// \param CollapsedNum Number of collapsed loops.
3256  /// \param Clauses List of clauses.
3257  /// \param AssociatedStmt Statement, associated with the directive.
3258  /// \param Exprs Helper expressions for CodeGen.
3259  ///
3261  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3262  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3263  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3264 
3265  /// Creates an empty directive with the place for \a NumClauses clauses.
3266  ///
3267  /// \param C AST context.
3268  /// \param CollapsedNum Number of collapsed nested loops.
3269  /// \param NumClauses Number of clauses.
3270  ///
3272  unsigned NumClauses,
3273  unsigned CollapsedNum,
3274  EmptyShell);
3275 
3276  static bool classof(const Stmt *T) {
3277  return T->getStmtClass() == OMPDistributeSimdDirectiveClass;
3278  }
3279 };
3280 
3281 /// This represents '#pragma omp target parallel for simd' directive.
3282 ///
3283 /// \code
3284 /// #pragma omp target parallel for simd private(a) map(b) safelen(c)
3285 /// \endcode
3286 /// In this example directive '#pragma omp target parallel for simd' has clauses
3287 /// 'private' with the variable 'a', 'map' with the variable 'b' and 'safelen'
3288 /// with the variable 'c'.
3289 ///
3291  friend class ASTStmtReader;
3292 
3293  /// Build directive with the given start and end location.
3294  ///
3295  /// \param StartLoc Starting location of the directive kind.
3296  /// \param EndLoc Ending location of the directive.
3297  /// \param CollapsedNum Number of collapsed nested loops.
3298  /// \param NumClauses Number of clauses.
3299  ///
3301  unsigned CollapsedNum, unsigned NumClauses)
3302  : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass,
3303  OMPD_target_parallel_for_simd, StartLoc, EndLoc,
3304  CollapsedNum, NumClauses) {}
3305 
3306  /// Build an empty directive.
3307  ///
3308  /// \param CollapsedNum Number of collapsed nested loops.
3309  /// \param NumClauses Number of clauses.
3310  ///
3311  explicit OMPTargetParallelForSimdDirective(unsigned CollapsedNum,
3312  unsigned NumClauses)
3313  : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass,
3314  OMPD_target_parallel_for_simd, SourceLocation(),
3315  SourceLocation(), CollapsedNum, NumClauses) {}
3316 
3317 public:
3318  /// Creates directive with a list of \a Clauses.
3319  ///
3320  /// \param C AST context.
3321  /// \param StartLoc Starting location of the directive kind.
3322  /// \param EndLoc Ending Location of the directive.
3323  /// \param CollapsedNum Number of collapsed loops.
3324  /// \param Clauses List of clauses.
3325  /// \param AssociatedStmt Statement, associated with the directive.
3326  /// \param Exprs Helper expressions for CodeGen.
3327  ///
3329  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3330  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3331  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3332 
3333  /// Creates an empty directive with the place for \a NumClauses clauses.
3334  ///
3335  /// \param C AST context.
3336  /// \param CollapsedNum Number of collapsed nested loops.
3337  /// \param NumClauses Number of clauses.
3338  ///
3340  unsigned NumClauses,
3341  unsigned CollapsedNum,
3342  EmptyShell);
3343 
3344  static bool classof(const Stmt *T) {
3345  return T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass;
3346  }
3347 };
3348 
3349 /// This represents '#pragma omp target simd' directive.
3350 ///
3351 /// \code
3352 /// #pragma omp target simd private(a) map(b) safelen(c)
3353 /// \endcode
3354 /// In this example directive '#pragma omp target simd' has clauses 'private'
3355 /// with the variable 'a', 'map' with the variable 'b' and 'safelen' with
3356 /// the variable 'c'.
3357 ///
3359  friend class ASTStmtReader;
3360 
3361  /// Build directive with the given start and end location.
3362  ///
3363  /// \param StartLoc Starting location of the directive kind.
3364  /// \param EndLoc Ending location of the directive.
3365  /// \param CollapsedNum Number of collapsed nested loops.
3366  /// \param NumClauses Number of clauses.
3367  ///
3369  unsigned CollapsedNum, unsigned NumClauses)
3370  : OMPLoopDirective(this, OMPTargetSimdDirectiveClass,
3371  OMPD_target_simd, StartLoc, EndLoc, CollapsedNum,
3372  NumClauses) {}
3373 
3374  /// Build an empty directive.
3375  ///
3376  /// \param CollapsedNum Number of collapsed nested loops.
3377  /// \param NumClauses Number of clauses.
3378  ///
3379  explicit OMPTargetSimdDirective(unsigned CollapsedNum, unsigned NumClauses)
3380  : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, OMPD_target_simd,
3381  SourceLocation(),SourceLocation(), CollapsedNum,
3382  NumClauses) {}
3383 
3384 public:
3385  /// Creates directive with a list of \a Clauses.
3386  ///
3387  /// \param C AST context.
3388  /// \param StartLoc Starting location of the directive kind.
3389  /// \param EndLoc Ending Location of the directive.
3390  /// \param CollapsedNum Number of collapsed loops.
3391  /// \param Clauses List of clauses.
3392  /// \param AssociatedStmt Statement, associated with the directive.
3393  /// \param Exprs Helper expressions for CodeGen.
3394  ///
3395  static OMPTargetSimdDirective *
3396  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3397  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3398  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3399 
3400  /// Creates an empty directive with the place for \a NumClauses clauses.
3401  ///
3402  /// \param C AST context.
3403  /// \param CollapsedNum Number of collapsed nested loops.
3404  /// \param NumClauses Number of clauses.
3405  ///
3407  unsigned NumClauses,
3408  unsigned CollapsedNum,
3409  EmptyShell);
3410 
3411  static bool classof(const Stmt *T) {
3412  return T->getStmtClass() == OMPTargetSimdDirectiveClass;
3413  }
3414 };
3415 
3416 /// This represents '#pragma omp teams distribute' directive.
3417 ///
3418 /// \code
3419 /// #pragma omp teams distribute private(a,b)
3420 /// \endcode
3421 /// In this example directive '#pragma omp teams distribute' has clauses
3422 /// 'private' with the variables 'a' and 'b'
3423 ///
3425  friend class ASTStmtReader;
3426 
3427  /// Build directive with the given start and end location.
3428  ///
3429  /// \param StartLoc Starting location of the directive kind.
3430  /// \param EndLoc Ending location of the directive.
3431  /// \param CollapsedNum Number of collapsed nested loops.
3432  /// \param NumClauses Number of clauses.
3433  ///
3435  unsigned CollapsedNum, unsigned NumClauses)
3436  : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass,
3437  OMPD_teams_distribute, StartLoc, EndLoc,
3438  CollapsedNum, NumClauses) {}
3439 
3440  /// Build an empty directive.
3441  ///
3442  /// \param CollapsedNum Number of collapsed nested loops.
3443  /// \param NumClauses Number of clauses.
3444  ///
3445  explicit OMPTeamsDistributeDirective(unsigned CollapsedNum,
3446  unsigned NumClauses)
3447  : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass,
3448  OMPD_teams_distribute, SourceLocation(),
3449  SourceLocation(), CollapsedNum, NumClauses) {}
3450 
3451 public:
3452  /// Creates directive with a list of \a Clauses.
3453  ///
3454  /// \param C AST context.
3455  /// \param StartLoc Starting location of the directive kind.
3456  /// \param EndLoc Ending Location of the directive.
3457  /// \param CollapsedNum Number of collapsed loops.
3458  /// \param Clauses List of clauses.
3459  /// \param AssociatedStmt Statement, associated with the directive.
3460  /// \param Exprs Helper expressions for CodeGen.
3461  ///
3463  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3464  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3465  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3466 
3467  /// Creates an empty directive with the place for \a NumClauses clauses.
3468  ///
3469  /// \param C AST context.
3470  /// \param CollapsedNum Number of collapsed nested loops.
3471  /// \param NumClauses Number of clauses.
3472  ///
3474  unsigned NumClauses,
3475  unsigned CollapsedNum,
3476  EmptyShell);
3477 
3478  static bool classof(const Stmt *T) {
3479  return T->getStmtClass() == OMPTeamsDistributeDirectiveClass;
3480  }
3481 };
3482 
3483 /// This represents '#pragma omp teams distribute simd'
3484 /// combined directive.
3485 ///
3486 /// \code
3487 /// #pragma omp teams distribute simd private(a,b)
3488 /// \endcode
3489 /// In this example directive '#pragma omp teams distribute simd'
3490 /// has clause 'private' with the variables 'a' and 'b'
3491 ///
3493  friend class ASTStmtReader;
3494 
3495  /// Build directive with the given start and end location.
3496  ///
3497  /// \param StartLoc Starting location of the directive kind.
3498  /// \param EndLoc Ending location of the directive.
3499  /// \param CollapsedNum Number of collapsed nested loops.
3500  /// \param NumClauses Number of clauses.
3501  ///
3503  SourceLocation EndLoc, unsigned CollapsedNum,
3504  unsigned NumClauses)
3505  : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass,
3506  OMPD_teams_distribute_simd, StartLoc, EndLoc,
3507  CollapsedNum, NumClauses) {}
3508 
3509  /// Build an empty directive.
3510  ///
3511  /// \param CollapsedNum Number of collapsed nested loops.
3512  /// \param NumClauses Number of clauses.
3513  ///
3514  explicit OMPTeamsDistributeSimdDirective(unsigned CollapsedNum,
3515  unsigned NumClauses)
3516  : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass,
3517  OMPD_teams_distribute_simd, SourceLocation(),
3518  SourceLocation(), CollapsedNum, NumClauses) {}
3519 
3520 public:
3521  /// Creates directive with a list of \a Clauses.
3522  ///
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.
3530  ///
3532  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3533  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3534  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3535 
3536  /// Creates an empty directive with the place
3537  /// for \a NumClauses clauses.
3538  ///
3539  /// \param C AST context.
3540  /// \param CollapsedNum Number of collapsed nested loops.
3541  /// \param NumClauses Number of clauses.
3542  ///
3544  unsigned NumClauses,
3545  unsigned CollapsedNum,
3546  EmptyShell);
3547 
3548  static bool classof(const Stmt *T) {
3549  return T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass;
3550  }
3551 };
3552 
3553 /// This represents '#pragma omp teams distribute parallel for simd' composite
3554 /// directive.
3555 ///
3556 /// \code
3557 /// #pragma omp teams distribute parallel for simd private(x)
3558 /// \endcode
3559 /// In this example directive '#pragma omp teams distribute parallel for simd'
3560 /// has clause 'private' with the variables 'x'
3561 ///
3563  : public OMPLoopDirective {
3564  friend class ASTStmtReader;
3565 
3566  /// Build directive with the given start and end location.
3567  ///
3568  /// \param StartLoc Starting location of the directive kind.
3569  /// \param EndLoc Ending location of the directive.
3570  /// \param CollapsedNum Number of collapsed nested loops.
3571  /// \param NumClauses Number of clauses.
3572  ///
3574  SourceLocation EndLoc,
3575  unsigned CollapsedNum,
3576  unsigned NumClauses)
3577  : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass,
3578  OMPD_teams_distribute_parallel_for_simd, StartLoc,
3579  EndLoc, CollapsedNum, NumClauses) {}
3580 
3581  /// Build an empty directive.
3582  ///
3583  /// \param CollapsedNum Number of collapsed nested loops.
3584  /// \param NumClauses Number of clauses.
3585  ///
3586  explicit OMPTeamsDistributeParallelForSimdDirective(unsigned CollapsedNum,
3587  unsigned NumClauses)
3588  : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass,
3589  OMPD_teams_distribute_parallel_for_simd,
3590  SourceLocation(), SourceLocation(), CollapsedNum,
3591  NumClauses) {}
3592 
3593 public:
3594  /// Creates directive with a list of \a Clauses.
3595  ///
3596  /// \param C AST context.
3597  /// \param StartLoc Starting location of the directive kind.
3598  /// \param EndLoc Ending Location of the directive.
3599  /// \param CollapsedNum Number of collapsed loops.
3600  /// \param Clauses List of clauses.
3601  /// \param AssociatedStmt Statement, associated with the directive.
3602  /// \param Exprs Helper expressions for CodeGen.
3603  ///
3605  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3606  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3607  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3608 
3609  /// Creates an empty directive with the place for \a NumClauses clauses.
3610  ///
3611  /// \param C AST context.
3612  /// \param CollapsedNum Number of collapsed nested loops.
3613  /// \param NumClauses Number of clauses.
3614  ///
3616  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3617  EmptyShell);
3618 
3619  static bool classof(const Stmt *T) {
3620  return T->getStmtClass() == OMPTeamsDistributeParallelForSimdDirectiveClass;
3621  }
3622 };
3623 
3624 /// This represents '#pragma omp teams distribute parallel for' composite
3625 /// directive.
3626 ///
3627 /// \code
3628 /// #pragma omp teams distribute parallel for private(x)
3629 /// \endcode
3630 /// In this example directive '#pragma omp teams distribute parallel for'
3631 /// has clause 'private' with the variables 'x'
3632 ///
3634  friend class ASTStmtReader;
3635  /// true if the construct has inner cancel directive.
3636  bool HasCancel = false;
3637 
3638  /// Build directive with the given start and end location.
3639  ///
3640  /// \param StartLoc Starting location of the directive kind.
3641  /// \param EndLoc Ending location of the directive.
3642  /// \param CollapsedNum Number of collapsed nested loops.
3643  /// \param NumClauses Number of clauses.
3644  ///
3646  SourceLocation EndLoc,
3647  unsigned CollapsedNum,
3648  unsigned NumClauses)
3649  : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
3650  OMPD_teams_distribute_parallel_for, StartLoc, EndLoc,
3651  CollapsedNum, NumClauses), HasCancel(false) {}
3652 
3653  /// Build an empty directive.
3654  ///
3655  /// \param CollapsedNum Number of collapsed nested loops.
3656  /// \param NumClauses Number of clauses.
3657  ///
3658  explicit OMPTeamsDistributeParallelForDirective(unsigned CollapsedNum,
3659  unsigned NumClauses)
3660  : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
3661  OMPD_teams_distribute_parallel_for, SourceLocation(),
3662  SourceLocation(), CollapsedNum, NumClauses),
3663  HasCancel(false) {}
3664 
3665  /// Set cancel state.
3666  void setHasCancel(bool Has) { HasCancel = Has; }
3667 
3668 public:
3669  /// Creates directive with a list of \a Clauses.
3670  ///
3671  /// \param C AST context.
3672  /// \param StartLoc Starting location of the directive kind.
3673  /// \param EndLoc Ending Location of the directive.
3674  /// \param CollapsedNum Number of collapsed loops.
3675  /// \param Clauses List of clauses.
3676  /// \param AssociatedStmt Statement, associated with the directive.
3677  /// \param Exprs Helper expressions for CodeGen.
3678  /// \param HasCancel true if this directive has inner cancel directive.
3679  ///
3681  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3682  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3683  Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
3684 
3685  /// Creates an empty directive with the place for \a NumClauses clauses.
3686  ///
3687  /// \param C AST context.
3688  /// \param CollapsedNum Number of collapsed nested loops.
3689  /// \param NumClauses Number of clauses.
3690  ///
3692  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3693  EmptyShell);
3694 
3695  /// Return true if current directive has inner cancel directive.
3696  bool hasCancel() const { return HasCancel; }
3697 
3698  static bool classof(const Stmt *T) {
3699  return T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass;
3700  }
3701 };
3702 
3703 /// This represents '#pragma omp target teams' directive.
3704 ///
3705 /// \code
3706 /// #pragma omp target teams if(a>0)
3707 /// \endcode
3708 /// In this example directive '#pragma omp target teams' has clause 'if' with
3709 /// condition 'a>0'.
3710 ///
3712  friend class ASTStmtReader;
3713  /// Build directive with the given start and end location.
3714  ///
3715  /// \param StartLoc Starting location of the directive kind.
3716  /// \param EndLoc Ending location of the directive.
3717  /// \param NumClauses Number of clauses.
3718  ///
3720  unsigned NumClauses)
3721  : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass,
3722  OMPD_target_teams, StartLoc, EndLoc, NumClauses,
3723  1) {}
3724 
3725  /// Build an empty directive.
3726  ///
3727  /// \param NumClauses Number of clauses.
3728  ///
3729  explicit OMPTargetTeamsDirective(unsigned NumClauses)
3730  : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass,
3731  OMPD_target_teams, SourceLocation(),
3732  SourceLocation(), NumClauses, 1) {}
3733 
3734 public:
3735  /// Creates directive with a list of \a Clauses.
3736  ///
3737  /// \param C AST context.
3738  /// \param StartLoc Starting location of the directive kind.
3739  /// \param EndLoc Ending Location of the directive.
3740  /// \param Clauses List of clauses.
3741  /// \param AssociatedStmt Statement, associated with the directive.
3742  ///
3743  static OMPTargetTeamsDirective *Create(const ASTContext &C,
3744  SourceLocation StartLoc,
3745  SourceLocation EndLoc,
3746  ArrayRef<OMPClause *> Clauses,
3747  Stmt *AssociatedStmt);
3748 
3749  /// Creates an empty directive with the place for \a NumClauses clauses.
3750  ///
3751  /// \param C AST context.
3752  /// \param NumClauses Number of clauses.
3753  ///
3755  unsigned NumClauses, EmptyShell);
3756 
3757  static bool classof(const Stmt *T) {
3758  return T->getStmtClass() == OMPTargetTeamsDirectiveClass;
3759  }
3760 };
3761 
3762 /// This represents '#pragma omp target teams distribute' combined directive.
3763 ///
3764 /// \code
3765 /// #pragma omp target teams distribute private(x)
3766 /// \endcode
3767 /// In this example directive '#pragma omp target teams distribute' has clause
3768 /// 'private' with the variables 'x'
3769 ///
3771  friend class ASTStmtReader;
3772 
3773  /// Build directive with the given start and end location.
3774  ///
3775  /// \param StartLoc Starting location of the directive kind.
3776  /// \param EndLoc Ending location of the directive.
3777  /// \param CollapsedNum Number of collapsed nested loops.
3778  /// \param NumClauses Number of clauses.
3779  ///
3781  SourceLocation EndLoc,
3782  unsigned CollapsedNum, unsigned NumClauses)
3783  : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass,
3784  OMPD_target_teams_distribute, StartLoc, EndLoc,
3785  CollapsedNum, NumClauses) {}
3786 
3787  /// Build an empty directive.
3788  ///
3789  /// \param CollapsedNum Number of collapsed nested loops.
3790  /// \param NumClauses Number of clauses.
3791  ///
3792  explicit OMPTargetTeamsDistributeDirective(unsigned CollapsedNum,
3793  unsigned NumClauses)
3794  : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass,
3795  OMPD_target_teams_distribute, SourceLocation(),
3796  SourceLocation(), CollapsedNum, NumClauses) {}
3797 
3798 public:
3799  /// Creates directive with a list of \a Clauses.
3800  ///
3801  /// \param C AST context.
3802  /// \param StartLoc Starting location of the directive kind.
3803  /// \param EndLoc Ending Location of the directive.
3804  /// \param CollapsedNum Number of collapsed loops.
3805  /// \param Clauses List of clauses.
3806  /// \param AssociatedStmt Statement, associated with the directive.
3807  /// \param Exprs Helper expressions for CodeGen.
3808  ///
3810  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3811  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3812  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3813 
3814  /// Creates an empty directive with the place for \a NumClauses clauses.
3815  ///
3816  /// \param C AST context.
3817  /// \param CollapsedNum Number of collapsed nested loops.
3818  /// \param NumClauses Number of clauses.
3819  ///
3821  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3822  EmptyShell);
3823 
3824  static bool classof(const Stmt *T) {
3825  return T->getStmtClass() == OMPTargetTeamsDistributeDirectiveClass;
3826  }
3827 };
3828 
3829 /// This represents '#pragma omp target teams distribute parallel for' combined
3830 /// directive.
3831 ///
3832 /// \code
3833 /// #pragma omp target teams distribute parallel for private(x)
3834 /// \endcode
3835 /// In this example directive '#pragma omp target teams distribute parallel
3836 /// for' has clause 'private' with the variables 'x'
3837 ///
3839  : public OMPLoopDirective {
3840  friend class ASTStmtReader;
3841  /// true if the construct has inner cancel directive.
3842  bool HasCancel = false;
3843 
3844  /// Build directive with the given start and end location.
3845  ///
3846  /// \param StartLoc Starting location of the directive kind.
3847  /// \param EndLoc Ending location of the directive.
3848  /// \param CollapsedNum Number of collapsed nested loops.
3849  /// \param NumClauses Number of clauses.
3850  ///
3852  SourceLocation EndLoc,
3853  unsigned CollapsedNum,
3854  unsigned NumClauses)
3855  : OMPLoopDirective(this,
3856  OMPTargetTeamsDistributeParallelForDirectiveClass,
3857  OMPD_target_teams_distribute_parallel_for, StartLoc,
3858  EndLoc, CollapsedNum, NumClauses),
3859  HasCancel(false) {}
3860 
3861  /// Build an empty directive.
3862  ///
3863  /// \param CollapsedNum Number of collapsed nested loops.
3864  /// \param NumClauses Number of clauses.
3865  ///
3866  explicit OMPTargetTeamsDistributeParallelForDirective(unsigned CollapsedNum,
3867  unsigned NumClauses)
3868  : OMPLoopDirective(
3869  this, OMPTargetTeamsDistributeParallelForDirectiveClass,
3870  OMPD_target_teams_distribute_parallel_for, SourceLocation(),
3871  SourceLocation(), CollapsedNum, NumClauses),
3872  HasCancel(false) {}
3873 
3874  /// Set cancel state.
3875  void setHasCancel(bool Has) { HasCancel = Has; }
3876 
3877 public:
3878  /// Creates directive with a list of \a Clauses.
3879  ///
3880  /// \param C AST context.
3881  /// \param StartLoc Starting location of the directive kind.
3882  /// \param EndLoc Ending Location of the directive.
3883  /// \param CollapsedNum Number of collapsed loops.
3884  /// \param Clauses List of clauses.
3885  /// \param AssociatedStmt Statement, associated with the directive.
3886  /// \param Exprs Helper expressions for CodeGen.
3887  /// \param HasCancel true if this directive has inner cancel directive.
3888  ///
3890  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3891  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3892  Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
3893 
3894  /// Creates an empty directive with the place for \a NumClauses clauses.
3895  ///
3896  /// \param C AST context.
3897  /// \param CollapsedNum Number of collapsed nested loops.
3898  /// \param NumClauses Number of clauses.
3899  ///
3901  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3902  EmptyShell);
3903 
3904  /// Return true if current directive has inner cancel directive.
3905  bool hasCancel() const { return HasCancel; }
3906 
3907  static bool classof(const Stmt *T) {
3908  return T->getStmtClass() ==
3909  OMPTargetTeamsDistributeParallelForDirectiveClass;
3910  }
3911 };
3912 
3913 /// This represents '#pragma omp target teams distribute parallel for simd'
3914 /// combined directive.
3915 ///
3916 /// \code
3917 /// #pragma omp target teams distribute parallel for simd private(x)
3918 /// \endcode
3919 /// In this example directive '#pragma omp target teams distribute parallel
3920 /// for simd' has clause 'private' with the variables 'x'
3921 ///
3923  : public OMPLoopDirective {
3924  friend class ASTStmtReader;
3925 
3926  /// Build directive with the given start and end location.
3927  ///
3928  /// \param StartLoc Starting location of the directive kind.
3929  /// \param EndLoc Ending location of the directive.
3930  /// \param CollapsedNum Number of collapsed nested loops.
3931  /// \param NumClauses Number of clauses.
3932  ///
3934  SourceLocation EndLoc,
3935  unsigned CollapsedNum,
3936  unsigned NumClauses)
3937  : OMPLoopDirective(this,
3938  OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
3939  OMPD_target_teams_distribute_parallel_for_simd,
3940  StartLoc, EndLoc, CollapsedNum, NumClauses) {}
3941 
3942  /// Build an empty directive.
3943  ///
3944  /// \param CollapsedNum Number of collapsed nested loops.
3945  /// \param NumClauses Number of clauses.
3946  ///
3948  unsigned CollapsedNum, unsigned NumClauses)
3949  : OMPLoopDirective(
3950  this, OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
3951  OMPD_target_teams_distribute_parallel_for_simd, SourceLocation(),
3952  SourceLocation(), CollapsedNum, NumClauses) {}
3953 
3954 public:
3955  /// Creates directive with a list of \a Clauses.
3956  ///
3957  /// \param C AST context.
3958  /// \param StartLoc Starting location of the directive kind.
3959  /// \param EndLoc Ending Location of the directive.
3960  /// \param CollapsedNum Number of collapsed loops.
3961  /// \param Clauses List of clauses.
3962  /// \param AssociatedStmt Statement, associated with the directive.
3963  /// \param Exprs Helper expressions for CodeGen.
3964  ///
3966  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3967  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3968  Stmt *AssociatedStmt, const HelperExprs &Exprs);
3969 
3970  /// Creates an empty directive with the place for \a NumClauses clauses.
3971  ///
3972  /// \param C AST context.
3973  /// \param CollapsedNum Number of collapsed nested loops.
3974  /// \param NumClauses Number of clauses.
3975  ///
3977  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
3978  EmptyShell);
3979 
3980  static bool classof(const Stmt *T) {
3981  return T->getStmtClass() ==
3982  OMPTargetTeamsDistributeParallelForSimdDirectiveClass;
3983  }
3984 };
3985 
3986 /// This represents '#pragma omp target teams distribute simd' combined
3987 /// directive.
3988 ///
3989 /// \code
3990 /// #pragma omp target teams distribute simd private(x)
3991 /// \endcode
3992 /// In this example directive '#pragma omp target teams distribute simd'
3993 /// has clause 'private' with the variables 'x'
3994 ///
3996  friend class ASTStmtReader;
3997 
3998  /// Build directive with the given start and end location.
3999  ///
4000  /// \param StartLoc Starting location of the directive kind.
4001  /// \param EndLoc Ending location of the directive.
4002  /// \param CollapsedNum Number of collapsed nested loops.
4003  /// \param NumClauses Number of clauses.
4004  ///
4006  SourceLocation EndLoc,
4007  unsigned CollapsedNum,
4008  unsigned NumClauses)
4009  : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
4010  OMPD_target_teams_distribute_simd, StartLoc, EndLoc,
4011  CollapsedNum, NumClauses) {}
4012 
4013  /// Build an empty directive.
4014  ///
4015  /// \param CollapsedNum Number of collapsed nested loops.
4016  /// \param NumClauses Number of clauses.
4017  ///
4018  explicit OMPTargetTeamsDistributeSimdDirective(unsigned CollapsedNum,
4019  unsigned NumClauses)
4020  : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
4021  OMPD_target_teams_distribute_simd, SourceLocation(),
4022  SourceLocation(), CollapsedNum, NumClauses) {}
4023 
4024 public:
4025  /// Creates directive with a list of \a Clauses.
4026  ///
4027  /// \param C AST context.
4028  /// \param StartLoc Starting location of the directive kind.
4029  /// \param EndLoc Ending Location of the directive.
4030  /// \param CollapsedNum Number of collapsed loops.
4031  /// \param Clauses List of clauses.
4032  /// \param AssociatedStmt Statement, associated with the directive.
4033  /// \param Exprs Helper expressions for CodeGen.
4034  ///
4036  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4037  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4038  Stmt *AssociatedStmt, const HelperExprs &Exprs);
4039 
4040  /// Creates an empty directive with the place for \a NumClauses clauses.
4041  ///
4042  /// \param C AST context.
4043  /// \param CollapsedNum Number of collapsed nested loops.
4044  /// \param NumClauses Number of clauses.
4045  ///
4047  CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
4048  EmptyShell);
4049 
4050  static bool classof(const Stmt *T) {
4051  return T->getStmtClass() == OMPTargetTeamsDistributeSimdDirectiveClass;
4052  }
4053 };
4054 
4055 } // end namespace clang
4056 
4057 #endif
void setPreInits(Stmt *PreInits)
Definition: StmtOpenMP.h:502
child_iterator child_begin()
Definition: Stmt.h:474
Expr * NLB
Update of LowerBound for statically scheduled &#39;omp for&#39; loops.
Definition: StmtOpenMP.h:680
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:336
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2116
This represents &#39;#pragma omp distribute simd&#39; composite directive.
Definition: StmtOpenMP.h:3222
Expr * getNextUpperBound() const
Definition: StmtOpenMP.h:851
SmallVector< Expr *, 4 > Finals
Final loop counter values for GodeGen.
Definition: StmtOpenMP.h:708
This represents &#39;#pragma omp master&#39; directive.
Definition: StmtOpenMP.h:1405
Expr * NUB
Update of UpperBound for statically scheduled omp loops for outer loop in combined constructs (e...
Definition: StmtOpenMP.h:647
SmallVector< Expr *, 4 > Updates
Expressions for loop counters update for CodeGen.
Definition: StmtOpenMP.h:706
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1745
void setEnsureUpperBound(Expr *EUB)
Definition: StmtOpenMP.h:533
Expr * getUpperBoundVariable() const
Definition: StmtOpenMP.h:819
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1394
ArrayRef< Expr * > inits() const
Definition: StmtOpenMP.h:959
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:268
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:975
OMPLoopDirective(const T *That, StmtClass SC, OpenMPDirectiveKind Kind, SourceLocation StartLoc, SourceLocation EndLoc, unsigned CollapsedNum, unsigned NumClauses, unsigned NumSpecialChildren=0)
Build instance of loop directive of class Kind.
Definition: StmtOpenMP.h:458
void setCombinedCond(Expr *CombCond)
Definition: StmtOpenMP.h:601
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2423
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
const Expr * getV() const
Definition: StmtOpenMP.h:2240
void setCombinedLowerBoundVariable(Expr *CombLB)
Definition: StmtOpenMP.h:581
void setHasCancel(bool Has)
Set cancel state.
Definition: StmtOpenMP.h:1332
Stmt - This represents one statement.
Definition: Stmt.h:66
void setLastIteration(Expr *LI)
Definition: StmtOpenMP.h:488
Expr * getLowerBoundVariable() const
Definition: StmtOpenMP.h:811
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3059
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2306
This represents &#39;#pragma omp for simd&#39; directive.
Definition: StmtOpenMP.h:1155
Expr * EUB
EnsureUpperBound – expression UB = min(UB, NumIterations).
Definition: StmtOpenMP.h:678
Expr * DistInc
DistInc - increment expression for distribute loop when found combined with a further loop level (e...
Definition: StmtOpenMP.h:692
This represents &#39;#pragma omp teams distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3633
SourceLocation getBeginLoc() const
Definition: StmtOpenMP.h:172
void setPrevEnsureUpperBound(Expr *PrevEUB)
Definition: StmtOpenMP.h:576
CapturedStmt * getInnermostCapturedStmt()
Get innermost captured statement for the construct.
Definition: StmtOpenMP.h:234
void setUpperBoundVariable(Expr *UB)
Definition: StmtOpenMP.h:519
void setNumIterations(Expr *NI)
Definition: StmtOpenMP.h:554
This represents &#39;#pragma omp target teams distribute&#39; combined directive.
Definition: StmtOpenMP.h:3770
void setNextLowerBound(Expr *NLB)
Definition: StmtOpenMP.h:540
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:464
This represents &#39;#pragma omp parallel for&#39; directive.
Definition: StmtOpenMP.h:1526
This represents &#39;#pragma omp target teams distribute parallel for&#39; combined directive.
Definition: StmtOpenMP.h:3838
Expr * getCombinedEnsureUpperBound() const
Definition: StmtOpenMP.h:903
void setIsLastIterVariable(Expr *IL)
Definition: StmtOpenMP.h:505
Expr * PrevLB
PreviousLowerBound - local variable passed to runtime in the enclosing schedule or null if that does ...
Definition: StmtOpenMP.h:685
SourceLocation getEndLoc() const
Definition: StmtOpenMP.h:178
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1730
This represents &#39;#pragma omp target exit data&#39; directive.
Definition: StmtOpenMP.h:2437
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:2620
const Stmt * getBody() const
Definition: StmtOpenMP.h:933
Expr * getCombinedUpperBoundVariable() const
Definition: StmtOpenMP.h:897
void setUpdates(ArrayRef< Expr *> UL)
Sets the list of update expressions for linear variables.
Expr * getCalcLastIteration() const
Definition: StmtOpenMP.h:779
void setInit(Expr *Init)
Definition: StmtOpenMP.h:500
The expressions built to support OpenMP loops in combined/composite pragmas (e.g. ...
Definition: StmtOpenMP.h:625
bool isXLHSInRHSPart() const
Return true if helper update expression has form &#39;OpaqueValueExpr(x) binop OpaqueValueExpr(expr)&#39; and...
Definition: StmtOpenMP.h:2234
const Expr * getUpdateExpr() const
Definition: StmtOpenMP.h:2228
ArrayRef< Expr * > finals() const
Definition: StmtOpenMP.h:971
Expr * LastIteration
Loop last iteration number.
Definition: StmtOpenMP.h:656
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1802
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:284
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3276
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:153
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2622
Expr * getEnsureUpperBound() const
Definition: StmtOpenMP.h:835
const CapturedStmt * getCapturedStmt(OpenMPDirectiveKind RegionKind) const
Returns the captured statement associated with the component region within the (combined) directive...
Definition: StmtOpenMP.h:217
Definition: Format.h:2031
Expr * getInc() const
Definition: StmtOpenMP.h:795
ArrayRef< Expr * > updates()
Definition: StmtOpenMP.h:963
This represents &#39;#pragma omp target simd&#39; directive.
Definition: StmtOpenMP.h:3358
static unsigned getArraysOffset(OpenMPDirectiveKind Kind)
Offset to the start of children expression arrays.
Definition: StmtOpenMP.h:468
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1846
Defines some OpenMP-specific enums and functions.
OpenMPDirectiveKind getDirectiveKind() const
Definition: StmtOpenMP.h:252
This represents &#39;#pragma omp barrier&#39; directive.
Definition: StmtOpenMP.h:1857
This is a common base class for loop directives (&#39;omp simd&#39;, &#39;omp for&#39;, &#39;omp for simd&#39; etc...
Definition: StmtOpenMP.h:346
This represents &#39;#pragma omp critical&#39; directive.
Definition: StmtOpenMP.h:1452
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
Definition: StmtOpenMP.h:2736
void setCond(Expr *Cond)
Definition: StmtOpenMP.h:497
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3411
This represents &#39;#pragma omp distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3073
This represents &#39;#pragma omp teams distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3562
ArrayRef< Expr * > finals()
Definition: StmtOpenMP.h:969
Expr * getIsLastIterVariable() const
Definition: StmtOpenMP.h:803
Expr * LB
DistributeLowerBound - used when composing &#39;omp distribute&#39; with &#39;omp for&#39; in a same construct...
Definition: StmtOpenMP.h:628
Expr * EUB
DistributeEnsureUpperBound - used when composing &#39;omp distribute&#39; with &#39;omp for&#39; in a same construct...
Definition: StmtOpenMP.h:634
Expr * getX()
Get &#39;x&#39; part of the associated expression/statement.
Definition: StmtOpenMP.h:2218
Expr * getIterationVariable() const
Definition: StmtOpenMP.h:771
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:3137
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3478
static bool classof(const Stmt *S)
Definition: StmtOpenMP.h:254
This represents &#39;#pragma omp cancellation point&#39; directive.
Definition: StmtOpenMP.h:2692
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2003
void setCombinedInit(Expr *CombInit)
Definition: StmtOpenMP.h:596
MutableArrayRef< Expr * > getFinals()
Sets the list of final update expressions for linear variables.
This represents &#39;#pragma omp teams&#39; directive.
Definition: StmtOpenMP.h:2635
Expr * getInit() const
Definition: StmtOpenMP.h:791
Expr * CalcLastIteration
Calculation of last iteration.
Definition: StmtOpenMP.h:660
This represents &#39;#pragma omp teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3492
bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a worksharing directive.
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2541
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:338
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1277
StmtClass
Definition: Stmt.h:68
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1732
void setFinals(ArrayRef< Expr *> FL)
Sets the list of final update expressions for linear variables.
Expr * NUB
Update of UpperBound for statically scheduled &#39;omp for&#39; loops.
Definition: StmtOpenMP.h:682
Expr * Cond
Loop condition.
Definition: StmtOpenMP.h:664
Expr * PreCond
Loop pre-condition.
Definition: StmtOpenMP.h:662
This represents &#39;#pragma omp target parallel for simd&#39; directive.
Definition: StmtOpenMP.h:3290
ArrayRef< Expr * > private_counters()
Definition: StmtOpenMP.h:951
The expressions built for the OpenMP loop CodeGen for the whole collapsed loop nest.
Definition: StmtOpenMP.h:652
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1335
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1591
This represents &#39;#pragma omp taskgroup&#39; directive.
Definition: StmtOpenMP.h:1945
Expr * getCombinedLowerBoundVariable() const
Definition: StmtOpenMP.h:891
Expr * IterationVarRef
Loop iteration variable.
Definition: StmtOpenMP.h:654
Expr * Init
Distribute loop iteration variable init used when composing &#39;omp distribute&#39; with &#39;omp for&#39; in a same...
Definition: StmtOpenMP.h:638
This represents &#39;#pragma omp distribute&#39; directive.
Definition: StmtOpenMP.h:2946
LLVM_ATTRIBUTE_DEPRECATED(SourceLocation getLocEnd() const LLVM_READONLY, "Use getEndLoc instead")
Returns ending location of directive.
Definition: StmtOpenMP.h:174
const Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
Definition: StmtOpenMP.h:204
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1589
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:3696
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2866
Expr - This represents one expression.
Definition: Expr.h:106
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
static unsigned numLoopChildren(unsigned CollapsedNum, OpenMPDirectiveKind Kind)
Children number.
Definition: StmtOpenMP.h:478
Stmt * IgnoreContainers(bool IgnoreCaptured=false)
Skip no-op (attributed, compound) container stmts and skip captured stmt at the top, if IgnoreCaptured is true.
Definition: Stmt.cpp:139
ArrayRef< OMPClause * > clauses() const
Definition: StmtOpenMP.h:270
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1139
This represents &#39;#pragma omp target teams distribute parallel for simd&#39; combined directive.
Definition: StmtOpenMP.h:3922
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1890
static llvm::iterator_range< specific_clause_iterator< SpecificClause > > getClausesOfKind(ArrayRef< OMPClause *> Clauses)
Definition: StmtOpenMP.h:130
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3000
This represents &#39;#pragma omp target teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3995
bool builtAll()
Check if all the expressions are built (does not check the worksharing ones).
Definition: StmtOpenMP.h:717
unsigned getNumClauses() const
Get number of clauses.
Definition: StmtOpenMP.h:192
Expr * getDistInc() const
Definition: StmtOpenMP.h:879
Expr * getNextLowerBound() const
Definition: StmtOpenMP.h:843
Expr * PrevUB
PreviousUpperBound - local variable passed to runtime in the enclosing schedule or null if that does ...
Definition: StmtOpenMP.h:688
Expr * getPrevEnsureUpperBound() const
Definition: StmtOpenMP.h:885
This represents &#39;#pragma omp for&#39; directive.
Definition: StmtOpenMP.h:1078
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2801
ArrayRef< Expr * > counters() const
Definition: StmtOpenMP.h:947
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
This represents &#39;#pragma omp target teams&#39; directive.
Definition: StmtOpenMP.h:3711
void setAssociatedStmt(Stmt *S)
Set the associated statement for the directive.
Definition: StmtOpenMP.h:85
bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a taskloop directive.
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1141
StmtIterator child_iterator
Child Iterators: All subclasses must implement &#39;children&#39; to permit easy iteration over the substatem...
Definition: Stmt.h:461
This represents &#39;#pragma omp cancel&#39; directive.
Definition: StmtOpenMP.h:2750
void setDistInc(Expr *DistInc)
Definition: StmtOpenMP.h:571
Expr * NLB
Update of LowerBound for statically scheduled omp loops for outer loop in combined constructs (e...
Definition: StmtOpenMP.h:644
void setClauses(ArrayRef< OMPClause *> Clauses)
Sets the list of variables for this clause.
Definition: StmtOpenMP.cpp:20
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2482
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2062
LLVM_ATTRIBUTE_DEPRECATED(SourceLocation getLocStart() const LLVM_READONLY, "Use getBeginLoc instead")
Returns starting location of directive kind.
Definition: StmtOpenMP.h:168
This file defines OpenMP AST classes for clauses.
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2249
This represents &#39;#pragma omp flush&#39; directive.
Definition: StmtOpenMP.h:2018
bool hasClausesOfKind() const
Returns true if the current directive has one or more clauses of a specific kind. ...
Definition: StmtOpenMP.h:162
This represents &#39;#pragma omp parallel for simd&#39; directive.
Definition: StmtOpenMP.h:1606
Expr * NumIterations
Loop number of iterations.
Definition: StmtOpenMP.h:658
void setLocStart(SourceLocation Loc)
Set starting location of directive kind.
Definition: StmtOpenMP.h:184
Expr * ST
Stride - local variable passed to runtime.
Definition: StmtOpenMP.h:676
Expr * getLastIteration() const
Definition: StmtOpenMP.h:775
const SpecificClause * getSingleClause() const
Gets a single clause of the specified kind associated with the current directive iff there is only on...
Definition: StmtOpenMP.h:148
bool isPostfixUpdate() const
Return true if &#39;v&#39; expression must be updated to original value of &#39;x&#39;, false if &#39;v&#39; must be updated ...
Definition: StmtOpenMP.h:2237
This represents &#39;#pragma omp target enter data&#39; directive.
Definition: StmtOpenMP.h:2378
SmallVector< Expr *, 4 > PrivateCounters
PrivateCounters Loop counters.
Definition: StmtOpenMP.h:702
void setLowerBoundVariable(Expr *LB)
Definition: StmtOpenMP.h:512
Expr * getStrideVariable() const
Definition: StmtOpenMP.h:827
ArrayRef< Expr * > updates() const
Definition: StmtOpenMP.h:965
const Stmt * getPreInits() const
Definition: StmtOpenMP.h:799
#define false
Definition: stdbool.h:33
Kind
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2738
This captures a statement into a function.
Definition: Stmt.h:2285
SmallVector< Expr *, 4 > Counters
Counters Loop counters.
Definition: StmtOpenMP.h:700
specific_clause_iterator(ArrayRef< OMPClause *> Clauses)
Definition: StmtOpenMP.h:110
This represents &#39;#pragma omp single&#39; directive.
Definition: StmtOpenMP.h:1350
Encodes a location in the source.
void setPrevLowerBoundVariable(Expr *PrevLB)
Definition: StmtOpenMP.h:561
void setIterationVariable(Expr *IV)
Definition: StmtOpenMP.h:485
MutableArrayRef< Expr * > getInits()
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:33
void setCombinedNextLowerBound(Expr *CombNLB)
Definition: StmtOpenMP.h:606
OMPClause * getClause(unsigned i) const
Returns specified clause.
Definition: StmtOpenMP.h:198
Expr * getExpr()
Get &#39;expr&#39; part of the associated expression/statement.
Definition: StmtOpenMP.h:2244
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2680
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Definition: StmtOpenMP.h:1510
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1337
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1934
This represents &#39;#pragma omp taskwait&#39; directive.
Definition: StmtOpenMP.h:1901
Expr * PrevEUB
PrevEUB - expression similar to EUB but to be used when loop scheduling uses PrevLB and PrevUB (e...
Definition: StmtOpenMP.h:698
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:51
bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind)
Checks if the specified directive kind is one of the composite or combined directives that need loop ...
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3757
llvm::iterator_range< specific_clause_iterator< SpecificClause > > getClausesOfKind() const
Definition: StmtOpenMP.h:138
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition: Stmt.h:2386
This represents &#39;#pragma omp target&#39; directive.
Definition: StmtOpenMP.h:2262
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1800
Expr * getV()
Get &#39;v&#39; part of the associated expression/statement.
Definition: StmtOpenMP.h:2239
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1512
DistCombinedHelperExprs DistCombinedFields
Expressions used when combining OpenMP loop pragmas.
Definition: StmtOpenMP.h:713
This represents &#39;#pragma omp ordered&#39; directive.
Definition: StmtOpenMP.h:2073
Expr * LB
LowerBound - local variable passed to runtime.
Definition: StmtOpenMP.h:672
void clear(unsigned Size)
Initialize all the fields to null.
Definition: StmtOpenMP.h:725
This represents &#39;#pragma omp target update&#39; directive.
Definition: StmtOpenMP.h:3014
Expr * Init
Loop iteration variable init.
Definition: StmtOpenMP.h:666
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Definition: Stmt.h:338
ArrayRef< Expr * > private_counters() const
Definition: StmtOpenMP.h:953
#define alignof
Definition: stdalign.h:29
void setPrevUpperBoundVariable(Expr *PrevUB)
Definition: StmtOpenMP.h:566
void setCombinedEnsureUpperBound(Expr *CombEUB)
Definition: StmtOpenMP.h:591
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3344
Dataflow Directional Tag Classes.
Expr * getPrevUpperBoundVariable() const
Definition: StmtOpenMP.h:873
const CapturedStmt * getInnermostCapturedStmt() const
Definition: StmtOpenMP.h:247
SmallVector< Expr *, 4 > Inits
Expressions for loop counters inits for CodeGen.
Definition: StmtOpenMP.h:704
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2933
void setCombinedUpperBoundVariable(Expr *CombUB)
Definition: StmtOpenMP.h:586
Expr * getCond() const
Definition: StmtOpenMP.h:787
This represents &#39;#pragma omp section&#39; directive.
Definition: StmtOpenMP.h:1288
This represents &#39;#pragma omp teams distribute&#39; directive.
Definition: StmtOpenMP.h:3424
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:3905
This represents &#39;#pragma omp simd&#39; directive.
Definition: StmtOpenMP.h:1013
StmtClass getStmtClass() const
Definition: Stmt.h:391
const Expr * getReductionRef() const
Returns reference to the task_reduction return variable.
Definition: StmtOpenMP.h:1996
Expr * getUpdateExpr()
Get helper expression of the form &#39;OpaqueValueExpr(x) binop OpaqueValueExpr(expr)&#39; or &#39;OpaqueValueExp...
Definition: StmtOpenMP.h:2225
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3824
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
This represents &#39;#pragma omp atomic&#39; directive.
Definition: StmtOpenMP.h:2128
Expr * getCombinedInit() const
Definition: StmtOpenMP.h:909
unsigned getCollapsedNumber() const
Get number of collapsed loops.
Definition: StmtOpenMP.h:769
Expr * getCombinedNextLowerBound() const
Definition: StmtOpenMP.h:921
ArrayRef< Expr * > counters()
Definition: StmtOpenMP.h:945
Expr * getCombinedNextUpperBound() const
Definition: StmtOpenMP.h:927
Iterates over a filtered subrange of clauses applied to a directive.
Definition: StmtOpenMP.h:96
void getOpenMPCaptureRegions(llvm::SmallVectorImpl< OpenMPDirectiveKind > &CaptureRegions, OpenMPDirectiveKind DKind)
Return the captured regions of an OpenMP directive.
bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a distribute directive.
ArrayRef< Expr * > inits()
Definition: StmtOpenMP.h:957
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:2364
Expr * Inc
Loop increment.
Definition: StmtOpenMP.h:668
const Expr * getExpr() const
Definition: StmtOpenMP.h:2245
Expr * getNumIterations() const
Definition: StmtOpenMP.h:859
bool hasAssociatedStmt() const
Returns true if directive has associated statement.
Definition: StmtOpenMP.h:201
Expr * getPrevLowerBoundVariable() const
Definition: StmtOpenMP.h:867
Expr * UB
DistributeUpperBound - used when composing &#39;omp distribute&#39; with &#39;omp for&#39; in a same construct...
Definition: StmtOpenMP.h:631
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:13790
Expr * UB
UpperBound - local variable passed to runtime.
Definition: StmtOpenMP.h:674
Defines the clang::SourceLocation class and associated facilities.
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1660
This represents &#39;#pragma omp target parallel&#39; directive.
Definition: StmtOpenMP.h:2495
void setStrideVariable(Expr *ST)
Definition: StmtOpenMP.h:526
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1064
Expr * getCombinedCond() const
Definition: StmtOpenMP.h:915
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1441
This represents &#39;#pragma omp taskloop simd&#39; directive.
Definition: StmtOpenMP.h:2880
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3139
Expr * getPreCond() const
Definition: StmtOpenMP.h:783
void setPreCond(Expr *PC)
Definition: StmtOpenMP.h:494
OMPExecutableDirective(const T *, StmtClass SC, OpenMPDirectiveKind K, SourceLocation StartLoc, SourceLocation EndLoc, unsigned NumClauses, unsigned NumChildren)
Build instance of directive of class K.
Definition: StmtOpenMP.h:67
This represents &#39;#pragma omp sections&#39; directive.
Definition: StmtOpenMP.h:1220
Expr * Cond
Distribute Loop condition used when composing &#39;omp distribute&#39; with &#39;omp for&#39; in a same construct...
Definition: StmtOpenMP.h:641
Stmt * PreInits
Init statement for all captured expressions.
Definition: StmtOpenMP.h:710
void setInits(ArrayRef< Expr *> IL)
Sets the list of the initial values for linear variables.
This represents &#39;#pragma omp target data&#39; directive.
Definition: StmtOpenMP.h:2320
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
Definition: StmtOpenMP.h:2799
void setNextUpperBound(Expr *NUB)
Definition: StmtOpenMP.h:547
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:3548
const Expr * getX() const
Definition: StmtOpenMP.h:2219
void setInc(Expr *Inc)
Definition: StmtOpenMP.h:501
Expr * IL
IsLastIteration - local flag variable passed to runtime.
Definition: StmtOpenMP.h:670
This represents &#39;#pragma omp taskyield&#39; directive.
Definition: StmtOpenMP.h:1813
This represents &#39;#pragma omp distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3153
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1674
void setCalcLastIteration(Expr *CLI)
Definition: StmtOpenMP.h:491
void setCombinedNextUpperBound(Expr *CombNUB)
Definition: StmtOpenMP.h:611
bool hasCancel() const
Return true if current directive has inner cancel directive.
Definition: StmtOpenMP.h:1275
void setLocEnd(SourceLocation Loc)
Set ending location of directive.
Definition: StmtOpenMP.h:189
static bool classof(const Stmt *T)
Definition: StmtOpenMP.h:1206
This represents &#39;#pragma omp target parallel for&#39; directive.
Definition: StmtOpenMP.h:2555
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
This represents &#39;#pragma omp taskloop&#39; directive.
Definition: StmtOpenMP.h:2815