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