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