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