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