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