clang 24.0.0git
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
18#include "clang/AST/Expr.h"
20#include "clang/AST/Stmt.h"
21#include "clang/AST/StmtCXX.h"
24#include "llvm/Support/Casting.h"
25
26namespace clang {
27
28class OMPInvariantPredicateBoundAttr;
29
30//===----------------------------------------------------------------------===//
31// AST classes for directives.
32//===----------------------------------------------------------------------===//
33
34/// Representation of an OpenMP canonical loop.
35///
36/// OpenMP 1.0 C/C++, section 2.4.1 for Construct; canonical-shape
37/// OpenMP 2.0 C/C++, section 2.4.1 for Construct; canonical-shape
38/// OpenMP 2.5, section 2.5.1 Loop Construct; canonical form
39/// OpenMP 3.1, section 2.5.1 Loop Construct; canonical form
40/// OpenMP 4.0, section 2.6 Canonical Loop Form
41/// OpenMP 4.5, section 2.6 Canonical Loop Form
42/// OpenMP 5.0, section 2.9.1 Canonical Loop Form
43/// OpenMP 5.1, section 2.11.1 Canonical Loop Nest Form
44///
45/// An OpenMP canonical loop is a for-statement or range-based for-statement
46/// with additional requirements that ensure that the number of iterations is
47/// known before entering the loop and allow skipping to an arbitrary iteration.
48/// The OMPCanonicalLoop AST node wraps a ForStmt or CXXForRangeStmt that is
49/// known to fulfill OpenMP's canonical loop requirements because of being
50/// associated to an OMPLoopBasedDirective. That is, the general structure is:
51///
52/// OMPLoopBasedDirective
53/// [`- CapturedStmt ]
54/// [ `- CapturedDecl]
55/// ` OMPCanonicalLoop
56/// `- ForStmt/CXXForRangeStmt
57/// `- Stmt
58///
59/// One or multiple CapturedStmt/CapturedDecl pairs may be inserted by some
60/// directives such as OMPParallelForDirective, but others do not need them
61/// (such as OMPTileDirective). In The OMPCanonicalLoop and
62/// ForStmt/CXXForRangeStmt pair is repeated for loop associated with the
63/// directive. A OMPCanonicalLoop must not appear in the AST unless associated
64/// with a OMPLoopBasedDirective. In an imperfectly nested loop nest, the
65/// OMPCanonicalLoop may also be wrapped in a CompoundStmt:
66///
67/// [...]
68/// ` OMPCanonicalLoop
69/// `- ForStmt/CXXForRangeStmt
70/// `- CompoundStmt
71/// |- Leading in-between code (if any)
72/// |- OMPCanonicalLoop
73/// | `- ForStmt/CXXForRangeStmt
74/// | `- ...
75/// `- Trailing in-between code (if any)
76///
77/// The leading/trailing in-between code must not itself be a OMPCanonicalLoop
78/// to avoid confusion which loop belongs to the nesting.
79///
80/// There are three different kinds of iteration variables for different
81/// purposes:
82/// * Loop user variable: The user-accessible variable with different value for
83/// each iteration.
84/// * Loop iteration variable: The variable used to identify a loop iteration;
85/// for range-based for-statement, this is the hidden iterator '__begin'. For
86/// other loops, it is identical to the loop user variable. Must be a
87/// random-access iterator, pointer or integer type.
88/// * Logical iteration counter: Normalized loop counter starting at 0 and
89/// incrementing by one at each iteration. Allows abstracting over the type
90/// of the loop iteration variable and is always an unsigned integer type
91/// appropriate to represent the range of the loop iteration variable. Its
92/// value corresponds to the logical iteration number in the OpenMP
93/// specification.
94///
95/// This AST node provides two captured statements:
96/// * The distance function which computes the number of iterations.
97/// * The loop user variable function that computes the loop user variable when
98/// given a logical iteration number.
99///
100/// These captured statements provide the link between C/C++ semantics and the
101/// logical iteration counters used by the OpenMPIRBuilder which is
102/// language-agnostic and therefore does not know e.g. how to advance a
103/// random-access iterator. The OpenMPIRBuilder will use this information to
104/// apply simd, workshare-loop, distribute, taskloop and loop directives to the
105/// loop. For compatibility with the non-OpenMPIRBuilder codegen path, an
106/// OMPCanonicalLoop can itself also be wrapped into the CapturedStmts of an
107/// OMPLoopDirective and skipped when searching for the associated syntactical
108/// loop.
109///
110/// Example:
111/// <code>
112/// std::vector<std::string> Container{1,2,3};
113/// for (std::string Str : Container)
114/// Body(Str);
115/// </code>
116/// which is syntactic sugar for approximately:
117/// <code>
118/// auto &&__range = Container;
119/// auto __begin = std::begin(__range);
120/// auto __end = std::end(__range);
121/// for (; __begin != __end; ++__begin) {
122/// std::String Str = *__begin;
123/// Body(Str);
124/// }
125/// </code>
126/// In this example, the loop user variable is `Str`, the loop iteration
127/// variable is `__begin` of type `std::vector<std::string>::iterator` and the
128/// logical iteration number type is `size_t` (unsigned version of
129/// `std::vector<std::string>::iterator::difference_type` aka `ptrdiff_t`).
130/// Therefore, the distance function will be
131/// <code>
132/// [&](size_t &Result) { Result = __end - __begin; }
133/// </code>
134/// and the loop variable function is
135/// <code>
136/// [&,__begin](std::vector<std::string>::iterator &Result, size_t Logical) {
137/// Result = __begin + Logical;
138/// }
139/// </code>
140/// The variable `__begin`, aka the loop iteration variable, is captured by
141/// value because it is modified in the loop body, but both functions require
142/// the initial value. The OpenMP specification explicitly leaves unspecified
143/// when the loop expressions are evaluated such that a capture by reference is
144/// sufficient.
145class OMPCanonicalLoop : public Stmt {
146 friend class ASTStmtReader;
147 friend class ASTStmtWriter;
148
149 /// Children of this AST node.
150 enum {
151 LOOP_STMT,
152 DISTANCE_FUNC,
153 LOOPVAR_FUNC,
154 LOOPVAR_REF,
155 LastSubStmt = LOOPVAR_REF
156 };
157
158private:
159 /// This AST node's children.
160 Stmt *SubStmts[LastSubStmt + 1] = {};
161
162 OMPCanonicalLoop() : Stmt(StmtClass::OMPCanonicalLoopClass) {}
163
164public:
165 /// Create a new OMPCanonicalLoop.
166 static OMPCanonicalLoop *create(const ASTContext &Ctx, Stmt *LoopStmt,
167 CapturedStmt *DistanceFunc,
168 CapturedStmt *LoopVarFunc,
169 DeclRefExpr *LoopVarRef) {
170 OMPCanonicalLoop *S = new (Ctx) OMPCanonicalLoop();
171 S->setLoopStmt(LoopStmt);
172 S->setDistanceFunc(DistanceFunc);
173 S->setLoopVarFunc(LoopVarFunc);
174 S->setLoopVarRef(LoopVarRef);
175 return S;
176 }
177
178 /// Create an empty OMPCanonicalLoop for deserialization.
179 static OMPCanonicalLoop *createEmpty(const ASTContext &Ctx) {
180 return new (Ctx) OMPCanonicalLoop();
181 }
182
183 static bool classof(const Stmt *S) {
184 return S->getStmtClass() == StmtClass::OMPCanonicalLoopClass;
185 }
186
187 SourceLocation getBeginLoc() const { return getLoopStmt()->getBeginLoc(); }
188 SourceLocation getEndLoc() const { return getLoopStmt()->getEndLoc(); }
189
190 /// Return this AST node's children.
191 /// @{
192 child_range children() {
193 return child_range(&SubStmts[0], &SubStmts[0] + LastSubStmt + 1);
194 }
195 const_child_range children() const {
196 return const_child_range(&SubStmts[0], &SubStmts[0] + LastSubStmt + 1);
197 }
198 /// @}
199
200 /// The wrapped syntactic loop statement (ForStmt or CXXForRangeStmt).
201 /// @{
202 Stmt *getLoopStmt() { return SubStmts[LOOP_STMT]; }
203 const Stmt *getLoopStmt() const { return SubStmts[LOOP_STMT]; }
204 void setLoopStmt(Stmt *S) {
205 assert((isa<ForStmt>(S) || isa<CXXForRangeStmt>(S)) &&
206 "Canonical loop must be a for loop (range-based or otherwise)");
207 SubStmts[LOOP_STMT] = S;
208 }
209 /// @}
210
211 /// The function that computes the number of loop iterations. Can be evaluated
212 /// before entering the loop but after the syntactical loop's init
213 /// statement(s).
214 ///
215 /// Function signature: void(LogicalTy &Result)
216 /// Any values necessary to compute the distance are captures of the closure.
217 /// @{
218 CapturedStmt *getDistanceFunc() {
219 return cast<CapturedStmt>(SubStmts[DISTANCE_FUNC]);
220 }
221 const CapturedStmt *getDistanceFunc() const {
222 return cast<CapturedStmt>(SubStmts[DISTANCE_FUNC]);
223 }
224 void setDistanceFunc(CapturedStmt *S) {
225 assert(S && "Expected non-null captured statement");
226 SubStmts[DISTANCE_FUNC] = S;
227 }
228 /// @}
229
230 /// The function that computes the loop user variable from a logical iteration
231 /// counter. Can be evaluated as first statement in the loop.
232 ///
233 /// Function signature: void(LoopVarTy &Result, LogicalTy Number)
234 /// Any other values required to compute the loop user variable (such as start
235 /// value, step size) are captured by the closure. In particular, the initial
236 /// value of loop iteration variable is captured by value to be unaffected by
237 /// previous iterations.
238 /// @{
239 CapturedStmt *getLoopVarFunc() {
240 return cast<CapturedStmt>(SubStmts[LOOPVAR_FUNC]);
241 }
242 const CapturedStmt *getLoopVarFunc() const {
243 return cast<CapturedStmt>(SubStmts[LOOPVAR_FUNC]);
244 }
245 void setLoopVarFunc(CapturedStmt *S) {
246 assert(S && "Expected non-null captured statement");
247 SubStmts[LOOPVAR_FUNC] = S;
248 }
249 /// @}
250
251 /// Reference to the loop user variable as accessed in the loop body.
252 /// @{
253 DeclRefExpr *getLoopVarRef() {
254 return cast<DeclRefExpr>(SubStmts[LOOPVAR_REF]);
255 }
256 const DeclRefExpr *getLoopVarRef() const {
257 return cast<DeclRefExpr>(SubStmts[LOOPVAR_REF]);
258 }
259 void setLoopVarRef(DeclRefExpr *E) {
260 assert(E && "Expected non-null loop variable");
261 SubStmts[LOOPVAR_REF] = E;
262 }
263 /// @}
264};
265
266/// This is a basic class for representing single OpenMP executable
267/// directive.
268///
269class OMPExecutableDirective : public Stmt {
270 friend class ASTStmtReader;
271 friend class ASTStmtWriter;
272
273 /// Kind of the directive.
274 OpenMPDirectiveKind Kind = llvm::omp::OMPD_unknown;
275 /// Starting location of the directive (directive keyword).
276 SourceLocation StartLoc;
277 /// Ending location of the directive.
278 SourceLocation EndLoc;
279
280 /// Get the clauses storage.
281 MutableArrayRef<OMPClause *> getClauses() {
282 if (!Data)
283 return {};
284 return Data->getClauses();
285 }
286
287protected:
288 /// Data, associated with the directive.
289 OMPChildren *Data = nullptr;
290
291 /// Build instance of directive of class \a K.
292 ///
293 /// \param SC Statement class.
294 /// \param K Kind of OpenMP directive.
295 /// \param StartLoc Starting location of the directive (directive keyword).
296 /// \param EndLoc Ending location of the directive.
297 ///
298 OMPExecutableDirective(StmtClass SC, OpenMPDirectiveKind K,
299 SourceLocation StartLoc, SourceLocation EndLoc)
300 : Stmt(SC), Kind(K), StartLoc(std::move(StartLoc)),
301 EndLoc(std::move(EndLoc)) {}
302
303 template <typename T, typename... Params>
304 static T *createDirective(const ASTContext &C, ArrayRef<OMPClause *> Clauses,
305 Stmt *AssociatedStmt, unsigned NumChildren,
306 Params &&... P) {
307 void *Mem =
308 C.Allocate(sizeof(T) + OMPChildren::size(Clauses.size(), AssociatedStmt,
309 NumChildren),
310 alignof(T));
311
312 auto *Data = OMPChildren::Create(reinterpret_cast<T *>(Mem) + 1, Clauses,
313 AssociatedStmt, NumChildren);
314 auto *Inst = new (Mem) T(std::forward<Params>(P)...);
315 Inst->Data = Data;
316 return Inst;
317 }
318
319 template <typename T, typename... Params>
320 static T *createEmptyDirective(const ASTContext &C, unsigned NumClauses,
321 bool HasAssociatedStmt, unsigned NumChildren,
322 Params &&... P) {
323 void *Mem =
324 C.Allocate(sizeof(T) + OMPChildren::size(NumClauses, HasAssociatedStmt,
325 NumChildren),
326 alignof(T));
327 auto *Data =
328 OMPChildren::CreateEmpty(reinterpret_cast<T *>(Mem) + 1, NumClauses,
329 HasAssociatedStmt, NumChildren);
330 auto *Inst = new (Mem) T(std::forward<Params>(P)...);
331 Inst->Data = Data;
332 return Inst;
333 }
334
335 template <typename T>
336 static T *createEmptyDirective(const ASTContext &C, unsigned NumClauses,
337 bool HasAssociatedStmt = false,
338 unsigned NumChildren = 0) {
339 void *Mem =
340 C.Allocate(sizeof(T) + OMPChildren::size(NumClauses, HasAssociatedStmt,
341 NumChildren),
342 alignof(T));
343 auto *Data =
344 OMPChildren::CreateEmpty(reinterpret_cast<T *>(Mem) + 1, NumClauses,
345 HasAssociatedStmt, NumChildren);
346 auto *Inst = new (Mem) T;
347 Inst->Data = Data;
348 return Inst;
349 }
350
351public:
352 /// Iterates over expressions/statements used in the construct.
353 class used_clauses_child_iterator
354 : public llvm::iterator_adaptor_base<
355 used_clauses_child_iterator, ArrayRef<OMPClause *>::iterator,
356 std::forward_iterator_tag, Stmt *, ptrdiff_t, Stmt *, Stmt *> {
357 ArrayRef<OMPClause *>::iterator End;
358 OMPClause::child_iterator ChildI, ChildEnd;
359
360 void MoveToNext() {
361 if (ChildI != ChildEnd)
362 return;
363 while (this->I != End) {
364 ++this->I;
365 if (this->I != End) {
366 ChildI = (*this->I)->used_children().begin();
367 ChildEnd = (*this->I)->used_children().end();
368 if (ChildI != ChildEnd)
369 return;
370 }
371 }
372 }
373
374 public:
375 explicit used_clauses_child_iterator(ArrayRef<OMPClause *> Clauses)
376 : used_clauses_child_iterator::iterator_adaptor_base(Clauses.begin()),
377 End(Clauses.end()) {
378 if (this->I != End) {
379 ChildI = (*this->I)->used_children().begin();
380 ChildEnd = (*this->I)->used_children().end();
381 MoveToNext();
382 }
383 }
384 Stmt *operator*() const { return *ChildI; }
385 Stmt *operator->() const { return **this; }
386
387 used_clauses_child_iterator &operator++() {
388 ++ChildI;
389 if (ChildI != ChildEnd)
390 return *this;
391 if (this->I != End) {
392 ++this->I;
393 if (this->I != End) {
394 ChildI = (*this->I)->used_children().begin();
395 ChildEnd = (*this->I)->used_children().end();
396 }
397 }
398 MoveToNext();
399 return *this;
400 }
401 };
402
403 static llvm::iterator_range<used_clauses_child_iterator>
404 used_clauses_children(ArrayRef<OMPClause *> Clauses) {
405 return {used_clauses_child_iterator(Clauses),
406 used_clauses_child_iterator(ArrayRef(Clauses.end(), (size_t)0))};
407 }
408
409 /// Iterates over a filtered subrange of clauses applied to a
410 /// directive.
411 ///
412 /// This iterator visits only clauses of type SpecificClause.
413 template <typename SpecificClause>
414 class specific_clause_iterator
415 : public llvm::iterator_adaptor_base<
416 specific_clause_iterator<SpecificClause>,
417 ArrayRef<OMPClause *>::const_iterator, std::forward_iterator_tag,
418 const SpecificClause *, ptrdiff_t, const SpecificClause *,
419 const SpecificClause *> {
420 ArrayRef<OMPClause *>::const_iterator End;
421
422 void SkipToNextClause() {
423 while (this->I != End && !isa<SpecificClause>(*this->I))
424 ++this->I;
425 }
426
427 public:
428 explicit specific_clause_iterator(ArrayRef<OMPClause *> Clauses)
429 : specific_clause_iterator::iterator_adaptor_base(Clauses.begin()),
430 End(Clauses.end()) {
431 SkipToNextClause();
432 }
433
434 const SpecificClause *operator*() const {
435 return cast<SpecificClause>(*this->I);
436 }
437 const SpecificClause *operator->() const { return **this; }
438
439 specific_clause_iterator &operator++() {
440 ++this->I;
441 SkipToNextClause();
442 return *this;
443 }
444 };
445
446 template <typename SpecificClause>
447 static llvm::iterator_range<specific_clause_iterator<SpecificClause>>
448 getClausesOfKind(ArrayRef<OMPClause *> Clauses) {
449 return {specific_clause_iterator<SpecificClause>(Clauses),
450 specific_clause_iterator<SpecificClause>(
451 ArrayRef(Clauses.end(), (size_t)0))};
452 }
453
454 template <typename SpecificClause>
455 llvm::iterator_range<specific_clause_iterator<SpecificClause>>
456 getClausesOfKind() const {
457 return getClausesOfKind<SpecificClause>(clauses());
458 }
459
460 /// Gets a single clause of the specified kind associated with the
461 /// current directive iff there is only one clause of this kind (and assertion
462 /// is fired if there is more than one clause is associated with the
463 /// directive). Returns nullptr if no clause of this kind is associated with
464 /// the directive.
465 template <typename SpecificClause>
466 static const SpecificClause *getSingleClause(ArrayRef<OMPClause *> Clauses) {
467 auto ClausesOfKind = getClausesOfKind<SpecificClause>(Clauses);
468
469 if (ClausesOfKind.begin() != ClausesOfKind.end()) {
470 assert(std::next(ClausesOfKind.begin()) == ClausesOfKind.end() &&
471 "There are at least 2 clauses of the specified kind");
472 return *ClausesOfKind.begin();
473 }
474 return nullptr;
475 }
476
477 template <typename SpecificClause>
478 const SpecificClause *getSingleClause() const {
479 return getSingleClause<SpecificClause>(clauses());
480 }
481
482 /// Returns true if the current directive has one or more clauses of a
483 /// specific kind.
484 template <typename SpecificClause>
485 bool hasClausesOfKind() const {
486 auto Clauses = getClausesOfKind<SpecificClause>();
487 return Clauses.begin() != Clauses.end();
488 }
489
490 /// Returns starting location of directive kind.
491 SourceLocation getBeginLoc() const { return StartLoc; }
492 /// Returns ending location of directive.
493 SourceLocation getEndLoc() const { return EndLoc; }
494
495 /// Set starting location of directive kind.
496 ///
497 /// \param Loc New starting location of directive.
498 ///
499 void setLocStart(SourceLocation Loc) { StartLoc = Loc; }
500 /// Set ending location of directive.
501 ///
502 /// \param Loc New ending location of directive.
503 ///
504 void setLocEnd(SourceLocation Loc) { EndLoc = Loc; }
505
506 /// Get number of clauses.
507 unsigned getNumClauses() const {
508 if (!Data)
509 return 0;
510 return Data->getNumClauses();
511 }
512
513 /// Returns specified clause.
514 ///
515 /// \param I Number of clause.
516 ///
517 OMPClause *getClause(unsigned I) const { return clauses()[I]; }
518
519 /// Returns true if directive has associated statement.
520 bool hasAssociatedStmt() const { return Data && Data->hasAssociatedStmt(); }
521
522 /// Returns statement associated with the directive.
523 const Stmt *getAssociatedStmt() const {
524 return const_cast<OMPExecutableDirective *>(this)->getAssociatedStmt();
525 }
526 Stmt *getAssociatedStmt() {
527 assert(hasAssociatedStmt() &&
528 "Expected directive with the associated statement.");
529 return Data->getAssociatedStmt();
530 }
531
532 /// Returns the captured statement associated with the
533 /// component region within the (combined) directive.
534 ///
535 /// \param RegionKind Component region kind.
536 const CapturedStmt *getCapturedStmt(OpenMPDirectiveKind RegionKind) const {
537 assert(hasAssociatedStmt() &&
538 "Expected directive with the associated statement.");
539 SmallVector<OpenMPDirectiveKind, 4> CaptureRegions;
540 getOpenMPCaptureRegions(CaptureRegions, getDirectiveKind());
541 return Data->getCapturedStmt(RegionKind, CaptureRegions);
542 }
543
544 /// Get innermost captured statement for the construct.
545 CapturedStmt *getInnermostCapturedStmt() {
546 assert(hasAssociatedStmt() &&
547 "Expected directive with the associated statement.");
548 SmallVector<OpenMPDirectiveKind, 4> CaptureRegions;
549 getOpenMPCaptureRegions(CaptureRegions, getDirectiveKind());
550 return Data->getInnermostCapturedStmt(CaptureRegions);
551 }
552
553 const CapturedStmt *getInnermostCapturedStmt() const {
554 return const_cast<OMPExecutableDirective *>(this)
555 ->getInnermostCapturedStmt();
556 }
557
558 OpenMPDirectiveKind getDirectiveKind() const { return Kind; }
559
560 static bool classof(const Stmt *S) {
561 return S->getStmtClass() >= firstOMPExecutableDirectiveConstant &&
562 S->getStmtClass() <= lastOMPExecutableDirectiveConstant;
563 }
564
565 child_range children() {
566 if (!Data)
567 return child_range(child_iterator(), child_iterator());
568 return Data->getAssociatedStmtAsRange();
569 }
570
571 const_child_range children() const {
572 return const_cast<OMPExecutableDirective *>(this)->children();
573 }
574
575 ArrayRef<OMPClause *> clauses() const {
576 if (!Data)
577 return {};
578 return Data->getClauses();
579 }
580
581 /// Returns whether or not this is a Standalone directive.
582 ///
583 /// Stand-alone directives are executable directives
584 /// that have no associated user code.
585 bool isStandaloneDirective() const;
586
587 /// Returns the AST node representing OpenMP structured-block of this
588 /// OpenMP executable directive,
589 /// Prerequisite: Executable Directive must not be Standalone directive.
590 const Stmt *getStructuredBlock() const {
591 return const_cast<OMPExecutableDirective *>(this)->getStructuredBlock();
592 }
593 Stmt *getStructuredBlock();
594
595 const Stmt *getRawStmt() const {
596 return const_cast<OMPExecutableDirective *>(this)->getRawStmt();
597 }
598 Stmt *getRawStmt() {
599 assert(hasAssociatedStmt() &&
600 "Expected directive with the associated statement.");
601 return Data->getRawStmt();
602 }
603};
604
605/// This represents '#pragma omp parallel' directive.
606///
607/// \code
608/// #pragma omp parallel private(a,b) reduction(+: c,d)
609/// \endcode
610/// In this example directive '#pragma omp parallel' has clauses 'private'
611/// with the variables 'a' and 'b' and 'reduction' with operator '+' and
612/// variables 'c' and 'd'.
613///
614class OMPParallelDirective : public OMPExecutableDirective {
615 friend class ASTStmtReader;
616 friend class OMPExecutableDirective;
617 /// true if the construct has inner cancel directive.
618 bool HasCancel = false;
619
620 /// Build directive with the given start and end location.
621 ///
622 /// \param StartLoc Starting location of the directive (directive keyword).
623 /// \param EndLoc Ending Location of the directive.
624 ///
625 OMPParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc)
626 : OMPExecutableDirective(OMPParallelDirectiveClass,
627 llvm::omp::OMPD_parallel, StartLoc, EndLoc) {}
628
629 /// Build an empty directive.
630 ///
631 explicit OMPParallelDirective()
632 : OMPExecutableDirective(OMPParallelDirectiveClass,
633 llvm::omp::OMPD_parallel, SourceLocation(),
634 SourceLocation()) {}
635
636 /// Sets special task reduction descriptor.
637 void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[0] = E; }
638
639 /// Set cancel state.
640 void setHasCancel(bool Has) { HasCancel = Has; }
641
642public:
643 /// Creates directive with a list of \a Clauses.
644 ///
645 /// \param C AST context.
646 /// \param StartLoc Starting location of the directive kind.
647 /// \param EndLoc Ending Location of the directive.
648 /// \param Clauses List of clauses.
649 /// \param AssociatedStmt Statement associated with the directive.
650 /// \param TaskRedRef Task reduction special reference expression to handle
651 /// taskgroup descriptor.
652 /// \param HasCancel true if this directive has inner cancel directive.
653 ///
654 static OMPParallelDirective *
655 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
656 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
657 bool HasCancel);
658
659 /// Creates an empty directive with the place for \a N clauses.
660 ///
661 /// \param C AST context.
662 /// \param NumClauses Number of clauses.
663 ///
664 static OMPParallelDirective *CreateEmpty(const ASTContext &C,
665 unsigned NumClauses, EmptyShell);
666
667 /// Returns special task reduction reference expression.
668 Expr *getTaskReductionRefExpr() {
669 return cast_or_null<Expr>(Data->getChildren()[0]);
670 }
671 const Expr *getTaskReductionRefExpr() const {
672 return const_cast<OMPParallelDirective *>(this)->getTaskReductionRefExpr();
673 }
674
675 /// Return true if current directive has inner cancel directive.
676 bool hasCancel() const { return HasCancel; }
677
678 static bool classof(const Stmt *T) {
679 return T->getStmtClass() == OMPParallelDirectiveClass;
680 }
681};
682
683// Forward declaration of a generic loop transformation. Used in the declaration
684// of OMPLoopBasedDirective.
685class OMPLoopTransformationDirective;
686
687/// The base class for all loop-based directives, including loop transformation
688/// directives.
689class OMPLoopBasedDirective : public OMPExecutableDirective {
690 friend class ASTStmtReader;
691
692protected:
693 /// Number of collapsed loops as specified by 'collapse' clause.
694 unsigned NumAssociatedLoops = 0;
695
696 /// Build instance of loop directive of class \a Kind.
697 ///
698 /// \param SC Statement class.
699 /// \param Kind Kind of OpenMP directive.
700 /// \param StartLoc Starting location of the directive (directive keyword).
701 /// \param EndLoc Ending location of the directive.
702 /// \param NumAssociatedLoops Number of loops associated with the construct.
703 ///
704 OMPLoopBasedDirective(StmtClass SC, OpenMPDirectiveKind Kind,
705 SourceLocation StartLoc, SourceLocation EndLoc,
706 unsigned NumAssociatedLoops)
707 : OMPExecutableDirective(SC, Kind, StartLoc, EndLoc),
708 NumAssociatedLoops(NumAssociatedLoops) {}
709
710public:
711 /// The expressions built to support OpenMP loops in combined/composite
712 /// pragmas (e.g. pragma omp distribute parallel for)
713 struct DistCombinedHelperExprs {
714 /// DistributeLowerBound - used when composing 'omp distribute' with
715 /// 'omp for' in a same construct.
716 Expr *LB;
717 /// DistributeUpperBound - used when composing 'omp distribute' with
718 /// 'omp for' in a same construct.
719 Expr *UB;
720 /// DistributeEnsureUpperBound - used when composing 'omp distribute'
721 /// with 'omp for' in a same construct, EUB depends on DistUB
722 Expr *EUB;
723 /// Distribute loop iteration variable init used when composing 'omp
724 /// distribute'
725 /// with 'omp for' in a same construct
726 Expr *Init;
727 /// Distribute Loop condition used when composing 'omp distribute'
728 /// with 'omp for' in a same construct
729 Expr *Cond;
730 /// Update of LowerBound for statically scheduled omp loops for
731 /// outer loop in combined constructs (e.g. 'distribute parallel for')
732 Expr *NLB;
733 /// Update of UpperBound for statically scheduled omp loops for
734 /// outer loop in combined constructs (e.g. 'distribute parallel for')
735 Expr *NUB;
736 /// Distribute Loop condition used when composing 'omp distribute'
737 /// with 'omp for' in a same construct when schedule is chunked.
738 Expr *DistCond;
739 /// 'omp parallel for' loop condition used when composed with
740 /// 'omp distribute' in the same construct and when schedule is
741 /// chunked and the chunk size is 1.
742 Expr *ParForInDistCond;
743 };
744
745 /// The expressions built for the OpenMP loop CodeGen for the
746 /// whole collapsed loop nest.
747 struct HelperExprs {
748 /// Loop iteration variable.
749 Expr *IterationVarRef;
750 /// Loop last iteration number.
751 Expr *LastIteration;
752 /// Loop number of iterations.
753 Expr *NumIterations;
754 /// Calculation of last iteration.
755 Expr *CalcLastIteration;
756 /// Loop pre-condition.
757 Expr *PreCond;
758 /// Loop condition.
759 Expr *Cond;
760 /// Loop iteration variable init.
761 Expr *Init;
762 /// Loop increment.
763 Expr *Inc;
764 /// IsLastIteration - local flag variable passed to runtime.
765 Expr *IL;
766 /// LowerBound - local variable passed to runtime.
767 Expr *LB;
768 /// UpperBound - local variable passed to runtime.
769 Expr *UB;
770 /// Stride - local variable passed to runtime.
771 Expr *ST;
772 /// EnsureUpperBound -- expression UB = min(UB, NumIterations).
773 Expr *EUB;
774 /// Update of LowerBound for statically scheduled 'omp for' loops.
775 Expr *NLB;
776 /// Update of UpperBound for statically scheduled 'omp for' loops.
777 Expr *NUB;
778 /// PreviousLowerBound - local variable passed to runtime in the
779 /// enclosing schedule or null if that does not apply.
780 Expr *PrevLB;
781 /// PreviousUpperBound - local variable passed to runtime in the
782 /// enclosing schedule or null if that does not apply.
783 Expr *PrevUB;
784 /// DistInc - increment expression for distribute loop when found
785 /// combined with a further loop level (e.g. in 'distribute parallel for')
786 /// expression IV = IV + ST
787 Expr *DistInc;
788 /// PrevEUB - expression similar to EUB but to be used when loop
789 /// scheduling uses PrevLB and PrevUB (e.g. in 'distribute parallel for'
790 /// when ensuring that the UB is either the calculated UB by the runtime or
791 /// the end of the assigned distribute chunk)
792 /// expression UB = min (UB, PrevUB)
793 Expr *PrevEUB;
794 /// Counters Loop counters.
795 SmallVector<Expr *, 4> Counters;
796 /// PrivateCounters Loop counters.
797 SmallVector<Expr *, 4> PrivateCounters;
798 /// Expressions for loop counters inits for CodeGen.
799 SmallVector<Expr *, 4> Inits;
800 /// Expressions for loop counters update for CodeGen.
801 SmallVector<Expr *, 4> Updates;
802 /// Final loop counter values for GodeGen.
803 SmallVector<Expr *, 4> Finals;
804 /// List of counters required for the generation of the non-rectangular
805 /// loops.
806 SmallVector<Expr *, 4> DependentCounters;
807 /// List of initializers required for the generation of the non-rectangular
808 /// loops.
809 SmallVector<Expr *, 4> DependentInits;
810 /// List of final conditions required for the generation of the
811 /// non-rectangular loops.
812 SmallVector<Expr *, 4> FinalsConditions;
813 /// Init statement for all captured expressions.
814 Stmt *PreInits;
815
816 /// Expressions used when combining OpenMP loop pragmas
817 DistCombinedHelperExprs DistCombinedFields;
818
819 /// Check if all the expressions are built (does not check the
820 /// worksharing ones).
821 bool builtAll() {
822 return IterationVarRef != nullptr && LastIteration != nullptr &&
823 NumIterations != nullptr && PreCond != nullptr &&
824 Cond != nullptr && Init != nullptr && Inc != nullptr;
825 }
826
827 /// Initialize all the fields to null.
828 /// \param Size Number of elements in the
829 /// counters/finals/updates/dependent_counters/dependent_inits/finals_conditions
830 /// arrays.
831 void clear(unsigned Size) {
832 IterationVarRef = nullptr;
833 LastIteration = nullptr;
834 CalcLastIteration = nullptr;
835 PreCond = nullptr;
836 Cond = nullptr;
837 Init = nullptr;
838 Inc = nullptr;
839 IL = nullptr;
840 LB = nullptr;
841 UB = nullptr;
842 ST = nullptr;
843 EUB = nullptr;
844 NLB = nullptr;
845 NUB = nullptr;
846 NumIterations = nullptr;
847 PrevLB = nullptr;
848 PrevUB = nullptr;
849 DistInc = nullptr;
850 PrevEUB = nullptr;
851 Counters.resize(Size);
852 PrivateCounters.resize(Size);
853 Inits.resize(Size);
854 Updates.resize(Size);
855 Finals.resize(Size);
856 DependentCounters.resize(Size);
857 DependentInits.resize(Size);
858 FinalsConditions.resize(Size);
859 for (unsigned I = 0; I < Size; ++I) {
860 Counters[I] = nullptr;
861 PrivateCounters[I] = nullptr;
862 Inits[I] = nullptr;
863 Updates[I] = nullptr;
864 Finals[I] = nullptr;
865 DependentCounters[I] = nullptr;
866 DependentInits[I] = nullptr;
867 FinalsConditions[I] = nullptr;
868 }
869 PreInits = nullptr;
870 DistCombinedFields.LB = nullptr;
871 DistCombinedFields.UB = nullptr;
872 DistCombinedFields.EUB = nullptr;
873 DistCombinedFields.Init = nullptr;
874 DistCombinedFields.Cond = nullptr;
875 DistCombinedFields.NLB = nullptr;
876 DistCombinedFields.NUB = nullptr;
877 DistCombinedFields.DistCond = nullptr;
878 DistCombinedFields.ParForInDistCond = nullptr;
879 }
880 };
881
882 /// Get number of collapsed loops.
883 unsigned getLoopsNumber() const { return NumAssociatedLoops; }
884
885 /// Try to find the next loop sub-statement in the specified statement \p
886 /// CurStmt.
887 /// \param TryImperfectlyNestedLoops true, if we need to try to look for the
888 /// imperfectly nested loop.
889 static Stmt *tryToFindNextInnerLoop(Stmt *CurStmt,
890 bool TryImperfectlyNestedLoops);
891 static const Stmt *tryToFindNextInnerLoop(const Stmt *CurStmt,
892 bool TryImperfectlyNestedLoops) {
893 return tryToFindNextInnerLoop(const_cast<Stmt *>(CurStmt),
894 TryImperfectlyNestedLoops);
895 }
896
897 /// Returns the intra-tile reinterpretation hint attached to \p S, or nullptr
898 /// if \p S does not carry one. See OMPInvariantPredicateBoundAttr.
899 static const OMPInvariantPredicateBoundAttr *getIntraTileHint(const Stmt *S);
900
901 /// If \p S is an intra-tile reinterpretation wrapper, returns the loop it
902 /// annotates; otherwise returns \p S unchanged.
903 static Stmt *ignoreIntraTileHint(Stmt *S);
904 static const Stmt *ignoreIntraTileHint(const Stmt *S) {
905 return ignoreIntraTileHint(const_cast<Stmt *>(S));
906 }
907
908 /// Returns the statements of \p Body that precede its last statement (the
909 /// nested loop), such as the user counter update `omp reverse` emits.
910 static ArrayRef<Stmt *> getStmtsBeforeNestedLoop(Stmt *Body);
911
912 /// Calls the specified callback function for all the loops in \p CurStmt,
913 /// from the outermost to the innermost.
914 ///
915 /// \p Loop is always a ForStmt or CXXForRangeStmt. \p HintWrapper is the
916 /// intra-tile OMPInvariantPredicateBoundAttr wrapper around that loop, or
917 /// nullptr if the loop has no such hint. Callers that need the hint (see
918 /// checkOpenMPIterationSpace) can peel \p HintWrapper themselves; everyone
919 /// else can ignore it.
920 ///
921 /// \p RelaxNestForPeeledTransformation allows a loop generated by a peeled
922 /// loop-transformation directive to hold statements before the next loop,
923 /// such as the user counter update `omp reverse` emits, so e.g. `omp tile`
924 /// accepts a nested `omp reverse` on a non-innermost loop. Only set it if the
925 /// caller re-emits those statements in the loops it generates; otherwise they
926 /// are dropped.
927 static bool
928 doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
929 unsigned NumLoops,
930 llvm::function_ref<bool(unsigned /*Cnt*/, Stmt * /*Loop*/,
931 Stmt * /*HintWrapper*/)>
933 llvm::function_ref<void(OMPLoopTransformationDirective *)>
936 static bool
937 doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
938 unsigned NumLoops,
939 llvm::function_ref<bool(unsigned, Stmt *)> Callback,
940 llvm::function_ref<void(OMPLoopTransformationDirective *)>
943 auto &&NewCallback = [Callback](unsigned Cnt, Stmt *Loop, Stmt *) {
944 return Callback(Cnt, Loop);
945 };
946 return doForAllLoops(CurStmt, TryImperfectlyNestedLoops, NumLoops,
947 NewCallback, OnTransformationCallback,
949 }
950 static bool
951 doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops,
952 unsigned NumLoops,
953 llvm::function_ref<bool(unsigned, const Stmt *)> Callback,
954 llvm::function_ref<void(const OMPLoopTransformationDirective *)>
957 auto &&NewCallback = [Callback](unsigned Cnt, Stmt *CurStmt) {
958 return Callback(Cnt, CurStmt);
959 };
960 auto &&NewTransformCb =
963 };
964 return doForAllLoops(const_cast<Stmt *>(CurStmt), TryImperfectlyNestedLoops,
965 NumLoops, NewCallback, NewTransformCb,
967 }
968
969 /// Calls the specified callback function for all the loops in \p CurStmt,
970 /// from the outermost to the innermost.
971 static bool doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
972 unsigned NumLoops,
973 llvm::function_ref<bool(unsigned, Stmt *)> Callback,
975 auto &&TransformCb = [](OMPLoopTransformationDirective *) {};
976 return doForAllLoops(CurStmt, TryImperfectlyNestedLoops, NumLoops, Callback,
978 }
979 static bool
980 doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops,
981 unsigned NumLoops,
982 llvm::function_ref<bool(unsigned, const Stmt *)> Callback,
984 auto &&NewCallback = [Callback](unsigned Cnt, const Stmt *CurStmt) {
985 return Callback(Cnt, CurStmt);
986 };
987 return doForAllLoops(const_cast<Stmt *>(CurStmt), TryImperfectlyNestedLoops,
988 NumLoops, NewCallback,
990 }
991
992 /// Calls the specified callback function for all the loop bodies in \p
993 /// CurStmt, from the outermost loop to the innermost.
995 Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops,
996 llvm::function_ref<void(unsigned, Stmt *, Stmt *)> Callback);
998 const Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops,
999 llvm::function_ref<void(unsigned, const Stmt *, const Stmt *)> Callback) {
1000 auto &&NewCallback = [Callback](unsigned Cnt, Stmt *Loop, Stmt *Body) {
1001 Callback(Cnt, Loop, Body);
1002 };
1003 doForAllLoopsBodies(const_cast<Stmt *>(CurStmt), TryImperfectlyNestedLoops,
1004 NumLoops, NewCallback);
1005 }
1006
1007 static bool classof(const Stmt *T) {
1008 if (auto *D = dyn_cast<OMPExecutableDirective>(T))
1009 return isOpenMPLoopDirective(D->getDirectiveKind());
1010 return false;
1011 }
1012};
1013
1014/// Common class of data shared between
1015/// OMPCanonicalLoopNestTransformationDirective and
1016/// OMPCanonicalLoopSequenceTransformationDirective
1018 friend class ASTStmtReader;
1019
1020 /// Number of (top-level) generated loops.
1021 /// This value is 1 for most transformations as they only map one loop nest
1022 /// into another.
1023 /// Some loop transformations (like a non-partial 'unroll') may not generate
1024 /// a loop nest, so this would be 0.
1025 /// Some loop transformations (like 'fuse' with looprange and 'split') may
1026 /// generate more than one loop nest, so the value would be >= 1.
1027 unsigned NumGeneratedTopLevelLoops = 1;
1028
1029 /// We need this because we cannot easily make OMPLoopTransformationDirective
1030 /// a proper Stmt.
1031 Stmt *S = nullptr;
1032
1033protected:
1035 NumGeneratedTopLevelLoops = N;
1036 }
1037
1038 explicit OMPLoopTransformationDirective(Stmt *S) : S(S) {}
1039
1040public:
1042 return NumGeneratedTopLevelLoops;
1043 }
1044
1045 /// Returns the specific directive related to this loop transformation.
1046 Stmt *getDirective() const { return S; }
1047
1048 /// Get the de-sugared statements after the loop transformation.
1049 ///
1050 /// Might be nullptr if either the directive generates no loops and is handled
1051 /// directly in CodeGen, or resolving a template-dependence context is
1052 /// required.
1053 Stmt *getTransformedStmt() const;
1054
1055 /// Return preinits statement.
1056 Stmt *getPreInits() const;
1057
1058 /// Return loop variable finalization statement, or nullptr if the concrete
1059 /// transformation does not produce one (e.g. unroll).
1060 Stmt *getFinals() const;
1061
1066};
1067
1068/// The base class for all transformation directives of canonical loop nests.
1070 : public OMPLoopBasedDirective,
1072 friend class ASTStmtReader;
1073
1074protected:
1076 StmtClass SC, OpenMPDirectiveKind Kind, SourceLocation StartLoc,
1077 SourceLocation EndLoc, unsigned NumAssociatedLoops)
1078 : OMPLoopBasedDirective(SC, Kind, StartLoc, EndLoc, NumAssociatedLoops),
1080
1081public:
1082 /// Return the number of associated (consumed) loops.
1083 unsigned getNumAssociatedLoops() const { return getLoopsNumber(); }
1084
1085 /// Get the de-sugared statements after the loop transformation.
1086 ///
1087 /// Might be nullptr if either the directive generates no loops and is handled
1088 /// directly in CodeGen, or resolving a template-dependence context is
1089 /// required.
1090 Stmt *getTransformedStmt() const;
1091
1092 /// Return preinits statement.
1093 Stmt *getPreInits() const;
1094
1095 /// Return loop variable finalization statement, or nullptr if the concrete
1096 /// transformation does not produce one (e.g. unroll).
1097 Stmt *getFinals() const;
1098
1099 static bool classof(const Stmt *T) {
1100 Stmt::StmtClass C = T->getStmtClass();
1101 return C == OMPTileDirectiveClass || C == OMPUnrollDirectiveClass ||
1102 C == OMPReverseDirectiveClass || C == OMPInterchangeDirectiveClass ||
1103 C == OMPStripeDirectiveClass || C == OMPFlattenDirectiveClass;
1104 }
1105};
1106
1107/// This is a common base class for loop directives ('omp simd', 'omp
1108/// for', 'omp for simd' etc.). It is responsible for the loop code generation.
1109///
1111 friend class ASTStmtReader;
1112
1113 /// Offsets to the stored exprs.
1114 /// This enumeration contains offsets to all the pointers to children
1115 /// expressions stored in OMPLoopDirective.
1116 /// The first 9 children are necessary for all the loop directives,
1117 /// the next 8 are specific to the worksharing ones, and the next 11 are
1118 /// used for combined constructs containing two pragmas associated to loops.
1119 /// After the fixed children, three arrays of length NumAssociatedLoops are
1120 /// allocated: loop counters, their updates and final values.
1121 /// PrevLowerBound and PrevUpperBound are used to communicate blocking
1122 /// information in composite constructs which require loop blocking
1123 /// DistInc is used to generate the increment expression for the distribute
1124 /// loop when combined with a further nested loop
1125 /// PrevEnsureUpperBound is used as the EnsureUpperBound expression for the
1126 /// for loop when combined with a previous distribute loop in the same pragma
1127 /// (e.g. 'distribute parallel for')
1128 ///
1129 enum {
1130 IterationVariableOffset = 0,
1131 LastIterationOffset = 1,
1132 CalcLastIterationOffset = 2,
1133 PreConditionOffset = 3,
1134 CondOffset = 4,
1135 InitOffset = 5,
1136 IncOffset = 6,
1137 PreInitsOffset = 7,
1138 // The '...End' enumerators do not correspond to child expressions - they
1139 // specify the offset to the end (and start of the following counters/
1140 // updates/finals/dependent_counters/dependent_inits/finals_conditions
1141 // arrays).
1142 DefaultEnd = 8,
1143 // The following 8 exprs are used by worksharing and distribute loops only.
1144 IsLastIterVariableOffset = 8,
1145 LowerBoundVariableOffset = 9,
1146 UpperBoundVariableOffset = 10,
1147 StrideVariableOffset = 11,
1148 EnsureUpperBoundOffset = 12,
1149 NextLowerBoundOffset = 13,
1150 NextUpperBoundOffset = 14,
1151 NumIterationsOffset = 15,
1152 // Offset to the end for worksharing loop directives.
1153 WorksharingEnd = 16,
1154 PrevLowerBoundVariableOffset = 16,
1155 PrevUpperBoundVariableOffset = 17,
1156 DistIncOffset = 18,
1157 PrevEnsureUpperBoundOffset = 19,
1158 CombinedLowerBoundVariableOffset = 20,
1159 CombinedUpperBoundVariableOffset = 21,
1160 CombinedEnsureUpperBoundOffset = 22,
1161 CombinedInitOffset = 23,
1162 CombinedConditionOffset = 24,
1163 CombinedNextLowerBoundOffset = 25,
1164 CombinedNextUpperBoundOffset = 26,
1165 CombinedDistConditionOffset = 27,
1166 CombinedParForInDistConditionOffset = 28,
1167 // Offset to the end (and start of the following
1168 // counters/updates/finals/dependent_counters/dependent_inits/finals_conditions
1169 // arrays) for combined distribute loop directives.
1170 CombinedDistributeEnd = 29,
1171 };
1172
1173 /// Get the counters storage.
1174 MutableArrayRef<Expr *> getCounters() {
1175 auto **Storage = reinterpret_cast<Expr **>(
1176 &Data->getChildren()[getArraysOffset(getDirectiveKind())]);
1177 return {Storage, getLoopsNumber()};
1178 }
1179
1180 /// Get the private counters storage.
1181 MutableArrayRef<Expr *> getPrivateCounters() {
1182 auto **Storage = reinterpret_cast<Expr **>(
1183 &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
1184 getLoopsNumber()]);
1185 return {Storage, getLoopsNumber()};
1186 }
1187
1188 /// Get the updates storage.
1189 MutableArrayRef<Expr *> getInits() {
1190 auto **Storage = reinterpret_cast<Expr **>(
1191 &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
1192 2 * getLoopsNumber()]);
1193 return {Storage, getLoopsNumber()};
1194 }
1195
1196 /// Get the updates storage.
1197 MutableArrayRef<Expr *> getUpdates() {
1198 auto **Storage = reinterpret_cast<Expr **>(
1199 &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
1200 3 * getLoopsNumber()]);
1201 return {Storage, getLoopsNumber()};
1202 }
1203
1204 /// Get the final counter updates storage.
1205 MutableArrayRef<Expr *> getFinals() {
1206 auto **Storage = reinterpret_cast<Expr **>(
1207 &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
1208 4 * getLoopsNumber()]);
1209 return {Storage, getLoopsNumber()};
1210 }
1211
1212 /// Get the dependent counters storage.
1213 MutableArrayRef<Expr *> getDependentCounters() {
1214 auto **Storage = reinterpret_cast<Expr **>(
1215 &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
1216 5 * getLoopsNumber()]);
1217 return {Storage, getLoopsNumber()};
1218 }
1219
1220 /// Get the dependent inits storage.
1221 MutableArrayRef<Expr *> getDependentInits() {
1222 auto **Storage = reinterpret_cast<Expr **>(
1223 &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
1224 6 * getLoopsNumber()]);
1225 return {Storage, getLoopsNumber()};
1226 }
1227
1228 /// Get the finals conditions storage.
1229 MutableArrayRef<Expr *> getFinalsConditions() {
1230 auto **Storage = reinterpret_cast<Expr **>(
1231 &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
1232 7 * getLoopsNumber()]);
1233 return {Storage, getLoopsNumber()};
1234 }
1235
1236protected:
1237 /// Build instance of loop directive of class \a Kind.
1238 ///
1239 /// \param SC Statement class.
1240 /// \param Kind Kind of OpenMP directive.
1241 /// \param StartLoc Starting location of the directive (directive keyword).
1242 /// \param EndLoc Ending location of the directive.
1243 /// \param CollapsedNum Number of collapsed loops from 'collapse' clause.
1244 ///
1245 OMPLoopDirective(StmtClass SC, OpenMPDirectiveKind Kind,
1246 SourceLocation StartLoc, SourceLocation EndLoc,
1247 unsigned CollapsedNum)
1248 : OMPLoopBasedDirective(SC, Kind, StartLoc, EndLoc, CollapsedNum) {}
1249
1250 /// Offset to the start of children expression arrays.
1251 static unsigned getArraysOffset(OpenMPDirectiveKind Kind) {
1252 if (isOpenMPLoopBoundSharingDirective(Kind))
1253 return CombinedDistributeEnd;
1254 if (isOpenMPWorksharingDirective(Kind) || isOpenMPTaskLoopDirective(Kind) ||
1255 isOpenMPGenericLoopDirective(Kind) || isOpenMPDistributeDirective(Kind))
1256 return WorksharingEnd;
1257 return DefaultEnd;
1258 }
1259
1260 /// Children number.
1261 static unsigned numLoopChildren(unsigned CollapsedNum,
1262 OpenMPDirectiveKind Kind) {
1263 return getArraysOffset(Kind) +
1264 8 * CollapsedNum; // Counters, PrivateCounters, Inits,
1265 // Updates, Finals, DependentCounters,
1266 // DependentInits, FinalsConditions.
1267 }
1268
1269 void setIterationVariable(Expr *IV) {
1270 Data->getChildren()[IterationVariableOffset] = IV;
1271 }
1272 void setLastIteration(Expr *LI) {
1273 Data->getChildren()[LastIterationOffset] = LI;
1274 }
1275 void setCalcLastIteration(Expr *CLI) {
1276 Data->getChildren()[CalcLastIterationOffset] = CLI;
1277 }
1278 void setPreCond(Expr *PC) { Data->getChildren()[PreConditionOffset] = PC; }
1279 void setCond(Expr *Cond) { Data->getChildren()[CondOffset] = Cond; }
1280 void setInit(Expr *Init) { Data->getChildren()[InitOffset] = Init; }
1281 void setInc(Expr *Inc) { Data->getChildren()[IncOffset] = Inc; }
1282 void setPreInits(Stmt *PreInits) {
1283 Data->getChildren()[PreInitsOffset] = PreInits;
1284 }
1285 void setIsLastIterVariable(Expr *IL) {
1286 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1287 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1288 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1289 isOpenMPDistributeDirective(getDirectiveKind())) &&
1290 "expected worksharing loop directive");
1291 Data->getChildren()[IsLastIterVariableOffset] = IL;
1292 }
1293 void setLowerBoundVariable(Expr *LB) {
1294 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1295 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1296 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1297 isOpenMPDistributeDirective(getDirectiveKind())) &&
1298 "expected worksharing loop directive");
1299 Data->getChildren()[LowerBoundVariableOffset] = LB;
1300 }
1301 void setUpperBoundVariable(Expr *UB) {
1302 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1303 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1304 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1305 isOpenMPDistributeDirective(getDirectiveKind())) &&
1306 "expected worksharing loop directive");
1307 Data->getChildren()[UpperBoundVariableOffset] = UB;
1308 }
1309 void setStrideVariable(Expr *ST) {
1310 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1311 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1312 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1313 isOpenMPDistributeDirective(getDirectiveKind())) &&
1314 "expected worksharing loop directive");
1315 Data->getChildren()[StrideVariableOffset] = ST;
1316 }
1317 void setEnsureUpperBound(Expr *EUB) {
1318 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1319 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1320 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1321 isOpenMPDistributeDirective(getDirectiveKind())) &&
1322 "expected worksharing loop directive");
1323 Data->getChildren()[EnsureUpperBoundOffset] = EUB;
1324 }
1325 void setNextLowerBound(Expr *NLB) {
1326 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1327 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1328 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1329 isOpenMPDistributeDirective(getDirectiveKind())) &&
1330 "expected worksharing loop directive");
1331 Data->getChildren()[NextLowerBoundOffset] = NLB;
1332 }
1333 void setNextUpperBound(Expr *NUB) {
1334 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1335 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1336 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1337 isOpenMPDistributeDirective(getDirectiveKind())) &&
1338 "expected worksharing loop directive");
1339 Data->getChildren()[NextUpperBoundOffset] = NUB;
1340 }
1341 void setNumIterations(Expr *NI) {
1342 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1343 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1344 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1345 isOpenMPDistributeDirective(getDirectiveKind())) &&
1346 "expected worksharing loop directive");
1347 Data->getChildren()[NumIterationsOffset] = NI;
1348 }
1349 void setPrevLowerBoundVariable(Expr *PrevLB) {
1350 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1351 "expected loop bound sharing directive");
1352 Data->getChildren()[PrevLowerBoundVariableOffset] = PrevLB;
1353 }
1354 void setPrevUpperBoundVariable(Expr *PrevUB) {
1355 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1356 "expected loop bound sharing directive");
1357 Data->getChildren()[PrevUpperBoundVariableOffset] = PrevUB;
1358 }
1359 void setDistInc(Expr *DistInc) {
1360 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1361 "expected loop bound sharing directive");
1362 Data->getChildren()[DistIncOffset] = DistInc;
1363 }
1364 void setPrevEnsureUpperBound(Expr *PrevEUB) {
1365 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1366 "expected loop bound sharing directive");
1367 Data->getChildren()[PrevEnsureUpperBoundOffset] = PrevEUB;
1368 }
1370 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1371 "expected loop bound sharing directive");
1372 Data->getChildren()[CombinedLowerBoundVariableOffset] = CombLB;
1373 }
1375 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1376 "expected loop bound sharing directive");
1377 Data->getChildren()[CombinedUpperBoundVariableOffset] = CombUB;
1378 }
1379 void setCombinedEnsureUpperBound(Expr *CombEUB) {
1380 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1381 "expected loop bound sharing directive");
1382 Data->getChildren()[CombinedEnsureUpperBoundOffset] = CombEUB;
1383 }
1384 void setCombinedInit(Expr *CombInit) {
1385 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1386 "expected loop bound sharing directive");
1387 Data->getChildren()[CombinedInitOffset] = CombInit;
1388 }
1389 void setCombinedCond(Expr *CombCond) {
1390 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1391 "expected loop bound sharing directive");
1392 Data->getChildren()[CombinedConditionOffset] = CombCond;
1393 }
1394 void setCombinedNextLowerBound(Expr *CombNLB) {
1395 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1396 "expected loop bound sharing directive");
1397 Data->getChildren()[CombinedNextLowerBoundOffset] = CombNLB;
1398 }
1399 void setCombinedNextUpperBound(Expr *CombNUB) {
1400 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1401 "expected loop bound sharing directive");
1402 Data->getChildren()[CombinedNextUpperBoundOffset] = CombNUB;
1403 }
1404 void setCombinedDistCond(Expr *CombDistCond) {
1405 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1406 "expected loop bound distribute sharing directive");
1407 Data->getChildren()[CombinedDistConditionOffset] = CombDistCond;
1408 }
1409 void setCombinedParForInDistCond(Expr *CombParForInDistCond) {
1410 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1411 "expected loop bound distribute sharing directive");
1412 Data->getChildren()[CombinedParForInDistConditionOffset] =
1413 CombParForInDistCond;
1414 }
1415 void setCounters(ArrayRef<Expr *> A);
1416 void setPrivateCounters(ArrayRef<Expr *> A);
1417 void setInits(ArrayRef<Expr *> A);
1418 void setUpdates(ArrayRef<Expr *> A);
1419 void setFinals(ArrayRef<Expr *> A);
1420 void setDependentCounters(ArrayRef<Expr *> A);
1421 void setDependentInits(ArrayRef<Expr *> A);
1422 void setFinalsConditions(ArrayRef<Expr *> A);
1423 /// Set the helper expressions used by this directive kind.
1424 void setHelperExprs(const HelperExprs &Exprs);
1425
1426public:
1427 Expr *getIterationVariable() const {
1428 return cast<Expr>(Data->getChildren()[IterationVariableOffset]);
1429 }
1430 Expr *getLastIteration() const {
1431 return cast<Expr>(Data->getChildren()[LastIterationOffset]);
1432 }
1433 Expr *getCalcLastIteration() const {
1434 return cast<Expr>(Data->getChildren()[CalcLastIterationOffset]);
1435 }
1436 Expr *getPreCond() const {
1437 return cast<Expr>(Data->getChildren()[PreConditionOffset]);
1438 }
1439 Expr *getCond() const { return cast<Expr>(Data->getChildren()[CondOffset]); }
1440 Expr *getInit() const { return cast<Expr>(Data->getChildren()[InitOffset]); }
1441 Expr *getInc() const { return cast<Expr>(Data->getChildren()[IncOffset]); }
1442 const Stmt *getPreInits() const {
1443 return Data->getChildren()[PreInitsOffset];
1444 }
1445 Stmt *getPreInits() { return Data->getChildren()[PreInitsOffset]; }
1447 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1448 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1449 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1450 isOpenMPDistributeDirective(getDirectiveKind())) &&
1451 "expected worksharing loop directive");
1452 return cast<Expr>(Data->getChildren()[IsLastIterVariableOffset]);
1453 }
1455 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1456 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1457 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1458 isOpenMPDistributeDirective(getDirectiveKind())) &&
1459 "expected worksharing loop directive");
1460 return cast<Expr>(Data->getChildren()[LowerBoundVariableOffset]);
1461 }
1463 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1464 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1465 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1466 isOpenMPDistributeDirective(getDirectiveKind())) &&
1467 "expected worksharing loop directive");
1468 return cast<Expr>(Data->getChildren()[UpperBoundVariableOffset]);
1469 }
1470 Expr *getStrideVariable() const {
1471 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1472 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1473 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1474 isOpenMPDistributeDirective(getDirectiveKind())) &&
1475 "expected worksharing loop directive");
1476 return cast<Expr>(Data->getChildren()[StrideVariableOffset]);
1477 }
1478 Expr *getEnsureUpperBound() const {
1479 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1480 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1481 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1482 isOpenMPDistributeDirective(getDirectiveKind())) &&
1483 "expected worksharing loop directive");
1484 return cast<Expr>(Data->getChildren()[EnsureUpperBoundOffset]);
1485 }
1486 Expr *getNextLowerBound() const {
1487 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1488 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1489 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1490 isOpenMPDistributeDirective(getDirectiveKind())) &&
1491 "expected worksharing loop directive");
1492 return cast<Expr>(Data->getChildren()[NextLowerBoundOffset]);
1493 }
1494 Expr *getNextUpperBound() const {
1495 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1496 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1497 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1498 isOpenMPDistributeDirective(getDirectiveKind())) &&
1499 "expected worksharing loop directive");
1500 return cast<Expr>(Data->getChildren()[NextUpperBoundOffset]);
1501 }
1502 Expr *getNumIterations() const {
1503 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
1504 isOpenMPGenericLoopDirective(getDirectiveKind()) ||
1505 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
1506 isOpenMPDistributeDirective(getDirectiveKind())) &&
1507 "expected worksharing loop directive");
1508 return cast<Expr>(Data->getChildren()[NumIterationsOffset]);
1509 }
1511 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1512 "expected loop bound sharing directive");
1513 return cast<Expr>(Data->getChildren()[PrevLowerBoundVariableOffset]);
1514 }
1516 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1517 "expected loop bound sharing directive");
1518 return cast<Expr>(Data->getChildren()[PrevUpperBoundVariableOffset]);
1519 }
1520 Expr *getDistInc() const {
1521 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1522 "expected loop bound sharing directive");
1523 return cast<Expr>(Data->getChildren()[DistIncOffset]);
1524 }
1526 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1527 "expected loop bound sharing directive");
1528 return cast<Expr>(Data->getChildren()[PrevEnsureUpperBoundOffset]);
1529 }
1531 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1532 "expected loop bound sharing directive");
1533 return cast<Expr>(Data->getChildren()[CombinedLowerBoundVariableOffset]);
1534 }
1536 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1537 "expected loop bound sharing directive");
1538 return cast<Expr>(Data->getChildren()[CombinedUpperBoundVariableOffset]);
1539 }
1541 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1542 "expected loop bound sharing directive");
1543 return cast<Expr>(Data->getChildren()[CombinedEnsureUpperBoundOffset]);
1544 }
1545 Expr *getCombinedInit() const {
1546 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1547 "expected loop bound sharing directive");
1548 return cast<Expr>(Data->getChildren()[CombinedInitOffset]);
1549 }
1550 Expr *getCombinedCond() const {
1551 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1552 "expected loop bound sharing directive");
1553 return cast<Expr>(Data->getChildren()[CombinedConditionOffset]);
1554 }
1556 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1557 "expected loop bound sharing directive");
1558 return cast<Expr>(Data->getChildren()[CombinedNextLowerBoundOffset]);
1559 }
1561 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1562 "expected loop bound sharing directive");
1563 return cast<Expr>(Data->getChildren()[CombinedNextUpperBoundOffset]);
1564 }
1565 Expr *getCombinedDistCond() const {
1566 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1567 "expected loop bound distribute sharing directive");
1568 return cast<Expr>(Data->getChildren()[CombinedDistConditionOffset]);
1569 }
1571 assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) &&
1572 "expected loop bound distribute sharing directive");
1573 return cast<Expr>(Data->getChildren()[CombinedParForInDistConditionOffset]);
1574 }
1575 Stmt *getBody();
1576 const Stmt *getBody() const {
1577 return const_cast<OMPLoopDirective *>(this)->getBody();
1578 }
1579
1580 ArrayRef<Expr *> counters() { return getCounters(); }
1581
1583 return const_cast<OMPLoopDirective *>(this)->getCounters();
1584 }
1585
1586 ArrayRef<Expr *> private_counters() { return getPrivateCounters(); }
1587
1589 return const_cast<OMPLoopDirective *>(this)->getPrivateCounters();
1590 }
1591
1592 ArrayRef<Expr *> inits() { return getInits(); }
1593
1595 return const_cast<OMPLoopDirective *>(this)->getInits();
1596 }
1597
1598 ArrayRef<Expr *> updates() { return getUpdates(); }
1599
1601 return const_cast<OMPLoopDirective *>(this)->getUpdates();
1602 }
1603
1604 ArrayRef<Expr *> finals() { return getFinals(); }
1605
1607 return const_cast<OMPLoopDirective *>(this)->getFinals();
1608 }
1609
1610 ArrayRef<Expr *> dependent_counters() { return getDependentCounters(); }
1611
1613 return const_cast<OMPLoopDirective *>(this)->getDependentCounters();
1614 }
1615
1616 ArrayRef<Expr *> dependent_inits() { return getDependentInits(); }
1617
1619 return const_cast<OMPLoopDirective *>(this)->getDependentInits();
1620 }
1621
1622 ArrayRef<Expr *> finals_conditions() { return getFinalsConditions(); }
1623
1625 return const_cast<OMPLoopDirective *>(this)->getFinalsConditions();
1626 }
1627
1628 static bool classof(const Stmt *T) {
1629 return T->getStmtClass() == OMPSimdDirectiveClass ||
1630 T->getStmtClass() == OMPForDirectiveClass ||
1631 T->getStmtClass() == OMPForSimdDirectiveClass ||
1632 T->getStmtClass() == OMPParallelForDirectiveClass ||
1633 T->getStmtClass() == OMPParallelForSimdDirectiveClass ||
1634 T->getStmtClass() == OMPTaskLoopDirectiveClass ||
1635 T->getStmtClass() == OMPTaskLoopSimdDirectiveClass ||
1636 T->getStmtClass() == OMPMaskedTaskLoopDirectiveClass ||
1637 T->getStmtClass() == OMPMaskedTaskLoopSimdDirectiveClass ||
1638 T->getStmtClass() == OMPMasterTaskLoopDirectiveClass ||
1639 T->getStmtClass() == OMPMasterTaskLoopSimdDirectiveClass ||
1640 T->getStmtClass() == OMPGenericLoopDirectiveClass ||
1641 T->getStmtClass() == OMPTeamsGenericLoopDirectiveClass ||
1642 T->getStmtClass() == OMPTargetTeamsGenericLoopDirectiveClass ||
1643 T->getStmtClass() == OMPParallelGenericLoopDirectiveClass ||
1644 T->getStmtClass() == OMPTargetParallelGenericLoopDirectiveClass ||
1645 T->getStmtClass() == OMPTargetGenericLoopDirectiveClass ||
1646 T->getStmtClass() == OMPParallelMaskedTaskLoopDirectiveClass ||
1647 T->getStmtClass() == OMPParallelMaskedTaskLoopSimdDirectiveClass ||
1648 T->getStmtClass() == OMPParallelMasterTaskLoopDirectiveClass ||
1649 T->getStmtClass() == OMPParallelMasterTaskLoopSimdDirectiveClass ||
1650 T->getStmtClass() == OMPDistributeDirectiveClass ||
1651 T->getStmtClass() == OMPTargetParallelForDirectiveClass ||
1652 T->getStmtClass() == OMPDistributeParallelForDirectiveClass ||
1653 T->getStmtClass() == OMPDistributeParallelForSimdDirectiveClass ||
1654 T->getStmtClass() == OMPDistributeSimdDirectiveClass ||
1655 T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass ||
1656 T->getStmtClass() == OMPTargetSimdDirectiveClass ||
1657 T->getStmtClass() == OMPTeamsDistributeDirectiveClass ||
1658 T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass ||
1659 T->getStmtClass() ==
1660 OMPTeamsDistributeParallelForSimdDirectiveClass ||
1661 T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass ||
1662 T->getStmtClass() ==
1663 OMPTargetTeamsDistributeParallelForDirectiveClass ||
1664 T->getStmtClass() ==
1665 OMPTargetTeamsDistributeParallelForSimdDirectiveClass ||
1666 T->getStmtClass() == OMPTargetTeamsDistributeDirectiveClass ||
1667 T->getStmtClass() == OMPTargetTeamsDistributeSimdDirectiveClass;
1668 }
1669};
1670
1671/// This represents '#pragma omp simd' directive.
1672///
1673/// \code
1674/// #pragma omp simd private(a,b) linear(i,j:s) reduction(+:c,d)
1675/// \endcode
1676/// In this example directive '#pragma omp simd' has clauses 'private'
1677/// with the variables 'a' and 'b', 'linear' with variables 'i', 'j' and
1678/// linear step 's', 'reduction' with operator '+' and variables 'c' and 'd'.
1679///
1680class OMPSimdDirective : public OMPLoopDirective {
1681 friend class ASTStmtReader;
1683 /// Build directive with the given start and end location.
1684 ///
1685 /// \param StartLoc Starting location of the directive kind.
1686 /// \param EndLoc Ending location of the directive.
1687 /// \param CollapsedNum Number of collapsed nested loops.
1688 ///
1689 OMPSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1690 unsigned CollapsedNum)
1691 : OMPLoopDirective(OMPSimdDirectiveClass, llvm::omp::OMPD_simd, StartLoc,
1692 EndLoc, CollapsedNum) {}
1693
1694 /// Build an empty directive.
1695 ///
1696 /// \param CollapsedNum Number of collapsed nested loops.
1697 ///
1698 explicit OMPSimdDirective(unsigned CollapsedNum)
1699 : OMPLoopDirective(OMPSimdDirectiveClass, llvm::omp::OMPD_simd,
1700 SourceLocation(), SourceLocation(), CollapsedNum) {}
1701
1702public:
1703 /// Creates directive with a list of \a Clauses.
1704 ///
1705 /// \param C AST context.
1706 /// \param StartLoc Starting location of the directive kind.
1707 /// \param EndLoc Ending Location of the directive.
1708 /// \param CollapsedNum Number of collapsed loops.
1709 /// \param Clauses List of clauses.
1710 /// \param AssociatedStmt Statement, associated with the directive.
1711 /// \param Exprs Helper expressions for CodeGen.
1712 ///
1713 static OMPSimdDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1714 SourceLocation EndLoc, unsigned CollapsedNum,
1715 ArrayRef<OMPClause *> Clauses,
1716 Stmt *AssociatedStmt,
1717 const HelperExprs &Exprs);
1718
1719 /// Creates an empty directive with the place
1720 /// for \a NumClauses clauses.
1721 ///
1722 /// \param C AST context.
1723 /// \param CollapsedNum Number of collapsed nested loops.
1724 /// \param NumClauses Number of clauses.
1725 ///
1726 static OMPSimdDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
1727 unsigned CollapsedNum, EmptyShell);
1728
1729 static bool classof(const Stmt *T) {
1730 return T->getStmtClass() == OMPSimdDirectiveClass;
1731 }
1732};
1733
1734/// This represents '#pragma omp for' directive.
1735///
1736/// \code
1737/// #pragma omp for private(a,b) reduction(+:c,d)
1738/// \endcode
1739/// In this example directive '#pragma omp for' has clauses 'private' with the
1740/// variables 'a' and 'b' and 'reduction' with operator '+' and variables 'c'
1741/// and 'd'.
1742///
1743class OMPForDirective : public OMPLoopDirective {
1744 friend class ASTStmtReader;
1746 /// true if current directive has inner cancel directive.
1747 bool HasCancel = false;
1748
1749 /// Build directive with the given start and end location.
1750 ///
1751 /// \param StartLoc Starting location of the directive kind.
1752 /// \param EndLoc Ending location of the directive.
1753 /// \param CollapsedNum Number of collapsed nested loops.
1754 ///
1755 OMPForDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1756 unsigned CollapsedNum)
1757 : OMPLoopDirective(OMPForDirectiveClass, llvm::omp::OMPD_for, StartLoc,
1758 EndLoc, CollapsedNum) {}
1759
1760 /// Build an empty directive.
1761 ///
1762 /// \param CollapsedNum Number of collapsed nested loops.
1763 ///
1764 explicit OMPForDirective(unsigned CollapsedNum)
1765 : OMPLoopDirective(OMPForDirectiveClass, llvm::omp::OMPD_for,
1766 SourceLocation(), SourceLocation(), CollapsedNum) {}
1767
1768 /// Sets special task reduction descriptor.
1769 void setTaskReductionRefExpr(Expr *E) {
1770 Data->getChildren()[numLoopChildren(getLoopsNumber(),
1771 llvm::omp::OMPD_for)] = E;
1772 }
1773
1774 /// Set cancel state.
1775 void setHasCancel(bool Has) { HasCancel = Has; }
1776
1777public:
1778 /// Creates directive with a list of \a Clauses.
1779 ///
1780 /// \param C AST context.
1781 /// \param StartLoc Starting location of the directive kind.
1782 /// \param EndLoc Ending Location of the directive.
1783 /// \param CollapsedNum Number of collapsed loops.
1784 /// \param Clauses List of clauses.
1785 /// \param AssociatedStmt Statement, associated with the directive.
1786 /// \param Exprs Helper expressions for CodeGen.
1787 /// \param TaskRedRef Task reduction special reference expression to handle
1788 /// taskgroup descriptor.
1789 /// \param HasCancel true if current directive has inner cancel directive.
1790 ///
1791 static OMPForDirective *Create(const ASTContext &C, SourceLocation StartLoc,
1792 SourceLocation EndLoc, unsigned CollapsedNum,
1793 ArrayRef<OMPClause *> Clauses,
1794 Stmt *AssociatedStmt, const HelperExprs &Exprs,
1795 Expr *TaskRedRef, bool HasCancel);
1796
1797 /// Creates an empty directive with the place
1798 /// for \a NumClauses clauses.
1799 ///
1800 /// \param C AST context.
1801 /// \param CollapsedNum Number of collapsed nested loops.
1802 /// \param NumClauses Number of clauses.
1803 ///
1804 static OMPForDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
1805 unsigned CollapsedNum, EmptyShell);
1806
1807 /// Returns special task reduction reference expression.
1809 return cast_or_null<Expr>(Data->getChildren()[numLoopChildren(
1810 getLoopsNumber(), llvm::omp::OMPD_for)]);
1811 }
1812 const Expr *getTaskReductionRefExpr() const {
1813 return const_cast<OMPForDirective *>(this)->getTaskReductionRefExpr();
1814 }
1815
1816 /// Return true if current directive has inner cancel directive.
1817 bool hasCancel() const { return HasCancel; }
1818
1819 static bool classof(const Stmt *T) {
1820 return T->getStmtClass() == OMPForDirectiveClass;
1821 }
1822};
1823
1824/// This represents '#pragma omp for simd' directive.
1825///
1826/// \code
1827/// #pragma omp for simd private(a,b) linear(i,j:s) reduction(+:c,d)
1828/// \endcode
1829/// In this example directive '#pragma omp for simd' has clauses 'private'
1830/// with the variables 'a' and 'b', 'linear' with variables 'i', 'j' and
1831/// linear step 's', 'reduction' with operator '+' and variables 'c' and 'd'.
1832///
1833class OMPForSimdDirective : public OMPLoopDirective {
1834 friend class ASTStmtReader;
1836 /// Build directive with the given start and end location.
1837 ///
1838 /// \param StartLoc Starting location of the directive kind.
1839 /// \param EndLoc Ending location of the directive.
1840 /// \param CollapsedNum Number of collapsed nested loops.
1841 ///
1842 OMPForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
1843 unsigned CollapsedNum)
1844 : OMPLoopDirective(OMPForSimdDirectiveClass, llvm::omp::OMPD_for_simd,
1845 StartLoc, EndLoc, CollapsedNum) {}
1846
1847 /// Build an empty directive.
1848 ///
1849 /// \param CollapsedNum Number of collapsed nested loops.
1850 ///
1851 explicit OMPForSimdDirective(unsigned CollapsedNum)
1852 : OMPLoopDirective(OMPForSimdDirectiveClass, llvm::omp::OMPD_for_simd,
1853 SourceLocation(), SourceLocation(), CollapsedNum) {}
1854
1855public:
1856 /// Creates directive with a list of \a Clauses.
1857 ///
1858 /// \param C AST context.
1859 /// \param StartLoc Starting location of the directive kind.
1860 /// \param EndLoc Ending Location of the directive.
1861 /// \param CollapsedNum Number of collapsed loops.
1862 /// \param Clauses List of clauses.
1863 /// \param AssociatedStmt Statement, associated with the directive.
1864 /// \param Exprs Helper expressions for CodeGen.
1865 ///
1866 static OMPForSimdDirective *
1867 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1868 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
1869 Stmt *AssociatedStmt, const HelperExprs &Exprs);
1870
1871 /// Creates an empty directive with the place
1872 /// for \a NumClauses clauses.
1873 ///
1874 /// \param C AST context.
1875 /// \param CollapsedNum Number of collapsed nested loops.
1876 /// \param NumClauses Number of clauses.
1877 ///
1878 static OMPForSimdDirective *CreateEmpty(const ASTContext &C,
1879 unsigned NumClauses,
1880 unsigned CollapsedNum, EmptyShell);
1881
1882 static bool classof(const Stmt *T) {
1883 return T->getStmtClass() == OMPForSimdDirectiveClass;
1884 }
1885};
1886
1887/// This represents '#pragma omp sections' directive.
1888///
1889/// \code
1890/// #pragma omp sections private(a,b) reduction(+:c,d)
1891/// \endcode
1892/// In this example directive '#pragma omp sections' has clauses 'private' with
1893/// the variables 'a' and 'b' and 'reduction' with operator '+' and variables
1894/// 'c' and 'd'.
1895///
1896class OMPSectionsDirective : public OMPExecutableDirective {
1897 friend class ASTStmtReader;
1899
1900 /// true if current directive has inner cancel directive.
1901 bool HasCancel = false;
1902
1903 /// Build directive with the given start and end location.
1904 ///
1905 /// \param StartLoc Starting location of the directive kind.
1906 /// \param EndLoc Ending location of the directive.
1907 ///
1908 OMPSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc)
1909 : OMPExecutableDirective(OMPSectionsDirectiveClass,
1910 llvm::omp::OMPD_sections, StartLoc, EndLoc) {}
1911
1912 /// Build an empty directive.
1913 ///
1914 explicit OMPSectionsDirective()
1915 : OMPExecutableDirective(OMPSectionsDirectiveClass,
1916 llvm::omp::OMPD_sections, SourceLocation(),
1917 SourceLocation()) {}
1918
1919 /// Sets special task reduction descriptor.
1920 void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[0] = E; }
1921
1922 /// Set cancel state.
1923 void setHasCancel(bool Has) { HasCancel = Has; }
1924
1925public:
1926 /// Creates directive with a list of \a Clauses.
1927 ///
1928 /// \param C AST context.
1929 /// \param StartLoc Starting location of the directive kind.
1930 /// \param EndLoc Ending Location of the directive.
1931 /// \param Clauses List of clauses.
1932 /// \param AssociatedStmt Statement, associated with the directive.
1933 /// \param TaskRedRef Task reduction special reference expression to handle
1934 /// taskgroup descriptor.
1935 /// \param HasCancel true if current directive has inner directive.
1936 ///
1937 static OMPSectionsDirective *
1938 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1939 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
1940 bool HasCancel);
1941
1942 /// Creates an empty directive with the place for \a NumClauses
1943 /// clauses.
1944 ///
1945 /// \param C AST context.
1946 /// \param NumClauses Number of clauses.
1947 ///
1948 static OMPSectionsDirective *CreateEmpty(const ASTContext &C,
1949 unsigned NumClauses, EmptyShell);
1950
1951 /// Returns special task reduction reference expression.
1953 return cast_or_null<Expr>(Data->getChildren()[0]);
1954 }
1955 const Expr *getTaskReductionRefExpr() const {
1956 return const_cast<OMPSectionsDirective *>(this)->getTaskReductionRefExpr();
1957 }
1958
1959 /// Return true if current directive has inner cancel directive.
1960 bool hasCancel() const { return HasCancel; }
1961
1962 static bool classof(const Stmt *T) {
1963 return T->getStmtClass() == OMPSectionsDirectiveClass;
1964 }
1965};
1966
1967/// This represents '#pragma omp section' directive.
1968///
1969/// \code
1970/// #pragma omp section
1971/// \endcode
1972///
1973class OMPSectionDirective : public OMPExecutableDirective {
1974 friend class ASTStmtReader;
1976
1977 /// true if current directive has inner cancel directive.
1978 bool HasCancel = false;
1979
1980 /// Build directive with the given start and end location.
1981 ///
1982 /// \param StartLoc Starting location of the directive kind.
1983 /// \param EndLoc Ending location of the directive.
1984 ///
1985 OMPSectionDirective(SourceLocation StartLoc, SourceLocation EndLoc)
1986 : OMPExecutableDirective(OMPSectionDirectiveClass,
1987 llvm::omp::OMPD_section, StartLoc, EndLoc) {}
1988
1989 /// Build an empty directive.
1990 ///
1991 explicit OMPSectionDirective()
1992 : OMPExecutableDirective(OMPSectionDirectiveClass,
1993 llvm::omp::OMPD_section, SourceLocation(),
1994 SourceLocation()) {}
1995
1996public:
1997 /// Creates directive.
1998 ///
1999 /// \param C AST context.
2000 /// \param StartLoc Starting location of the directive kind.
2001 /// \param EndLoc Ending Location of the directive.
2002 /// \param AssociatedStmt Statement, associated with the directive.
2003 /// \param HasCancel true if current directive has inner directive.
2004 ///
2005 static OMPSectionDirective *Create(const ASTContext &C,
2006 SourceLocation StartLoc,
2007 SourceLocation EndLoc,
2008 Stmt *AssociatedStmt, bool HasCancel);
2009
2010 /// Creates an empty directive.
2011 ///
2012 /// \param C AST context.
2013 ///
2014 static OMPSectionDirective *CreateEmpty(const ASTContext &C, EmptyShell);
2015
2016 /// Set cancel state.
2017 void setHasCancel(bool Has) { HasCancel = Has; }
2018
2019 /// Return true if current directive has inner cancel directive.
2020 bool hasCancel() const { return HasCancel; }
2021
2022 static bool classof(const Stmt *T) {
2023 return T->getStmtClass() == OMPSectionDirectiveClass;
2024 }
2025};
2026
2027/// This represents '#pragma omp scope' directive.
2028/// \code
2029/// #pragma omp scope private(a,b) nowait
2030/// \endcode
2031/// In this example directive '#pragma omp scope' has clauses 'private' with
2032/// the variables 'a' and 'b' and nowait.
2033///
2034class OMPScopeDirective final : public OMPExecutableDirective {
2035 friend class ASTStmtReader;
2037
2038 /// Build directive with the given start and end location.
2039 ///
2040 /// \param StartLoc Starting location of the directive kind.
2041 /// \param EndLoc Ending location of the directive.
2042 ///
2043 OMPScopeDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2044 : OMPExecutableDirective(OMPScopeDirectiveClass, llvm::omp::OMPD_scope,
2045 StartLoc, EndLoc) {}
2046
2047 /// Build an empty directive.
2048 ///
2049 explicit OMPScopeDirective()
2050 : OMPExecutableDirective(OMPScopeDirectiveClass, llvm::omp::OMPD_scope,
2051 SourceLocation(), SourceLocation()) {}
2052
2053public:
2054 /// Creates directive.
2055 ///
2056 /// \param C AST context.
2057 /// \param StartLoc Starting location of the directive kind.
2058 /// \param EndLoc Ending Location of the directive.
2059 /// \param AssociatedStmt Statement, associated with the directive.
2060 ///
2061 static OMPScopeDirective *Create(const ASTContext &C, SourceLocation StartLoc,
2062 SourceLocation EndLoc,
2063 ArrayRef<OMPClause *> Clauses,
2064 Stmt *AssociatedStmt);
2065
2066 /// Creates an empty directive.
2067 ///
2068 /// \param C AST context.
2069 ///
2070 static OMPScopeDirective *CreateEmpty(const ASTContext &C,
2071 unsigned NumClauses, EmptyShell);
2072
2073 static bool classof(const Stmt *T) {
2074 return T->getStmtClass() == OMPScopeDirectiveClass;
2075 }
2076};
2077
2078/// This represents '#pragma omp single' directive.
2079///
2080/// \code
2081/// #pragma omp single private(a,b) copyprivate(c,d)
2082/// \endcode
2083/// In this example directive '#pragma omp single' has clauses 'private' with
2084/// the variables 'a' and 'b' and 'copyprivate' with variables 'c' and 'd'.
2085///
2086class OMPSingleDirective : public OMPExecutableDirective {
2087 friend class ASTStmtReader;
2089 /// Build directive with the given start and end location.
2090 ///
2091 /// \param StartLoc Starting location of the directive kind.
2092 /// \param EndLoc Ending location of the directive.
2093 ///
2094 OMPSingleDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2095 : OMPExecutableDirective(OMPSingleDirectiveClass, llvm::omp::OMPD_single,
2096 StartLoc, EndLoc) {}
2097
2098 /// Build an empty directive.
2099 ///
2100 explicit OMPSingleDirective()
2101 : OMPExecutableDirective(OMPSingleDirectiveClass, llvm::omp::OMPD_single,
2102 SourceLocation(), SourceLocation()) {}
2103
2104public:
2105 /// Creates directive with a list of \a Clauses.
2106 ///
2107 /// \param C AST context.
2108 /// \param StartLoc Starting location of the directive kind.
2109 /// \param EndLoc Ending Location of the directive.
2110 /// \param Clauses List of clauses.
2111 /// \param AssociatedStmt Statement, associated with the directive.
2112 ///
2113 static OMPSingleDirective *
2114 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2115 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2116
2117 /// Creates an empty directive with the place for \a NumClauses
2118 /// clauses.
2119 ///
2120 /// \param C AST context.
2121 /// \param NumClauses Number of clauses.
2122 ///
2123 static OMPSingleDirective *CreateEmpty(const ASTContext &C,
2124 unsigned NumClauses, EmptyShell);
2125
2126 static bool classof(const Stmt *T) {
2127 return T->getStmtClass() == OMPSingleDirectiveClass;
2128 }
2129};
2130
2131/// This represents '#pragma omp master' directive.
2132///
2133/// \code
2134/// #pragma omp master
2135/// \endcode
2136///
2137class OMPMasterDirective : public OMPExecutableDirective {
2138 friend class ASTStmtReader;
2140 /// Build directive with the given start and end location.
2141 ///
2142 /// \param StartLoc Starting location of the directive kind.
2143 /// \param EndLoc Ending location of the directive.
2144 ///
2145 OMPMasterDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2146 : OMPExecutableDirective(OMPMasterDirectiveClass, llvm::omp::OMPD_master,
2147 StartLoc, EndLoc) {}
2148
2149 /// Build an empty directive.
2150 ///
2151 explicit OMPMasterDirective()
2152 : OMPExecutableDirective(OMPMasterDirectiveClass, llvm::omp::OMPD_master,
2153 SourceLocation(), SourceLocation()) {}
2154
2155public:
2156 /// Creates directive.
2157 ///
2158 /// \param C AST context.
2159 /// \param StartLoc Starting location of the directive kind.
2160 /// \param EndLoc Ending Location of the directive.
2161 /// \param AssociatedStmt Statement, associated with the directive.
2162 ///
2163 static OMPMasterDirective *Create(const ASTContext &C,
2164 SourceLocation StartLoc,
2165 SourceLocation EndLoc,
2166 Stmt *AssociatedStmt);
2167
2168 /// Creates an empty directive.
2169 ///
2170 /// \param C AST context.
2171 ///
2172 static OMPMasterDirective *CreateEmpty(const ASTContext &C, EmptyShell);
2173
2174 static bool classof(const Stmt *T) {
2175 return T->getStmtClass() == OMPMasterDirectiveClass;
2176 }
2177};
2178
2179/// This represents '#pragma omp critical' directive.
2180///
2181/// \code
2182/// #pragma omp critical
2183/// \endcode
2184///
2185class OMPCriticalDirective : public OMPExecutableDirective {
2186 friend class ASTStmtReader;
2188 /// Name of the directive.
2189 DeclarationNameInfo DirName;
2190 /// Build directive with the given start and end location.
2191 ///
2192 /// \param Name Name of the directive.
2193 /// \param StartLoc Starting location of the directive kind.
2194 /// \param EndLoc Ending location of the directive.
2195 ///
2196 OMPCriticalDirective(const DeclarationNameInfo &Name, SourceLocation StartLoc,
2197 SourceLocation EndLoc)
2198 : OMPExecutableDirective(OMPCriticalDirectiveClass,
2199 llvm::omp::OMPD_critical, StartLoc, EndLoc),
2200 DirName(Name) {}
2201
2202 /// Build an empty directive.
2203 ///
2204 explicit OMPCriticalDirective()
2205 : OMPExecutableDirective(OMPCriticalDirectiveClass,
2206 llvm::omp::OMPD_critical, SourceLocation(),
2207 SourceLocation()) {}
2208
2209 /// Set name of the directive.
2210 ///
2211 /// \param Name Name of the directive.
2212 ///
2213 void setDirectiveName(const DeclarationNameInfo &Name) { DirName = Name; }
2214
2215public:
2216 /// Creates directive.
2217 ///
2218 /// \param C AST context.
2219 /// \param Name Name of the directive.
2220 /// \param StartLoc Starting location of the directive kind.
2221 /// \param EndLoc Ending Location of the directive.
2222 /// \param Clauses List of clauses.
2223 /// \param AssociatedStmt Statement, associated with the directive.
2224 ///
2225 static OMPCriticalDirective *
2226 Create(const ASTContext &C, const DeclarationNameInfo &Name,
2227 SourceLocation StartLoc, SourceLocation EndLoc,
2228 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
2229
2230 /// Creates an empty directive.
2231 ///
2232 /// \param C AST context.
2233 /// \param NumClauses Number of clauses.
2234 ///
2235 static OMPCriticalDirective *CreateEmpty(const ASTContext &C,
2236 unsigned NumClauses, EmptyShell);
2237
2238 /// Return name of the directive.
2239 ///
2240 DeclarationNameInfo getDirectiveName() const { return DirName; }
2241
2242 static bool classof(const Stmt *T) {
2243 return T->getStmtClass() == OMPCriticalDirectiveClass;
2244 }
2245};
2246
2247/// This represents '#pragma omp parallel for' directive.
2248///
2249/// \code
2250/// #pragma omp parallel for private(a,b) reduction(+:c,d)
2251/// \endcode
2252/// In this example directive '#pragma omp parallel for' has clauses 'private'
2253/// with the variables 'a' and 'b' and 'reduction' with operator '+' and
2254/// variables 'c' and 'd'.
2255///
2256class OMPParallelForDirective : public OMPLoopDirective {
2257 friend class ASTStmtReader;
2259
2260 /// true if current region has inner cancel directive.
2261 bool HasCancel = false;
2262
2263 /// Build directive with the given start and end location.
2264 ///
2265 /// \param StartLoc Starting location of the directive kind.
2266 /// \param EndLoc Ending location of the directive.
2267 /// \param CollapsedNum Number of collapsed nested loops.
2268 ///
2269 OMPParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2270 unsigned CollapsedNum)
2271 : OMPLoopDirective(OMPParallelForDirectiveClass,
2272 llvm::omp::OMPD_parallel_for, StartLoc, EndLoc,
2273 CollapsedNum) {}
2274
2275 /// Build an empty directive.
2276 ///
2277 /// \param CollapsedNum Number of collapsed nested loops.
2278 ///
2279 explicit OMPParallelForDirective(unsigned CollapsedNum)
2280 : OMPLoopDirective(OMPParallelForDirectiveClass,
2281 llvm::omp::OMPD_parallel_for, SourceLocation(),
2282 SourceLocation(), CollapsedNum) {}
2283
2284 /// Sets special task reduction descriptor.
2285 void setTaskReductionRefExpr(Expr *E) {
2286 Data->getChildren()[numLoopChildren(getLoopsNumber(),
2287 llvm::omp::OMPD_parallel_for)] = E;
2288 }
2289
2290 /// Set cancel state.
2291 void setHasCancel(bool Has) { HasCancel = Has; }
2292
2293public:
2294 /// Creates directive with a list of \a Clauses.
2295 ///
2296 /// \param C AST context.
2297 /// \param StartLoc Starting location of the directive kind.
2298 /// \param EndLoc Ending Location of the directive.
2299 /// \param CollapsedNum Number of collapsed loops.
2300 /// \param Clauses List of clauses.
2301 /// \param AssociatedStmt Statement, associated with the directive.
2302 /// \param Exprs Helper expressions for CodeGen.
2303 /// \param TaskRedRef Task reduction special reference expression to handle
2304 /// taskgroup descriptor.
2305 /// \param HasCancel true if current directive has inner cancel directive.
2306 ///
2307 static OMPParallelForDirective *
2308 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2309 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2310 Stmt *AssociatedStmt, const HelperExprs &Exprs, Expr *TaskRedRef,
2311 bool HasCancel);
2312
2313 /// Creates an empty directive with the place
2314 /// for \a NumClauses clauses.
2315 ///
2316 /// \param C AST context.
2317 /// \param CollapsedNum Number of collapsed nested loops.
2318 /// \param NumClauses Number of clauses.
2319 ///
2320 static OMPParallelForDirective *CreateEmpty(const ASTContext &C,
2321 unsigned NumClauses,
2322 unsigned CollapsedNum,
2323 EmptyShell);
2324
2325 /// Returns special task reduction reference expression.
2327 return cast_or_null<Expr>(Data->getChildren()[numLoopChildren(
2328 getLoopsNumber(), llvm::omp::OMPD_parallel_for)]);
2329 }
2330 const Expr *getTaskReductionRefExpr() const {
2331 return const_cast<OMPParallelForDirective *>(this)
2333 }
2334
2335 /// Return true if current directive has inner cancel directive.
2336 bool hasCancel() const { return HasCancel; }
2337
2338 static bool classof(const Stmt *T) {
2339 return T->getStmtClass() == OMPParallelForDirectiveClass;
2340 }
2341};
2342
2343/// This represents '#pragma omp parallel for simd' directive.
2344///
2345/// \code
2346/// #pragma omp parallel for simd private(a,b) linear(i,j:s) reduction(+:c,d)
2347/// \endcode
2348/// In this example directive '#pragma omp parallel for simd' has clauses
2349/// 'private' with the variables 'a' and 'b', 'linear' with variables 'i', 'j'
2350/// and linear step 's', 'reduction' with operator '+' and variables 'c' and
2351/// 'd'.
2352///
2353class OMPParallelForSimdDirective : public OMPLoopDirective {
2354 friend class ASTStmtReader;
2356 /// Build directive with the given start and end location.
2357 ///
2358 /// \param StartLoc Starting location of the directive kind.
2359 /// \param EndLoc Ending location of the directive.
2360 /// \param CollapsedNum Number of collapsed nested loops.
2361 ///
2362 OMPParallelForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
2363 unsigned CollapsedNum)
2364 : OMPLoopDirective(OMPParallelForSimdDirectiveClass,
2365 llvm::omp::OMPD_parallel_for_simd, StartLoc, EndLoc,
2366 CollapsedNum) {}
2367
2368 /// Build an empty directive.
2369 ///
2370 /// \param CollapsedNum Number of collapsed nested loops.
2371 ///
2372 explicit OMPParallelForSimdDirective(unsigned CollapsedNum)
2373 : OMPLoopDirective(OMPParallelForSimdDirectiveClass,
2374 llvm::omp::OMPD_parallel_for_simd, SourceLocation(),
2375 SourceLocation(), CollapsedNum) {}
2376
2377public:
2378 /// Creates directive with a list of \a Clauses.
2379 ///
2380 /// \param C AST context.
2381 /// \param StartLoc Starting location of the directive kind.
2382 /// \param EndLoc Ending Location of the directive.
2383 /// \param CollapsedNum Number of collapsed loops.
2384 /// \param Clauses List of clauses.
2385 /// \param AssociatedStmt Statement, associated with the directive.
2386 /// \param Exprs Helper expressions for CodeGen.
2387 ///
2388 static OMPParallelForSimdDirective *
2389 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2390 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
2391 Stmt *AssociatedStmt, const HelperExprs &Exprs);
2392
2393 /// Creates an empty directive with the place
2394 /// for \a NumClauses clauses.
2395 ///
2396 /// \param C AST context.
2397 /// \param CollapsedNum Number of collapsed nested loops.
2398 /// \param NumClauses Number of clauses.
2399 ///
2400 static OMPParallelForSimdDirective *CreateEmpty(const ASTContext &C,
2401 unsigned NumClauses,
2402 unsigned CollapsedNum,
2403 EmptyShell);
2404
2405 static bool classof(const Stmt *T) {
2406 return T->getStmtClass() == OMPParallelForSimdDirectiveClass;
2407 }
2408};
2409
2410/// This represents '#pragma omp parallel master' directive.
2411///
2412/// \code
2413/// #pragma omp parallel master private(a,b)
2414/// \endcode
2415/// In this example directive '#pragma omp parallel master' has clauses
2416/// 'private' with the variables 'a' and 'b'
2417///
2418class OMPParallelMasterDirective : public OMPExecutableDirective {
2419 friend class ASTStmtReader;
2421
2422 OMPParallelMasterDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2423 : OMPExecutableDirective(OMPParallelMasterDirectiveClass,
2424 llvm::omp::OMPD_parallel_master, StartLoc,
2425 EndLoc) {}
2426
2428 : OMPExecutableDirective(OMPParallelMasterDirectiveClass,
2429 llvm::omp::OMPD_parallel_master,
2430 SourceLocation(), SourceLocation()) {}
2431
2432 /// Sets special task reduction descriptor.
2433 void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[0] = E; }
2434
2435public:
2436 /// Creates directive with a list of \a Clauses.
2437 ///
2438 /// \param C AST context.
2439 /// \param StartLoc Starting location of the directive kind.
2440 /// \param EndLoc Ending Location of the directive.
2441 /// \param Clauses List of clauses.
2442 /// \param AssociatedStmt Statement, associated with the directive.
2443 /// \param TaskRedRef Task reduction special reference expression to handle
2444 /// taskgroup descriptor.
2445 ///
2446 static OMPParallelMasterDirective *
2447 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2448 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef);
2449
2450 /// Creates an empty directive with the place for \a NumClauses
2451 /// clauses.
2452 ///
2453 /// \param C AST context.
2454 /// \param NumClauses Number of clauses.
2455 ///
2456 static OMPParallelMasterDirective *
2457 CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
2458
2459 /// Returns special task reduction reference expression.
2461 return cast_or_null<Expr>(Data->getChildren()[0]);
2462 }
2463 const Expr *getTaskReductionRefExpr() const {
2464 return const_cast<OMPParallelMasterDirective *>(this)
2466 }
2467
2468 static bool classof(const Stmt *T) {
2469 return T->getStmtClass() == OMPParallelMasterDirectiveClass;
2470 }
2471};
2472
2473/// This represents '#pragma omp parallel masked' directive.
2474///
2475/// \code
2476/// #pragma omp parallel masked filter(tid)
2477/// \endcode
2478/// In this example directive '#pragma omp parallel masked' has a clause
2479/// 'filter' with the variable tid
2480///
2481class OMPParallelMaskedDirective final : public OMPExecutableDirective {
2482 friend class ASTStmtReader;
2484
2485 OMPParallelMaskedDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2486 : OMPExecutableDirective(OMPParallelMaskedDirectiveClass,
2487 llvm::omp::OMPD_parallel_masked, StartLoc,
2488 EndLoc) {}
2489
2491 : OMPExecutableDirective(OMPParallelMaskedDirectiveClass,
2492 llvm::omp::OMPD_parallel_masked,
2493 SourceLocation(), SourceLocation()) {}
2494
2495 /// Sets special task reduction descriptor.
2496 void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[0] = E; }
2497
2498public:
2499 /// Creates directive with a list of \a Clauses.
2500 ///
2501 /// \param C AST context.
2502 /// \param StartLoc Starting location of the directive kind.
2503 /// \param EndLoc Ending Location of the directive.
2504 /// \param Clauses List of clauses.
2505 /// \param AssociatedStmt Statement, associated with the directive.
2506 /// \param TaskRedRef Task reduction special reference expression to handle
2507 /// taskgroup descriptor.
2508 ///
2509 static OMPParallelMaskedDirective *
2510 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2511 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef);
2512
2513 /// Creates an empty directive with the place for \a NumClauses
2514 /// clauses.
2515 ///
2516 /// \param C AST context.
2517 /// \param NumClauses Number of clauses.
2518 ///
2519 static OMPParallelMaskedDirective *
2520 CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
2521
2522 /// Returns special task reduction reference expression.
2524 return cast_or_null<Expr>(Data->getChildren()[0]);
2525 }
2526 const Expr *getTaskReductionRefExpr() const {
2527 return const_cast<OMPParallelMaskedDirective *>(this)
2529 }
2530
2531 static bool classof(const Stmt *T) {
2532 return T->getStmtClass() == OMPParallelMaskedDirectiveClass;
2533 }
2534};
2535
2536/// This represents '#pragma omp parallel sections' directive.
2537///
2538/// \code
2539/// #pragma omp parallel sections private(a,b) reduction(+:c,d)
2540/// \endcode
2541/// In this example directive '#pragma omp parallel sections' has clauses
2542/// 'private' with the variables 'a' and 'b' and 'reduction' with operator '+'
2543/// and variables 'c' and 'd'.
2544///
2545class OMPParallelSectionsDirective : public OMPExecutableDirective {
2546 friend class ASTStmtReader;
2548
2549 /// true if current directive has inner cancel directive.
2550 bool HasCancel = false;
2551
2552 /// Build directive with the given start and end location.
2553 ///
2554 /// \param StartLoc Starting location of the directive kind.
2555 /// \param EndLoc Ending location of the directive.
2556 ///
2557 OMPParallelSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2558 : OMPExecutableDirective(OMPParallelSectionsDirectiveClass,
2559 llvm::omp::OMPD_parallel_sections, StartLoc,
2560 EndLoc) {}
2561
2562 /// Build an empty directive.
2563 ///
2565 : OMPExecutableDirective(OMPParallelSectionsDirectiveClass,
2566 llvm::omp::OMPD_parallel_sections,
2567 SourceLocation(), SourceLocation()) {}
2568
2569 /// Sets special task reduction descriptor.
2570 void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[0] = E; }
2571
2572 /// Set cancel state.
2573 void setHasCancel(bool Has) { HasCancel = Has; }
2574
2575public:
2576 /// Creates directive with a list of \a Clauses.
2577 ///
2578 /// \param C AST context.
2579 /// \param StartLoc Starting location of the directive kind.
2580 /// \param EndLoc Ending Location of the directive.
2581 /// \param Clauses List of clauses.
2582 /// \param AssociatedStmt Statement, associated with the directive.
2583 /// \param TaskRedRef Task reduction special reference expression to handle
2584 /// taskgroup descriptor.
2585 /// \param HasCancel true if current directive has inner cancel directive.
2586 ///
2587 static OMPParallelSectionsDirective *
2588 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2589 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
2590 bool HasCancel);
2591
2592 /// Creates an empty directive with the place for \a NumClauses
2593 /// clauses.
2594 ///
2595 /// \param C AST context.
2596 /// \param NumClauses Number of clauses.
2597 ///
2598 static OMPParallelSectionsDirective *
2599 CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
2600
2601 /// Returns special task reduction reference expression.
2603 return cast_or_null<Expr>(Data->getChildren()[0]);
2604 }
2605 const Expr *getTaskReductionRefExpr() const {
2606 return const_cast<OMPParallelSectionsDirective *>(this)
2608 }
2609
2610 /// Return true if current directive has inner cancel directive.
2611 bool hasCancel() const { return HasCancel; }
2612
2613 static bool classof(const Stmt *T) {
2614 return T->getStmtClass() == OMPParallelSectionsDirectiveClass;
2615 }
2616};
2617
2618/// This represents '#pragma omp task' directive.
2619///
2620/// \code
2621/// #pragma omp task private(a,b) final(d)
2622/// \endcode
2623/// In this example directive '#pragma omp task' has clauses 'private' with the
2624/// variables 'a' and 'b' and 'final' with condition 'd'.
2625///
2626class OMPTaskDirective : public OMPExecutableDirective {
2627 friend class ASTStmtReader;
2629 /// true if this directive has inner cancel directive.
2630 bool HasCancel = false;
2631
2632 /// Build directive with the given start and end location.
2633 ///
2634 /// \param StartLoc Starting location of the directive kind.
2635 /// \param EndLoc Ending location of the directive.
2636 ///
2637 OMPTaskDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2638 : OMPExecutableDirective(OMPTaskDirectiveClass, llvm::omp::OMPD_task,
2639 StartLoc, EndLoc) {}
2640
2641 /// Build an empty directive.
2642 ///
2643 explicit OMPTaskDirective()
2644 : OMPExecutableDirective(OMPTaskDirectiveClass, llvm::omp::OMPD_task,
2645 SourceLocation(), SourceLocation()) {}
2646
2647 /// Set cancel state.
2648 void setHasCancel(bool Has) { HasCancel = Has; }
2649
2650public:
2651 /// Creates directive with a list of \a Clauses.
2652 ///
2653 /// \param C AST context.
2654 /// \param StartLoc Starting location of the directive kind.
2655 /// \param EndLoc Ending Location of the directive.
2656 /// \param Clauses List of clauses.
2657 /// \param AssociatedStmt Statement, associated with the directive.
2658 /// \param HasCancel true, if current directive has inner cancel directive.
2659 ///
2660 static OMPTaskDirective *Create(const ASTContext &C, SourceLocation StartLoc,
2661 SourceLocation EndLoc,
2662 ArrayRef<OMPClause *> Clauses,
2663 Stmt *AssociatedStmt, bool HasCancel);
2664
2665 /// Creates an empty directive with the place for \a NumClauses
2666 /// clauses.
2667 ///
2668 /// \param C AST context.
2669 /// \param NumClauses Number of clauses.
2670 ///
2671 static OMPTaskDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
2672 EmptyShell);
2673
2674 /// Return true if current directive has inner cancel directive.
2675 bool hasCancel() const { return HasCancel; }
2676
2677 static bool classof(const Stmt *T) {
2678 return T->getStmtClass() == OMPTaskDirectiveClass;
2679 }
2680};
2681
2682/// This represents '#pragma omp taskyield' directive.
2683///
2684/// \code
2685/// #pragma omp taskyield
2686/// \endcode
2687///
2688class OMPTaskyieldDirective : public OMPExecutableDirective {
2689 friend class ASTStmtReader;
2691 /// Build directive with the given start and end location.
2692 ///
2693 /// \param StartLoc Starting location of the directive kind.
2694 /// \param EndLoc Ending location of the directive.
2695 ///
2696 OMPTaskyieldDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2697 : OMPExecutableDirective(OMPTaskyieldDirectiveClass,
2698 llvm::omp::OMPD_taskyield, StartLoc, EndLoc) {}
2699
2700 /// Build an empty directive.
2701 ///
2702 explicit OMPTaskyieldDirective()
2703 : OMPExecutableDirective(OMPTaskyieldDirectiveClass,
2704 llvm::omp::OMPD_taskyield, SourceLocation(),
2705 SourceLocation()) {}
2706
2707public:
2708 /// Creates directive.
2709 ///
2710 /// \param C AST context.
2711 /// \param StartLoc Starting location of the directive kind.
2712 /// \param EndLoc Ending Location of the directive.
2713 ///
2714 static OMPTaskyieldDirective *
2715 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
2716
2717 /// Creates an empty directive.
2718 ///
2719 /// \param C AST context.
2720 ///
2721 static OMPTaskyieldDirective *CreateEmpty(const ASTContext &C, EmptyShell);
2722
2723 static bool classof(const Stmt *T) {
2724 return T->getStmtClass() == OMPTaskyieldDirectiveClass;
2725 }
2726};
2727
2728/// This represents '#pragma omp barrier' directive.
2729///
2730/// \code
2731/// #pragma omp barrier
2732/// \endcode
2733///
2734class OMPBarrierDirective : public OMPExecutableDirective {
2735 friend class ASTStmtReader;
2737 /// Build directive with the given start and end location.
2738 ///
2739 /// \param StartLoc Starting location of the directive kind.
2740 /// \param EndLoc Ending location of the directive.
2741 ///
2742 OMPBarrierDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2743 : OMPExecutableDirective(OMPBarrierDirectiveClass,
2744 llvm::omp::OMPD_barrier, StartLoc, EndLoc) {}
2745
2746 /// Build an empty directive.
2747 ///
2748 explicit OMPBarrierDirective()
2749 : OMPExecutableDirective(OMPBarrierDirectiveClass,
2750 llvm::omp::OMPD_barrier, SourceLocation(),
2751 SourceLocation()) {}
2752
2753public:
2754 /// Creates directive.
2755 ///
2756 /// \param C AST context.
2757 /// \param StartLoc Starting location of the directive kind.
2758 /// \param EndLoc Ending Location of the directive.
2759 ///
2760 static OMPBarrierDirective *
2761 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
2762
2763 /// Creates an empty directive.
2764 ///
2765 /// \param C AST context.
2766 ///
2767 static OMPBarrierDirective *CreateEmpty(const ASTContext &C, EmptyShell);
2768
2769 static bool classof(const Stmt *T) {
2770 return T->getStmtClass() == OMPBarrierDirectiveClass;
2771 }
2772};
2773
2774/// This represents '#pragma omp taskwait' directive.
2775///
2776/// \code
2777/// #pragma omp taskwait
2778/// \endcode
2779///
2780class OMPTaskwaitDirective : public OMPExecutableDirective {
2781 friend class ASTStmtReader;
2783 /// Build directive with the given start and end location.
2784 ///
2785 /// \param StartLoc Starting location of the directive kind.
2786 /// \param EndLoc Ending location of the directive.
2787 ///
2788 OMPTaskwaitDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2789 : OMPExecutableDirective(OMPTaskwaitDirectiveClass,
2790 llvm::omp::OMPD_taskwait, StartLoc, EndLoc) {}
2791
2792 /// Build an empty directive.
2793 ///
2794 explicit OMPTaskwaitDirective()
2795 : OMPExecutableDirective(OMPTaskwaitDirectiveClass,
2796 llvm::omp::OMPD_taskwait, SourceLocation(),
2797 SourceLocation()) {}
2798
2799public:
2800 /// Creates directive.
2801 ///
2802 /// \param C AST context.
2803 /// \param StartLoc Starting location of the directive kind.
2804 /// \param EndLoc Ending Location of the directive.
2805 /// \param Clauses List of clauses.
2806 ///
2807 static OMPTaskwaitDirective *Create(const ASTContext &C,
2808 SourceLocation StartLoc,
2809 SourceLocation EndLoc,
2810 ArrayRef<OMPClause *> Clauses);
2811
2812 /// Creates an empty directive.
2813 ///
2814 /// \param C AST context.
2815 /// \param NumClauses Number of clauses.
2816 ///
2817 static OMPTaskwaitDirective *CreateEmpty(const ASTContext &C,
2818 unsigned NumClauses, EmptyShell);
2819
2820 static bool classof(const Stmt *T) {
2821 return T->getStmtClass() == OMPTaskwaitDirectiveClass;
2822 }
2823};
2824
2825/// This represents '#pragma omp taskgroup' directive.
2826///
2827/// \code
2828/// #pragma omp taskgroup
2829/// \endcode
2830///
2831class OMPTaskgroupDirective : public OMPExecutableDirective {
2832 friend class ASTStmtReader;
2834 /// Build directive with the given start and end location.
2835 ///
2836 /// \param StartLoc Starting location of the directive kind.
2837 /// \param EndLoc Ending location of the directive.
2838 ///
2839 OMPTaskgroupDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2840 : OMPExecutableDirective(OMPTaskgroupDirectiveClass,
2841 llvm::omp::OMPD_taskgroup, StartLoc, EndLoc) {}
2842
2843 /// Build an empty directive.
2844 ///
2845 explicit OMPTaskgroupDirective()
2846 : OMPExecutableDirective(OMPTaskgroupDirectiveClass,
2847 llvm::omp::OMPD_taskgroup, SourceLocation(),
2848 SourceLocation()) {}
2849
2850 /// Sets the task_reduction return variable.
2851 void setReductionRef(Expr *RR) { Data->getChildren()[0] = RR; }
2852
2853public:
2854 /// Creates directive.
2855 ///
2856 /// \param C AST context.
2857 /// \param StartLoc Starting location of the directive kind.
2858 /// \param EndLoc Ending Location of the directive.
2859 /// \param Clauses List of clauses.
2860 /// \param AssociatedStmt Statement, associated with the directive.
2861 /// \param ReductionRef Reference to the task_reduction return variable.
2862 ///
2863 static OMPTaskgroupDirective *
2864 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2865 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2866 Expr *ReductionRef);
2867
2868 /// Creates an empty directive.
2869 ///
2870 /// \param C AST context.
2871 /// \param NumClauses Number of clauses.
2872 ///
2873 static OMPTaskgroupDirective *CreateEmpty(const ASTContext &C,
2874 unsigned NumClauses, EmptyShell);
2875
2876
2877 /// Returns reference to the task_reduction return variable.
2878 const Expr *getReductionRef() const {
2879 return const_cast<OMPTaskgroupDirective *>(this)->getReductionRef();
2880 }
2881 Expr *getReductionRef() { return cast_or_null<Expr>(Data->getChildren()[0]); }
2882
2883 static bool classof(const Stmt *T) {
2884 return T->getStmtClass() == OMPTaskgroupDirectiveClass;
2885 }
2886};
2887
2888/// This represents '#pragma omp flush' directive.
2889///
2890/// \code
2891/// #pragma omp flush(a,b)
2892/// \endcode
2893/// In this example directive '#pragma omp flush' has 2 arguments- variables 'a'
2894/// and 'b'.
2895/// 'omp flush' directive does not have clauses but have an optional list of
2896/// variables to flush. This list of variables is stored within some fake clause
2897/// FlushClause.
2898class OMPFlushDirective : public OMPExecutableDirective {
2899 friend class ASTStmtReader;
2901 /// Build directive with the given start and end location.
2902 ///
2903 /// \param StartLoc Starting location of the directive kind.
2904 /// \param EndLoc Ending location of the directive.
2905 ///
2906 OMPFlushDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2907 : OMPExecutableDirective(OMPFlushDirectiveClass, llvm::omp::OMPD_flush,
2908 StartLoc, EndLoc) {}
2909
2910 /// Build an empty directive.
2911 ///
2912 explicit OMPFlushDirective()
2913 : OMPExecutableDirective(OMPFlushDirectiveClass, llvm::omp::OMPD_flush,
2914 SourceLocation(), SourceLocation()) {}
2915
2916public:
2917 /// Creates directive with a list of \a Clauses.
2918 ///
2919 /// \param C AST context.
2920 /// \param StartLoc Starting location of the directive kind.
2921 /// \param EndLoc Ending Location of the directive.
2922 /// \param Clauses List of clauses (only single OMPFlushClause clause is
2923 /// allowed).
2924 ///
2925 static OMPFlushDirective *Create(const ASTContext &C, SourceLocation StartLoc,
2926 SourceLocation EndLoc,
2927 ArrayRef<OMPClause *> Clauses);
2928
2929 /// Creates an empty directive with the place for \a NumClauses
2930 /// clauses.
2931 ///
2932 /// \param C AST context.
2933 /// \param NumClauses Number of clauses.
2934 ///
2935 static OMPFlushDirective *CreateEmpty(const ASTContext &C,
2936 unsigned NumClauses, EmptyShell);
2937
2938 static bool classof(const Stmt *T) {
2939 return T->getStmtClass() == OMPFlushDirectiveClass;
2940 }
2941};
2942
2943/// This represents '#pragma omp depobj' directive.
2944///
2945/// \code
2946/// #pragma omp depobj(a) depend(in:x,y)
2947/// \endcode
2948/// In this example directive '#pragma omp depobj' initializes a depobj object
2949/// 'a' with dependence type 'in' and a list with 'x' and 'y' locators.
2950class OMPDepobjDirective final : public OMPExecutableDirective {
2951 friend class ASTStmtReader;
2953
2954 /// Build directive with the given start and end location.
2955 ///
2956 /// \param StartLoc Starting location of the directive kind.
2957 /// \param EndLoc Ending location of the directive.
2958 ///
2959 OMPDepobjDirective(SourceLocation StartLoc, SourceLocation EndLoc)
2960 : OMPExecutableDirective(OMPDepobjDirectiveClass, llvm::omp::OMPD_depobj,
2961 StartLoc, EndLoc) {}
2962
2963 /// Build an empty directive.
2964 ///
2965 explicit OMPDepobjDirective()
2966 : OMPExecutableDirective(OMPDepobjDirectiveClass, llvm::omp::OMPD_depobj,
2967 SourceLocation(), SourceLocation()) {}
2968
2969public:
2970 /// Creates directive with a list of \a Clauses.
2971 ///
2972 /// \param C AST context.
2973 /// \param StartLoc Starting location of the directive kind.
2974 /// \param EndLoc Ending Location of the directive.
2975 /// \param Clauses List of clauses.
2976 ///
2977 static OMPDepobjDirective *Create(const ASTContext &C,
2978 SourceLocation StartLoc,
2979 SourceLocation EndLoc,
2980 ArrayRef<OMPClause *> Clauses);
2981
2982 /// Creates an empty directive with the place for \a NumClauses
2983 /// clauses.
2984 ///
2985 /// \param C AST context.
2986 /// \param NumClauses Number of clauses.
2987 ///
2988 static OMPDepobjDirective *CreateEmpty(const ASTContext &C,
2989 unsigned NumClauses, EmptyShell);
2990
2991 static bool classof(const Stmt *T) {
2992 return T->getStmtClass() == OMPDepobjDirectiveClass;
2993 }
2994};
2995
2996/// This represents standalone '#pragma omp ordered' directive.
2997///
2998/// \code
2999/// #pragma omp ordered
3000/// \endcode
3001///
3002class OMPOrderedStandaloneDirective : public OMPExecutableDirective {
3003 friend class ASTStmtReader;
3005 /// Build directive with the given start and end location.
3006 ///
3007 /// \param StartLoc Starting location of the directive kind.
3008 /// \param EndLoc Ending location of the directive.
3009 ///
3010 OMPOrderedStandaloneDirective(SourceLocation StartLoc, SourceLocation EndLoc)
3011 : OMPExecutableDirective(OMPOrderedStandaloneDirectiveClass,
3012 llvm::omp::OMPD_ordered_standalone, StartLoc,
3013 EndLoc) {}
3014
3015 /// Build an empty directive.
3016 ///
3018 : OMPExecutableDirective(OMPOrderedStandaloneDirectiveClass,
3019 llvm::omp::OMPD_ordered_standalone,
3020 SourceLocation(), SourceLocation()) {}
3021
3022public:
3023 /// Creates directive.
3024 ///
3025 /// \param C AST context.
3026 /// \param StartLoc Starting location of the directive kind.
3027 /// \param EndLoc Ending Location of the directive.
3028 /// \param Clauses List of clauses.
3029 ///
3030 static OMPOrderedStandaloneDirective *Create(const ASTContext &C,
3031 SourceLocation StartLoc,
3032 SourceLocation EndLoc,
3033 ArrayRef<OMPClause *> Clauses);
3034
3035 /// Creates an empty directive.
3036 ///
3037 /// \param C AST context.
3038 /// \param NumClauses Number of clauses.
3039 ///
3040 static OMPOrderedStandaloneDirective *
3041 CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
3042
3043 static bool classof(const Stmt *T) {
3044 return T->getStmtClass() == OMPOrderedStandaloneDirectiveClass;
3045 }
3046};
3047
3048/// This represents block-associated '#pragma omp ordered' directive.
3049///
3050/// \code
3051/// #pragma omp ordered
3052/// { body }
3053/// \endcode
3054///
3055class OMPOrderedBlockAssocDirective : public OMPExecutableDirective {
3056 friend class ASTStmtReader;
3058 /// Build directive with the given start and end location.
3059 ///
3060 /// \param StartLoc Starting location of the directive kind.
3061 /// \param EndLoc Ending location of the directive.
3062 ///
3063 OMPOrderedBlockAssocDirective(SourceLocation StartLoc, SourceLocation EndLoc)
3064 : OMPExecutableDirective(OMPOrderedBlockAssocDirectiveClass,
3065 llvm::omp::OMPD_ordered_blockassoc, StartLoc,
3066 EndLoc) {}
3067
3068 /// Build an empty directive.
3069 ///
3071 : OMPExecutableDirective(OMPOrderedBlockAssocDirectiveClass,
3072 llvm::omp::OMPD_ordered_blockassoc,
3073 SourceLocation(), SourceLocation()) {}
3074
3075public:
3076 /// Creates directive.
3077 ///
3078 /// \param C AST context.
3079 /// \param StartLoc Starting location of the directive kind.
3080 /// \param EndLoc Ending Location of the directive.
3081 /// \param Clauses List of clauses.
3082 /// \param AssociatedStmt Statement, associated with the directive.
3083 ///
3084 static OMPOrderedBlockAssocDirective *
3085 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3086 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
3087
3088 /// Creates an empty directive.
3089 ///
3090 /// \param C AST context.
3091 /// \param NumClauses Number of clauses.
3092 ///
3093 static OMPOrderedBlockAssocDirective *
3094 CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
3095
3096 static bool classof(const Stmt *T) {
3097 return T->getStmtClass() == OMPOrderedBlockAssocDirectiveClass;
3098 }
3099};
3100
3101/// This represents '#pragma omp atomic' directive.
3102///
3103/// \code
3104/// #pragma omp atomic capture
3105/// \endcode
3106/// In this example directive '#pragma omp atomic' has clause 'capture'.
3107///
3108class OMPAtomicDirective : public OMPExecutableDirective {
3109 friend class ASTStmtReader;
3111
3112 struct FlagTy {
3113 /// Used for 'atomic update' or 'atomic capture' constructs. They may
3114 /// have atomic expressions of forms:
3115 /// \code
3116 /// x = x binop expr;
3117 /// x = expr binop x;
3118 /// \endcode
3119 /// This field is 1 for the first form of the expression and 0 for the
3120 /// second. Required for correct codegen of non-associative operations (like
3121 /// << or >>).
3122 LLVM_PREFERRED_TYPE(bool)
3123 uint8_t IsXLHSInRHSPart : 1;
3124 /// Used for 'atomic update' or 'atomic capture' constructs. They may
3125 /// have atomic expressions of forms:
3126 /// \code
3127 /// v = x; <update x>;
3128 /// <update x>; v = x;
3129 /// \endcode
3130 /// This field is 1 for the first(postfix) form of the expression and 0
3131 /// otherwise.
3132 LLVM_PREFERRED_TYPE(bool)
3133 uint8_t IsPostfixUpdate : 1;
3134 /// 1 if 'v' is updated only when the condition is false (compare capture
3135 /// only).
3136 LLVM_PREFERRED_TYPE(bool)
3137 uint8_t IsFailOnly : 1;
3138 } Flags;
3139
3140 /// Build directive with the given start and end location.
3141 ///
3142 /// \param StartLoc Starting location of the directive kind.
3143 /// \param EndLoc Ending location of the directive.
3144 ///
3145 OMPAtomicDirective(SourceLocation StartLoc, SourceLocation EndLoc)
3146 : OMPExecutableDirective(OMPAtomicDirectiveClass, llvm::omp::OMPD_atomic,
3147 StartLoc, EndLoc) {}
3148
3149 /// Build an empty directive.
3150 ///
3151 explicit OMPAtomicDirective()
3152 : OMPExecutableDirective(OMPAtomicDirectiveClass, llvm::omp::OMPD_atomic,
3153 SourceLocation(), SourceLocation()) {}
3154
3155 enum DataPositionTy : size_t {
3156 POS_X = 0,
3157 POS_V,
3158 POS_E,
3159 POS_UpdateExpr,
3160 POS_D,
3161 POS_Cond,
3162 POS_R,
3163 };
3164
3165 /// Set 'x' part of the associated expression/statement.
3166 void setX(Expr *X) { Data->getChildren()[DataPositionTy::POS_X] = X; }
3167 /// Set helper expression of the form
3168 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
3169 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
3170 void setUpdateExpr(Expr *UE) {
3171 Data->getChildren()[DataPositionTy::POS_UpdateExpr] = UE;
3172 }
3173 /// Set 'v' part of the associated expression/statement.
3174 void setV(Expr *V) { Data->getChildren()[DataPositionTy::POS_V] = V; }
3175 /// Set 'r' part of the associated expression/statement.
3176 void setR(Expr *R) { Data->getChildren()[DataPositionTy::POS_R] = R; }
3177 /// Set 'expr' part of the associated expression/statement.
3178 void setExpr(Expr *E) { Data->getChildren()[DataPositionTy::POS_E] = E; }
3179 /// Set 'd' part of the associated expression/statement.
3180 void setD(Expr *D) { Data->getChildren()[DataPositionTy::POS_D] = D; }
3181 /// Set conditional expression in `atomic compare`.
3182 void setCond(Expr *C) { Data->getChildren()[DataPositionTy::POS_Cond] = C; }
3183
3184public:
3186 /// 'x' part of the associated expression/statement.
3187 Expr *X = nullptr;
3188 /// 'v' part of the associated expression/statement.
3189 Expr *V = nullptr;
3190 // 'r' part of the associated expression/statement.
3191 Expr *R = nullptr;
3192 /// 'expr' part of the associated expression/statement.
3193 Expr *E = nullptr;
3194 /// UE Helper expression of the form:
3195 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
3196 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
3197 Expr *UE = nullptr;
3198 /// 'd' part of the associated expression/statement.
3199 Expr *D = nullptr;
3200 /// Conditional expression in `atomic compare` construct.
3201 Expr *Cond = nullptr;
3202 /// True if UE has the first form and false if the second.
3204 /// True if original value of 'x' must be stored in 'v', not an updated one.
3206 /// True if 'v' is updated only when the condition is false (compare capture
3207 /// only).
3209 };
3210
3211 /// Creates directive with a list of \a Clauses and 'x', 'v' and 'expr'
3212 /// parts of the atomic construct (see Section 2.12.6, atomic Construct, for
3213 /// detailed description of 'x', 'v' and 'expr').
3214 ///
3215 /// \param C AST context.
3216 /// \param StartLoc Starting location of the directive kind.
3217 /// \param EndLoc Ending Location of the directive.
3218 /// \param Clauses List of clauses.
3219 /// \param AssociatedStmt Statement, associated with the directive.
3220 /// \param Exprs Associated expressions or statements.
3221 static OMPAtomicDirective *Create(const ASTContext &C,
3222 SourceLocation StartLoc,
3223 SourceLocation EndLoc,
3224 ArrayRef<OMPClause *> Clauses,
3225 Stmt *AssociatedStmt, Expressions Exprs);
3226
3227 /// Creates an empty directive with the place for \a NumClauses
3228 /// clauses.
3229 ///
3230 /// \param C AST context.
3231 /// \param NumClauses Number of clauses.
3232 ///
3233 static OMPAtomicDirective *CreateEmpty(const ASTContext &C,
3234 unsigned NumClauses, EmptyShell);
3235
3236 /// Get 'x' part of the associated expression/statement.
3237 Expr *getX() {
3238 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_X]);
3239 }
3240 const Expr *getX() const {
3241 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_X]);
3242 }
3243 /// Get helper expression of the form
3244 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
3245 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
3247 return cast_or_null<Expr>(
3248 Data->getChildren()[DataPositionTy::POS_UpdateExpr]);
3249 }
3250 const Expr *getUpdateExpr() const {
3251 return cast_or_null<Expr>(
3252 Data->getChildren()[DataPositionTy::POS_UpdateExpr]);
3253 }
3254 /// Return true if helper update expression has form
3255 /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and false if it has form
3256 /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
3257 bool isXLHSInRHSPart() const { return Flags.IsXLHSInRHSPart; }
3258 /// Return true if 'v' expression must be updated to original value of
3259 /// 'x', false if 'v' must be updated to the new value of 'x'.
3260 bool isPostfixUpdate() const { return Flags.IsPostfixUpdate; }
3261 /// Return true if 'v' is updated only when the condition is evaluated false
3262 /// (compare capture only).
3263 bool isFailOnly() const { return Flags.IsFailOnly; }
3264 /// Get 'v' part of the associated expression/statement.
3265 Expr *getV() {
3266 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_V]);
3267 }
3268 const Expr *getV() const {
3269 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_V]);
3270 }
3271 /// Get 'r' part of the associated expression/statement.
3272 Expr *getR() {
3273 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_R]);
3274 }
3275 const Expr *getR() const {
3276 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_R]);
3277 }
3278 /// Get 'expr' part of the associated expression/statement.
3279 Expr *getExpr() {
3280 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_E]);
3281 }
3282 const Expr *getExpr() const {
3283 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_E]);
3284 }
3285 /// Get 'd' part of the associated expression/statement.
3286 Expr *getD() {
3287 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_D]);
3288 }
3289 Expr *getD() const {
3290 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_D]);
3291 }
3292 /// Get the 'cond' part of the source atomic expression.
3293 Expr *getCondExpr() {
3294 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_Cond]);
3295 }
3296 Expr *getCondExpr() const {
3297 return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_Cond]);
3298 }
3299
3300 static bool classof(const Stmt *T) {
3301 return T->getStmtClass() == OMPAtomicDirectiveClass;
3302 }
3303};
3304
3305/// This represents '#pragma omp target' directive.
3306///
3307/// \code
3308/// #pragma omp target if(a)
3309/// \endcode
3310/// In this example directive '#pragma omp target' has clause 'if' with
3311/// condition 'a'.
3312///
3313class OMPTargetDirective : public OMPExecutableDirective {
3314 friend class ASTStmtReader;
3316 /// Build directive with the given start and end location.
3317 ///
3318 /// \param StartLoc Starting location of the directive kind.
3319 /// \param EndLoc Ending location of the directive.
3320 ///
3321 OMPTargetDirective(SourceLocation StartLoc, SourceLocation EndLoc)
3322 : OMPExecutableDirective(OMPTargetDirectiveClass, llvm::omp::OMPD_target,
3323 StartLoc, EndLoc) {}
3324
3325 /// Build an empty directive.
3326 ///
3327 explicit OMPTargetDirective()
3328 : OMPExecutableDirective(OMPTargetDirectiveClass, llvm::omp::OMPD_target,
3329 SourceLocation(), SourceLocation()) {}
3330
3331public:
3332 /// Creates directive with a list of \a Clauses.
3333 ///
3334 /// \param C AST context.
3335 /// \param StartLoc Starting location of the directive kind.
3336 /// \param EndLoc Ending Location of the directive.
3337 /// \param Clauses List of clauses.
3338 /// \param AssociatedStmt Statement, associated with the directive.
3339 ///
3340 static OMPTargetDirective *
3341 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3342 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
3343
3344 /// Creates an empty directive with the place for \a NumClauses
3345 /// clauses.
3346 ///
3347 /// \param C AST context.
3348 /// \param NumClauses Number of clauses.
3349 ///
3350 static OMPTargetDirective *CreateEmpty(const ASTContext &C,
3351 unsigned NumClauses, EmptyShell);
3352
3353 static bool classof(const Stmt *T) {
3354 return T->getStmtClass() == OMPTargetDirectiveClass;
3355 }
3356};
3357
3358/// This represents '#pragma omp target data' directive.
3359///
3360/// \code
3361/// #pragma omp target data device(0) if(a) map(b[:])
3362/// \endcode
3363/// In this example directive '#pragma omp target data' has clauses 'device'
3364/// with the value '0', 'if' with condition 'a' and 'map' with array
3365/// section 'b[:]'.
3366///
3367class OMPTargetDataDirective : public OMPExecutableDirective {
3368 friend class ASTStmtReader;
3370 /// Build directive with the given start and end location.
3371 ///
3372 /// \param StartLoc Starting location of the directive kind.
3373 /// \param EndLoc Ending Location of the directive.
3374 ///
3375 OMPTargetDataDirective(SourceLocation StartLoc, SourceLocation EndLoc)
3376 : OMPExecutableDirective(OMPTargetDataDirectiveClass,
3377 llvm::omp::OMPD_target_data, StartLoc, EndLoc) {}
3378
3379 /// Build an empty directive.
3380 ///
3381 explicit OMPTargetDataDirective()
3382 : OMPExecutableDirective(OMPTargetDataDirectiveClass,
3383 llvm::omp::OMPD_target_data, SourceLocation(),
3384 SourceLocation()) {}
3385
3386public:
3387 /// Creates directive with a list of \a Clauses.
3388 ///
3389 /// \param C AST context.
3390 /// \param StartLoc Starting location of the directive kind.
3391 /// \param EndLoc Ending Location of the directive.
3392 /// \param Clauses List of clauses.
3393 /// \param AssociatedStmt Statement, associated with the directive.
3394 ///
3395 static OMPTargetDataDirective *
3396 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3397 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
3398
3399 /// Creates an empty directive with the place for \a N clauses.
3400 ///
3401 /// \param C AST context.
3402 /// \param N The number of clauses.
3403 ///
3404 static OMPTargetDataDirective *CreateEmpty(const ASTContext &C, unsigned N,
3405 EmptyShell);
3406
3407 static bool classof(const Stmt *T) {
3408 return T->getStmtClass() == OMPTargetDataDirectiveClass;
3409 }
3410};
3411
3412/// This represents '#pragma omp target enter data' directive.
3413///
3414/// \code
3415/// #pragma omp target enter data device(0) if(a) map(b[:])
3416/// \endcode
3417/// In this example directive '#pragma omp target enter data' has clauses
3418/// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
3419/// section 'b[:]'.
3420///
3421class OMPTargetEnterDataDirective : public OMPExecutableDirective {
3422 friend class ASTStmtReader;
3424 /// Build directive with the given start and end location.
3425 ///
3426 /// \param StartLoc Starting location of the directive kind.
3427 /// \param EndLoc Ending Location of the directive.
3428 ///
3429 OMPTargetEnterDataDirective(SourceLocation StartLoc, SourceLocation EndLoc)
3430 : OMPExecutableDirective(OMPTargetEnterDataDirectiveClass,
3431 llvm::omp::OMPD_target_enter_data, StartLoc,
3432 EndLoc) {}
3433
3434 /// Build an empty directive.
3435 ///
3437 : OMPExecutableDirective(OMPTargetEnterDataDirectiveClass,
3438 llvm::omp::OMPD_target_enter_data,
3439 SourceLocation(), SourceLocation()) {}
3440
3441public:
3442 /// Creates directive with a list of \a Clauses.
3443 ///
3444 /// \param C AST context.
3445 /// \param StartLoc Starting location of the directive kind.
3446 /// \param EndLoc Ending Location of the directive.
3447 /// \param Clauses List of clauses.
3448 /// \param AssociatedStmt Statement, associated with the directive.
3449 ///
3450 static OMPTargetEnterDataDirective *
3451 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3452 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
3453
3454 /// Creates an empty directive with the place for \a N clauses.
3455 ///
3456 /// \param C AST context.
3457 /// \param N The number of clauses.
3458 ///
3459 static OMPTargetEnterDataDirective *CreateEmpty(const ASTContext &C,
3460 unsigned N, EmptyShell);
3461
3462 static bool classof(const Stmt *T) {
3463 return T->getStmtClass() == OMPTargetEnterDataDirectiveClass;
3464 }
3465};
3466
3467/// This represents '#pragma omp target exit data' directive.
3468///
3469/// \code
3470/// #pragma omp target exit data device(0) if(a) map(b[:])
3471/// \endcode
3472/// In this example directive '#pragma omp target exit data' has clauses
3473/// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
3474/// section 'b[:]'.
3475///
3476class OMPTargetExitDataDirective : public OMPExecutableDirective {
3477 friend class ASTStmtReader;
3479 /// Build directive with the given start and end location.
3480 ///
3481 /// \param StartLoc Starting location of the directive kind.
3482 /// \param EndLoc Ending Location of the directive.
3483 ///
3484 OMPTargetExitDataDirective(SourceLocation StartLoc, SourceLocation EndLoc)
3485 : OMPExecutableDirective(OMPTargetExitDataDirectiveClass,
3486 llvm::omp::OMPD_target_exit_data, StartLoc,
3487 EndLoc) {}
3488
3489 /// Build an empty directive.
3490 ///
3492 : OMPExecutableDirective(OMPTargetExitDataDirectiveClass,
3493 llvm::omp::OMPD_target_exit_data,
3494 SourceLocation(), SourceLocation()) {}
3495
3496public:
3497 /// Creates directive with a list of \a Clauses.
3498 ///
3499 /// \param C AST context.
3500 /// \param StartLoc Starting location of the directive kind.
3501 /// \param EndLoc Ending Location of the directive.
3502 /// \param Clauses List of clauses.
3503 /// \param AssociatedStmt Statement, associated with the directive.
3504 ///
3505 static OMPTargetExitDataDirective *
3506 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3507 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
3508
3509 /// Creates an empty directive with the place for \a N clauses.
3510 ///
3511 /// \param C AST context.
3512 /// \param N The number of clauses.
3513 ///
3514 static OMPTargetExitDataDirective *CreateEmpty(const ASTContext &C,
3515 unsigned N, EmptyShell);
3516
3517 static bool classof(const Stmt *T) {
3518 return T->getStmtClass() == OMPTargetExitDataDirectiveClass;
3519 }
3520};
3521
3522/// This represents '#pragma omp target parallel' directive.
3523///
3524/// \code
3525/// #pragma omp target parallel if(a)
3526/// \endcode
3527/// In this example directive '#pragma omp target parallel' has clause 'if' with
3528/// condition 'a'.
3529///
3530class OMPTargetParallelDirective : public OMPExecutableDirective {
3531 friend class ASTStmtReader;
3533 /// true if the construct has inner cancel directive.
3534 bool HasCancel = false;
3535
3536 /// Build directive with the given start and end location.
3537 ///
3538 /// \param StartLoc Starting location of the directive kind.
3539 /// \param EndLoc Ending location of the directive.
3540 ///
3541 OMPTargetParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc)
3542 : OMPExecutableDirective(OMPTargetParallelDirectiveClass,
3543 llvm::omp::OMPD_target_parallel, StartLoc,
3544 EndLoc) {}
3545
3546 /// Build an empty directive.
3547 ///
3549 : OMPExecutableDirective(OMPTargetParallelDirectiveClass,
3550 llvm::omp::OMPD_target_parallel,
3551 SourceLocation(), SourceLocation()) {}
3552
3553 /// Sets special task reduction descriptor.
3554 void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[0] = E; }
3555 /// Set cancel state.
3556 void setHasCancel(bool Has) { HasCancel = Has; }
3557
3558public:
3559 /// Creates directive with a list of \a Clauses.
3560 ///
3561 /// \param C AST context.
3562 /// \param StartLoc Starting location of the directive kind.
3563 /// \param EndLoc Ending Location of the directive.
3564 /// \param Clauses List of clauses.
3565 /// \param AssociatedStmt Statement, associated with the directive.
3566 /// \param TaskRedRef Task reduction special reference expression to handle
3567 /// taskgroup descriptor.
3568 /// \param HasCancel true if this directive has inner cancel directive.
3569 ///
3570 static OMPTargetParallelDirective *
3571 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3572 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
3573 bool HasCancel);
3574
3575 /// Creates an empty directive with the place for \a NumClauses
3576 /// clauses.
3577 ///
3578 /// \param C AST context.
3579 /// \param NumClauses Number of clauses.
3580 ///
3581 static OMPTargetParallelDirective *
3582 CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell);
3583
3584 /// Returns special task reduction reference expression.
3586 return cast_or_null<Expr>(Data->getChildren()[0]);
3587 }
3588 const Expr *getTaskReductionRefExpr() const {
3589 return const_cast<OMPTargetParallelDirective *>(this)
3591 }
3592
3593 /// Return true if current directive has inner cancel directive.
3594 bool hasCancel() const { return HasCancel; }
3595
3596 static bool classof(const Stmt *T) {
3597 return T->getStmtClass() == OMPTargetParallelDirectiveClass;
3598 }
3599};
3600
3601/// This represents '#pragma omp target parallel for' directive.
3602///
3603/// \code
3604/// #pragma omp target parallel for private(a,b) reduction(+:c,d)
3605/// \endcode
3606/// In this example directive '#pragma omp target parallel for' has clauses
3607/// 'private' with the variables 'a' and 'b' and 'reduction' with operator '+'
3608/// and variables 'c' and 'd'.
3609///
3610class OMPTargetParallelForDirective : public OMPLoopDirective {
3611 friend class ASTStmtReader;
3613
3614 /// true if current region has inner cancel directive.
3615 bool HasCancel = false;
3616
3617 /// Build directive with the given start and end location.
3618 ///
3619 /// \param StartLoc Starting location of the directive kind.
3620 /// \param EndLoc Ending location of the directive.
3621 /// \param CollapsedNum Number of collapsed nested loops.
3622 ///
3623 OMPTargetParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3624 unsigned CollapsedNum)
3625 : OMPLoopDirective(OMPTargetParallelForDirectiveClass,
3626 llvm::omp::OMPD_target_parallel_for, StartLoc, EndLoc,
3627 CollapsedNum) {}
3628
3629 /// Build an empty directive.
3630 ///
3631 /// \param CollapsedNum Number of collapsed nested loops.
3632 ///
3633 explicit OMPTargetParallelForDirective(unsigned CollapsedNum)
3634 : OMPLoopDirective(OMPTargetParallelForDirectiveClass,
3635 llvm::omp::OMPD_target_parallel_for, SourceLocation(),
3636 SourceLocation(), CollapsedNum) {}
3637
3638 /// Sets special task reduction descriptor.
3639 void setTaskReductionRefExpr(Expr *E) {
3640 Data->getChildren()[numLoopChildren(
3641 getLoopsNumber(), llvm::omp::OMPD_target_parallel_for)] = E;
3642 }
3643
3644 /// Set cancel state.
3645 void setHasCancel(bool Has) { HasCancel = Has; }
3646
3647public:
3648 /// Creates directive with a list of \a Clauses.
3649 ///
3650 /// \param C AST context.
3651 /// \param StartLoc Starting location of the directive kind.
3652 /// \param EndLoc Ending Location of the directive.
3653 /// \param CollapsedNum Number of collapsed loops.
3654 /// \param Clauses List of clauses.
3655 /// \param AssociatedStmt Statement, associated with the directive.
3656 /// \param Exprs Helper expressions for CodeGen.
3657 /// \param TaskRedRef Task reduction special reference expression to handle
3658 /// taskgroup descriptor.
3659 /// \param HasCancel true if current directive has inner cancel directive.
3660 ///
3661 static OMPTargetParallelForDirective *
3662 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3663 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3664 Stmt *AssociatedStmt, const HelperExprs &Exprs, Expr *TaskRedRef,
3665 bool HasCancel);
3666
3667 /// Creates an empty directive with the place
3668 /// for \a NumClauses clauses.
3669 ///
3670 /// \param C AST context.
3671 /// \param CollapsedNum Number of collapsed nested loops.
3672 /// \param NumClauses Number of clauses.
3673 ///
3674 static OMPTargetParallelForDirective *CreateEmpty(const ASTContext &C,
3675 unsigned NumClauses,
3676 unsigned CollapsedNum,
3677 EmptyShell);
3678
3679 /// Returns special task reduction reference expression.
3681 return cast_or_null<Expr>(Data->getChildren()[numLoopChildren(
3682 getLoopsNumber(), llvm::omp::OMPD_target_parallel_for)]);
3683 }
3684 const Expr *getTaskReductionRefExpr() const {
3685 return const_cast<OMPTargetParallelForDirective *>(this)
3687 }
3688
3689 /// Return true if current directive has inner cancel directive.
3690 bool hasCancel() const { return HasCancel; }
3691
3692 static bool classof(const Stmt *T) {
3693 return T->getStmtClass() == OMPTargetParallelForDirectiveClass;
3694 }
3695};
3696
3697/// This represents '#pragma omp teams' directive.
3698///
3699/// \code
3700/// #pragma omp teams if(a)
3701/// \endcode
3702/// In this example directive '#pragma omp teams' has clause 'if' with
3703/// condition 'a'.
3704///
3705class OMPTeamsDirective : public OMPExecutableDirective {
3706 friend class ASTStmtReader;
3708 /// Build directive with the given start and end location.
3709 ///
3710 /// \param StartLoc Starting location of the directive kind.
3711 /// \param EndLoc Ending location of the directive.
3712 ///
3713 OMPTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc)
3714 : OMPExecutableDirective(OMPTeamsDirectiveClass, llvm::omp::OMPD_teams,
3715 StartLoc, EndLoc) {}
3716
3717 /// Build an empty directive.
3718 ///
3719 explicit OMPTeamsDirective()
3720 : OMPExecutableDirective(OMPTeamsDirectiveClass, llvm::omp::OMPD_teams,
3721 SourceLocation(), SourceLocation()) {}
3722
3723public:
3724 /// Creates directive with a list of \a Clauses.
3725 ///
3726 /// \param C AST context.
3727 /// \param StartLoc Starting location of the directive kind.
3728 /// \param EndLoc Ending Location of the directive.
3729 /// \param Clauses List of clauses.
3730 /// \param AssociatedStmt Statement, associated with the directive.
3731 ///
3732 static OMPTeamsDirective *Create(const ASTContext &C, SourceLocation StartLoc,
3733 SourceLocation EndLoc,
3734 ArrayRef<OMPClause *> Clauses,
3735 Stmt *AssociatedStmt);
3736
3737 /// Creates an empty directive with the place for \a NumClauses
3738 /// clauses.
3739 ///
3740 /// \param C AST context.
3741 /// \param NumClauses Number of clauses.
3742 ///
3743 static OMPTeamsDirective *CreateEmpty(const ASTContext &C,
3744 unsigned NumClauses, EmptyShell);
3745
3746 static bool classof(const Stmt *T) {
3747 return T->getStmtClass() == OMPTeamsDirectiveClass;
3748 }
3749};
3750
3751/// This represents '#pragma omp cancellation point' directive.
3752///
3753/// \code
3754/// #pragma omp cancellation point for
3755/// \endcode
3756///
3757/// In this example a cancellation point is created for innermost 'for' region.
3758class OMPCancellationPointDirective : public OMPExecutableDirective {
3759 friend class ASTStmtReader;
3761 OpenMPDirectiveKind CancelRegion = llvm::omp::OMPD_unknown;
3762 /// Build directive with the given start and end location.
3763 ///
3764 /// \param StartLoc Starting location of the directive kind.
3765 /// \param EndLoc Ending location of the directive.
3766 /// statements and child expressions.
3767 ///
3768 OMPCancellationPointDirective(SourceLocation StartLoc, SourceLocation EndLoc)
3769 : OMPExecutableDirective(OMPCancellationPointDirectiveClass,
3770 llvm::omp::OMPD_cancellation_point, StartLoc,
3771 EndLoc) {}
3772
3773 /// Build an empty directive.
3775 : OMPExecutableDirective(OMPCancellationPointDirectiveClass,
3776 llvm::omp::OMPD_cancellation_point,
3777 SourceLocation(), SourceLocation()) {}
3778
3779 /// Set cancel region for current cancellation point.
3780 /// \param CR Cancellation region.
3781 void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; }
3782
3783public:
3784 /// Creates directive.
3785 ///
3786 /// \param C AST context.
3787 /// \param StartLoc Starting location of the directive kind.
3788 /// \param EndLoc Ending Location of the directive.
3789 ///
3790 static OMPCancellationPointDirective *
3791 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3792 OpenMPDirectiveKind CancelRegion);
3793
3794 /// Creates an empty directive.
3795 ///
3796 /// \param C AST context.
3797 ///
3798 static OMPCancellationPointDirective *CreateEmpty(const ASTContext &C,
3799 EmptyShell);
3800
3801 /// Get cancellation region for the current cancellation point.
3802 OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; }
3803
3804 static bool classof(const Stmt *T) {
3805 return T->getStmtClass() == OMPCancellationPointDirectiveClass;
3806 }
3807};
3808
3809/// This represents '#pragma omp cancel' directive.
3810///
3811/// \code
3812/// #pragma omp cancel for
3813/// \endcode
3814///
3815/// In this example a cancel is created for innermost 'for' region.
3816class OMPCancelDirective : public OMPExecutableDirective {
3817 friend class ASTStmtReader;
3819 OpenMPDirectiveKind CancelRegion = llvm::omp::OMPD_unknown;
3820 /// Build directive with the given start and end location.
3821 ///
3822 /// \param StartLoc Starting location of the directive kind.
3823 /// \param EndLoc Ending location of the directive.
3824 ///
3825 OMPCancelDirective(SourceLocation StartLoc, SourceLocation EndLoc)
3826 : OMPExecutableDirective(OMPCancelDirectiveClass, llvm::omp::OMPD_cancel,
3827 StartLoc, EndLoc) {}
3828
3829 /// Build an empty directive.
3830 ///
3831 explicit OMPCancelDirective()
3832 : OMPExecutableDirective(OMPCancelDirectiveClass, llvm::omp::OMPD_cancel,
3833 SourceLocation(), SourceLocation()) {}
3834
3835 /// Set cancel region for current cancellation point.
3836 /// \param CR Cancellation region.
3837 void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; }
3838
3839public:
3840 /// Creates directive.
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 Clauses List of clauses.
3846 ///
3847 static OMPCancelDirective *
3848 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3849 ArrayRef<OMPClause *> Clauses, OpenMPDirectiveKind CancelRegion);
3850
3851 /// Creates an empty directive.
3852 ///
3853 /// \param C AST context.
3854 /// \param NumClauses Number of clauses.
3855 ///
3856 static OMPCancelDirective *CreateEmpty(const ASTContext &C,
3857 unsigned NumClauses, EmptyShell);
3858
3859 /// Get cancellation region for the current cancellation point.
3860 OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; }
3861
3862 static bool classof(const Stmt *T) {
3863 return T->getStmtClass() == OMPCancelDirectiveClass;
3864 }
3865};
3866
3867/// This represents '#pragma omp taskloop' directive.
3868///
3869/// \code
3870/// #pragma omp taskloop private(a,b) grainsize(val) num_tasks(num)
3871/// \endcode
3872/// In this example directive '#pragma omp taskloop' has clauses 'private'
3873/// with the variables 'a' and 'b', 'grainsize' with expression 'val' and
3874/// 'num_tasks' with expression 'num'.
3875///
3876class OMPTaskLoopDirective : public OMPLoopDirective {
3877 friend class ASTStmtReader;
3879 /// true if the construct has inner cancel directive.
3880 bool HasCancel = false;
3881
3882 /// Build directive with the given start and end location.
3883 ///
3884 /// \param StartLoc Starting location of the directive kind.
3885 /// \param EndLoc Ending location of the directive.
3886 /// \param CollapsedNum Number of collapsed nested loops.
3887 ///
3888 OMPTaskLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3889 unsigned CollapsedNum)
3890 : OMPLoopDirective(OMPTaskLoopDirectiveClass, llvm::omp::OMPD_taskloop,
3891 StartLoc, EndLoc, CollapsedNum) {}
3892
3893 /// Build an empty directive.
3894 ///
3895 /// \param CollapsedNum Number of collapsed nested loops.
3896 ///
3897 explicit OMPTaskLoopDirective(unsigned CollapsedNum)
3898 : OMPLoopDirective(OMPTaskLoopDirectiveClass, llvm::omp::OMPD_taskloop,
3899 SourceLocation(), SourceLocation(), CollapsedNum) {}
3900
3901 /// Set cancel state.
3902 void setHasCancel(bool Has) { HasCancel = Has; }
3903
3904public:
3905 /// Creates directive with a list of \a Clauses.
3906 ///
3907 /// \param C AST context.
3908 /// \param StartLoc Starting location of the directive kind.
3909 /// \param EndLoc Ending Location of the directive.
3910 /// \param CollapsedNum Number of collapsed loops.
3911 /// \param Clauses List of clauses.
3912 /// \param AssociatedStmt Statement, associated with the directive.
3913 /// \param Exprs Helper expressions for CodeGen.
3914 /// \param HasCancel true if this directive has inner cancel directive.
3915 ///
3916 static OMPTaskLoopDirective *
3917 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3918 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3919 Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
3920
3921 /// Creates an empty directive with the place
3922 /// for \a NumClauses clauses.
3923 ///
3924 /// \param C AST context.
3925 /// \param CollapsedNum Number of collapsed nested loops.
3926 /// \param NumClauses Number of clauses.
3927 ///
3928 static OMPTaskLoopDirective *CreateEmpty(const ASTContext &C,
3929 unsigned NumClauses,
3930 unsigned CollapsedNum, EmptyShell);
3931
3932 /// Return true if current directive has inner cancel directive.
3933 bool hasCancel() const { return HasCancel; }
3934
3935 static bool classof(const Stmt *T) {
3936 return T->getStmtClass() == OMPTaskLoopDirectiveClass;
3937 }
3938};
3939
3940/// This represents '#pragma omp taskloop simd' directive.
3941///
3942/// \code
3943/// #pragma omp taskloop simd private(a,b) grainsize(val) num_tasks(num)
3944/// \endcode
3945/// In this example directive '#pragma omp taskloop simd' has clauses 'private'
3946/// with the variables 'a' and 'b', 'grainsize' with expression 'val' and
3947/// 'num_tasks' with expression 'num'.
3948///
3949class OMPTaskLoopSimdDirective : public OMPLoopDirective {
3950 friend class ASTStmtReader;
3952 /// Build directive with the given start and end location.
3953 ///
3954 /// \param StartLoc Starting location of the directive kind.
3955 /// \param EndLoc Ending location of the directive.
3956 /// \param CollapsedNum Number of collapsed nested loops.
3957 ///
3958 OMPTaskLoopSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
3959 unsigned CollapsedNum)
3960 : OMPLoopDirective(OMPTaskLoopSimdDirectiveClass,
3961 llvm::omp::OMPD_taskloop_simd, StartLoc, EndLoc,
3962 CollapsedNum) {}
3963
3964 /// Build an empty directive.
3965 ///
3966 /// \param CollapsedNum Number of collapsed nested loops.
3967 ///
3968 explicit OMPTaskLoopSimdDirective(unsigned CollapsedNum)
3969 : OMPLoopDirective(OMPTaskLoopSimdDirectiveClass,
3970 llvm::omp::OMPD_taskloop_simd, SourceLocation(),
3971 SourceLocation(), CollapsedNum) {}
3972
3973public:
3974 /// Creates directive with a list of \a Clauses.
3975 ///
3976 /// \param C AST context.
3977 /// \param StartLoc Starting location of the directive kind.
3978 /// \param EndLoc Ending Location of the directive.
3979 /// \param CollapsedNum Number of collapsed loops.
3980 /// \param Clauses List of clauses.
3981 /// \param AssociatedStmt Statement, associated with the directive.
3982 /// \param Exprs Helper expressions for CodeGen.
3983 ///
3984 static OMPTaskLoopSimdDirective *
3985 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
3986 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
3987 Stmt *AssociatedStmt, const HelperExprs &Exprs);
3988
3989 /// Creates an empty directive with the place
3990 /// for \a NumClauses clauses.
3991 ///
3992 /// \param C AST context.
3993 /// \param CollapsedNum Number of collapsed nested loops.
3994 /// \param NumClauses Number of clauses.
3995 ///
3996 static OMPTaskLoopSimdDirective *CreateEmpty(const ASTContext &C,
3997 unsigned NumClauses,
3998 unsigned CollapsedNum,
3999 EmptyShell);
4000
4001 static bool classof(const Stmt *T) {
4002 return T->getStmtClass() == OMPTaskLoopSimdDirectiveClass;
4003 }
4004};
4005
4006/// This represents '#pragma omp master taskloop' directive.
4007///
4008/// \code
4009/// #pragma omp master taskloop private(a,b) grainsize(val) num_tasks(num)
4010/// \endcode
4011/// In this example directive '#pragma omp master taskloop' has clauses
4012/// 'private' with the variables 'a' and 'b', 'grainsize' with expression 'val'
4013/// and 'num_tasks' with expression 'num'.
4014///
4015class OMPMasterTaskLoopDirective : public OMPLoopDirective {
4016 friend class ASTStmtReader;
4018 /// true if the construct has inner cancel directive.
4019 bool HasCancel = false;
4020
4021 /// Build directive with the given start and end location.
4022 ///
4023 /// \param StartLoc Starting location of the directive kind.
4024 /// \param EndLoc Ending location of the directive.
4025 /// \param CollapsedNum Number of collapsed nested loops.
4026 ///
4027 OMPMasterTaskLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc,
4028 unsigned CollapsedNum)
4029 : OMPLoopDirective(OMPMasterTaskLoopDirectiveClass,
4030 llvm::omp::OMPD_master_taskloop, StartLoc, EndLoc,
4031 CollapsedNum) {}
4032
4033 /// Build an empty directive.
4034 ///
4035 /// \param CollapsedNum Number of collapsed nested loops.
4036 ///
4037 explicit OMPMasterTaskLoopDirective(unsigned CollapsedNum)
4038 : OMPLoopDirective(OMPMasterTaskLoopDirectiveClass,
4039 llvm::omp::OMPD_master_taskloop, SourceLocation(),
4040 SourceLocation(), CollapsedNum) {}
4041
4042 /// Set cancel state.
4043 void setHasCancel(bool Has) { HasCancel = Has; }
4044
4045public:
4046 /// Creates directive with a list of \a Clauses.
4047 ///
4048 /// \param C AST context.
4049 /// \param StartLoc Starting location of the directive kind.
4050 /// \param EndLoc Ending Location of the directive.
4051 /// \param CollapsedNum Number of collapsed loops.
4052 /// \param Clauses List of clauses.
4053 /// \param AssociatedStmt Statement, associated with the directive.
4054 /// \param Exprs Helper expressions for CodeGen.
4055 /// \param HasCancel true if this directive has inner cancel directive.
4056 ///
4057 static OMPMasterTaskLoopDirective *
4058 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4059 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4060 Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
4061
4062 /// Creates an empty directive with the place
4063 /// for \a NumClauses clauses.
4064 ///
4065 /// \param C AST context.
4066 /// \param CollapsedNum Number of collapsed nested loops.
4067 /// \param NumClauses Number of clauses.
4068 ///
4069 static OMPMasterTaskLoopDirective *CreateEmpty(const ASTContext &C,
4070 unsigned NumClauses,
4071 unsigned CollapsedNum,
4072 EmptyShell);
4073
4074 /// Return true if current directive has inner cancel directive.
4075 bool hasCancel() const { return HasCancel; }
4076
4077 static bool classof(const Stmt *T) {
4078 return T->getStmtClass() == OMPMasterTaskLoopDirectiveClass;
4079 }
4080};
4081
4082/// This represents '#pragma omp masked taskloop' directive.
4083///
4084/// \code
4085/// #pragma omp masked taskloop private(a,b) grainsize(val) num_tasks(num)
4086/// \endcode
4087/// In this example directive '#pragma omp masked taskloop' has clauses
4088/// 'private' with the variables 'a' and 'b', 'grainsize' with expression 'val'
4089/// and 'num_tasks' with expression 'num'.
4090///
4091class OMPMaskedTaskLoopDirective final : public OMPLoopDirective {
4092 friend class ASTStmtReader;
4094 /// true if the construct has inner cancel directive.
4095 bool HasCancel = false;
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 ///
4103 OMPMaskedTaskLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc,
4104 unsigned CollapsedNum)
4105 : OMPLoopDirective(OMPMaskedTaskLoopDirectiveClass,
4106 llvm::omp::OMPD_masked_taskloop, StartLoc, EndLoc,
4107 CollapsedNum) {}
4108
4109 /// Build an empty directive.
4110 ///
4111 /// \param CollapsedNum Number of collapsed nested loops.
4112 ///
4113 explicit OMPMaskedTaskLoopDirective(unsigned CollapsedNum)
4114 : OMPLoopDirective(OMPMaskedTaskLoopDirectiveClass,
4115 llvm::omp::OMPD_masked_taskloop, SourceLocation(),
4116 SourceLocation(), CollapsedNum) {}
4117
4118 /// Set cancel state.
4119 void setHasCancel(bool Has) { HasCancel = Has; }
4120
4121public:
4122 /// Creates directive with a list of \a Clauses.
4123 ///
4124 /// \param C AST context.
4125 /// \param StartLoc Starting location of the directive kind.
4126 /// \param EndLoc Ending Location of the directive.
4127 /// \param CollapsedNum Number of collapsed loops.
4128 /// \param Clauses List of clauses.
4129 /// \param AssociatedStmt Statement, associated with the directive.
4130 /// \param Exprs Helper expressions for CodeGen.
4131 /// \param HasCancel true if this directive has inner cancel directive.
4132 ///
4133 static OMPMaskedTaskLoopDirective *
4134 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4135 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4136 Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
4137
4138 /// Creates an empty directive with the place
4139 /// for \a NumClauses clauses.
4140 ///
4141 /// \param C AST context.
4142 /// \param CollapsedNum Number of collapsed nested loops.
4143 /// \param NumClauses Number of clauses.
4144 ///
4145 static OMPMaskedTaskLoopDirective *CreateEmpty(const ASTContext &C,
4146 unsigned NumClauses,
4147 unsigned CollapsedNum,
4148 EmptyShell);
4149
4150 /// Return true if current directive has inner cancel directive.
4151 bool hasCancel() const { return HasCancel; }
4152
4153 static bool classof(const Stmt *T) {
4154 return T->getStmtClass() == OMPMaskedTaskLoopDirectiveClass;
4155 }
4156};
4157
4158/// This represents '#pragma omp master taskloop simd' directive.
4159///
4160/// \code
4161/// #pragma omp master taskloop simd private(a,b) grainsize(val) num_tasks(num)
4162/// \endcode
4163/// In this example directive '#pragma omp master taskloop simd' has clauses
4164/// 'private' with the variables 'a' and 'b', 'grainsize' with expression 'val'
4165/// and 'num_tasks' with expression 'num'.
4166///
4167class OMPMasterTaskLoopSimdDirective : public OMPLoopDirective {
4168 friend class ASTStmtReader;
4170 /// Build directive with the given start and end location.
4171 ///
4172 /// \param StartLoc Starting location of the directive kind.
4173 /// \param EndLoc Ending location of the directive.
4174 /// \param CollapsedNum Number of collapsed nested loops.
4175 ///
4176 OMPMasterTaskLoopSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
4177 unsigned CollapsedNum)
4178 : OMPLoopDirective(OMPMasterTaskLoopSimdDirectiveClass,
4179 llvm::omp::OMPD_master_taskloop_simd, StartLoc, EndLoc,
4180 CollapsedNum) {}
4181
4182 /// Build an empty directive.
4183 ///
4184 /// \param CollapsedNum Number of collapsed nested loops.
4185 ///
4186 explicit OMPMasterTaskLoopSimdDirective(unsigned CollapsedNum)
4187 : OMPLoopDirective(OMPMasterTaskLoopSimdDirectiveClass,
4188 llvm::omp::OMPD_master_taskloop_simd, SourceLocation(),
4189 SourceLocation(), CollapsedNum) {}
4190
4191public:
4192 /// Creates directive with a list of \p Clauses.
4193 ///
4194 /// \param C AST context.
4195 /// \param StartLoc Starting location of the directive kind.
4196 /// \param EndLoc Ending Location of the directive.
4197 /// \param CollapsedNum Number of collapsed loops.
4198 /// \param Clauses List of clauses.
4199 /// \param AssociatedStmt Statement, associated with the directive.
4200 /// \param Exprs Helper expressions for CodeGen.
4201 ///
4202 static OMPMasterTaskLoopSimdDirective *
4203 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4204 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4205 Stmt *AssociatedStmt, const HelperExprs &Exprs);
4206
4207 /// Creates an empty directive with the place for \p NumClauses clauses.
4208 ///
4209 /// \param C AST context.
4210 /// \param CollapsedNum Number of collapsed nested loops.
4211 /// \param NumClauses Number of clauses.
4212 ///
4213 static OMPMasterTaskLoopSimdDirective *CreateEmpty(const ASTContext &C,
4214 unsigned NumClauses,
4215 unsigned CollapsedNum,
4216 EmptyShell);
4217
4218 static bool classof(const Stmt *T) {
4219 return T->getStmtClass() == OMPMasterTaskLoopSimdDirectiveClass;
4220 }
4221};
4222
4223/// This represents '#pragma omp masked taskloop simd' directive.
4224///
4225/// \code
4226/// #pragma omp masked taskloop simd private(a,b) grainsize(val) num_tasks(num)
4227/// \endcode
4228/// In this example directive '#pragma omp masked taskloop simd' has clauses
4229/// 'private' with the variables 'a' and 'b', 'grainsize' with expression 'val'
4230/// and 'num_tasks' with expression 'num'.
4231///
4232class OMPMaskedTaskLoopSimdDirective final : public OMPLoopDirective {
4233 friend class ASTStmtReader;
4235 /// Build directive with the given start and end location.
4236 ///
4237 /// \param StartLoc Starting location of the directive kind.
4238 /// \param EndLoc Ending location of the directive.
4239 /// \param CollapsedNum Number of collapsed nested loops.
4240 ///
4241 OMPMaskedTaskLoopSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
4242 unsigned CollapsedNum)
4243 : OMPLoopDirective(OMPMaskedTaskLoopSimdDirectiveClass,
4244 llvm::omp::OMPD_masked_taskloop_simd, StartLoc, EndLoc,
4245 CollapsedNum) {}
4246
4247 /// Build an empty directive.
4248 ///
4249 /// \param CollapsedNum Number of collapsed nested loops.
4250 ///
4251 explicit OMPMaskedTaskLoopSimdDirective(unsigned CollapsedNum)
4252 : OMPLoopDirective(OMPMaskedTaskLoopSimdDirectiveClass,
4253 llvm::omp::OMPD_masked_taskloop_simd, SourceLocation(),
4254 SourceLocation(), CollapsedNum) {}
4255
4256public:
4257 /// Creates directive with a list of \p Clauses.
4258 ///
4259 /// \param C AST context.
4260 /// \param StartLoc Starting location of the directive kind.
4261 /// \param EndLoc Ending Location of the directive.
4262 /// \param CollapsedNum Number of collapsed loops.
4263 /// \param Clauses List of clauses.
4264 /// \param AssociatedStmt Statement, associated with the directive.
4265 /// \param Exprs Helper expressions for CodeGen.
4266 ///
4267 static OMPMaskedTaskLoopSimdDirective *
4268 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4269 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4270 Stmt *AssociatedStmt, const HelperExprs &Exprs);
4271
4272 /// Creates an empty directive with the place for \p NumClauses clauses.
4273 ///
4274 /// \param C AST context.
4275 /// \param CollapsedNum Number of collapsed nested loops.
4276 /// \param NumClauses Number of clauses.
4277 ///
4278 static OMPMaskedTaskLoopSimdDirective *CreateEmpty(const ASTContext &C,
4279 unsigned NumClauses,
4280 unsigned CollapsedNum,
4281 EmptyShell);
4282
4283 static bool classof(const Stmt *T) {
4284 return T->getStmtClass() == OMPMaskedTaskLoopSimdDirectiveClass;
4285 }
4286};
4287
4288/// This represents '#pragma omp parallel master taskloop' directive.
4289///
4290/// \code
4291/// #pragma omp parallel master taskloop private(a,b) grainsize(val)
4292/// num_tasks(num)
4293/// \endcode
4294/// In this example directive '#pragma omp parallel master taskloop' has clauses
4295/// 'private' with the variables 'a' and 'b', 'grainsize' with expression 'val'
4296/// and 'num_tasks' with expression 'num'.
4297///
4298class OMPParallelMasterTaskLoopDirective : public OMPLoopDirective {
4299 friend class ASTStmtReader;
4301 /// true if the construct has inner cancel directive.
4302 bool HasCancel = false;
4303
4304 /// Build directive with the given start and end location.
4305 ///
4306 /// \param StartLoc Starting location of the directive kind.
4307 /// \param EndLoc Ending location of the directive.
4308 /// \param CollapsedNum Number of collapsed nested loops.
4309 ///
4310 OMPParallelMasterTaskLoopDirective(SourceLocation StartLoc,
4311 SourceLocation EndLoc,
4312 unsigned CollapsedNum)
4313 : OMPLoopDirective(OMPParallelMasterTaskLoopDirectiveClass,
4314 llvm::omp::OMPD_parallel_master_taskloop, StartLoc,
4315 EndLoc, CollapsedNum) {}
4316
4317 /// Build an empty directive.
4318 ///
4319 /// \param CollapsedNum Number of collapsed nested loops.
4320 ///
4321 explicit OMPParallelMasterTaskLoopDirective(unsigned CollapsedNum)
4322 : OMPLoopDirective(OMPParallelMasterTaskLoopDirectiveClass,
4323 llvm::omp::OMPD_parallel_master_taskloop,
4324 SourceLocation(), SourceLocation(), CollapsedNum) {}
4325
4326 /// Set cancel state.
4327 void setHasCancel(bool Has) { HasCancel = Has; }
4328
4329public:
4330 /// Creates directive with a list of \a Clauses.
4331 ///
4332 /// \param C AST context.
4333 /// \param StartLoc Starting location of the directive kind.
4334 /// \param EndLoc Ending Location of the directive.
4335 /// \param CollapsedNum Number of collapsed loops.
4336 /// \param Clauses List of clauses.
4337 /// \param AssociatedStmt Statement, associated with the directive.
4338 /// \param Exprs Helper expressions for CodeGen.
4339 /// \param HasCancel true if this directive has inner cancel directive.
4340 ///
4341 static OMPParallelMasterTaskLoopDirective *
4342 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4343 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4344 Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
4345
4346 /// Creates an empty directive with the place
4347 /// for \a NumClauses clauses.
4348 ///
4349 /// \param C AST context.
4350 /// \param CollapsedNum Number of collapsed nested loops.
4351 /// \param NumClauses Number of clauses.
4352 ///
4353 static OMPParallelMasterTaskLoopDirective *CreateEmpty(const ASTContext &C,
4354 unsigned NumClauses,
4355 unsigned CollapsedNum,
4356 EmptyShell);
4357
4358 /// Return true if current directive has inner cancel directive.
4359 bool hasCancel() const { return HasCancel; }
4360
4361 static bool classof(const Stmt *T) {
4362 return T->getStmtClass() == OMPParallelMasterTaskLoopDirectiveClass;
4363 }
4364};
4365
4366/// This represents '#pragma omp parallel masked taskloop' directive.
4367///
4368/// \code
4369/// #pragma omp parallel masked taskloop private(a,b) grainsize(val)
4370/// num_tasks(num)
4371/// \endcode
4372/// In this example directive '#pragma omp parallel masked taskloop' has clauses
4373/// 'private' with the variables 'a' and 'b', 'grainsize' with expression 'val'
4374/// and 'num_tasks' with expression 'num'.
4375///
4376class OMPParallelMaskedTaskLoopDirective final : public OMPLoopDirective {
4377 friend class ASTStmtReader;
4379 /// true if the construct has inner cancel directive.
4380 bool HasCancel = false;
4381
4382 /// Build directive with the given start and end location.
4383 ///
4384 /// \param StartLoc Starting location of the directive kind.
4385 /// \param EndLoc Ending location of the directive.
4386 /// \param CollapsedNum Number of collapsed nested loops.
4387 ///
4388 OMPParallelMaskedTaskLoopDirective(SourceLocation StartLoc,
4389 SourceLocation EndLoc,
4390 unsigned CollapsedNum)
4391 : OMPLoopDirective(OMPParallelMaskedTaskLoopDirectiveClass,
4392 llvm::omp::OMPD_parallel_masked_taskloop, StartLoc,
4393 EndLoc, CollapsedNum) {}
4394
4395 /// Build an empty directive.
4396 ///
4397 /// \param CollapsedNum Number of collapsed nested loops.
4398 ///
4399 explicit OMPParallelMaskedTaskLoopDirective(unsigned CollapsedNum)
4400 : OMPLoopDirective(OMPParallelMaskedTaskLoopDirectiveClass,
4401 llvm::omp::OMPD_parallel_masked_taskloop,
4402 SourceLocation(), SourceLocation(), CollapsedNum) {}
4403
4404 /// Set cancel state.
4405 void setHasCancel(bool Has) { HasCancel = Has; }
4406
4407public:
4408 /// Creates directive with a list of \a Clauses.
4409 ///
4410 /// \param C AST context.
4411 /// \param StartLoc Starting location of the directive kind.
4412 /// \param EndLoc Ending Location of the directive.
4413 /// \param CollapsedNum Number of collapsed loops.
4414 /// \param Clauses List of clauses.
4415 /// \param AssociatedStmt Statement, associated with the directive.
4416 /// \param Exprs Helper expressions for CodeGen.
4417 /// \param HasCancel true if this directive has inner cancel directive.
4418 ///
4419 static OMPParallelMaskedTaskLoopDirective *
4420 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4421 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4422 Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
4423
4424 /// Creates an empty directive with the place
4425 /// for \a NumClauses clauses.
4426 ///
4427 /// \param C AST context.
4428 /// \param CollapsedNum Number of collapsed nested loops.
4429 /// \param NumClauses Number of clauses.
4430 ///
4431 static OMPParallelMaskedTaskLoopDirective *CreateEmpty(const ASTContext &C,
4432 unsigned NumClauses,
4433 unsigned CollapsedNum,
4434 EmptyShell);
4435
4436 /// Return true if current directive has inner cancel directive.
4437 bool hasCancel() const { return HasCancel; }
4438
4439 static bool classof(const Stmt *T) {
4440 return T->getStmtClass() == OMPParallelMaskedTaskLoopDirectiveClass;
4441 }
4442};
4443
4444/// This represents '#pragma omp parallel master taskloop simd' directive.
4445///
4446/// \code
4447/// #pragma omp parallel master taskloop simd private(a,b) grainsize(val)
4448/// num_tasks(num)
4449/// \endcode
4450/// In this example directive '#pragma omp parallel master taskloop simd' has
4451/// clauses 'private' with the variables 'a' and 'b', 'grainsize' with
4452/// expression 'val' and 'num_tasks' with expression 'num'.
4453///
4454class OMPParallelMasterTaskLoopSimdDirective : public OMPLoopDirective {
4455 friend class ASTStmtReader;
4457 /// Build directive with the given start and end location.
4458 ///
4459 /// \param StartLoc Starting location of the directive kind.
4460 /// \param EndLoc Ending location of the directive.
4461 /// \param CollapsedNum Number of collapsed nested loops.
4462 ///
4463 OMPParallelMasterTaskLoopSimdDirective(SourceLocation StartLoc,
4464 SourceLocation EndLoc,
4465 unsigned CollapsedNum)
4466 : OMPLoopDirective(OMPParallelMasterTaskLoopSimdDirectiveClass,
4467 llvm::omp::OMPD_parallel_master_taskloop_simd,
4468 StartLoc, EndLoc, CollapsedNum) {}
4469
4470 /// Build an empty directive.
4471 ///
4472 /// \param CollapsedNum Number of collapsed nested loops.
4473 ///
4474 explicit OMPParallelMasterTaskLoopSimdDirective(unsigned CollapsedNum)
4475 : OMPLoopDirective(OMPParallelMasterTaskLoopSimdDirectiveClass,
4476 llvm::omp::OMPD_parallel_master_taskloop_simd,
4477 SourceLocation(), SourceLocation(), CollapsedNum) {}
4478
4479public:
4480 /// Creates directive with a list of \p Clauses.
4481 ///
4482 /// \param C AST context.
4483 /// \param StartLoc Starting location of the directive kind.
4484 /// \param EndLoc Ending Location of the directive.
4485 /// \param CollapsedNum Number of collapsed loops.
4486 /// \param Clauses List of clauses.
4487 /// \param AssociatedStmt Statement, associated with the directive.
4488 /// \param Exprs Helper expressions for CodeGen.
4489 ///
4490 static OMPParallelMasterTaskLoopSimdDirective *
4491 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4492 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4493 Stmt *AssociatedStmt, const HelperExprs &Exprs);
4494
4495 /// Creates an empty directive with the place
4496 /// for \a NumClauses clauses.
4497 ///
4498 /// \param C AST context.
4499 /// \param CollapsedNum Number of collapsed nested loops.
4500 /// \param NumClauses Number of clauses.
4501 ///
4502 static OMPParallelMasterTaskLoopSimdDirective *
4503 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
4504 EmptyShell);
4505
4506 static bool classof(const Stmt *T) {
4507 return T->getStmtClass() == OMPParallelMasterTaskLoopSimdDirectiveClass;
4508 }
4509};
4510
4511/// This represents '#pragma omp parallel masked taskloop simd' directive.
4512///
4513/// \code
4514/// #pragma omp parallel masked taskloop simd private(a,b) grainsize(val)
4515/// num_tasks(num)
4516/// \endcode
4517/// In this example directive '#pragma omp parallel masked taskloop simd' has
4518/// clauses 'private' with the variables 'a' and 'b', 'grainsize' with
4519/// expression 'val' and 'num_tasks' with expression 'num'.
4520///
4521class OMPParallelMaskedTaskLoopSimdDirective final : public OMPLoopDirective {
4522 friend class ASTStmtReader;
4524 /// Build directive with the given start and end location.
4525 ///
4526 /// \param StartLoc Starting location of the directive kind.
4527 /// \param EndLoc Ending location of the directive.
4528 /// \param CollapsedNum Number of collapsed nested loops.
4529 ///
4530 OMPParallelMaskedTaskLoopSimdDirective(SourceLocation StartLoc,
4531 SourceLocation EndLoc,
4532 unsigned CollapsedNum)
4533 : OMPLoopDirective(OMPParallelMaskedTaskLoopSimdDirectiveClass,
4534 llvm::omp::OMPD_parallel_masked_taskloop_simd,
4535 StartLoc, EndLoc, CollapsedNum) {}
4536
4537 /// Build an empty directive.
4538 ///
4539 /// \param CollapsedNum Number of collapsed nested loops.
4540 ///
4541 explicit OMPParallelMaskedTaskLoopSimdDirective(unsigned CollapsedNum)
4542 : OMPLoopDirective(OMPParallelMaskedTaskLoopSimdDirectiveClass,
4543 llvm::omp::OMPD_parallel_masked_taskloop_simd,
4544 SourceLocation(), SourceLocation(), CollapsedNum) {}
4545
4546public:
4547 /// Creates directive with a list of \p Clauses.
4548 ///
4549 /// \param C AST context.
4550 /// \param StartLoc Starting location of the directive kind.
4551 /// \param EndLoc Ending Location of the directive.
4552 /// \param CollapsedNum Number of collapsed loops.
4553 /// \param Clauses List of clauses.
4554 /// \param AssociatedStmt Statement, associated with the directive.
4555 /// \param Exprs Helper expressions for CodeGen.
4556 ///
4557 static OMPParallelMaskedTaskLoopSimdDirective *
4558 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4559 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4560 Stmt *AssociatedStmt, const HelperExprs &Exprs);
4561
4562 /// Creates an empty directive with the place
4563 /// for \a NumClauses clauses.
4564 ///
4565 /// \param C AST context.
4566 /// \param CollapsedNum Number of collapsed nested loops.
4567 /// \param NumClauses Number of clauses.
4568 ///
4569 static OMPParallelMaskedTaskLoopSimdDirective *
4570 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
4571 EmptyShell);
4572
4573 static bool classof(const Stmt *T) {
4574 return T->getStmtClass() == OMPParallelMaskedTaskLoopSimdDirectiveClass;
4575 }
4576};
4577
4578/// This represents '#pragma omp distribute' directive.
4579///
4580/// \code
4581/// #pragma omp distribute private(a,b)
4582/// \endcode
4583/// In this example directive '#pragma omp distribute' has clauses 'private'
4584/// with the variables 'a' and 'b'
4585///
4586class OMPDistributeDirective : public OMPLoopDirective {
4587 friend class ASTStmtReader;
4589
4590 /// Build directive with the given start and end location.
4591 ///
4592 /// \param StartLoc Starting location of the directive kind.
4593 /// \param EndLoc Ending location of the directive.
4594 /// \param CollapsedNum Number of collapsed nested loops.
4595 ///
4596 OMPDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
4597 unsigned CollapsedNum)
4598 : OMPLoopDirective(OMPDistributeDirectiveClass,
4599 llvm::omp::OMPD_distribute, StartLoc, EndLoc,
4600 CollapsedNum) {}
4601
4602 /// Build an empty directive.
4603 ///
4604 /// \param CollapsedNum Number of collapsed nested loops.
4605 ///
4606 explicit OMPDistributeDirective(unsigned CollapsedNum)
4607 : OMPLoopDirective(OMPDistributeDirectiveClass,
4608 llvm::omp::OMPD_distribute, SourceLocation(),
4609 SourceLocation(), CollapsedNum) {}
4610
4611public:
4612 /// Creates directive with a list of \a Clauses.
4613 ///
4614 /// \param C AST context.
4615 /// \param StartLoc Starting location of the directive kind.
4616 /// \param EndLoc Ending Location of the directive.
4617 /// \param CollapsedNum Number of collapsed loops.
4618 /// \param Clauses List of clauses.
4619 /// \param AssociatedStmt Statement, associated with the directive.
4620 /// \param Exprs Helper expressions for CodeGen.
4621 ///
4622 static OMPDistributeDirective *
4623 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4624 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4625 Stmt *AssociatedStmt, const HelperExprs &Exprs);
4626
4627 /// Creates an empty directive with the place
4628 /// for \a NumClauses clauses.
4629 ///
4630 /// \param C AST context.
4631 /// \param CollapsedNum Number of collapsed nested loops.
4632 /// \param NumClauses Number of clauses.
4633 ///
4634 static OMPDistributeDirective *CreateEmpty(const ASTContext &C,
4635 unsigned NumClauses,
4636 unsigned CollapsedNum, EmptyShell);
4637
4638 static bool classof(const Stmt *T) {
4639 return T->getStmtClass() == OMPDistributeDirectiveClass;
4640 }
4641};
4642
4643/// This represents '#pragma omp target update' directive.
4644///
4645/// \code
4646/// #pragma omp target update to(a) from(b) device(1)
4647/// \endcode
4648/// In this example directive '#pragma omp target update' has clause 'to' with
4649/// argument 'a', clause 'from' with argument 'b' and clause 'device' with
4650/// argument '1'.
4651///
4652class OMPTargetUpdateDirective : public OMPExecutableDirective {
4653 friend class ASTStmtReader;
4655 /// Build directive with the given start and end location.
4656 ///
4657 /// \param StartLoc Starting location of the directive kind.
4658 /// \param EndLoc Ending Location of the directive.
4659 ///
4660 OMPTargetUpdateDirective(SourceLocation StartLoc, SourceLocation EndLoc)
4661 : OMPExecutableDirective(OMPTargetUpdateDirectiveClass,
4662 llvm::omp::OMPD_target_update, StartLoc,
4663 EndLoc) {}
4664
4665 /// Build an empty directive.
4666 ///
4667 explicit OMPTargetUpdateDirective()
4668 : OMPExecutableDirective(OMPTargetUpdateDirectiveClass,
4669 llvm::omp::OMPD_target_update, SourceLocation(),
4670 SourceLocation()) {}
4671
4672public:
4673 /// Creates directive with a list of \a Clauses.
4674 ///
4675 /// \param C AST context.
4676 /// \param StartLoc Starting location of the directive kind.
4677 /// \param EndLoc Ending Location of the directive.
4678 /// \param Clauses List of clauses.
4679 /// \param AssociatedStmt Statement, associated with the directive.
4680 ///
4681 static OMPTargetUpdateDirective *
4682 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4683 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
4684
4685 /// Creates an empty directive with the place for \a NumClauses
4686 /// clauses.
4687 ///
4688 /// \param C AST context.
4689 /// \param NumClauses The number of clauses.
4690 ///
4691 static OMPTargetUpdateDirective *CreateEmpty(const ASTContext &C,
4692 unsigned NumClauses, EmptyShell);
4693
4694 static bool classof(const Stmt *T) {
4695 return T->getStmtClass() == OMPTargetUpdateDirectiveClass;
4696 }
4697};
4698
4699/// This represents '#pragma omp distribute parallel for' composite
4700/// directive.
4701///
4702/// \code
4703/// #pragma omp distribute parallel for private(a,b)
4704/// \endcode
4705/// In this example directive '#pragma omp distribute parallel for' has clause
4706/// 'private' with the variables 'a' and 'b'
4707///
4708class OMPDistributeParallelForDirective : public OMPLoopDirective {
4709 friend class ASTStmtReader;
4711 /// true if the construct has inner cancel directive.
4712 bool HasCancel = false;
4713
4714 /// Build directive with the given start and end location.
4715 ///
4716 /// \param StartLoc Starting location of the directive kind.
4717 /// \param EndLoc Ending location of the directive.
4718 /// \param CollapsedNum Number of collapsed nested loops.
4719 ///
4720 OMPDistributeParallelForDirective(SourceLocation StartLoc,
4721 SourceLocation EndLoc,
4722 unsigned CollapsedNum)
4723 : OMPLoopDirective(OMPDistributeParallelForDirectiveClass,
4724 llvm::omp::OMPD_distribute_parallel_for, StartLoc,
4725 EndLoc, CollapsedNum) {}
4726
4727 /// Build an empty directive.
4728 ///
4729 /// \param CollapsedNum Number of collapsed nested loops.
4730 ///
4731 explicit OMPDistributeParallelForDirective(unsigned CollapsedNum)
4732 : OMPLoopDirective(OMPDistributeParallelForDirectiveClass,
4733 llvm::omp::OMPD_distribute_parallel_for,
4734 SourceLocation(), SourceLocation(), CollapsedNum) {}
4735
4736 /// Sets special task reduction descriptor.
4737 void setTaskReductionRefExpr(Expr *E) {
4738 Data->getChildren()[numLoopChildren(
4739 getLoopsNumber(), llvm::omp::OMPD_distribute_parallel_for)] = E;
4740 }
4741
4742 /// Set cancel state.
4743 void setHasCancel(bool Has) { HasCancel = Has; }
4744
4745public:
4746 /// Creates directive with a list of \a Clauses.
4747 ///
4748 /// \param C AST context.
4749 /// \param StartLoc Starting location of the directive kind.
4750 /// \param EndLoc Ending Location of the directive.
4751 /// \param CollapsedNum Number of collapsed loops.
4752 /// \param Clauses List of clauses.
4753 /// \param AssociatedStmt Statement, associated with the directive.
4754 /// \param Exprs Helper expressions for CodeGen.
4755 /// \param TaskRedRef Task reduction special reference expression to handle
4756 /// taskgroup descriptor.
4757 /// \param HasCancel true if this directive has inner cancel directive.
4758 ///
4759 static OMPDistributeParallelForDirective *
4760 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4761 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4762 Stmt *AssociatedStmt, const HelperExprs &Exprs, Expr *TaskRedRef,
4763 bool HasCancel);
4764
4765 /// Creates an empty directive with the place
4766 /// for \a NumClauses clauses.
4767 ///
4768 /// \param C AST context.
4769 /// \param CollapsedNum Number of collapsed nested loops.
4770 /// \param NumClauses Number of clauses.
4771 ///
4772 static OMPDistributeParallelForDirective *CreateEmpty(const ASTContext &C,
4773 unsigned NumClauses,
4774 unsigned CollapsedNum,
4775 EmptyShell);
4776
4777 /// Returns special task reduction reference expression.
4779 return cast_or_null<Expr>(Data->getChildren()[numLoopChildren(
4780 getLoopsNumber(), llvm::omp::OMPD_distribute_parallel_for)]);
4781 }
4782 const Expr *getTaskReductionRefExpr() const {
4783 return const_cast<OMPDistributeParallelForDirective *>(this)
4785 }
4786
4787 /// Return true if current directive has inner cancel directive.
4788 bool hasCancel() const { return HasCancel; }
4789
4790 static bool classof(const Stmt *T) {
4791 return T->getStmtClass() == OMPDistributeParallelForDirectiveClass;
4792 }
4793};
4794
4795/// This represents '#pragma omp distribute parallel for simd' composite
4796/// directive.
4797///
4798/// \code
4799/// #pragma omp distribute parallel for simd private(x)
4800/// \endcode
4801/// In this example directive '#pragma omp distribute parallel for simd' has
4802/// clause 'private' with the variables 'x'
4803///
4804class OMPDistributeParallelForSimdDirective final : public OMPLoopDirective {
4805 friend class ASTStmtReader;
4807
4808 /// Build directive with the given start and end location.
4809 ///
4810 /// \param StartLoc Starting location of the directive kind.
4811 /// \param EndLoc Ending location of the directive.
4812 /// \param CollapsedNum Number of collapsed nested loops.
4813 ///
4814 OMPDistributeParallelForSimdDirective(SourceLocation StartLoc,
4815 SourceLocation EndLoc,
4816 unsigned CollapsedNum)
4817 : OMPLoopDirective(OMPDistributeParallelForSimdDirectiveClass,
4818 llvm::omp::OMPD_distribute_parallel_for_simd, StartLoc,
4819 EndLoc, CollapsedNum) {}
4820
4821 /// Build an empty directive.
4822 ///
4823 /// \param CollapsedNum Number of collapsed nested loops.
4824 ///
4825 explicit OMPDistributeParallelForSimdDirective(unsigned CollapsedNum)
4826 : OMPLoopDirective(OMPDistributeParallelForSimdDirectiveClass,
4827 llvm::omp::OMPD_distribute_parallel_for_simd,
4828 SourceLocation(), SourceLocation(), CollapsedNum) {}
4829
4830public:
4831 /// Creates directive with a list of \a Clauses.
4832 ///
4833 /// \param C AST context.
4834 /// \param StartLoc Starting location of the directive kind.
4835 /// \param EndLoc Ending Location of the directive.
4836 /// \param CollapsedNum Number of collapsed loops.
4837 /// \param Clauses List of clauses.
4838 /// \param AssociatedStmt Statement, associated with the directive.
4839 /// \param Exprs Helper expressions for CodeGen.
4840 ///
4841 static OMPDistributeParallelForSimdDirective *Create(
4842 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4843 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4844 Stmt *AssociatedStmt, const HelperExprs &Exprs);
4845
4846 /// Creates an empty directive with the place for \a NumClauses clauses.
4847 ///
4848 /// \param C AST context.
4849 /// \param CollapsedNum Number of collapsed nested loops.
4850 /// \param NumClauses Number of clauses.
4851 ///
4852 static OMPDistributeParallelForSimdDirective *CreateEmpty(
4853 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
4854 EmptyShell);
4855
4856 static bool classof(const Stmt *T) {
4857 return T->getStmtClass() == OMPDistributeParallelForSimdDirectiveClass;
4858 }
4859};
4860
4861/// This represents '#pragma omp distribute simd' composite directive.
4862///
4863/// \code
4864/// #pragma omp distribute simd private(x)
4865/// \endcode
4866/// In this example directive '#pragma omp distribute simd' has clause
4867/// 'private' with the variables 'x'
4868///
4869class OMPDistributeSimdDirective final : public OMPLoopDirective {
4870 friend class ASTStmtReader;
4872
4873 /// Build directive with the given start and end location.
4874 ///
4875 /// \param StartLoc Starting location of the directive kind.
4876 /// \param EndLoc Ending location of the directive.
4877 /// \param CollapsedNum Number of collapsed nested loops.
4878 ///
4879 OMPDistributeSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
4880 unsigned CollapsedNum)
4881 : OMPLoopDirective(OMPDistributeSimdDirectiveClass,
4882 llvm::omp::OMPD_distribute_simd, StartLoc, EndLoc,
4883 CollapsedNum) {}
4884
4885 /// Build an empty directive.
4886 ///
4887 /// \param CollapsedNum Number of collapsed nested loops.
4888 ///
4889 explicit OMPDistributeSimdDirective(unsigned CollapsedNum)
4890 : OMPLoopDirective(OMPDistributeSimdDirectiveClass,
4891 llvm::omp::OMPD_distribute_simd, SourceLocation(),
4892 SourceLocation(), CollapsedNum) {}
4893
4894public:
4895 /// Creates directive with a list of \a Clauses.
4896 ///
4897 /// \param C AST context.
4898 /// \param StartLoc Starting location of the directive kind.
4899 /// \param EndLoc Ending Location of the directive.
4900 /// \param CollapsedNum Number of collapsed loops.
4901 /// \param Clauses List of clauses.
4902 /// \param AssociatedStmt Statement, associated with the directive.
4903 /// \param Exprs Helper expressions for CodeGen.
4904 ///
4905 static OMPDistributeSimdDirective *
4906 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4907 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4908 Stmt *AssociatedStmt, const HelperExprs &Exprs);
4909
4910 /// Creates an empty directive with the place for \a NumClauses clauses.
4911 ///
4912 /// \param C AST context.
4913 /// \param CollapsedNum Number of collapsed nested loops.
4914 /// \param NumClauses Number of clauses.
4915 ///
4916 static OMPDistributeSimdDirective *CreateEmpty(const ASTContext &C,
4917 unsigned NumClauses,
4918 unsigned CollapsedNum,
4919 EmptyShell);
4920
4921 static bool classof(const Stmt *T) {
4922 return T->getStmtClass() == OMPDistributeSimdDirectiveClass;
4923 }
4924};
4925
4926/// This represents '#pragma omp target parallel for simd' directive.
4927///
4928/// \code
4929/// #pragma omp target parallel for simd private(a) map(b) safelen(c)
4930/// \endcode
4931/// In this example directive '#pragma omp target parallel for simd' has clauses
4932/// 'private' with the variable 'a', 'map' with the variable 'b' and 'safelen'
4933/// with the variable 'c'.
4934///
4935class OMPTargetParallelForSimdDirective final : public OMPLoopDirective {
4936 friend class ASTStmtReader;
4938
4939 /// Build directive with the given start and end location.
4940 ///
4941 /// \param StartLoc Starting location of the directive kind.
4942 /// \param EndLoc Ending location of the directive.
4943 /// \param CollapsedNum Number of collapsed nested loops.
4944 ///
4945 OMPTargetParallelForSimdDirective(SourceLocation StartLoc,
4946 SourceLocation EndLoc,
4947 unsigned CollapsedNum)
4948 : OMPLoopDirective(OMPTargetParallelForSimdDirectiveClass,
4949 llvm::omp::OMPD_target_parallel_for_simd, StartLoc,
4950 EndLoc, CollapsedNum) {}
4951
4952 /// Build an empty directive.
4953 ///
4954 /// \param CollapsedNum Number of collapsed nested loops.
4955 ///
4956 explicit OMPTargetParallelForSimdDirective(unsigned CollapsedNum)
4957 : OMPLoopDirective(OMPTargetParallelForSimdDirectiveClass,
4958 llvm::omp::OMPD_target_parallel_for_simd,
4959 SourceLocation(), SourceLocation(), CollapsedNum) {}
4960
4961public:
4962 /// Creates directive with a list of \a Clauses.
4963 ///
4964 /// \param C AST context.
4965 /// \param StartLoc Starting location of the directive kind.
4966 /// \param EndLoc Ending Location of the directive.
4967 /// \param CollapsedNum Number of collapsed loops.
4968 /// \param Clauses List of clauses.
4969 /// \param AssociatedStmt Statement, associated with the directive.
4970 /// \param Exprs Helper expressions for CodeGen.
4971 ///
4972 static OMPTargetParallelForSimdDirective *
4973 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
4974 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
4975 Stmt *AssociatedStmt, const HelperExprs &Exprs);
4976
4977 /// Creates an empty directive with the place for \a NumClauses clauses.
4978 ///
4979 /// \param C AST context.
4980 /// \param CollapsedNum Number of collapsed nested loops.
4981 /// \param NumClauses Number of clauses.
4982 ///
4983 static OMPTargetParallelForSimdDirective *CreateEmpty(const ASTContext &C,
4984 unsigned NumClauses,
4985 unsigned CollapsedNum,
4986 EmptyShell);
4987
4988 static bool classof(const Stmt *T) {
4989 return T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass;
4990 }
4991};
4992
4993/// This represents '#pragma omp target simd' directive.
4994///
4995/// \code
4996/// #pragma omp target simd private(a) map(b) safelen(c)
4997/// \endcode
4998/// In this example directive '#pragma omp target simd' has clauses 'private'
4999/// with the variable 'a', 'map' with the variable 'b' and 'safelen' with
5000/// the variable 'c'.
5001///
5002class OMPTargetSimdDirective final : public OMPLoopDirective {
5003 friend class ASTStmtReader;
5005
5006 /// Build directive with the given start and end location.
5007 ///
5008 /// \param StartLoc Starting location of the directive kind.
5009 /// \param EndLoc Ending location of the directive.
5010 /// \param CollapsedNum Number of collapsed nested loops.
5011 ///
5012 OMPTargetSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc,
5013 unsigned CollapsedNum)
5014 : OMPLoopDirective(OMPTargetSimdDirectiveClass,
5015 llvm::omp::OMPD_target_simd, StartLoc, EndLoc,
5016 CollapsedNum) {}
5017
5018 /// Build an empty directive.
5019 ///
5020 /// \param CollapsedNum Number of collapsed nested loops.
5021 ///
5022 explicit OMPTargetSimdDirective(unsigned CollapsedNum)
5023 : OMPLoopDirective(OMPTargetSimdDirectiveClass,
5024 llvm::omp::OMPD_target_simd, SourceLocation(),
5025 SourceLocation(), CollapsedNum) {}
5026
5027public:
5028 /// Creates directive with a list of \a Clauses.
5029 ///
5030 /// \param C AST context.
5031 /// \param StartLoc Starting location of the directive kind.
5032 /// \param EndLoc Ending Location of the directive.
5033 /// \param CollapsedNum Number of collapsed loops.
5034 /// \param Clauses List of clauses.
5035 /// \param AssociatedStmt Statement, associated with the directive.
5036 /// \param Exprs Helper expressions for CodeGen.
5037 ///
5038 static OMPTargetSimdDirective *
5039 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5040 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
5041 Stmt *AssociatedStmt, const HelperExprs &Exprs);
5042
5043 /// Creates an empty directive with the place for \a NumClauses clauses.
5044 ///
5045 /// \param C AST context.
5046 /// \param CollapsedNum Number of collapsed nested loops.
5047 /// \param NumClauses Number of clauses.
5048 ///
5049 static OMPTargetSimdDirective *CreateEmpty(const ASTContext &C,
5050 unsigned NumClauses,
5051 unsigned CollapsedNum,
5052 EmptyShell);
5053
5054 static bool classof(const Stmt *T) {
5055 return T->getStmtClass() == OMPTargetSimdDirectiveClass;
5056 }
5057};
5058
5059/// This represents '#pragma omp teams distribute' directive.
5060///
5061/// \code
5062/// #pragma omp teams distribute private(a,b)
5063/// \endcode
5064/// In this example directive '#pragma omp teams distribute' has clauses
5065/// 'private' with the variables 'a' and 'b'
5066///
5067class OMPTeamsDistributeDirective final : public OMPLoopDirective {
5068 friend class ASTStmtReader;
5070
5071 /// Build directive with the given start and end location.
5072 ///
5073 /// \param StartLoc Starting location of the directive kind.
5074 /// \param EndLoc Ending location of the directive.
5075 /// \param CollapsedNum Number of collapsed nested loops.
5076 ///
5077 OMPTeamsDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
5078 unsigned CollapsedNum)
5079 : OMPLoopDirective(OMPTeamsDistributeDirectiveClass,
5080 llvm::omp::OMPD_teams_distribute, StartLoc, EndLoc,
5081 CollapsedNum) {}
5082
5083 /// Build an empty directive.
5084 ///
5085 /// \param CollapsedNum Number of collapsed nested loops.
5086 ///
5087 explicit OMPTeamsDistributeDirective(unsigned CollapsedNum)
5088 : OMPLoopDirective(OMPTeamsDistributeDirectiveClass,
5089 llvm::omp::OMPD_teams_distribute, SourceLocation(),
5090 SourceLocation(), CollapsedNum) {}
5091
5092public:
5093 /// Creates directive with a list of \a Clauses.
5094 ///
5095 /// \param C AST context.
5096 /// \param StartLoc Starting location of the directive kind.
5097 /// \param EndLoc Ending Location of the directive.
5098 /// \param CollapsedNum Number of collapsed loops.
5099 /// \param Clauses List of clauses.
5100 /// \param AssociatedStmt Statement, associated with the directive.
5101 /// \param Exprs Helper expressions for CodeGen.
5102 ///
5103 static OMPTeamsDistributeDirective *
5104 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5105 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
5106 Stmt *AssociatedStmt, const HelperExprs &Exprs);
5107
5108 /// Creates an empty directive with the place for \a NumClauses clauses.
5109 ///
5110 /// \param C AST context.
5111 /// \param CollapsedNum Number of collapsed nested loops.
5112 /// \param NumClauses Number of clauses.
5113 ///
5114 static OMPTeamsDistributeDirective *CreateEmpty(const ASTContext &C,
5115 unsigned NumClauses,
5116 unsigned CollapsedNum,
5117 EmptyShell);
5118
5119 static bool classof(const Stmt *T) {
5120 return T->getStmtClass() == OMPTeamsDistributeDirectiveClass;
5121 }
5122};
5123
5124/// This represents '#pragma omp teams distribute simd'
5125/// combined directive.
5126///
5127/// \code
5128/// #pragma omp teams distribute simd private(a,b)
5129/// \endcode
5130/// In this example directive '#pragma omp teams distribute simd'
5131/// has clause 'private' with the variables 'a' and 'b'
5132///
5133class OMPTeamsDistributeSimdDirective final : public OMPLoopDirective {
5134 friend class ASTStmtReader;
5136
5137 /// Build directive with the given start and end location.
5138 ///
5139 /// \param StartLoc Starting location of the directive kind.
5140 /// \param EndLoc Ending location of the directive.
5141 /// \param CollapsedNum Number of collapsed nested loops.
5142 ///
5143 OMPTeamsDistributeSimdDirective(SourceLocation StartLoc,
5144 SourceLocation EndLoc, unsigned CollapsedNum)
5145 : OMPLoopDirective(OMPTeamsDistributeSimdDirectiveClass,
5146 llvm::omp::OMPD_teams_distribute_simd, StartLoc,
5147 EndLoc, CollapsedNum) {}
5148
5149 /// Build an empty directive.
5150 ///
5151 /// \param CollapsedNum Number of collapsed nested loops.
5152 ///
5153 explicit OMPTeamsDistributeSimdDirective(unsigned CollapsedNum)
5154 : OMPLoopDirective(OMPTeamsDistributeSimdDirectiveClass,
5155 llvm::omp::OMPD_teams_distribute_simd,
5156 SourceLocation(), SourceLocation(), CollapsedNum) {}
5157
5158public:
5159 /// Creates directive with a list of \a Clauses.
5160 ///
5161 /// \param C AST context.
5162 /// \param StartLoc Starting location of the directive kind.
5163 /// \param EndLoc Ending Location of the directive.
5164 /// \param CollapsedNum Number of collapsed loops.
5165 /// \param Clauses List of clauses.
5166 /// \param AssociatedStmt Statement, associated with the directive.
5167 /// \param Exprs Helper expressions for CodeGen.
5168 ///
5169 static OMPTeamsDistributeSimdDirective *
5170 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5171 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
5172 Stmt *AssociatedStmt, const HelperExprs &Exprs);
5173
5174 /// Creates an empty directive with the place
5175 /// for \a NumClauses clauses.
5176 ///
5177 /// \param C AST context.
5178 /// \param CollapsedNum Number of collapsed nested loops.
5179 /// \param NumClauses Number of clauses.
5180 ///
5181 static OMPTeamsDistributeSimdDirective *CreateEmpty(const ASTContext &C,
5182 unsigned NumClauses,
5183 unsigned CollapsedNum,
5184 EmptyShell);
5185
5186 static bool classof(const Stmt *T) {
5187 return T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass;
5188 }
5189};
5190
5191/// This represents '#pragma omp teams distribute parallel for simd' composite
5192/// directive.
5193///
5194/// \code
5195/// #pragma omp teams distribute parallel for simd private(x)
5196/// \endcode
5197/// In this example directive '#pragma omp teams distribute parallel for simd'
5198/// has clause 'private' with the variables 'x'
5199///
5200class OMPTeamsDistributeParallelForSimdDirective final
5201 : public OMPLoopDirective {
5202 friend class ASTStmtReader;
5204
5205 /// Build directive with the given start and end location.
5206 ///
5207 /// \param StartLoc Starting location of the directive kind.
5208 /// \param EndLoc Ending location of the directive.
5209 /// \param CollapsedNum Number of collapsed nested loops.
5210 ///
5211 OMPTeamsDistributeParallelForSimdDirective(SourceLocation StartLoc,
5212 SourceLocation EndLoc,
5213 unsigned CollapsedNum)
5214 : OMPLoopDirective(OMPTeamsDistributeParallelForSimdDirectiveClass,
5215 llvm::omp::OMPD_teams_distribute_parallel_for_simd,
5216 StartLoc, EndLoc, CollapsedNum) {}
5217
5218 /// Build an empty directive.
5219 ///
5220 /// \param CollapsedNum Number of collapsed nested loops.
5221 ///
5222 explicit OMPTeamsDistributeParallelForSimdDirective(unsigned CollapsedNum)
5223 : OMPLoopDirective(OMPTeamsDistributeParallelForSimdDirectiveClass,
5224 llvm::omp::OMPD_teams_distribute_parallel_for_simd,
5225 SourceLocation(), SourceLocation(), CollapsedNum) {}
5226
5227public:
5228 /// Creates directive with a list of \a Clauses.
5229 ///
5230 /// \param C AST context.
5231 /// \param StartLoc Starting location of the directive kind.
5232 /// \param EndLoc Ending Location of the directive.
5233 /// \param CollapsedNum Number of collapsed loops.
5234 /// \param Clauses List of clauses.
5235 /// \param AssociatedStmt Statement, associated with the directive.
5236 /// \param Exprs Helper expressions for CodeGen.
5237 ///
5238 static OMPTeamsDistributeParallelForSimdDirective *
5239 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5240 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
5241 Stmt *AssociatedStmt, const HelperExprs &Exprs);
5242
5243 /// Creates an empty directive with the place for \a NumClauses clauses.
5244 ///
5245 /// \param C AST context.
5246 /// \param CollapsedNum Number of collapsed nested loops.
5247 /// \param NumClauses Number of clauses.
5248 ///
5249 static OMPTeamsDistributeParallelForSimdDirective *
5250 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
5251 EmptyShell);
5252
5253 static bool classof(const Stmt *T) {
5254 return T->getStmtClass() == OMPTeamsDistributeParallelForSimdDirectiveClass;
5255 }
5256};
5257
5258/// This represents '#pragma omp teams distribute parallel for' composite
5259/// directive.
5260///
5261/// \code
5262/// #pragma omp teams distribute parallel for private(x)
5263/// \endcode
5264/// In this example directive '#pragma omp teams distribute parallel for'
5265/// has clause 'private' with the variables 'x'
5266///
5267class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective {
5268 friend class ASTStmtReader;
5270 /// true if the construct has inner cancel directive.
5271 bool HasCancel = false;
5272
5273 /// Build directive with the given start and end location.
5274 ///
5275 /// \param StartLoc Starting location of the directive kind.
5276 /// \param EndLoc Ending location of the directive.
5277 /// \param CollapsedNum Number of collapsed nested loops.
5278 ///
5279 OMPTeamsDistributeParallelForDirective(SourceLocation StartLoc,
5280 SourceLocation EndLoc,
5281 unsigned CollapsedNum)
5282 : OMPLoopDirective(OMPTeamsDistributeParallelForDirectiveClass,
5283 llvm::omp::OMPD_teams_distribute_parallel_for,
5284 StartLoc, EndLoc, CollapsedNum) {}
5285
5286 /// Build an empty directive.
5287 ///
5288 /// \param CollapsedNum Number of collapsed nested loops.
5289 ///
5290 explicit OMPTeamsDistributeParallelForDirective(unsigned CollapsedNum)
5291 : OMPLoopDirective(OMPTeamsDistributeParallelForDirectiveClass,
5292 llvm::omp::OMPD_teams_distribute_parallel_for,
5293 SourceLocation(), SourceLocation(), CollapsedNum) {}
5294
5295 /// Sets special task reduction descriptor.
5296 void setTaskReductionRefExpr(Expr *E) {
5297 Data->getChildren()[numLoopChildren(
5298 getLoopsNumber(), llvm::omp::OMPD_teams_distribute_parallel_for)] = E;
5299 }
5300
5301 /// Set cancel state.
5302 void setHasCancel(bool Has) { HasCancel = Has; }
5303
5304public:
5305 /// Creates directive with a list of \a Clauses.
5306 ///
5307 /// \param C AST context.
5308 /// \param StartLoc Starting location of the directive kind.
5309 /// \param EndLoc Ending Location of the directive.
5310 /// \param CollapsedNum Number of collapsed loops.
5311 /// \param Clauses List of clauses.
5312 /// \param AssociatedStmt Statement, associated with the directive.
5313 /// \param Exprs Helper expressions for CodeGen.
5314 /// \param TaskRedRef Task reduction special reference expression to handle
5315 /// taskgroup descriptor.
5316 /// \param HasCancel true if this directive has inner cancel directive.
5317 ///
5318 static OMPTeamsDistributeParallelForDirective *
5319 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5320 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
5321 Stmt *AssociatedStmt, const HelperExprs &Exprs, Expr *TaskRedRef,
5322 bool HasCancel);
5323
5324 /// Creates an empty directive with the place for \a NumClauses clauses.
5325 ///
5326 /// \param C AST context.
5327 /// \param CollapsedNum Number of collapsed nested loops.
5328 /// \param NumClauses Number of clauses.
5329 ///
5330 static OMPTeamsDistributeParallelForDirective *
5331 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
5332 EmptyShell);
5333
5334 /// Returns special task reduction reference expression.
5336 return cast_or_null<Expr>(Data->getChildren()[numLoopChildren(
5337 getLoopsNumber(), llvm::omp::OMPD_teams_distribute_parallel_for)]);
5338 }
5339 const Expr *getTaskReductionRefExpr() const {
5340 return const_cast<OMPTeamsDistributeParallelForDirective *>(this)
5342 }
5343
5344 /// Return true if current directive has inner cancel directive.
5345 bool hasCancel() const { return HasCancel; }
5346
5347 static bool classof(const Stmt *T) {
5348 return T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass;
5349 }
5350};
5351
5352/// This represents '#pragma omp target teams' directive.
5353///
5354/// \code
5355/// #pragma omp target teams if(a>0)
5356/// \endcode
5357/// In this example directive '#pragma omp target teams' has clause 'if' with
5358/// condition 'a>0'.
5359///
5360class OMPTargetTeamsDirective final : public OMPExecutableDirective {
5361 friend class ASTStmtReader;
5363 /// Build directive with the given start and end location.
5364 ///
5365 /// \param StartLoc Starting location of the directive kind.
5366 /// \param EndLoc Ending location of the directive.
5367 ///
5368 OMPTargetTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc)
5369 : OMPExecutableDirective(OMPTargetTeamsDirectiveClass,
5370 llvm::omp::OMPD_target_teams, StartLoc, EndLoc) {
5371 }
5372
5373 /// Build an empty directive.
5374 ///
5375 explicit OMPTargetTeamsDirective()
5376 : OMPExecutableDirective(OMPTargetTeamsDirectiveClass,
5377 llvm::omp::OMPD_target_teams, SourceLocation(),
5378 SourceLocation()) {}
5379
5380public:
5381 /// Creates directive with a list of \a Clauses.
5382 ///
5383 /// \param C AST context.
5384 /// \param StartLoc Starting location of the directive kind.
5385 /// \param EndLoc Ending Location of the directive.
5386 /// \param Clauses List of clauses.
5387 /// \param AssociatedStmt Statement, associated with the directive.
5388 ///
5389 static OMPTargetTeamsDirective *Create(const ASTContext &C,
5390 SourceLocation StartLoc,
5391 SourceLocation EndLoc,
5392 ArrayRef<OMPClause *> Clauses,
5393 Stmt *AssociatedStmt);
5394
5395 /// Creates an empty directive with the place for \a NumClauses clauses.
5396 ///
5397 /// \param C AST context.
5398 /// \param NumClauses Number of clauses.
5399 ///
5400 static OMPTargetTeamsDirective *CreateEmpty(const ASTContext &C,
5401 unsigned NumClauses, EmptyShell);
5402
5403 static bool classof(const Stmt *T) {
5404 return T->getStmtClass() == OMPTargetTeamsDirectiveClass;
5405 }
5406};
5407
5408/// This represents '#pragma omp target teams distribute' combined directive.
5409///
5410/// \code
5411/// #pragma omp target teams distribute private(x)
5412/// \endcode
5413/// In this example directive '#pragma omp target teams distribute' has clause
5414/// 'private' with the variables 'x'
5415///
5416class OMPTargetTeamsDistributeDirective final : public OMPLoopDirective {
5417 friend class ASTStmtReader;
5419
5420 /// Build directive with the given start and end location.
5421 ///
5422 /// \param StartLoc Starting location of the directive kind.
5423 /// \param EndLoc Ending location of the directive.
5424 /// \param CollapsedNum Number of collapsed nested loops.
5425 ///
5426 OMPTargetTeamsDistributeDirective(SourceLocation StartLoc,
5427 SourceLocation EndLoc,
5428 unsigned CollapsedNum)
5429 : OMPLoopDirective(OMPTargetTeamsDistributeDirectiveClass,
5430 llvm::omp::OMPD_target_teams_distribute, StartLoc,
5431 EndLoc, CollapsedNum) {}
5432
5433 /// Build an empty directive.
5434 ///
5435 /// \param CollapsedNum Number of collapsed nested loops.
5436 ///
5437 explicit OMPTargetTeamsDistributeDirective(unsigned CollapsedNum)
5438 : OMPLoopDirective(OMPTargetTeamsDistributeDirectiveClass,
5439 llvm::omp::OMPD_target_teams_distribute,
5440 SourceLocation(), SourceLocation(), CollapsedNum) {}
5441
5442public:
5443 /// Creates directive with a list of \a Clauses.
5444 ///
5445 /// \param C AST context.
5446 /// \param StartLoc Starting location of the directive kind.
5447 /// \param EndLoc Ending Location of the directive.
5448 /// \param CollapsedNum Number of collapsed loops.
5449 /// \param Clauses List of clauses.
5450 /// \param AssociatedStmt Statement, associated with the directive.
5451 /// \param Exprs Helper expressions for CodeGen.
5452 ///
5453 static OMPTargetTeamsDistributeDirective *
5454 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5455 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
5456 Stmt *AssociatedStmt, const HelperExprs &Exprs);
5457
5458 /// Creates an empty directive with the place for \a NumClauses clauses.
5459 ///
5460 /// \param C AST context.
5461 /// \param CollapsedNum Number of collapsed nested loops.
5462 /// \param NumClauses Number of clauses.
5463 ///
5464 static OMPTargetTeamsDistributeDirective *
5465 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
5466 EmptyShell);
5467
5468 static bool classof(const Stmt *T) {
5469 return T->getStmtClass() == OMPTargetTeamsDistributeDirectiveClass;
5470 }
5471};
5472
5473/// This represents '#pragma omp target teams distribute parallel for' combined
5474/// directive.
5475///
5476/// \code
5477/// #pragma omp target teams distribute parallel for private(x)
5478/// \endcode
5479/// In this example directive '#pragma omp target teams distribute parallel
5480/// for' has clause 'private' with the variables 'x'
5481///
5482class OMPTargetTeamsDistributeParallelForDirective final
5483 : public OMPLoopDirective {
5484 friend class ASTStmtReader;
5486 /// true if the construct has inner cancel directive.
5487 bool HasCancel = false;
5488
5489 /// Build directive with the given start and end location.
5490 ///
5491 /// \param StartLoc Starting location of the directive kind.
5492 /// \param EndLoc Ending location of the directive.
5493 /// \param CollapsedNum Number of collapsed nested loops.
5494 ///
5495 OMPTargetTeamsDistributeParallelForDirective(SourceLocation StartLoc,
5496 SourceLocation EndLoc,
5497 unsigned CollapsedNum)
5498 : OMPLoopDirective(OMPTargetTeamsDistributeParallelForDirectiveClass,
5499 llvm::omp::OMPD_target_teams_distribute_parallel_for,
5500 StartLoc, EndLoc, CollapsedNum) {}
5501
5502 /// Build an empty directive.
5503 ///
5504 /// \param CollapsedNum Number of collapsed nested loops.
5505 ///
5506 explicit OMPTargetTeamsDistributeParallelForDirective(unsigned CollapsedNum)
5507 : OMPLoopDirective(OMPTargetTeamsDistributeParallelForDirectiveClass,
5508 llvm::omp::OMPD_target_teams_distribute_parallel_for,
5509 SourceLocation(), SourceLocation(), CollapsedNum) {}
5510
5511 /// Sets special task reduction descriptor.
5512 void setTaskReductionRefExpr(Expr *E) {
5513 Data->getChildren()[numLoopChildren(
5514 getLoopsNumber(),
5515 llvm::omp::OMPD_target_teams_distribute_parallel_for)] = E;
5516 }
5517
5518 /// Set cancel state.
5519 void setHasCancel(bool Has) { HasCancel = Has; }
5520
5521public:
5522 /// Creates directive with a list of \a Clauses.
5523 ///
5524 /// \param C AST context.
5525 /// \param StartLoc Starting location of the directive kind.
5526 /// \param EndLoc Ending Location of the directive.
5527 /// \param CollapsedNum Number of collapsed loops.
5528 /// \param Clauses List of clauses.
5529 /// \param AssociatedStmt Statement, associated with the directive.
5530 /// \param Exprs Helper expressions for CodeGen.
5531 /// \param TaskRedRef Task reduction special reference expression to handle
5532 /// taskgroup descriptor.
5533 /// \param HasCancel true if this directive has inner cancel directive.
5534 ///
5535 static OMPTargetTeamsDistributeParallelForDirective *
5536 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5537 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
5538 Stmt *AssociatedStmt, const HelperExprs &Exprs, Expr *TaskRedRef,
5539 bool HasCancel);
5540
5541 /// Creates an empty directive with the place for \a NumClauses clauses.
5542 ///
5543 /// \param C AST context.
5544 /// \param CollapsedNum Number of collapsed nested loops.
5545 /// \param NumClauses Number of clauses.
5546 ///
5547 static OMPTargetTeamsDistributeParallelForDirective *
5548 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
5549 EmptyShell);
5550
5551 /// Returns special task reduction reference expression.
5553 return cast_or_null<Expr>(Data->getChildren()[numLoopChildren(
5554 getLoopsNumber(),
5555 llvm::omp::OMPD_target_teams_distribute_parallel_for)]);
5556 }
5557 const Expr *getTaskReductionRefExpr() const {
5558 return const_cast<OMPTargetTeamsDistributeParallelForDirective *>(this)
5560 }
5561
5562 /// Return true if current directive has inner cancel directive.
5563 bool hasCancel() const { return HasCancel; }
5564
5565 static bool classof(const Stmt *T) {
5566 return T->getStmtClass() ==
5567 OMPTargetTeamsDistributeParallelForDirectiveClass;
5568 }
5569};
5570
5571/// This represents '#pragma omp target teams distribute parallel for simd'
5572/// combined directive.
5573///
5574/// \code
5575/// #pragma omp target teams distribute parallel for simd private(x)
5576/// \endcode
5577/// In this example directive '#pragma omp target teams distribute parallel
5578/// for simd' has clause 'private' with the variables 'x'
5579///
5580class OMPTargetTeamsDistributeParallelForSimdDirective final
5581 : public OMPLoopDirective {
5582 friend class ASTStmtReader;
5584
5585 /// Build directive with the given start and end location.
5586 ///
5587 /// \param StartLoc Starting location of the directive kind.
5588 /// \param EndLoc Ending location of the directive.
5589 /// \param CollapsedNum Number of collapsed nested loops.
5590 ///
5591 OMPTargetTeamsDistributeParallelForSimdDirective(SourceLocation StartLoc,
5592 SourceLocation EndLoc,
5593 unsigned CollapsedNum)
5595 OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
5596 llvm::omp::OMPD_target_teams_distribute_parallel_for_simd, StartLoc,
5597 EndLoc, CollapsedNum) {}
5598
5599 /// Build an empty directive.
5600 ///
5601 /// \param CollapsedNum Number of collapsed nested loops.
5602 ///
5604 unsigned CollapsedNum)
5606 OMPTargetTeamsDistributeParallelForSimdDirectiveClass,
5607 llvm::omp::OMPD_target_teams_distribute_parallel_for_simd,
5608 SourceLocation(), SourceLocation(), CollapsedNum) {}
5609
5610public:
5611 /// Creates directive with a list of \a Clauses.
5612 ///
5613 /// \param C AST context.
5614 /// \param StartLoc Starting location of the directive kind.
5615 /// \param EndLoc Ending Location of the directive.
5616 /// \param CollapsedNum Number of collapsed loops.
5617 /// \param Clauses List of clauses.
5618 /// \param AssociatedStmt Statement, associated with the directive.
5619 /// \param Exprs Helper expressions for CodeGen.
5620 ///
5621 static OMPTargetTeamsDistributeParallelForSimdDirective *
5622 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5623 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
5624 Stmt *AssociatedStmt, const HelperExprs &Exprs);
5625
5626 /// Creates an empty directive with the place for \a NumClauses clauses.
5627 ///
5628 /// \param C AST context.
5629 /// \param CollapsedNum Number of collapsed nested loops.
5630 /// \param NumClauses Number of clauses.
5631 ///
5632 static OMPTargetTeamsDistributeParallelForSimdDirective *
5633 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
5634 EmptyShell);
5635
5636 static bool classof(const Stmt *T) {
5637 return T->getStmtClass() ==
5638 OMPTargetTeamsDistributeParallelForSimdDirectiveClass;
5639 }
5640};
5641
5642/// This represents '#pragma omp target teams distribute simd' combined
5643/// directive.
5644///
5645/// \code
5646/// #pragma omp target teams distribute simd private(x)
5647/// \endcode
5648/// In this example directive '#pragma omp target teams distribute simd'
5649/// has clause 'private' with the variables 'x'
5650///
5651class OMPTargetTeamsDistributeSimdDirective final : public OMPLoopDirective {
5652 friend class ASTStmtReader;
5654
5655 /// Build directive with the given start and end location.
5656 ///
5657 /// \param StartLoc Starting location of the directive kind.
5658 /// \param EndLoc Ending location of the directive.
5659 /// \param CollapsedNum Number of collapsed nested loops.
5660 ///
5661 OMPTargetTeamsDistributeSimdDirective(SourceLocation StartLoc,
5662 SourceLocation EndLoc,
5663 unsigned CollapsedNum)
5664 : OMPLoopDirective(OMPTargetTeamsDistributeSimdDirectiveClass,
5665 llvm::omp::OMPD_target_teams_distribute_simd, StartLoc,
5666 EndLoc, CollapsedNum) {}
5667
5668 /// Build an empty directive.
5669 ///
5670 /// \param CollapsedNum Number of collapsed nested loops.
5671 ///
5672 explicit OMPTargetTeamsDistributeSimdDirective(unsigned CollapsedNum)
5673 : OMPLoopDirective(OMPTargetTeamsDistributeSimdDirectiveClass,
5674 llvm::omp::OMPD_target_teams_distribute_simd,
5675 SourceLocation(), SourceLocation(), CollapsedNum) {}
5676
5677public:
5678 /// Creates directive with a list of \a Clauses.
5679 ///
5680 /// \param C AST context.
5681 /// \param StartLoc Starting location of the directive kind.
5682 /// \param EndLoc Ending Location of the directive.
5683 /// \param CollapsedNum Number of collapsed loops.
5684 /// \param Clauses List of clauses.
5685 /// \param AssociatedStmt Statement, associated with the directive.
5686 /// \param Exprs Helper expressions for CodeGen.
5687 ///
5688 static OMPTargetTeamsDistributeSimdDirective *
5689 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5690 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
5691 Stmt *AssociatedStmt, const HelperExprs &Exprs);
5692
5693 /// Creates an empty directive with the place for \a NumClauses clauses.
5694 ///
5695 /// \param C AST context.
5696 /// \param CollapsedNum Number of collapsed nested loops.
5697 /// \param NumClauses Number of clauses.
5698 ///
5699 static OMPTargetTeamsDistributeSimdDirective *
5700 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
5701 EmptyShell);
5702
5703 static bool classof(const Stmt *T) {
5704 return T->getStmtClass() == OMPTargetTeamsDistributeSimdDirectiveClass;
5705 }
5706};
5707
5708/// This represents the '#pragma omp tile' loop transformation directive.
5709class OMPTileDirective final
5711 friend class ASTStmtReader;
5713
5714 /// Default list of offsets.
5715 enum {
5716 PreInitsOffset = 0,
5717 TransformedStmtOffset,
5718 FinalsOffset,
5719 };
5720
5721 explicit OMPTileDirective(SourceLocation StartLoc, SourceLocation EndLoc,
5722 unsigned NumLoops)
5724 OMPTileDirectiveClass, llvm::omp::OMPD_tile, StartLoc, EndLoc,
5725 NumLoops) {}
5726
5727 void setPreInits(Stmt *PreInits) {
5728 Data->getChildren()[PreInitsOffset] = PreInits;
5729 }
5730
5731 void setTransformedStmt(Stmt *S) {
5732 Data->getChildren()[TransformedStmtOffset] = S;
5733 }
5734
5735 void setFinals(Stmt *Finals) { Data->getChildren()[FinalsOffset] = Finals; }
5736
5737public:
5738 /// Create a new AST node representation for '#pragma omp tile'.
5739 ///
5740 /// \param C Context of the AST.
5741 /// \param StartLoc Location of the introducer (e.g. the 'omp' token).
5742 /// \param EndLoc Location of the directive's end (e.g. the tok::eod).
5743 /// \param Clauses The directive's clauses.
5744 /// \param NumLoops Number of associated loops (number of items in the
5745 /// 'sizes' clause).
5746 /// \param AssociatedStmt The outermost associated loop.
5747 /// \param TransformedStmt The loop nest after tiling, or nullptr in
5748 /// dependent contexts.
5749 /// \param PreInits Helper preinits statements for the loop nest.
5750 /// \param Finals Loop variable finalization statements.
5751 static OMPTileDirective *
5752 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5753 ArrayRef<OMPClause *> Clauses, unsigned NumLoops, Stmt *AssociatedStmt,
5754 Stmt *TransformedStmt, Stmt *PreInits, Stmt *Finals);
5755
5756 /// Build an empty '#pragma omp tile' AST node for deserialization.
5757 ///
5758 /// \param C Context of the AST.
5759 /// \param NumClauses Number of clauses to allocate.
5760 /// \param NumLoops Number of associated loops to allocate.
5761 static OMPTileDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
5762 unsigned NumLoops);
5763
5764 /// Gets/sets the associated loops after tiling.
5765 ///
5766 /// This is in de-sugared format stored as a CompoundStmt.
5767 ///
5768 /// \code
5769 /// for (...)
5770 /// ...
5771 /// \endcode
5772 ///
5773 /// Note that if the generated loops a become associated loops of another
5774 /// directive, they may need to be hoisted before them.
5775 Stmt *getTransformedStmt() const {
5776 return Data->getChildren()[TransformedStmtOffset];
5777 }
5778
5779 /// Return preinits statement.
5780 Stmt *getPreInits() const { return Data->getChildren()[PreInitsOffset]; }
5781
5782 /// Return finals statement (loop variable finalization).
5783 Stmt *getFinals() const { return Data->getChildren()[FinalsOffset]; }
5784
5785 static bool classof(const Stmt *T) {
5786 return T->getStmtClass() == OMPTileDirectiveClass;
5787 }
5788};
5789
5790/// This represents the '#pragma omp stripe' loop transformation directive.
5791class OMPStripeDirective final
5793 friend class ASTStmtReader;
5795
5796 /// Default list of offsets.
5797 enum {
5798 PreInitsOffset = 0,
5799 TransformedStmtOffset,
5800 FinalsOffset,
5801 };
5802
5803 explicit OMPStripeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
5804 unsigned NumLoops)
5806 OMPStripeDirectiveClass, llvm::omp::OMPD_stripe, StartLoc, EndLoc,
5807 NumLoops) {}
5808
5809 void setPreInits(Stmt *PreInits) {
5810 Data->getChildren()[PreInitsOffset] = PreInits;
5811 }
5812
5813 void setTransformedStmt(Stmt *S) {
5814 Data->getChildren()[TransformedStmtOffset] = S;
5815 }
5816
5817 void setFinals(Stmt *Finals) { Data->getChildren()[FinalsOffset] = Finals; }
5818
5819public:
5820 /// Create a new AST node representation for '#pragma omp stripe'.
5821 ///
5822 /// \param C Context of the AST.
5823 /// \param StartLoc Location of the introducer (e.g. the 'omp' token).
5824 /// \param EndLoc Location of the directive's end (e.g. the tok::eod).
5825 /// \param Clauses The directive's clauses.
5826 /// \param NumLoops Number of associated loops (number of items in the
5827 /// 'sizes' clause).
5828 /// \param AssociatedStmt The outermost associated loop.
5829 /// \param TransformedStmt The loop nest after striping, or nullptr in
5830 /// dependent contexts.
5831 /// \param PreInits Helper preinits statements for the loop nest.
5832 /// \param Finals Loop variable finalization statements.
5833 static OMPStripeDirective *
5834 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5835 ArrayRef<OMPClause *> Clauses, unsigned NumLoops, Stmt *AssociatedStmt,
5836 Stmt *TransformedStmt, Stmt *PreInits, Stmt *Finals);
5837
5838 /// Build an empty '#pragma omp stripe' AST node for deserialization.
5839 ///
5840 /// \param C Context of the AST.
5841 /// \param NumClauses Number of clauses to allocate.
5842 /// \param NumLoops Number of associated loops to allocate.
5843 static OMPStripeDirective *
5844 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned NumLoops);
5845 /// Gets/sets the associated loops after striping.
5846 ///
5847 /// This is in de-sugared format stored as a CompoundStmt.
5848 ///
5849 /// \code
5850 /// for (...)
5851 /// ...
5852 /// \endcode
5853 ///
5854 /// Note that if the generated loops a become associated loops of another
5855 /// directive, they may need to be hoisted before them.
5856 Stmt *getTransformedStmt() const {
5857 return Data->getChildren()[TransformedStmtOffset];
5858 }
5859
5860 /// Return preinits statement.
5861 Stmt *getPreInits() const { return Data->getChildren()[PreInitsOffset]; }
5862
5863 /// Return finals statement (loop variable finalization).
5864 Stmt *getFinals() const { return Data->getChildren()[FinalsOffset]; }
5865
5866 static bool classof(const Stmt *T) {
5867 return T->getStmtClass() == OMPStripeDirectiveClass;
5868 }
5869};
5870
5871/// This represents the '#pragma omp unroll' loop transformation directive.
5872///
5873/// \code
5874/// #pragma omp unroll
5875/// for (int i = 0; i < 64; ++i)
5876/// \endcode
5877class OMPUnrollDirective final
5879 friend class ASTStmtReader;
5881
5882 /// Default list of offsets.
5883 enum {
5884 PreInitsOffset = 0,
5885 TransformedStmtOffset,
5886 FinalsOffset,
5887 };
5888
5889 explicit OMPUnrollDirective(SourceLocation StartLoc, SourceLocation EndLoc)
5890 : OMPCanonicalLoopNestTransformationDirective(OMPUnrollDirectiveClass,
5891 llvm::omp::OMPD_unroll,
5892 StartLoc, EndLoc, 1) {}
5893
5894 /// Set the pre-init statements.
5895 void setPreInits(Stmt *PreInits) {
5896 Data->getChildren()[PreInitsOffset] = PreInits;
5897 }
5898
5899 void setFinals(Stmt *Finals) { Data->getChildren()[FinalsOffset] = Finals; }
5900
5901 /// Set the de-sugared statement.
5902 void setTransformedStmt(Stmt *S) {
5903 Data->getChildren()[TransformedStmtOffset] = S;
5904 }
5905
5906public:
5907 /// Create a new AST node representation for '#pragma omp unroll'.
5908 ///
5909 /// \param C Context of the AST.
5910 /// \param StartLoc Location of the introducer (e.g. the 'omp' token).
5911 /// \param EndLoc Location of the directive's end (e.g. the tok::eod).
5912 /// \param Clauses The directive's clauses.
5913 /// \param AssociatedStmt The outermost associated loop.
5914 /// \param TransformedStmt The loop nest after tiling, or nullptr in
5915 /// dependent contexts.
5916 /// \param PreInits Helper preinits statements for the loop nest.
5917 /// \param Finals Loop variable finalization statements.
5918 static OMPUnrollDirective *
5919 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
5920 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
5921 unsigned NumGeneratedTopLevelLoops, Stmt *TransformedStmt,
5922 Stmt *PreInits, Stmt *Finals);
5923
5924 /// Build an empty '#pragma omp unroll' AST node for deserialization.
5925 ///
5926 /// \param C Context of the AST.
5927 /// \param NumClauses Number of clauses to allocate.
5928 static OMPUnrollDirective *CreateEmpty(const ASTContext &C,
5929 unsigned NumClauses);
5930
5931 /// Get the de-sugared associated loops after unrolling.
5932 ///
5933 /// This is only used if the unrolled loop becomes an associated loop of
5934 /// another directive, otherwise the loop is emitted directly using loop
5935 /// transformation metadata. When the unrolled loop cannot be used by another
5936 /// directive (e.g. because of the full clause), the transformed stmt can also
5937 /// be nullptr.
5938 Stmt *getTransformedStmt() const {
5939 return Data->getChildren()[TransformedStmtOffset];
5940 }
5941
5942 /// Return the pre-init statements.
5943 Stmt *getPreInits() const { return Data->getChildren()[PreInitsOffset]; }
5944
5945 /// Return finals statement, used when an enclosing loop transformation
5946 /// consumes the unrolled loop.
5947 Stmt *getFinals() const { return Data->getChildren()[FinalsOffset]; }
5948
5949 static bool classof(const Stmt *T) {
5950 return T->getStmtClass() == OMPUnrollDirectiveClass;
5951 }
5952};
5953
5954/// Represents the '#pragma omp reverse' loop transformation directive.
5955///
5956/// \code
5957/// #pragma omp reverse
5958/// for (int i = 0; i < n; ++i)
5959/// ...
5960/// \endcode
5961class OMPReverseDirective final
5963 friend class ASTStmtReader;
5965
5966 /// Offsets of child members.
5967 enum {
5968 PreInitsOffset = 0,
5969 TransformedStmtOffset,
5970 FinalsOffset,
5971 };
5972
5973 explicit OMPReverseDirective(SourceLocation StartLoc, SourceLocation EndLoc,
5974 unsigned NumLoops)
5976 OMPReverseDirectiveClass, llvm::omp::OMPD_reverse, StartLoc, EndLoc,
5977 NumLoops) {}
5978
5979 void setPreInits(Stmt *PreInits) {
5980 Data->getChildren()[PreInitsOffset] = PreInits;
5981 }
5982
5983 void setTransformedStmt(Stmt *S) {
5984 Data->getChildren()[TransformedStmtOffset] = S;
5985 }
5986
5987 void setFinals(Stmt *Finals) { Data->getChildren()[FinalsOffset] = Finals; }
5988
5989public:
5990 /// Create a new AST node representation for '#pragma omp reverse'.
5991 ///
5992 /// \param C Context of the AST.
5993 /// \param StartLoc Location of the introducer (e.g. the 'omp' token).
5994 /// \param EndLoc Location of the directive's end (e.g. the tok::eod).
5995 /// \param NumLoops Number of affected loops
5996 /// \param AssociatedStmt The outermost associated loop.
5997 /// \param TransformedStmt The loop nest after tiling, or nullptr in
5998 /// dependent contexts.
5999 /// \param PreInits Helper preinits statements for the loop nest.
6000 /// \param Finals Loop variable finalization statements.
6001 static OMPReverseDirective *
6002 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
6003 Stmt *AssociatedStmt, unsigned NumLoops, Stmt *TransformedStmt,
6004 Stmt *PreInits, Stmt *Finals);
6005
6006 /// Build an empty '#pragma omp reverse' AST node for deserialization.
6007 ///
6008 /// \param C Context of the AST.
6009 /// \param NumLoops Number of associated loops to allocate
6010 static OMPReverseDirective *CreateEmpty(const ASTContext &C,
6011 unsigned NumLoops);
6012
6013 /// Gets/sets the associated loops after the transformation, i.e. after
6014 /// de-sugaring.
6015 Stmt *getTransformedStmt() const {
6016 return Data->getChildren()[TransformedStmtOffset];
6017 }
6018
6019 /// Return preinits statement.
6020 Stmt *getPreInits() const { return Data->getChildren()[PreInitsOffset]; }
6021
6022 /// Return finals statement.
6023 Stmt *getFinals() const { return Data->getChildren()[FinalsOffset]; }
6024
6025 static bool classof(const Stmt *T) {
6026 return T->getStmtClass() == OMPReverseDirectiveClass;
6027 }
6028};
6029
6030/// Represents the '#pragma omp interchange' loop transformation directive.
6031///
6032/// \code{c}
6033/// #pragma omp interchange
6034/// for (int i = 0; i < m; ++i)
6035/// for (int j = 0; j < n; ++j)
6036/// ..
6037/// \endcode
6038class OMPInterchangeDirective final
6040 friend class ASTStmtReader;
6042
6043 /// Offsets of child members.
6044 enum {
6045 PreInitsOffset = 0,
6046 TransformedStmtOffset,
6047 FinalsOffset,
6048 };
6049
6050 explicit OMPInterchangeDirective(SourceLocation StartLoc,
6051 SourceLocation EndLoc, unsigned NumLoops)
6053 OMPInterchangeDirectiveClass, llvm::omp::OMPD_interchange, StartLoc,
6054 EndLoc, NumLoops) {}
6055
6056 void setPreInits(Stmt *PreInits) {
6057 Data->getChildren()[PreInitsOffset] = PreInits;
6058 }
6059
6060 void setTransformedStmt(Stmt *S) {
6061 Data->getChildren()[TransformedStmtOffset] = S;
6062 }
6063
6064 void setFinals(Stmt *Finals) { Data->getChildren()[FinalsOffset] = Finals; }
6065
6066public:
6067 /// Create a new AST node representation for '#pragma omp interchange'.
6068 ///
6069 /// \param C Context of the AST.
6070 /// \param StartLoc Location of the introducer (e.g. the 'omp' token).
6071 /// \param EndLoc Location of the directive's end (e.g. the tok::eod).
6072 /// \param Clauses The directive's clauses.
6073 /// \param NumLoops Number of affected loops
6074 /// (number of items in the 'permutation' clause if present).
6075 /// \param AssociatedStmt The outermost associated loop.
6076 /// \param TransformedStmt The loop nest after tiling, or nullptr in
6077 /// dependent contexts.
6078 /// \param PreInits Helper preinits statements for the loop nest.
6079 /// \param Finals Loop variable finalization statements.
6080 static OMPInterchangeDirective *
6081 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
6082 ArrayRef<OMPClause *> Clauses, unsigned NumLoops, Stmt *AssociatedStmt,
6083 Stmt *TransformedStmt, Stmt *PreInits, Stmt *Finals);
6084
6085 /// Build an empty '#pragma omp interchange' AST node for deserialization.
6086 ///
6087 /// \param C Context of the AST.
6088 /// \param NumClauses Number of clauses to allocate.
6089 /// \param NumLoops Number of associated loops to allocate.
6090 static OMPInterchangeDirective *
6091 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned NumLoops);
6092
6093 /// Gets the associated loops after the transformation. This is the de-sugared
6094 /// replacement or nullptr in dependent contexts.
6095 Stmt *getTransformedStmt() const {
6096 return Data->getChildren()[TransformedStmtOffset];
6097 }
6098
6099 /// Return preinits statement.
6100 Stmt *getPreInits() const { return Data->getChildren()[PreInitsOffset]; }
6101
6102 /// Return finals statement.
6103 Stmt *getFinals() const { return Data->getChildren()[FinalsOffset]; }
6104
6105 static bool classof(const Stmt *T) {
6106 return T->getStmtClass() == OMPInterchangeDirectiveClass;
6107 }
6108};
6109
6110/// Represents the '#pragma omp flatten' loop transformation directive.
6111///
6112/// \code{c}
6113/// #pragma omp flatten
6114/// for (int i = 0; i < m; ++i)
6115/// for (int j = 0; j < n; ++j)
6116/// ..
6117/// \endcode
6118class OMPFlattenDirective final
6120 friend class ASTStmtReader;
6122
6123 /// Offsets of child members.
6124 enum {
6125 PreInitsOffset = 0,
6126 TransformedStmtOffset,
6127 FinalsOffset,
6128 };
6129
6130 explicit OMPFlattenDirective(SourceLocation StartLoc, SourceLocation EndLoc,
6131 unsigned NumLoops)
6133 OMPFlattenDirectiveClass, llvm::omp::OMPD_flatten, StartLoc, EndLoc,
6134 NumLoops) {}
6135
6136 void setPreInits(Stmt *PreInits) {
6137 Data->getChildren()[PreInitsOffset] = PreInits;
6138 }
6139
6140 void setTransformedStmt(Stmt *S) {
6141 Data->getChildren()[TransformedStmtOffset] = S;
6142 }
6143
6144 void setFinals(Stmt *S) { Data->getChildren()[FinalsOffset] = S; }
6145
6146public:
6147 /// Create a new AST node representation for '#pragma omp flatten'.
6148 ///
6149 /// \param C Context of the AST.
6150 /// \param StartLoc Location of the introducer (e.g. the 'omp' token).
6151 /// \param EndLoc Location of the directive's end (e.g. the tok::eod).
6152 /// \param Clauses The directive's clauses.
6153 /// \param NumLoops Number of affected loops (the flatten depth: the
6154 /// argument of the 'depth' clause, or 2 if omitted).
6155 /// \param AssociatedStmt The outermost associated loop.
6156 /// \param TransformedStmt The flattened loop, or nullptr in dependent
6157 /// contexts.
6158 /// \param PreInits Helper preinits statements for the loop nest.
6159 /// \param Finals Updates to the original loop variables after the loop.
6160 static OMPFlattenDirective *
6161 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
6162 ArrayRef<OMPClause *> Clauses, unsigned NumLoops, Stmt *AssociatedStmt,
6163 Stmt *TransformedStmt, Stmt *PreInits, Stmt *Finals);
6164
6165 /// Build an empty '#pragma omp flatten' AST node for deserialization.
6166 ///
6167 /// \param C Context of the AST.
6168 /// \param NumClauses Number of clauses to allocate.
6169 /// \param NumLoops Number of associated loops to allocate.
6170 static OMPFlattenDirective *
6171 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned NumLoops);
6172
6173 /// Gets the flattened loop after the transformation. This is the de-sugared
6174 /// replacement or nullptr in dependent contexts.
6175 Stmt *getTransformedStmt() const {
6176 return Data->getChildren()[TransformedStmtOffset];
6177 }
6178
6179 /// Return preinits statement.
6180 Stmt *getPreInits() const { return Data->getChildren()[PreInitsOffset]; }
6181
6182 /// Return updates to the original loop variables after the flattened loop.
6183 Stmt *getFinals() const { return Data->getChildren()[FinalsOffset]; }
6184
6185 static bool classof(const Stmt *T) {
6186 return T->getStmtClass() == OMPFlattenDirectiveClass;
6187 }
6188};
6189
6190/// The base class for all transformation directives of canonical loop
6191/// sequences (currently only 'fuse')
6193 : public OMPExecutableDirective,
6195 friend class ASTStmtReader;
6196
6197protected:
6199 StmtClass SC, OpenMPDirectiveKind Kind, SourceLocation StartLoc,
6200 SourceLocation EndLoc)
6201 : OMPExecutableDirective(SC, Kind, StartLoc, EndLoc),
6203
6204public:
6205 /// Get the de-sugared statements after the loop transformation.
6206 ///
6207 /// Might be nullptr if either the directive generates no loops and is handled
6208 /// directly in CodeGen, or resolving a template-dependence context is
6209 /// required.
6210 Stmt *getTransformedStmt() const;
6211
6212 /// Return preinits statement.
6213 Stmt *getPreInits() const;
6214
6215 /// Return loop variable finalization statement, or nullptr if the concrete
6216 /// transformation does not produce one.
6217 Stmt *getFinals() const;
6218
6219 static bool classof(const Stmt *T) {
6220 Stmt::StmtClass C = T->getStmtClass();
6221 return C == OMPFuseDirectiveClass;
6222 }
6223};
6224
6225/// Represents the '#pragma omp fuse' loop transformation directive
6226///
6227/// \code{c}
6228/// #pragma omp fuse
6229/// {
6230/// for(int i = 0; i < m1; ++i) {...}
6231/// for(int j = 0; j < m2; ++j) {...}
6232/// ...
6233/// }
6234/// \endcode
6235class OMPFuseDirective final
6237 friend class ASTStmtReader;
6239
6240 // Offsets of child members.
6241 enum {
6242 PreInitsOffset = 0,
6243 TransformedStmtOffset,
6244 FinalsOffset,
6245 };
6246
6247 explicit OMPFuseDirective(SourceLocation StartLoc, SourceLocation EndLoc)
6249 OMPFuseDirectiveClass, llvm::omp::OMPD_fuse, StartLoc, EndLoc) {}
6250
6251 void setPreInits(Stmt *PreInits) {
6252 Data->getChildren()[PreInitsOffset] = PreInits;
6253 }
6254
6255 void setTransformedStmt(Stmt *S) {
6256 Data->getChildren()[TransformedStmtOffset] = S;
6257 }
6258
6259 void setFinals(Stmt *Finals) { Data->getChildren()[FinalsOffset] = Finals; }
6260
6261public:
6262 /// Create a new AST node representation for #pragma omp fuse'
6263 ///
6264 /// \param C Context of the AST
6265 /// \param StartLoc Location of the introducer (e.g the 'omp' token)
6266 /// \param EndLoc Location of the directive's end (e.g the tok::eod)
6267 /// \param Clauses The directive's clauses
6268 /// \param NumLoops Total number of loops in the canonical loop sequence.
6269 /// \param NumGeneratedTopLevelLoops Number of top-level generated loops.
6270 // Typically 1 but looprange clause can
6271 // change this.
6272 /// \param AssociatedStmt The outermost associated loop
6273 /// \param TransformedStmt The loop nest after fusion, or nullptr in
6274 /// dependent
6275 /// \param PreInits Helper preinits statements for the loop nest
6276 /// \param Finals Loop variable finalization statements
6277 static OMPFuseDirective *Create(const ASTContext &C, SourceLocation StartLoc,
6278 SourceLocation EndLoc,
6279 ArrayRef<OMPClause *> Clauses,
6280 unsigned NumGeneratedTopLevelLoops,
6281 Stmt *AssociatedStmt, Stmt *TransformedStmt,
6282 Stmt *PreInits, Stmt *Finals);
6283
6284 /// Build an empty '#pragma omp fuse' AST node for deserialization
6285 ///
6286 /// \param C Context of the AST
6287 /// \param NumClauses Number of clauses to allocate
6288 /// \param NumLoops Number of top level loops to allocate
6289 static OMPFuseDirective *CreateEmpty(const ASTContext &C,
6290 unsigned NumClauses);
6291
6292 /// Gets the associated loops after the transformation. This is the de-sugared
6293 /// replacement or nulltpr in dependent contexts.
6294 Stmt *getTransformedStmt() const {
6295 return Data->getChildren()[TransformedStmtOffset];
6296 }
6297
6298 /// Return preinits statement.
6299 Stmt *getPreInits() const { return Data->getChildren()[PreInitsOffset]; }
6300
6301 /// Return finals statement.
6302 Stmt *getFinals() const { return Data->getChildren()[FinalsOffset]; }
6303
6304 static bool classof(const Stmt *T) {
6305 return T->getStmtClass() == OMPFuseDirectiveClass;
6306 }
6307};
6308
6309/// Represents the '#pragma omp split' loop transformation directive.
6310///
6311/// \code{.c}
6312/// #pragma omp split counts(3, omp_fill, 2)
6313/// for (int i = 0; i < n; ++i)
6314/// ...
6315/// \endcode
6316///
6317/// This directive transforms a single loop into multiple loops based on
6318/// index ranges. The transformation splits the iteration space of the loop
6319/// into multiple contiguous ranges. The \c counts clause is required and
6320/// exactly one list item must be \c omp_fill.
6321class OMPSplitDirective final
6323 friend class ASTStmtReader;
6325
6326 /// Offsets of child members.
6327 enum {
6328 PreInitsOffset = 0,
6329 TransformedStmtOffset,
6330 FinalsOffset,
6331 };
6332
6333 explicit OMPSplitDirective(SourceLocation StartLoc, SourceLocation EndLoc,
6334 unsigned NumLoops)
6336 OMPSplitDirectiveClass, llvm::omp::OMPD_split, StartLoc, EndLoc,
6337 NumLoops) {}
6338
6339 void setPreInits(Stmt *PreInits) {
6340 Data->getChildren()[PreInitsOffset] = PreInits;
6341 }
6342
6343 void setTransformedStmt(Stmt *S) {
6344 Data->getChildren()[TransformedStmtOffset] = S;
6345 }
6346
6347 void setFinals(Stmt *Finals) { Data->getChildren()[FinalsOffset] = Finals; }
6348
6349public:
6350 /// Create a new AST node representation for '#pragma omp split'.
6351 ///
6352 /// \param C Context of the AST.
6353 /// \param StartLoc Location of the introducer (e.g. the 'omp' token).
6354 /// \param EndLoc Location of the directive's end (e.g. the tok::eod).
6355 /// \param Clauses The directive's clauses (e.g. the required \c counts
6356 /// clause).
6357 /// \param NumLoops Number of affected loops (should be 1 for split).
6358 /// \param AssociatedStmt The outermost associated loop.
6359 /// \param TransformedStmt The loop nest after splitting, or nullptr in
6360 /// dependent contexts.
6361 /// \param PreInits Helper preinits statements for the loop nest.
6362 /// \param Finals Loop variable finalization statements.
6363 static OMPSplitDirective *
6364 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
6365 ArrayRef<OMPClause *> Clauses, unsigned NumLoops, Stmt *AssociatedStmt,
6366 Stmt *TransformedStmt, Stmt *PreInits, Stmt *Finals);
6367
6368 /// Build an empty '#pragma omp split' AST node for deserialization.
6369 ///
6370 /// \param C Context of the AST.
6371 /// \param NumClauses Number of clauses to allocate.
6372 /// \param NumLoops Number of associated loops to allocate.
6373 static OMPSplitDirective *CreateEmpty(const ASTContext &C,
6374 unsigned NumClauses, unsigned NumLoops);
6375
6376 /// Gets/sets the associated loops after the transformation, i.e. after
6377 /// de-sugaring.
6378 Stmt *getTransformedStmt() const {
6379 return Data->getChildren()[TransformedStmtOffset];
6380 }
6381
6382 /// Return preinits statement.
6383 Stmt *getPreInits() const { return Data->getChildren()[PreInitsOffset]; }
6384
6385 /// Return finals statement (loop variable finalization).
6386 Stmt *getFinals() const { return Data->getChildren()[FinalsOffset]; }
6387
6388 static bool classof(const Stmt *T) {
6389 return T->getStmtClass() == OMPSplitDirectiveClass;
6390 }
6391};
6392
6393/// This represents '#pragma omp scan' directive.
6394///
6395/// \code
6396/// #pragma omp scan inclusive(a)
6397/// \endcode
6398/// In this example directive '#pragma omp scan' has clause 'inclusive' with
6399/// list item 'a'.
6400class OMPScanDirective final : public OMPExecutableDirective {
6401 friend class ASTStmtReader;
6403 /// Build directive with the given start and end location.
6404 ///
6405 /// \param StartLoc Starting location of the directive kind.
6406 /// \param EndLoc Ending location of the directive.
6407 ///
6408 OMPScanDirective(SourceLocation StartLoc, SourceLocation EndLoc)
6409 : OMPExecutableDirective(OMPScanDirectiveClass, llvm::omp::OMPD_scan,
6410 StartLoc, EndLoc) {}
6411
6412 /// Build an empty directive.
6413 ///
6414 explicit OMPScanDirective()
6415 : OMPExecutableDirective(OMPScanDirectiveClass, llvm::omp::OMPD_scan,
6416 SourceLocation(), SourceLocation()) {}
6417
6418public:
6419 /// Creates directive with a list of \a Clauses.
6420 ///
6421 /// \param C AST context.
6422 /// \param StartLoc Starting location of the directive kind.
6423 /// \param EndLoc Ending Location of the directive.
6424 /// \param Clauses List of clauses (only single OMPFlushClause clause is
6425 /// allowed).
6426 ///
6427 static OMPScanDirective *Create(const ASTContext &C, SourceLocation StartLoc,
6428 SourceLocation EndLoc,
6429 ArrayRef<OMPClause *> Clauses);
6430
6431 /// Creates an empty directive with the place for \a NumClauses
6432 /// clauses.
6433 ///
6434 /// \param C AST context.
6435 /// \param NumClauses Number of clauses.
6436 ///
6437 static OMPScanDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
6438 EmptyShell);
6439
6440 static bool classof(const Stmt *T) {
6441 return T->getStmtClass() == OMPScanDirectiveClass;
6442 }
6443};
6444
6445/// This represents '#pragma omp interop' directive.
6446///
6447/// \code
6448/// #pragma omp interop init(target:obj) device(x) depend(inout:y) nowait
6449/// \endcode
6450/// In this example directive '#pragma omp interop' has
6451/// clauses 'init', 'device', 'depend' and 'nowait'.
6452///
6453class OMPInteropDirective final : public OMPExecutableDirective {
6454 friend class ASTStmtReader;
6456
6457 /// Build directive with the given start and end location.
6458 ///
6459 /// \param StartLoc Starting location of the directive.
6460 /// \param EndLoc Ending location of the directive.
6461 ///
6462 OMPInteropDirective(SourceLocation StartLoc, SourceLocation EndLoc)
6463 : OMPExecutableDirective(OMPInteropDirectiveClass,
6464 llvm::omp::OMPD_interop, StartLoc, EndLoc) {}
6465
6466 /// Build an empty directive.
6467 ///
6468 explicit OMPInteropDirective()
6469 : OMPExecutableDirective(OMPInteropDirectiveClass,
6470 llvm::omp::OMPD_interop, SourceLocation(),
6471 SourceLocation()) {}
6472
6473public:
6474 /// Creates directive.
6475 ///
6476 /// \param C AST context.
6477 /// \param StartLoc Starting location of the directive.
6478 /// \param EndLoc Ending Location of the directive.
6479 /// \param Clauses The directive's clauses.
6480 ///
6481 static OMPInteropDirective *Create(const ASTContext &C,
6482 SourceLocation StartLoc,
6483 SourceLocation EndLoc,
6484 ArrayRef<OMPClause *> Clauses);
6485
6486 /// Creates an empty directive.
6487 ///
6488 /// \param C AST context.
6489 ///
6490 static OMPInteropDirective *CreateEmpty(const ASTContext &C,
6491 unsigned NumClauses, EmptyShell);
6492
6493 static bool classof(const Stmt *T) {
6494 return T->getStmtClass() == OMPInteropDirectiveClass;
6495 }
6496};
6497
6498/// This represents '#pragma omp dispatch' directive.
6499///
6500/// \code
6501/// #pragma omp dispatch device(dnum)
6502/// \endcode
6503/// This example shows a directive '#pragma omp dispatch' with a
6504/// device clause with variable 'dnum'.
6505///
6506class OMPDispatchDirective final : public OMPExecutableDirective {
6507 friend class ASTStmtReader;
6509
6510 /// The location of the target-call.
6511 SourceLocation TargetCallLoc;
6512
6513 /// Set the location of the target-call.
6514 void setTargetCallLoc(SourceLocation Loc) { TargetCallLoc = Loc; }
6515
6516 /// Build directive with the given start and end location.
6517 ///
6518 /// \param StartLoc Starting location of the directive kind.
6519 /// \param EndLoc Ending location of the directive.
6520 ///
6521 OMPDispatchDirective(SourceLocation StartLoc, SourceLocation EndLoc)
6522 : OMPExecutableDirective(OMPDispatchDirectiveClass,
6523 llvm::omp::OMPD_dispatch, StartLoc, EndLoc) {}
6524
6525 /// Build an empty directive.
6526 ///
6527 explicit OMPDispatchDirective()
6528 : OMPExecutableDirective(OMPDispatchDirectiveClass,
6529 llvm::omp::OMPD_dispatch, SourceLocation(),
6530 SourceLocation()) {}
6531
6532public:
6533 /// Creates directive with a list of \a Clauses.
6534 ///
6535 /// \param C AST context.
6536 /// \param StartLoc Starting location of the directive kind.
6537 /// \param EndLoc Ending Location of the directive.
6538 /// \param Clauses List of clauses.
6539 /// \param AssociatedStmt Statement, associated with the directive.
6540 /// \param TargetCallLoc Location of the target-call.
6541 ///
6542 static OMPDispatchDirective *
6543 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
6544 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
6545 SourceLocation TargetCallLoc);
6546
6547 /// Creates an empty directive with the place for \a NumClauses
6548 /// clauses.
6549 ///
6550 /// \param C AST context.
6551 /// \param NumClauses Number of clauses.
6552 ///
6553 static OMPDispatchDirective *CreateEmpty(const ASTContext &C,
6554 unsigned NumClauses, EmptyShell);
6555
6556 /// Return location of target-call.
6557 SourceLocation getTargetCallLoc() const { return TargetCallLoc; }
6558
6559 static bool classof(const Stmt *T) {
6560 return T->getStmtClass() == OMPDispatchDirectiveClass;
6561 }
6562};
6563
6564/// This represents '#pragma omp masked' directive.
6565/// \code
6566/// #pragma omp masked filter(tid)
6567/// \endcode
6568/// This example shows a directive '#pragma omp masked' with a filter clause
6569/// with variable 'tid'.
6570///
6571class OMPMaskedDirective final : public OMPExecutableDirective {
6572 friend class ASTStmtReader;
6574
6575 /// Build directive with the given start and end location.
6576 ///
6577 /// \param StartLoc Starting location of the directive kind.
6578 /// \param EndLoc Ending location of the directive.
6579 ///
6580 OMPMaskedDirective(SourceLocation StartLoc, SourceLocation EndLoc)
6581 : OMPExecutableDirective(OMPMaskedDirectiveClass, llvm::omp::OMPD_masked,
6582 StartLoc, EndLoc) {}
6583
6584 /// Build an empty directive.
6585 ///
6586 explicit OMPMaskedDirective()
6587 : OMPExecutableDirective(OMPMaskedDirectiveClass, llvm::omp::OMPD_masked,
6588 SourceLocation(), SourceLocation()) {}
6589
6590public:
6591 /// Creates directive.
6592 ///
6593 /// \param C AST context.
6594 /// \param StartLoc Starting location of the directive kind.
6595 /// \param EndLoc Ending Location of the directive.
6596 /// \param AssociatedStmt Statement, associated with the directive.
6597 ///
6598 static OMPMaskedDirective *
6599 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
6600 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
6601
6602 /// Creates an empty directive.
6603 ///
6604 /// \param C AST context.
6605 ///
6606 static OMPMaskedDirective *CreateEmpty(const ASTContext &C,
6607 unsigned NumClauses, EmptyShell);
6608
6609 static bool classof(const Stmt *T) {
6610 return T->getStmtClass() == OMPMaskedDirectiveClass;
6611 }
6612};
6613
6614/// This represents '#pragma omp metadirective' directive.
6615///
6616/// \code
6617/// #pragma omp metadirective when(user={condition(N>10)}: parallel for)
6618/// \endcode
6619/// In this example directive '#pragma omp metadirective' has clauses 'when'
6620/// with a dynamic user condition to check if a variable 'N > 10'.
6621/// The directive holds one variant per 'when' or 'otherwise' clause: the
6622/// complete directive (or the plain associated statement), its condition and
6623/// its context selectors.
6624///
6625class OMPMetaDirective final : public OMPExecutableDirective {
6626 friend class ASTStmtReader;
6628
6629 /// True if the last variant is the implicit 'otherwise' added when the
6630 /// directive has no 'otherwise' clause.
6631 bool HasImplicitOtherwise = false;
6632
6633 OMPMetaDirective(SourceLocation StartLoc, SourceLocation EndLoc)
6634 : OMPExecutableDirective(OMPMetaDirectiveClass,
6635 llvm::omp::OMPD_metadirective, StartLoc,
6636 EndLoc) {}
6637
6638 /// Layout: the children hold the variants, then their conditions; the
6639 /// trait infos follow the children.
6640 static size_t getTraitInfosOffset(unsigned NumVariants) {
6641 return llvm::alignTo(OMPChildren::size(/*NumClauses=*/0,
6642 /*HasAssociatedStmt=*/false,
6643 2 * NumVariants),
6644 alignof(OMPTraitInfo *));
6645 }
6646 static OMPMetaDirective *allocate(const ASTContext &C, unsigned NumVariants,
6647 SourceLocation StartLoc,
6648 SourceLocation EndLoc);
6649
6650 MutableArrayRef<Stmt *> getTrailingVariants() {
6651 return Data->getChildren().take_front(getNumVariants());
6652 }
6653 MutableArrayRef<Expr *> getTrailingConditions() {
6654 return {reinterpret_cast<Expr **>(Data->getChildren().data() +
6655 getNumVariants()),
6656 getNumVariants()};
6657 }
6658 MutableArrayRef<OMPTraitInfo *> getTrailingTraitInfos() {
6659 return {reinterpret_cast<OMPTraitInfo **>(
6660 reinterpret_cast<char *>(Data) +
6661 getTraitInfosOffset(getNumVariants())),
6662 getNumVariants()};
6663 }
6664 ArrayRef<Stmt *> getTrailingVariants() const {
6665 return const_cast<OMPMetaDirective *>(this)->getTrailingVariants();
6666 }
6667 ArrayRef<Expr *> getTrailingConditions() const {
6668 return const_cast<OMPMetaDirective *>(this)->getTrailingConditions();
6669 }
6670 ArrayRef<OMPTraitInfo *> getTrailingTraitInfos() const {
6671 return const_cast<OMPMetaDirective *>(this)->getTrailingTraitInfos();
6672 }
6673
6674 void setHasImplicitOtherwise(bool V) { HasImplicitOtherwise = V; }
6675
6676public:
6677 static OMPMetaDirective *
6678 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
6679 ArrayRef<Stmt *> Variants, ArrayRef<Expr *> Conditions,
6680 ArrayRef<OMPTraitInfo *> TraitInfos, bool HasImplicitOtherwise);
6681 static OMPMetaDirective *CreateEmpty(const ASTContext &C,
6682 unsigned NumVariants, EmptyShell);
6683
6684 unsigned getNumVariants() const { return Data->getChildren().size() / 2; }
6685 bool hasImplicitOtherwise() const { return HasImplicitOtherwise; }
6686 ArrayRef<Stmt *> variants() const { return getTrailingVariants(); }
6687 ArrayRef<Expr *> conditions() const { return getTrailingConditions(); }
6689 return getTrailingTraitInfos();
6690 }
6691
6692 child_range children() {
6693 MutableArrayRef<Stmt *> Children = Data->getChildren();
6694 return child_range(Children.begin(), Children.end());
6695 }
6696 const_child_range children() const {
6697 return const_cast<OMPMetaDirective *>(this)->children();
6698 }
6699
6700 static bool classof(const Stmt *T) {
6701 return T->getStmtClass() == OMPMetaDirectiveClass;
6702 }
6703};
6704
6705/// This represents '#pragma omp loop' directive.
6706///
6707/// \code
6708/// #pragma omp loop private(a,b) binding(parallel) order(concurrent)
6709/// \endcode
6710/// In this example directive '#pragma omp loop' has
6711/// clauses 'private' with the variables 'a' and 'b', 'binding' with
6712/// modifier 'parallel' and 'order(concurrent).
6713///
6714class OMPGenericLoopDirective final : public OMPLoopDirective {
6715 friend class ASTStmtReader;
6717 /// Build directive with the given start and end location.
6718 ///
6719 /// \param StartLoc Starting location of the directive kind.
6720 /// \param EndLoc Ending location of the directive.
6721 /// \param CollapsedNum Number of collapsed nested loops.
6722 ///
6723 OMPGenericLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc,
6724 unsigned CollapsedNum)
6725 : OMPLoopDirective(OMPGenericLoopDirectiveClass, llvm::omp::OMPD_loop,
6726 StartLoc, EndLoc, CollapsedNum) {}
6727
6728 /// Build an empty directive.
6729 ///
6730 /// \param CollapsedNum Number of collapsed nested loops.
6731 ///
6732 explicit OMPGenericLoopDirective(unsigned CollapsedNum)
6733 : OMPLoopDirective(OMPGenericLoopDirectiveClass, llvm::omp::OMPD_loop,
6734 SourceLocation(), SourceLocation(), CollapsedNum) {}
6735
6736public:
6737 /// Creates directive with a list of \p Clauses.
6738 ///
6739 /// \param C AST context.
6740 /// \param StartLoc Starting location of the directive kind.
6741 /// \param EndLoc Ending Location of the directive.
6742 /// \param CollapsedNum Number of collapsed loops.
6743 /// \param Clauses List of clauses.
6744 /// \param AssociatedStmt Statement, associated with the directive.
6745 /// \param Exprs Helper expressions for CodeGen.
6746 ///
6747 static OMPGenericLoopDirective *
6748 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
6749 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
6750 Stmt *AssociatedStmt, const HelperExprs &Exprs);
6751
6752 /// Creates an empty directive with a place for \a NumClauses clauses.
6753 ///
6754 /// \param C AST context.
6755 /// \param NumClauses Number of clauses.
6756 /// \param CollapsedNum Number of collapsed nested loops.
6757 ///
6758 static OMPGenericLoopDirective *CreateEmpty(const ASTContext &C,
6759 unsigned NumClauses,
6760 unsigned CollapsedNum,
6761 EmptyShell);
6762
6763 static bool classof(const Stmt *T) {
6764 return T->getStmtClass() == OMPGenericLoopDirectiveClass;
6765 }
6766};
6767
6768/// This represents '#pragma omp teams loop' directive.
6769///
6770/// \code
6771/// #pragma omp teams loop private(a,b) order(concurrent)
6772/// \endcode
6773/// In this example directive '#pragma omp teams loop' has
6774/// clauses 'private' with the variables 'a' and 'b', and order(concurrent).
6775///
6776class OMPTeamsGenericLoopDirective final : public OMPLoopDirective {
6777 friend class ASTStmtReader;
6779 /// Build directive with the given start and end location.
6780 ///
6781 /// \param StartLoc Starting location of the directive kind.
6782 /// \param EndLoc Ending location of the directive.
6783 /// \param CollapsedNum Number of collapsed nested loops.
6784 ///
6785 OMPTeamsGenericLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc,
6786 unsigned CollapsedNum)
6787 : OMPLoopDirective(OMPTeamsGenericLoopDirectiveClass,
6788 llvm::omp::OMPD_teams_loop, StartLoc, EndLoc,
6789 CollapsedNum) {}
6790
6791 /// Build an empty directive.
6792 ///
6793 /// \param CollapsedNum Number of collapsed nested loops.
6794 ///
6795 explicit OMPTeamsGenericLoopDirective(unsigned CollapsedNum)
6796 : OMPLoopDirective(OMPTeamsGenericLoopDirectiveClass,
6797 llvm::omp::OMPD_teams_loop, SourceLocation(),
6798 SourceLocation(), CollapsedNum) {}
6799
6800public:
6801 /// Creates directive with a list of \p Clauses.
6802 ///
6803 /// \param C AST context.
6804 /// \param StartLoc Starting location of the directive kind.
6805 /// \param EndLoc Ending Location of the directive.
6806 /// \param CollapsedNum Number of collapsed loops.
6807 /// \param Clauses List of clauses.
6808 /// \param AssociatedStmt Statement, associated with the directive.
6809 /// \param Exprs Helper expressions for CodeGen.
6810 ///
6811 static OMPTeamsGenericLoopDirective *
6812 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
6813 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
6814 Stmt *AssociatedStmt, const HelperExprs &Exprs);
6815
6816 /// Creates an empty directive with the place
6817 /// for \a NumClauses clauses.
6818 ///
6819 /// \param C AST context.
6820 /// \param CollapsedNum Number of collapsed nested loops.
6821 /// \param NumClauses Number of clauses.
6822 ///
6823 static OMPTeamsGenericLoopDirective *CreateEmpty(const ASTContext &C,
6824 unsigned NumClauses,
6825 unsigned CollapsedNum,
6826 EmptyShell);
6827
6828 static bool classof(const Stmt *T) {
6829 return T->getStmtClass() == OMPTeamsGenericLoopDirectiveClass;
6830 }
6831};
6832
6833/// This represents '#pragma omp target teams loop' directive.
6834///
6835/// \code
6836/// #pragma omp target teams loop private(a,b) order(concurrent)
6837/// \endcode
6838/// In this example directive '#pragma omp target teams loop' has
6839/// clauses 'private' with the variables 'a' and 'b', and order(concurrent).
6840///
6841class OMPTargetTeamsGenericLoopDirective final : public OMPLoopDirective {
6842 friend class ASTStmtReader;
6844 /// true if loop directive's associated loop can be a parallel for.
6845 bool CanBeParallelFor = false;
6846 /// Build directive with the given start and end location.
6847 ///
6848 /// \param StartLoc Starting location of the directive kind.
6849 /// \param EndLoc Ending location of the directive.
6850 /// \param CollapsedNum Number of collapsed nested loops.
6851 ///
6852 OMPTargetTeamsGenericLoopDirective(SourceLocation StartLoc,
6853 SourceLocation EndLoc,
6854 unsigned CollapsedNum)
6855 : OMPLoopDirective(OMPTargetTeamsGenericLoopDirectiveClass,
6856 llvm::omp::OMPD_target_teams_loop, StartLoc, EndLoc,
6857 CollapsedNum) {}
6858
6859 /// Build an empty directive.
6860 ///
6861 /// \param CollapsedNum Number of collapsed nested loops.
6862 ///
6863 explicit OMPTargetTeamsGenericLoopDirective(unsigned CollapsedNum)
6864 : OMPLoopDirective(OMPTargetTeamsGenericLoopDirectiveClass,
6865 llvm::omp::OMPD_target_teams_loop, SourceLocation(),
6866 SourceLocation(), CollapsedNum) {}
6867
6868 /// Set whether associated loop can be a parallel for.
6869 void setCanBeParallelFor(bool ParFor) { CanBeParallelFor = ParFor; }
6870
6871public:
6872 /// Creates directive with a list of \p Clauses.
6873 ///
6874 /// \param C AST context.
6875 /// \param StartLoc Starting location of the directive kind.
6876 /// \param EndLoc Ending Location of the directive.
6877 /// \param CollapsedNum Number of collapsed loops.
6878 /// \param Clauses List of clauses.
6879 /// \param AssociatedStmt Statement, associated with the directive.
6880 /// \param Exprs Helper expressions for CodeGen.
6881 ///
6882 static OMPTargetTeamsGenericLoopDirective *
6883 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
6884 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
6885 Stmt *AssociatedStmt, const HelperExprs &Exprs, bool CanBeParallelFor);
6886
6887 /// Creates an empty directive with the place
6888 /// for \a NumClauses clauses.
6889 ///
6890 /// \param C AST context.
6891 /// \param CollapsedNum Number of collapsed nested loops.
6892 /// \param NumClauses Number of clauses.
6893 ///
6894 static OMPTargetTeamsGenericLoopDirective *CreateEmpty(const ASTContext &C,
6895 unsigned NumClauses,
6896 unsigned CollapsedNum,
6897 EmptyShell);
6898
6899 /// Return true if current loop directive's associated loop can be a
6900 /// parallel for.
6901 bool canBeParallelFor() const { return CanBeParallelFor; }
6902
6903 static bool classof(const Stmt *T) {
6904 return T->getStmtClass() == OMPTargetTeamsGenericLoopDirectiveClass;
6905 }
6906};
6907
6908/// This represents '#pragma omp parallel loop' directive.
6909///
6910/// \code
6911/// #pragma omp parallel loop private(a,b) order(concurrent)
6912/// \endcode
6913/// In this example directive '#pragma omp parallel loop' has
6914/// clauses 'private' with the variables 'a' and 'b', and order(concurrent).
6915///
6916class OMPParallelGenericLoopDirective final : public OMPLoopDirective {
6917 friend class ASTStmtReader;
6919 /// Build directive with the given start and end location.
6920 ///
6921 /// \param StartLoc Starting location of the directive kind.
6922 /// \param EndLoc Ending location of the directive.
6923 /// \param CollapsedNum Number of collapsed nested loops.
6924 ///
6925 OMPParallelGenericLoopDirective(SourceLocation StartLoc,
6926 SourceLocation EndLoc, unsigned CollapsedNum)
6927 : OMPLoopDirective(OMPParallelGenericLoopDirectiveClass,
6928 llvm::omp::OMPD_parallel_loop, StartLoc, EndLoc,
6929 CollapsedNum) {}
6930
6931 /// Build an empty directive.
6932 ///
6933 /// \param CollapsedNum Number of collapsed nested loops.
6934 ///
6935 explicit OMPParallelGenericLoopDirective(unsigned CollapsedNum)
6936 : OMPLoopDirective(OMPParallelGenericLoopDirectiveClass,
6937 llvm::omp::OMPD_parallel_loop, SourceLocation(),
6938 SourceLocation(), CollapsedNum) {}
6939
6940public:
6941 /// Creates directive with a list of \p Clauses.
6942 ///
6943 /// \param C AST context.
6944 /// \param StartLoc Starting location of the directive kind.
6945 /// \param EndLoc Ending Location of the directive.
6946 /// \param CollapsedNum Number of collapsed loops.
6947 /// \param Clauses List of clauses.
6948 /// \param AssociatedStmt Statement, associated with the directive.
6949 /// \param Exprs Helper expressions for CodeGen.
6950 ///
6951 static OMPParallelGenericLoopDirective *
6952 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
6953 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
6954 Stmt *AssociatedStmt, const HelperExprs &Exprs);
6955
6956 /// Creates an empty directive with the place
6957 /// for \a NumClauses clauses.
6958 ///
6959 /// \param C AST context.
6960 /// \param CollapsedNum Number of collapsed nested loops.
6961 /// \param NumClauses Number of clauses.
6962 ///
6963 static OMPParallelGenericLoopDirective *CreateEmpty(const ASTContext &C,
6964 unsigned NumClauses,
6965 unsigned CollapsedNum,
6966 EmptyShell);
6967
6968 static bool classof(const Stmt *T) {
6969 return T->getStmtClass() == OMPParallelGenericLoopDirectiveClass;
6970 }
6971};
6972
6973/// This represents '#pragma omp target parallel loop' directive.
6974///
6975/// \code
6976/// #pragma omp target parallel loop private(a,b) order(concurrent)
6977/// \endcode
6978/// In this example directive '#pragma omp target parallel loop' has
6979/// clauses 'private' with the variables 'a' and 'b', and order(concurrent).
6980///
6981class OMPTargetParallelGenericLoopDirective final : public OMPLoopDirective {
6982 friend class ASTStmtReader;
6984 /// Build directive with the given start and end location.
6985 ///
6986 /// \param StartLoc Starting location of the directive kind.
6987 /// \param EndLoc Ending location of the directive.
6988 /// \param CollapsedNum Number of collapsed nested loops.
6989 ///
6990 OMPTargetParallelGenericLoopDirective(SourceLocation StartLoc,
6991 SourceLocation EndLoc,
6992 unsigned CollapsedNum)
6993 : OMPLoopDirective(OMPTargetParallelGenericLoopDirectiveClass,
6994 llvm::omp::OMPD_target_parallel_loop, StartLoc, EndLoc,
6995 CollapsedNum) {}
6996
6997 /// Build an empty directive.
6998 ///
6999 /// \param CollapsedNum Number of collapsed nested loops.
7000 ///
7001 explicit OMPTargetParallelGenericLoopDirective(unsigned CollapsedNum)
7002 : OMPLoopDirective(OMPTargetParallelGenericLoopDirectiveClass,
7003 llvm::omp::OMPD_target_parallel_loop, SourceLocation(),
7004 SourceLocation(), CollapsedNum) {}
7005
7006public:
7007 /// Creates directive with a list of \p Clauses.
7008 ///
7009 /// \param C AST context.
7010 /// \param StartLoc Starting location of the directive kind.
7011 /// \param EndLoc Ending Location of the directive.
7012 /// \param CollapsedNum Number of collapsed loops.
7013 /// \param Clauses List of clauses.
7014 /// \param AssociatedStmt Statement, associated with the directive.
7015 /// \param Exprs Helper expressions for CodeGen.
7016 ///
7017 static OMPTargetParallelGenericLoopDirective *
7018 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
7019 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
7020 Stmt *AssociatedStmt, const HelperExprs &Exprs);
7021
7022 /// Creates an empty directive with the place
7023 /// for \a NumClauses clauses.
7024 ///
7025 /// \param C AST context.
7026 /// \param CollapsedNum Number of collapsed nested loops.
7027 /// \param NumClauses Number of clauses.
7028 ///
7029 static OMPTargetParallelGenericLoopDirective *
7030 CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
7031 EmptyShell);
7032
7033 static bool classof(const Stmt *T) {
7034 return T->getStmtClass() == OMPTargetParallelGenericLoopDirectiveClass;
7035 }
7036};
7037
7038/// This represents '#pragma omp target loop' directive.
7039///
7040/// \code
7041/// #pragma omp target loop private(a,b) order(concurrent)
7042/// \endcode
7043/// In this example directive '#pragma omp target loop' has
7044/// clauses 'private' with the variables 'a' and 'b', and order(concurrent).
7045///
7046class OMPTargetGenericLoopDirective final : public OMPLoopDirective {
7047 friend class ASTStmtReader;
7049 /// Build directive with the given start and end location.
7050 ///
7051 /// \param StartLoc Starting location of the directive kind.
7052 /// \param EndLoc Ending location of the directive.
7053 /// \param CollapsedNum Number of collapsed nested loops.
7054 ///
7055 OMPTargetGenericLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc,
7056 unsigned CollapsedNum)
7057 : OMPLoopDirective(OMPTargetGenericLoopDirectiveClass,
7058 llvm::omp::OMPD_target_loop, StartLoc, EndLoc,
7059 CollapsedNum) {}
7060
7061 /// Build an empty directive.
7062 ///
7063 /// \param CollapsedNum Number of collapsed nested loops.
7064 ///
7065 explicit OMPTargetGenericLoopDirective(unsigned CollapsedNum)
7066 : OMPLoopDirective(OMPTargetGenericLoopDirectiveClass,
7067 llvm::omp::OMPD_target_loop, SourceLocation(),
7068 SourceLocation(), CollapsedNum) {}
7069
7070public:
7071 /// Creates directive with a list of \p Clauses.
7072 ///
7073 /// \param C AST context.
7074 /// \param StartLoc Starting location of the directive kind.
7075 /// \param EndLoc Ending Location of the directive.
7076 /// \param CollapsedNum Number of collapsed loops.
7077 /// \param Clauses List of clauses.
7078 /// \param AssociatedStmt Statement, associated with the directive.
7079 /// \param Exprs Helper expressions for CodeGen.
7080 ///
7081 static OMPTargetGenericLoopDirective *
7082 Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
7083 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
7084 Stmt *AssociatedStmt, const HelperExprs &Exprs);
7085
7086 /// Creates an empty directive with the place
7087 /// for \a NumClauses clauses.
7088 ///
7089 /// \param C AST context.
7090 /// \param CollapsedNum Number of collapsed nested loops.
7091 /// \param NumClauses Number of clauses.
7092 ///
7093 static OMPTargetGenericLoopDirective *CreateEmpty(const ASTContext &C,
7094 unsigned NumClauses,
7095 unsigned CollapsedNum,
7096 EmptyShell);
7097
7098 static bool classof(const Stmt *T) {
7099 return T->getStmtClass() == OMPTargetGenericLoopDirectiveClass;
7100 }
7101};
7102
7103/// This represents '#pragma omp error' directive.
7104///
7105/// \code
7106/// #pragma omp error
7107/// \endcode
7108class OMPErrorDirective final : public OMPExecutableDirective {
7109 friend class ASTStmtReader;
7111 /// Build directive with the given start and end location.
7112 ///
7113 /// \param StartLoc Starting location of the directive kind.
7114 /// \param EndLoc Ending location of the directive.
7115 ///
7116 OMPErrorDirective(SourceLocation StartLoc, SourceLocation EndLoc)
7117 : OMPExecutableDirective(OMPErrorDirectiveClass, llvm::omp::OMPD_error,
7118 StartLoc, EndLoc) {}
7119 /// Build an empty directive.
7120 ///
7121 explicit OMPErrorDirective()
7122 : OMPExecutableDirective(OMPErrorDirectiveClass, llvm::omp::OMPD_error,
7123 SourceLocation(), SourceLocation()) {}
7124
7125public:
7126 ///
7127 /// \param C AST context.
7128 /// \param StartLoc Starting location of the directive kind.
7129 /// \param EndLoc Ending Location of the directive.
7130 /// \param Clauses List of clauses.
7131 ///
7132 static OMPErrorDirective *Create(const ASTContext &C, SourceLocation StartLoc,
7133 SourceLocation EndLoc,
7134 ArrayRef<OMPClause *> Clauses);
7135
7136 /// Creates an empty directive.
7137 ///
7138 /// \param C AST context.
7139 ///
7140 static OMPErrorDirective *CreateEmpty(const ASTContext &C,
7141 unsigned NumClauses, EmptyShell);
7142
7143 static bool classof(const Stmt *T) {
7144 return T->getStmtClass() == OMPErrorDirectiveClass;
7145 }
7146};
7147
7148// It's not really an executable directive, but it seems convenient to use
7149// that as the parent class.
7150class OMPAssumeDirective final : public OMPExecutableDirective {
7151 friend class ASTStmtReader;
7153
7154private:
7155 OMPAssumeDirective(SourceLocation StartLoc, SourceLocation EndLoc)
7156 : OMPExecutableDirective(OMPAssumeDirectiveClass, llvm::omp::OMPD_assume,
7157 StartLoc, EndLoc) {}
7158
7159 explicit OMPAssumeDirective()
7160 : OMPExecutableDirective(OMPAssumeDirectiveClass, llvm::omp::OMPD_assume,
7161 SourceLocation(), SourceLocation()) {}
7162
7163public:
7164 static OMPAssumeDirective *Create(const ASTContext &Ctx,
7165 SourceLocation StartLoc,
7166 SourceLocation EndLoc,
7167 ArrayRef<OMPClause *> Clauses, Stmt *AStmt);
7168
7169 static OMPAssumeDirective *CreateEmpty(const ASTContext &C,
7170 unsigned NumClauses, EmptyShell);
7171
7172 static bool classof(const Stmt *T) {
7173 return T->getStmtClass() == OMPAssumeDirectiveClass;
7174 }
7175};
7176
7177} // end namespace clang
7178
7179namespace llvm {
7180// Allow a Stmt* be casted correctly to an OMPLoopTransformationDirective*.
7181// The default routines would just use a C-style cast which won't work well
7182// for the multiple inheritance here. We have to use a static cast from the
7183// corresponding subclass.
7184template <>
7186 : public NullableValueCastFailed<clang::OMPLoopTransformationDirective *>,
7188 clang::OMPLoopTransformationDirective *, clang::Stmt *,
7189 CastInfo<clang::OMPLoopTransformationDirective, clang::Stmt *>> {
7190 static bool isPossible(const clang::Stmt *T) {
7191 return clang::OMPLoopTransformationDirective::classof(T);
7192 }
7193
7194 static clang::OMPLoopTransformationDirective *doCast(clang::Stmt *T) {
7195 if (auto *D =
7196 dyn_cast<clang::OMPCanonicalLoopNestTransformationDirective>(T))
7197 return static_cast<clang::OMPLoopTransformationDirective *>(D);
7198 if (auto *D =
7199 dyn_cast<clang::OMPCanonicalLoopSequenceTransformationDirective>(T))
7200 return static_cast<clang::OMPLoopTransformationDirective *>(D);
7201 llvm_unreachable("unexpected type");
7202 }
7203};
7204template <>
7207 clang::OMPLoopTransformationDirective, const clang::Stmt *,
7208 CastInfo<clang::OMPLoopTransformationDirective, clang::Stmt *>> {};
7209
7210} // namespace llvm
7211
7212#endif
Defines the clang::ASTContext interface.
#define V(N, I)
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, clang::CharUnits CU)
Definition CharUnits.h:194
SmallVector< AnnotatedLine *, 1 > Children
If this token starts a block, this contains all the unwrapped lines in it.
#define X(type, name)
Definition Value.h:97
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
Defines the clang::SourceLocation class and associated facilities.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:245
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp atomic' directive.
Expr * getR()
Get 'r' part of the associated expression/statement.
Expr * getX()
Get 'x' part of the associated expression/statement.
Expr * getD() const
const Expr * getUpdateExpr() const
bool isFailOnly() const
Return true if 'v' is updated only when the condition is evaluated false (compare capture only).
Expr * getCondExpr() const
bool isPostfixUpdate() const
Return true if 'v' expression must be updated to original value of 'x', false if 'v' must be updated ...
const Expr * getV() const
const Expr * getR() const
Expr * getExpr()
Get 'expr' part of the associated expression/statement.
Expr * getV()
Get 'v' part of the associated expression/statement.
const Expr * getX() const
static bool classof(const Stmt *T)
const Expr * getExpr() const
bool isXLHSInRHSPart() const
Return true if helper update expression has form 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and...
Expr * getD()
Get 'd' part of the associated expression/statement.
friend class OMPExecutableDirective
Expr * getUpdateExpr()
Get helper expression of the form 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or 'OpaqueValueExp...
friend class ASTStmtReader
Expr * getCondExpr()
Get the 'cond' part of the source atomic expression.
static OMPAtomicDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
static OMPAtomicDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt, Expressions Exprs)
Creates directive with a list of Clauses and 'x', 'v' and 'expr' parts of the atomic construct (see S...
This represents 'pragma omp barrier' directive.
friend class OMPExecutableDirective
friend class ASTStmtReader
static bool classof(const Stmt *T)
This represents 'pragma omp cancel' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
This represents 'pragma omp cancellation point' directive.
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
static bool classof(const Stmt *T)
The base class for all transformation directives of canonical loop nests.
OMPCanonicalLoopNestTransformationDirective(StmtClass SC, OpenMPDirectiveKind Kind, SourceLocation StartLoc, SourceLocation EndLoc, unsigned NumAssociatedLoops)
unsigned getNumAssociatedLoops() const
Return the number of associated (consumed) loops.
The base class for all transformation directives of canonical loop sequences (currently only 'fuse')
OMPCanonicalLoopSequenceTransformationDirective(StmtClass SC, OpenMPDirectiveKind Kind, SourceLocation StartLoc, SourceLocation EndLoc)
This represents 'pragma omp critical' directive.
friend class OMPExecutableDirective
friend class ASTStmtReader
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
static bool classof(const Stmt *T)
This represents 'pragma omp depobj' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp dispatch' directive.
SourceLocation getTargetCallLoc() const
Return location of target-call.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp distribute' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp distribute parallel for' composite directive.
static bool classof(const Stmt *T)
bool hasCancel() const
Return true if current directive has inner cancel directive.
const Expr * getTaskReductionRefExpr() const
Expr * getTaskReductionRefExpr()
Returns special task reduction reference expression.
This represents 'pragma omp distribute parallel for simd' composite directive.
static bool classof(const Stmt *T)
This represents 'pragma omp distribute simd' composite directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
This represents 'pragma omp error' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
Represents the 'pragma omp flatten' loop transformation directive.
static bool classof(const Stmt *T)
Stmt * getPreInits() const
Return preinits statement.
friend class OMPExecutableDirective
Stmt * getTransformedStmt() const
Gets the flattened loop after the transformation.
friend class ASTStmtReader
Stmt * getFinals() const
Return updates to the original loop variables after the flattened loop.
This represents 'pragma omp flush' directive.
friend class OMPExecutableDirective
friend class ASTStmtReader
static bool classof(const Stmt *T)
This represents 'pragma omp for' directive.
bool hasCancel() const
Return true if current directive has inner cancel directive.
static bool classof(const Stmt *T)
Expr * getTaskReductionRefExpr()
Returns special task reduction reference expression.
friend class OMPExecutableDirective
friend class ASTStmtReader
const Expr * getTaskReductionRefExpr() const
This represents 'pragma omp for simd' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
Represents the 'pragma omp fuse' loop transformation directive.
static bool classof(const Stmt *T)
Stmt * getFinals() const
Return finals statement.
Stmt * getPreInits() const
Return preinits statement.
friend class OMPExecutableDirective
friend class ASTStmtReader
Stmt * getTransformedStmt() const
Gets the associated loops after the transformation.
This represents 'pragma omp loop' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
Represents the 'pragma omp interchange' loop transformation directive.
Stmt * getFinals() const
Return finals statement.
Stmt * getTransformedStmt() const
Gets the associated loops after the transformation.
Stmt * getPreInits() const
Return preinits statement.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp interop' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc....
void setCombinedNextUpperBound(Expr *CombNUB)
Expr * getCombinedUpperBoundVariable() const
void setInc(Expr *Inc)
Expr * getPreCond() const
void setNextUpperBound(Expr *NUB)
Expr * getPrevUpperBoundVariable() const
Expr * getIsLastIterVariable() const
static unsigned numLoopChildren(unsigned CollapsedNum, OpenMPDirectiveKind Kind)
Children number.
Expr * getCombinedLowerBoundVariable() const
void setUpperBoundVariable(Expr *UB)
static bool classof(const Stmt *T)
Expr * getCombinedCond() const
void setIsLastIterVariable(Expr *IL)
Expr * getCombinedInit() const
void setPrevEnsureUpperBound(Expr *PrevEUB)
Expr * getLowerBoundVariable() const
void setCombinedLowerBoundVariable(Expr *CombLB)
void setPreInits(Stmt *PreInits)
OMPLoopDirective(StmtClass SC, OpenMPDirectiveKind Kind, SourceLocation StartLoc, SourceLocation EndLoc, unsigned CollapsedNum)
Build instance of loop directive of class Kind.
ArrayRef< Expr * > dependent_inits() const
Expr * getCombinedNextLowerBound() const
void setInit(Expr *Init)
ArrayRef< Expr * > finals_conditions()
ArrayRef< Expr * > counters()
void setNextLowerBound(Expr *NLB)
Expr * getInc() const
ArrayRef< Expr * > private_counters()
Expr * getUpperBoundVariable() const
ArrayRef< Expr * > dependent_counters() const
void setCombinedParForInDistCond(Expr *CombParForInDistCond)
void setEnsureUpperBound(Expr *EUB)
void setCombinedNextLowerBound(Expr *CombNLB)
Expr * getCombinedDistCond() const
Expr * getPrevLowerBoundVariable() const
ArrayRef< Expr * > dependent_inits()
void setPrevLowerBoundVariable(Expr *PrevLB)
void setCombinedCond(Expr *CombCond)
Expr * getNextLowerBound() const
void setLowerBoundVariable(Expr *LB)
Expr * getDistInc() const
const Stmt * getBody() const
void setPrevUpperBoundVariable(Expr *PrevUB)
ArrayRef< Expr * > inits() const
ArrayRef< Expr * > updates()
Expr * getCond() const
Expr * getNextUpperBound() const
Expr * getLastIteration() const
Expr * getEnsureUpperBound() const
void setCombinedUpperBoundVariable(Expr *CombUB)
Stmt * getPreInits()
const Stmt * getPreInits() const
Expr * getCalcLastIteration() const
ArrayRef< Expr * > updates() const
void setStrideVariable(Expr *ST)
void setCond(Expr *Cond)
void setCombinedDistCond(Expr *CombDistCond)
void setCalcLastIteration(Expr *CLI)
void setDistInc(Expr *DistInc)
ArrayRef< Expr * > finals() const
void setCombinedEnsureUpperBound(Expr *CombEUB)
ArrayRef< Expr * > finals_conditions() const
Expr * getCombinedNextUpperBound() const
void setIterationVariable(Expr *IV)
ArrayRef< Expr * > private_counters() const
Expr * getIterationVariable() const
Expr * getStrideVariable() const
Expr * getNumIterations() const
friend class ASTStmtReader
Expr * getCombinedParForInDistCond() const
Expr * getInit() const
void setPreCond(Expr *PC)
static unsigned getArraysOffset(OpenMPDirectiveKind Kind)
Offset to the start of children expression arrays.
ArrayRef< Expr * > finals()
void setNumIterations(Expr *NI)
void setLastIteration(Expr *LI)
Expr * getPrevEnsureUpperBound() const
Expr * getCombinedEnsureUpperBound() const
ArrayRef< Expr * > dependent_counters()
void setCombinedInit(Expr *CombInit)
ArrayRef< Expr * > counters() const
ArrayRef< Expr * > inits()
Common class of data shared between OMPCanonicalLoopNestTransformationDirective and OMPCanonicalLoopS...
static bool classof(const Stmt *T)
Stmt * getDirective() const
Returns the specific directive related to this loop transformation.
void setNumGeneratedTopLevelLoops(unsigned N)
unsigned getNumGeneratedTopLevelLoops() const
This represents 'pragma omp masked' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp masked taskloop' directive.
static bool classof(const Stmt *T)
bool hasCancel() const
Return true if current directive has inner cancel directive.
friend class OMPExecutableDirective
This represents 'pragma omp masked taskloop simd' directive.
static bool classof(const Stmt *T)
This represents 'pragma omp master' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp master taskloop' directive.
static bool classof(const Stmt *T)
bool hasCancel() const
Return true if current directive has inner cancel directive.
friend class OMPExecutableDirective
This represents 'pragma omp master taskloop simd' directive.
static bool classof(const Stmt *T)
bool hasImplicitOtherwise() const
ArrayRef< Expr * > conditions() const
ArrayRef< OMPTraitInfo * > traitInfos() const
static bool classof(const Stmt *T)
child_range children()
const_child_range children() const
unsigned getNumVariants() const
friend class OMPExecutableDirective
friend class ASTStmtReader
ArrayRef< Stmt * > variants() const
This represents block-associated 'pragma omp ordered' directive.
static bool classof(const Stmt *T)
This represents standalone 'pragma omp ordered' directive.
static bool classof(const Stmt *T)
This represents 'pragma omp parallel for' directive.
const Expr * getTaskReductionRefExpr() const
Expr * getTaskReductionRefExpr()
Returns special task reduction reference expression.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
bool hasCancel() const
Return true if current directive has inner cancel directive.
friend class ASTStmtReader
This represents 'pragma omp parallel for simd' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
This represents 'pragma omp parallel loop' directive.
static bool classof(const Stmt *T)
This represents 'pragma omp parallel masked' directive.
Expr * getTaskReductionRefExpr()
Returns special task reduction reference expression.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
const Expr * getTaskReductionRefExpr() const
This represents 'pragma omp parallel masked taskloop' directive.
bool hasCancel() const
Return true if current directive has inner cancel directive.
static bool classof(const Stmt *T)
This represents 'pragma omp parallel masked taskloop simd' directive.
static bool classof(const Stmt *T)
This represents 'pragma omp parallel master' directive.
static bool classof(const Stmt *T)
const Expr * getTaskReductionRefExpr() const
Expr * getTaskReductionRefExpr()
Returns special task reduction reference expression.
friend class OMPExecutableDirective
This represents 'pragma omp parallel master taskloop' directive.
bool hasCancel() const
Return true if current directive has inner cancel directive.
static bool classof(const Stmt *T)
This represents 'pragma omp parallel master taskloop simd' directive.
static bool classof(const Stmt *T)
This represents 'pragma omp parallel sections' directive.
static bool classof(const Stmt *T)
bool hasCancel() const
Return true if current directive has inner cancel directive.
friend class OMPExecutableDirective
const Expr * getTaskReductionRefExpr() const
Expr * getTaskReductionRefExpr()
Returns special task reduction reference expression.
Represents the 'pragma omp reverse' loop transformation directive.
Stmt * getPreInits() const
Return preinits statement.
Stmt * getTransformedStmt() const
Gets/sets the associated loops after the transformation, i.e.
Stmt * getFinals() const
Return finals statement.
friend class OMPExecutableDirective
static bool classof(const Stmt *T)
friend class ASTStmtReader
This represents 'pragma omp scan' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp scope' directive.
friend class OMPExecutableDirective
friend class ASTStmtReader
static bool classof(const Stmt *T)
This represents 'pragma omp section' directive.
void setHasCancel(bool Has)
Set cancel state.
static bool classof(const Stmt *T)
bool hasCancel() const
Return true if current directive has inner cancel directive.
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp sections' directive.
const Expr * getTaskReductionRefExpr() const
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
bool hasCancel() const
Return true if current directive has inner cancel directive.
friend class ASTStmtReader
Expr * getTaskReductionRefExpr()
Returns special task reduction reference expression.
This represents 'pragma omp simd' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp single' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
Represents the 'pragma omp split' loop transformation directive.
Stmt * getPreInits() const
Return preinits statement.
Stmt * getFinals() const
Return finals statement (loop variable finalization).
Stmt * getTransformedStmt() const
Gets/sets the associated loops after the transformation, i.e.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents the 'pragma omp stripe' loop transformation directive.
static bool classof(const Stmt *T)
Stmt * getPreInits() const
Return preinits statement.
Stmt * getTransformedStmt() const
Gets/sets the associated loops after striping.
Stmt * getFinals() const
Return finals statement (loop variable finalization).
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp target data' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp target' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp target enter data' directive.
friend class OMPExecutableDirective
static bool classof(const Stmt *T)
This represents 'pragma omp target exit data' directive.
friend class OMPExecutableDirective
static bool classof(const Stmt *T)
This represents 'pragma omp target loop' directive.
static bool classof(const Stmt *T)
This represents 'pragma omp target parallel' directive.
static bool classof(const Stmt *T)
bool hasCancel() const
Return true if current directive has inner cancel directive.
const Expr * getTaskReductionRefExpr() const
Expr * getTaskReductionRefExpr()
Returns special task reduction reference expression.
friend class OMPExecutableDirective
This represents 'pragma omp target parallel for' directive.
const Expr * getTaskReductionRefExpr() const
static bool classof(const Stmt *T)
bool hasCancel() const
Return true if current directive has inner cancel directive.
Expr * getTaskReductionRefExpr()
Returns special task reduction reference expression.
This represents 'pragma omp target parallel for simd' directive.
static bool classof(const Stmt *T)
This represents 'pragma omp target parallel loop' directive.
static bool classof(const Stmt *T)
This represents 'pragma omp target simd' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp target teams' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp target teams distribute' combined directive.
static bool classof(const Stmt *T)
This represents 'pragma omp target teams distribute parallel for' combined directive.
Expr * getTaskReductionRefExpr()
Returns special task reduction reference expression.
bool hasCancel() const
Return true if current directive has inner cancel directive.
This represents 'pragma omp target teams distribute parallel for simd' combined directive.
This represents 'pragma omp target teams distribute simd' combined directive.
static bool classof(const Stmt *T)
This represents 'pragma omp target teams loop' directive.
static bool classof(const Stmt *T)
bool canBeParallelFor() const
Return true if current loop directive's associated loop can be a parallel for.
This represents 'pragma omp target update' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
This represents 'pragma omp task' directive.
bool hasCancel() const
Return true if current directive has inner cancel directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp taskloop' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
bool hasCancel() const
Return true if current directive has inner cancel directive.
This represents 'pragma omp taskloop simd' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
This represents 'pragma omp taskgroup' directive.
const Expr * getReductionRef() const
Returns reference to the task_reduction return variable.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp taskwait' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp taskyield' directive.
friend class OMPExecutableDirective
static bool classof(const Stmt *T)
friend class ASTStmtReader
This represents 'pragma omp teams' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
friend class ASTStmtReader
This represents 'pragma omp teams distribute' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
This represents 'pragma omp teams distribute parallel for' composite directive.
bool hasCancel() const
Return true if current directive has inner cancel directive.
static bool classof(const Stmt *T)
const Expr * getTaskReductionRefExpr() const
Expr * getTaskReductionRefExpr()
Returns special task reduction reference expression.
This represents 'pragma omp teams distribute parallel for simd' composite directive.
This represents 'pragma omp teams distribute simd' combined directive.
static bool classof(const Stmt *T)
This represents 'pragma omp teams loop' directive.
static bool classof(const Stmt *T)
friend class OMPExecutableDirective
This represents the 'pragma omp tile' loop transformation directive.
static bool classof(const Stmt *T)
Stmt * getPreInits() const
Return preinits statement.
Stmt * getTransformedStmt() const
Gets/sets the associated loops after tiling.
friend class OMPExecutableDirective
friend class ASTStmtReader
Stmt * getFinals() const
Return finals statement (loop variable finalization).
This represents the 'pragma omp unroll' loop transformation directive.
Stmt * getPreInits() const
Return the pre-init statements.
static bool classof(const Stmt *T)
Stmt * getTransformedStmt() const
Get the de-sugared associated loops after unrolling.
Stmt * getFinals() const
Return finals statement, used when an enclosing loop transformation consumes the unrolled loop.
friend class OMPExecutableDirective
friend class ASTStmtReader
Stmt - This represents one statement.
Definition Stmt.h:85
bool Init(InterpState &S, CodePtr OpPC)
Definition Interp.h:2381
bool Inc(InterpState &S, CodePtr OpPC, bool CanOverflow)
1) Pops a pointer from the stack 2) Load the value from the pointer 3) Writes the value increased by ...
Definition Interp.h:960
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions &DiagOpts, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
Top level wrappers for InstallAPI frontend operations.
MutableArrayRef< Expr * > getFinals()
Sets the list of final update expressions for linear variables.
Stmt Stmt llvm::function_ref< void(OMPLoopTransformationDirective *)> OnTransformationCallback
Definition StmtOpenMP.h:934
Stmt Stmt llvm::function_ref< void(OMPLoopTransformationDirective *)> bool RelaxNestForPeeledTransformation
Definition StmtOpenMP.h:935
static bool classof(const OMPClause *T)
Stmt Stmt * Callback
Definition StmtOpenMP.h:930
void setFinals(ArrayRef< Expr * > FL)
Sets the list of final update expressions for linear variables.
Stmt * getStructuredBlock()
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
static void doForAllLoopsBodies(Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, llvm::function_ref< void(unsigned, Stmt *, Stmt *)> Callback)
Calls the specified callback function for all the loop bodies in CurStmt, from the outermost loop to ...
static bool classof(const Stmt *T)
static bool doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, llvm::function_ref< bool(unsigned, Stmt *)> Callback, llvm::function_ref< void(OMPLoopTransformationDirective *)> OnTransformationCallback, bool RelaxNestForPeeledTransformation=false)
Definition StmtOpenMP.h:937
const FunctionProtoType * T
child_range used_children()
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition OpenMPKinds.h:25
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
void getOpenMPCaptureRegions(llvm::SmallVectorImpl< OpenMPDirectiveKind > &CaptureRegions, OpenMPDirectiveKind DKind)
Return the captured regions of an OpenMP directive.
MutableArrayRef< Expr * > getInits()
child_range children()
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 __builtin_riscv_mqwacc_i64 uint8_t
Expr * Cond
Conditional expression in atomic compare construct. */.
Expr * X
'x' part of the associated expression/statement.
bool IsXLHSInRHSPart
True if UE has the first form and false if the second.
Expr * E
'expr' part of the associated expression/statement.
Expr * D
'd' part of the associated expression/statement.
Expr * V
'v' part of the associated expression/statement.
bool IsFailOnly
True if 'v' is updated only when the condition is false (compare capture only).
Expr * UE
UE Helper expression of the form: 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or 'OpaqueValueExp...
bool IsPostfixUpdate
True if original value of 'x' must be stored in 'v', not an updated one.
static clang::OMPLoopTransformationDirective * doCast(clang::Stmt *T)