brintos

brintos / llvm-project-archived public Read only

0
0
Text · 115.1 KiB · a5b0cd3 Raw
2719 lines · cpp
1//===--- StmtOpenMP.cpp - Classes for OpenMP directives -------------------===//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-exception6//7//===----------------------------------------------------------------------===//8//9// This file implements the subclasses of Stmt class declared in StmtOpenMP.h10//11//===----------------------------------------------------------------------===//12 13#include "clang/AST/ASTContext.h"14#include "clang/AST/StmtOpenMP.h"15 16using namespace clang;17using namespace llvm::omp;18 19size_t OMPChildren::size(unsigned NumClauses, bool HasAssociatedStmt,20                         unsigned NumChildren) {21  return llvm::alignTo(22      totalSizeToAlloc<OMPClause *, Stmt *>(23          NumClauses, NumChildren + (HasAssociatedStmt ? 1 : 0)),24      alignof(OMPChildren));25}26 27void OMPChildren::setClauses(ArrayRef<OMPClause *> Clauses) {28  assert(Clauses.size() == NumClauses &&29         "Number of clauses is not the same as the preallocated buffer");30  llvm::copy(Clauses, getTrailingObjects<OMPClause *>());31}32 33MutableArrayRef<Stmt *> OMPChildren::getChildren() {34  return getTrailingObjects<Stmt *>(NumChildren);35}36 37OMPChildren *OMPChildren::Create(void *Mem, ArrayRef<OMPClause *> Clauses) {38  auto *Data = CreateEmpty(Mem, Clauses.size());39  Data->setClauses(Clauses);40  return Data;41}42 43OMPChildren *OMPChildren::Create(void *Mem, ArrayRef<OMPClause *> Clauses,44                                 Stmt *S, unsigned NumChildren) {45  auto *Data = CreateEmpty(Mem, Clauses.size(), S, NumChildren);46  Data->setClauses(Clauses);47  if (S)48    Data->setAssociatedStmt(S);49  return Data;50}51 52OMPChildren *OMPChildren::CreateEmpty(void *Mem, unsigned NumClauses,53                                      bool HasAssociatedStmt,54                                      unsigned NumChildren) {55  return new (Mem) OMPChildren(NumClauses, NumChildren, HasAssociatedStmt);56}57 58bool OMPExecutableDirective::isStandaloneDirective() const {59  // Special case: 'omp target enter data', 'omp target exit data',60  // 'omp target update' are stand-alone directives, but for implementation61  // reasons they have empty synthetic structured block, to simplify codegen.62  if (isa<OMPTargetEnterDataDirective>(this) ||63      isa<OMPTargetExitDataDirective>(this) ||64      isa<OMPTargetUpdateDirective>(this))65    return true;66  return !hasAssociatedStmt();67}68 69Stmt *OMPExecutableDirective::getStructuredBlock() {70  assert(!isStandaloneDirective() &&71         "Standalone Executable Directives don't have Structured Blocks.");72  if (auto *LD = dyn_cast<OMPLoopDirective>(this))73    return LD->getBody();74  return getRawStmt();75}76 77Stmt *78OMPLoopBasedDirective::tryToFindNextInnerLoop(Stmt *CurStmt,79                                              bool TryImperfectlyNestedLoops) {80  Stmt *OrigStmt = CurStmt;81  CurStmt = CurStmt->IgnoreContainers();82  // Additional work for imperfectly nested loops, introduced in OpenMP 5.0.83  if (TryImperfectlyNestedLoops) {84    if (auto *CS = dyn_cast<CompoundStmt>(CurStmt)) {85      CurStmt = nullptr;86      SmallVector<CompoundStmt *, 4> Statements(1, CS);87      SmallVector<CompoundStmt *, 4> NextStatements;88      while (!Statements.empty()) {89        CS = Statements.pop_back_val();90        if (!CS)91          continue;92        for (Stmt *S : CS->body()) {93          if (!S)94            continue;95          if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(S))96            S = CanonLoop->getLoopStmt();97          if (isa<ForStmt>(S) || isa<CXXForRangeStmt>(S) ||98              (isa<OMPLoopBasedDirective>(S) && !isa<OMPLoopDirective>(S))) {99            // Only single loop construct is allowed.100            if (CurStmt) {101              CurStmt = OrigStmt;102              break;103            }104            CurStmt = S;105            continue;106          }107          S = S->IgnoreContainers();108          if (auto *InnerCS = dyn_cast_or_null<CompoundStmt>(S))109            NextStatements.push_back(InnerCS);110        }111        if (Statements.empty()) {112          // Found single inner loop or multiple loops - exit.113          if (CurStmt)114            break;115          Statements.swap(NextStatements);116        }117      }118      if (!CurStmt)119        CurStmt = OrigStmt;120    }121  }122  return CurStmt;123}124 125bool OMPLoopBasedDirective::doForAllLoops(126    Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops,127    llvm::function_ref<bool(unsigned, Stmt *)> Callback,128    llvm::function_ref<void(OMPLoopTransformationDirective *)>129        OnTransformationCallback) {130  CurStmt = CurStmt->IgnoreContainers();131  for (unsigned Cnt = 0; Cnt < NumLoops; ++Cnt) {132    while (true) {133      auto *Dir = dyn_cast<OMPLoopTransformationDirective>(CurStmt);134      if (!Dir)135        break;136 137      OnTransformationCallback(Dir);138 139      Stmt *TransformedStmt = Dir->getTransformedStmt();140      if (!TransformedStmt) {141        unsigned NumGeneratedTopLevelLoops =142            Dir->getNumGeneratedTopLevelLoops();143        if (NumGeneratedTopLevelLoops == 0) {144          // May happen if the loop transformation does not result in a145          // generated loop (such as full unrolling).146          break;147        }148        if (NumGeneratedTopLevelLoops > 0) {149          // The loop transformation construct has generated loops, but these150          // may not have been generated yet due to being in a dependent151          // context.152          return true;153        }154      }155 156      CurStmt = TransformedStmt;157    }158    if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(CurStmt))159      CurStmt = CanonLoop->getLoopStmt();160    if (Callback(Cnt, CurStmt))161      return false;162    // Move on to the next nested for loop, or to the loop body.163    // OpenMP [2.8.1, simd construct, Restrictions]164    // All loops associated with the construct must be perfectly nested; that165    // is, there must be no intervening code nor any OpenMP directive between166    // any two loops.167    if (auto *For = dyn_cast<ForStmt>(CurStmt)) {168      CurStmt = For->getBody();169    } else {170      assert(isa<CXXForRangeStmt>(CurStmt) &&171             "Expected canonical for or range-based for loops.");172      CurStmt = cast<CXXForRangeStmt>(CurStmt)->getBody();173    }174    CurStmt = OMPLoopBasedDirective::tryToFindNextInnerLoop(175        CurStmt, TryImperfectlyNestedLoops);176  }177  return true;178}179 180void OMPLoopBasedDirective::doForAllLoopsBodies(181    Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops,182    llvm::function_ref<void(unsigned, Stmt *, Stmt *)> Callback) {183  bool Res = OMPLoopBasedDirective::doForAllLoops(184      CurStmt, TryImperfectlyNestedLoops, NumLoops,185      [Callback](unsigned Cnt, Stmt *Loop) {186        Stmt *Body = nullptr;187        if (auto *For = dyn_cast<ForStmt>(Loop)) {188          Body = For->getBody();189        } else {190          assert(isa<CXXForRangeStmt>(Loop) &&191                 "Expected canonical for or range-based for loops.");192          Body = cast<CXXForRangeStmt>(Loop)->getBody();193        }194        if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(Body))195          Body = CanonLoop->getLoopStmt();196        Callback(Cnt, Loop, Body);197        return false;198      });199  assert(Res && "Expected only loops");200  (void)Res;201}202 203Stmt *OMPLoopDirective::getBody() {204  // This relies on the loop form is already checked by Sema.205  Stmt *Body = nullptr;206  OMPLoopBasedDirective::doForAllLoopsBodies(207      Data->getRawStmt(), /*TryImperfectlyNestedLoops=*/true,208      NumAssociatedLoops,209      [&Body](unsigned, Stmt *, Stmt *BodyStmt) { Body = BodyStmt; });210  return Body;211}212 213void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) {214  assert(A.size() == getLoopsNumber() &&215         "Number of loop counters is not the same as the collapsed number");216  llvm::copy(A, getCounters().begin());217}218 219void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) {220  assert(A.size() == getLoopsNumber() && "Number of loop private counters "221                                         "is not the same as the collapsed "222                                         "number");223  llvm::copy(A, getPrivateCounters().begin());224}225 226void OMPLoopDirective::setInits(ArrayRef<Expr *> A) {227  assert(A.size() == getLoopsNumber() &&228         "Number of counter inits is not the same as the collapsed number");229  llvm::copy(A, getInits().begin());230}231 232void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) {233  assert(A.size() == getLoopsNumber() &&234         "Number of counter updates is not the same as the collapsed number");235  llvm::copy(A, getUpdates().begin());236}237 238void OMPLoopDirective::setFinals(ArrayRef<Expr *> A) {239  assert(A.size() == getLoopsNumber() &&240         "Number of counter finals is not the same as the collapsed number");241  llvm::copy(A, getFinals().begin());242}243 244void OMPLoopDirective::setDependentCounters(ArrayRef<Expr *> A) {245  assert(246      A.size() == getLoopsNumber() &&247      "Number of dependent counters is not the same as the collapsed number");248  llvm::copy(A, getDependentCounters().begin());249}250 251void OMPLoopDirective::setDependentInits(ArrayRef<Expr *> A) {252  assert(A.size() == getLoopsNumber() &&253         "Number of dependent inits is not the same as the collapsed number");254  llvm::copy(A, getDependentInits().begin());255}256 257void OMPLoopDirective::setFinalsConditions(ArrayRef<Expr *> A) {258  assert(A.size() == getLoopsNumber() &&259         "Number of finals conditions is not the same as the collapsed number");260  llvm::copy(A, getFinalsConditions().begin());261}262 263OMPMetaDirective *OMPMetaDirective::Create(const ASTContext &C,264                                           SourceLocation StartLoc,265                                           SourceLocation EndLoc,266                                           ArrayRef<OMPClause *> Clauses,267                                           Stmt *AssociatedStmt, Stmt *IfStmt) {268  auto *Dir = createDirective<OMPMetaDirective>(269      C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);270  Dir->setIfStmt(IfStmt);271  return Dir;272}273 274OMPMetaDirective *OMPMetaDirective::CreateEmpty(const ASTContext &C,275                                                unsigned NumClauses,276                                                EmptyShell) {277  return createEmptyDirective<OMPMetaDirective>(C, NumClauses,278                                                /*HasAssociatedStmt=*/true,279                                                /*NumChildren=*/1);280}281 282OMPParallelDirective *OMPParallelDirective::Create(283    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,284    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,285    bool HasCancel) {286  auto *Dir = createDirective<OMPParallelDirective>(287      C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);288  Dir->setTaskReductionRefExpr(TaskRedRef);289  Dir->setHasCancel(HasCancel);290  return Dir;291}292 293OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C,294                                                        unsigned NumClauses,295                                                        EmptyShell) {296  return createEmptyDirective<OMPParallelDirective>(C, NumClauses,297                                                    /*HasAssociatedStmt=*/true,298                                                    /*NumChildren=*/1);299}300 301OMPSimdDirective *302OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,303                         SourceLocation EndLoc, unsigned CollapsedNum,304                         ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,305                         const HelperExprs &Exprs) {306  auto *Dir = createDirective<OMPSimdDirective>(307      C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_simd),308      StartLoc, EndLoc, CollapsedNum);309  Dir->setIterationVariable(Exprs.IterationVarRef);310  Dir->setLastIteration(Exprs.LastIteration);311  Dir->setCalcLastIteration(Exprs.CalcLastIteration);312  Dir->setPreCond(Exprs.PreCond);313  Dir->setCond(Exprs.Cond);314  Dir->setInit(Exprs.Init);315  Dir->setInc(Exprs.Inc);316  Dir->setCounters(Exprs.Counters);317  Dir->setPrivateCounters(Exprs.PrivateCounters);318  Dir->setInits(Exprs.Inits);319  Dir->setUpdates(Exprs.Updates);320  Dir->setFinals(Exprs.Finals);321  Dir->setDependentCounters(Exprs.DependentCounters);322  Dir->setDependentInits(Exprs.DependentInits);323  Dir->setFinalsConditions(Exprs.FinalsConditions);324  Dir->setPreInits(Exprs.PreInits);325  return Dir;326}327 328OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C,329                                                unsigned NumClauses,330                                                unsigned CollapsedNum,331                                                EmptyShell) {332  return createEmptyDirective<OMPSimdDirective>(333      C, NumClauses, /*HasAssociatedStmt=*/true,334      numLoopChildren(CollapsedNum, OMPD_simd), CollapsedNum);335}336 337OMPForDirective *OMPForDirective::Create(338    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,339    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,340    const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {341  auto *Dir = createDirective<OMPForDirective>(342      C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_for) + 1,343      StartLoc, EndLoc, CollapsedNum);344  Dir->setIterationVariable(Exprs.IterationVarRef);345  Dir->setLastIteration(Exprs.LastIteration);346  Dir->setCalcLastIteration(Exprs.CalcLastIteration);347  Dir->setPreCond(Exprs.PreCond);348  Dir->setCond(Exprs.Cond);349  Dir->setInit(Exprs.Init);350  Dir->setInc(Exprs.Inc);351  Dir->setIsLastIterVariable(Exprs.IL);352  Dir->setLowerBoundVariable(Exprs.LB);353  Dir->setUpperBoundVariable(Exprs.UB);354  Dir->setStrideVariable(Exprs.ST);355  Dir->setEnsureUpperBound(Exprs.EUB);356  Dir->setNextLowerBound(Exprs.NLB);357  Dir->setNextUpperBound(Exprs.NUB);358  Dir->setNumIterations(Exprs.NumIterations);359  Dir->setCounters(Exprs.Counters);360  Dir->setPrivateCounters(Exprs.PrivateCounters);361  Dir->setInits(Exprs.Inits);362  Dir->setUpdates(Exprs.Updates);363  Dir->setFinals(Exprs.Finals);364  Dir->setDependentCounters(Exprs.DependentCounters);365  Dir->setDependentInits(Exprs.DependentInits);366  Dir->setFinalsConditions(Exprs.FinalsConditions);367  Dir->setPreInits(Exprs.PreInits);368  Dir->setTaskReductionRefExpr(TaskRedRef);369  Dir->setHasCancel(HasCancel);370  return Dir;371}372 373Stmt *OMPLoopTransformationDirective::getTransformedStmt() const {374  if (auto *D = dyn_cast<OMPCanonicalLoopNestTransformationDirective>(S))375    return D->getTransformedStmt();376  if (auto *D = dyn_cast<OMPCanonicalLoopSequenceTransformationDirective>(S))377    return D->getTransformedStmt();378  llvm_unreachable("unexpected object type");379}380 381Stmt *OMPLoopTransformationDirective::getPreInits() const {382  if (auto *D = dyn_cast<OMPCanonicalLoopNestTransformationDirective>(S))383    return D->getPreInits();384  if (auto *D = dyn_cast<OMPCanonicalLoopSequenceTransformationDirective>(S))385    return D->getPreInits();386  llvm_unreachable("unexpected object type");387}388 389Stmt *OMPCanonicalLoopNestTransformationDirective::getTransformedStmt() const {390  switch (getStmtClass()) {391#define STMT(CLASS, PARENT)392#define ABSTRACT_STMT(CLASS)393#define OMPCANONICALLOOPNESTTRANSFORMATIONDIRECTIVE(CLASS, PARENT)             \394  case Stmt::CLASS##Class:                                                     \395    return static_cast<const CLASS *>(this)->getTransformedStmt();396#include "clang/AST/StmtNodes.inc"397  default:398    llvm_unreachable("Not a loop transformation for canonical loop nests");399  }400}401 402Stmt *OMPCanonicalLoopNestTransformationDirective::getPreInits() const {403  switch (getStmtClass()) {404#define STMT(CLASS, PARENT)405#define ABSTRACT_STMT(CLASS)406#define OMPCANONICALLOOPNESTTRANSFORMATIONDIRECTIVE(CLASS, PARENT)             \407  case Stmt::CLASS##Class:                                                     \408    return static_cast<const CLASS *>(this)->getPreInits();409#include "clang/AST/StmtNodes.inc"410  default:411    llvm_unreachable("Not a loop transformation for canonical loop nests");412  }413}414 415Stmt *416OMPCanonicalLoopSequenceTransformationDirective::getTransformedStmt() const {417  switch (getStmtClass()) {418#define STMT(CLASS, PARENT)419#define ABSTRACT_STMT(CLASS)420#define OMPCANONICALLOOPSEQUENCETRANSFORMATIONDIRECTIVE(CLASS, PARENT)         \421  case Stmt::CLASS##Class:                                                     \422    return static_cast<const CLASS *>(this)->getTransformedStmt();423#include "clang/AST/StmtNodes.inc"424  default:425    llvm_unreachable("Not a loop transformation for canonical loop sequences");426  }427}428 429Stmt *OMPCanonicalLoopSequenceTransformationDirective::getPreInits() const {430  switch (getStmtClass()) {431#define STMT(CLASS, PARENT)432#define ABSTRACT_STMT(CLASS)433#define OMPCANONICALLOOPSEQUENCETRANSFORMATIONDIRECTIVE(CLASS, PARENT)         \434  case Stmt::CLASS##Class:                                                     \435    return static_cast<const CLASS *>(this)->getPreInits();436#include "clang/AST/StmtNodes.inc"437  default:438    llvm_unreachable("Not a loop transformation for canonical loop sequences");439  }440}441 442OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C,443                                              unsigned NumClauses,444                                              unsigned CollapsedNum,445                                              EmptyShell) {446  return createEmptyDirective<OMPForDirective>(447      C, NumClauses, /*HasAssociatedStmt=*/true,448      numLoopChildren(CollapsedNum, OMPD_for) + 1, CollapsedNum);449}450 451OMPTileDirective *452OMPTileDirective::Create(const ASTContext &C, SourceLocation StartLoc,453                         SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,454                         unsigned NumLoops, Stmt *AssociatedStmt,455                         Stmt *TransformedStmt, Stmt *PreInits) {456  OMPTileDirective *Dir = createDirective<OMPTileDirective>(457      C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc,458      NumLoops);459  Dir->setTransformedStmt(TransformedStmt);460  Dir->setPreInits(PreInits);461  return Dir;462}463 464OMPTileDirective *OMPTileDirective::CreateEmpty(const ASTContext &C,465                                                unsigned NumClauses,466                                                unsigned NumLoops) {467  return createEmptyDirective<OMPTileDirective>(468      C, NumClauses, /*HasAssociatedStmt=*/true, TransformedStmtOffset + 1,469      SourceLocation(), SourceLocation(), NumLoops);470}471 472OMPStripeDirective *473OMPStripeDirective::Create(const ASTContext &C, SourceLocation StartLoc,474                           SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,475                           unsigned NumLoops, Stmt *AssociatedStmt,476                           Stmt *TransformedStmt, Stmt *PreInits) {477  OMPStripeDirective *Dir = createDirective<OMPStripeDirective>(478      C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc,479      NumLoops);480  Dir->setTransformedStmt(TransformedStmt);481  Dir->setPreInits(PreInits);482  return Dir;483}484 485OMPStripeDirective *OMPStripeDirective::CreateEmpty(const ASTContext &C,486                                                    unsigned NumClauses,487                                                    unsigned NumLoops) {488  return createEmptyDirective<OMPStripeDirective>(489      C, NumClauses, /*HasAssociatedStmt=*/true, TransformedStmtOffset + 1,490      SourceLocation(), SourceLocation(), NumLoops);491}492 493OMPUnrollDirective *OMPUnrollDirective::Create(494    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,495    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,496    unsigned NumGeneratedTopLevelLoops, Stmt *TransformedStmt, Stmt *PreInits) {497  assert(NumGeneratedTopLevelLoops <= 1 &&498         "Unrolling generates at most one loop");499 500  auto *Dir = createDirective<OMPUnrollDirective>(501      C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc);502  Dir->setNumGeneratedTopLevelLoops(NumGeneratedTopLevelLoops);503  Dir->setTransformedStmt(TransformedStmt);504  Dir->setPreInits(PreInits);505  return Dir;506}507 508OMPUnrollDirective *OMPUnrollDirective::CreateEmpty(const ASTContext &C,509                                                    unsigned NumClauses) {510  return createEmptyDirective<OMPUnrollDirective>(511      C, NumClauses, /*HasAssociatedStmt=*/true, TransformedStmtOffset + 1,512      SourceLocation(), SourceLocation());513}514 515OMPReverseDirective *516OMPReverseDirective::Create(const ASTContext &C, SourceLocation StartLoc,517                            SourceLocation EndLoc, Stmt *AssociatedStmt,518                            unsigned NumLoops, Stmt *TransformedStmt,519                            Stmt *PreInits) {520  OMPReverseDirective *Dir = createDirective<OMPReverseDirective>(521      C, {}, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc,522      NumLoops);523  Dir->setTransformedStmt(TransformedStmt);524  Dir->setPreInits(PreInits);525  return Dir;526}527 528OMPReverseDirective *OMPReverseDirective::CreateEmpty(const ASTContext &C,529                                                      unsigned NumLoops) {530  return createEmptyDirective<OMPReverseDirective>(531      C, /*NumClauses=*/0, /*HasAssociatedStmt=*/true,532      TransformedStmtOffset + 1, SourceLocation(), SourceLocation(), NumLoops);533}534 535OMPInterchangeDirective *OMPInterchangeDirective::Create(536    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,537    ArrayRef<OMPClause *> Clauses, unsigned NumLoops, Stmt *AssociatedStmt,538    Stmt *TransformedStmt, Stmt *PreInits) {539  OMPInterchangeDirective *Dir = createDirective<OMPInterchangeDirective>(540      C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc,541      NumLoops);542  Dir->setTransformedStmt(TransformedStmt);543  Dir->setPreInits(PreInits);544  return Dir;545}546 547OMPInterchangeDirective *548OMPInterchangeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,549                                     unsigned NumLoops) {550  return createEmptyDirective<OMPInterchangeDirective>(551      C, NumClauses, /*HasAssociatedStmt=*/true, TransformedStmtOffset + 1,552      SourceLocation(), SourceLocation(), NumLoops);553}554 555OMPFuseDirective *OMPFuseDirective::Create(556    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,557    ArrayRef<OMPClause *> Clauses, unsigned NumGeneratedTopLevelLoops,558    Stmt *AssociatedStmt, Stmt *TransformedStmt, Stmt *PreInits) {559 560  OMPFuseDirective *Dir = createDirective<OMPFuseDirective>(561      C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc);562  Dir->setTransformedStmt(TransformedStmt);563  Dir->setPreInits(PreInits);564  Dir->setNumGeneratedTopLevelLoops(NumGeneratedTopLevelLoops);565  return Dir;566}567 568OMPFuseDirective *OMPFuseDirective::CreateEmpty(const ASTContext &C,569                                                unsigned NumClauses) {570  OMPFuseDirective *Dir = createEmptyDirective<OMPFuseDirective>(571      C, NumClauses, /*HasAssociatedStmt=*/true, TransformedStmtOffset + 1,572      SourceLocation(), SourceLocation());573  return Dir;574}575 576OMPForSimdDirective *577OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,578                            SourceLocation EndLoc, unsigned CollapsedNum,579                            ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,580                            const HelperExprs &Exprs) {581  auto *Dir = createDirective<OMPForSimdDirective>(582      C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_for_simd),583      StartLoc, EndLoc, CollapsedNum);584  Dir->setIterationVariable(Exprs.IterationVarRef);585  Dir->setLastIteration(Exprs.LastIteration);586  Dir->setCalcLastIteration(Exprs.CalcLastIteration);587  Dir->setPreCond(Exprs.PreCond);588  Dir->setCond(Exprs.Cond);589  Dir->setInit(Exprs.Init);590  Dir->setInc(Exprs.Inc);591  Dir->setIsLastIterVariable(Exprs.IL);592  Dir->setLowerBoundVariable(Exprs.LB);593  Dir->setUpperBoundVariable(Exprs.UB);594  Dir->setStrideVariable(Exprs.ST);595  Dir->setEnsureUpperBound(Exprs.EUB);596  Dir->setNextLowerBound(Exprs.NLB);597  Dir->setNextUpperBound(Exprs.NUB);598  Dir->setNumIterations(Exprs.NumIterations);599  Dir->setCounters(Exprs.Counters);600  Dir->setPrivateCounters(Exprs.PrivateCounters);601  Dir->setInits(Exprs.Inits);602  Dir->setUpdates(Exprs.Updates);603  Dir->setFinals(Exprs.Finals);604  Dir->setDependentCounters(Exprs.DependentCounters);605  Dir->setDependentInits(Exprs.DependentInits);606  Dir->setFinalsConditions(Exprs.FinalsConditions);607  Dir->setPreInits(Exprs.PreInits);608  return Dir;609}610 611OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C,612                                                      unsigned NumClauses,613                                                      unsigned CollapsedNum,614                                                      EmptyShell) {615  return createEmptyDirective<OMPForSimdDirective>(616      C, NumClauses, /*HasAssociatedStmt=*/true,617      numLoopChildren(CollapsedNum, OMPD_for_simd), CollapsedNum);618}619 620OMPSectionsDirective *OMPSectionsDirective::Create(621    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,622    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,623    bool HasCancel) {624  auto *Dir = createDirective<OMPSectionsDirective>(C, Clauses, AssociatedStmt,625                                                    /*NumChildren=*/1, StartLoc,626                                                    EndLoc);627  Dir->setTaskReductionRefExpr(TaskRedRef);628  Dir->setHasCancel(HasCancel);629  return Dir;630}631 632OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C,633                                                        unsigned NumClauses,634                                                        EmptyShell) {635  return createEmptyDirective<OMPSectionsDirective>(C, NumClauses,636                                                    /*HasAssociatedStmt=*/true,637                                                    /*NumChildren=*/1);638}639 640OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C,641                                                 SourceLocation StartLoc,642                                                 SourceLocation EndLoc,643                                                 Stmt *AssociatedStmt,644                                                 bool HasCancel) {645  auto *Dir =646      createDirective<OMPSectionDirective>(C, {}, AssociatedStmt,647                                           /*NumChildren=*/0, StartLoc, EndLoc);648  Dir->setHasCancel(HasCancel);649  return Dir;650}651 652OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,653                                                      EmptyShell) {654  return createEmptyDirective<OMPSectionDirective>(C, /*NumClauses=*/0,655                                                   /*HasAssociatedStmt=*/true);656}657 658OMPScopeDirective *OMPScopeDirective::Create(const ASTContext &C,659                                             SourceLocation StartLoc,660                                             SourceLocation EndLoc,661                                             ArrayRef<OMPClause *> Clauses,662                                             Stmt *AssociatedStmt) {663  return createDirective<OMPScopeDirective>(C, Clauses, AssociatedStmt,664                                            /*NumChildren=*/0, StartLoc,665                                            EndLoc);666}667 668OMPScopeDirective *OMPScopeDirective::CreateEmpty(const ASTContext &C,669                                                  unsigned NumClauses,670                                                  EmptyShell) {671  return createEmptyDirective<OMPScopeDirective>(C, NumClauses,672                                                 /*HasAssociatedStmt=*/true);673}674 675OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,676                                               SourceLocation StartLoc,677                                               SourceLocation EndLoc,678                                               ArrayRef<OMPClause *> Clauses,679                                               Stmt *AssociatedStmt) {680  return createDirective<OMPSingleDirective>(C, Clauses, AssociatedStmt,681                                             /*NumChildren=*/0, StartLoc,682                                             EndLoc);683}684 685OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,686                                                    unsigned NumClauses,687                                                    EmptyShell) {688  return createEmptyDirective<OMPSingleDirective>(C, NumClauses,689                                                  /*HasAssociatedStmt=*/true);690}691 692OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C,693                                               SourceLocation StartLoc,694                                               SourceLocation EndLoc,695                                               Stmt *AssociatedStmt) {696  return createDirective<OMPMasterDirective>(C, {}, AssociatedStmt,697                                             /*NumChildren=*/0, StartLoc,698                                             EndLoc);699}700 701OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C,702                                                    EmptyShell) {703  return createEmptyDirective<OMPMasterDirective>(C, /*NumClauses=*/0,704                                                  /*HasAssociatedStmt=*/true);705}706 707OMPCriticalDirective *OMPCriticalDirective::Create(708    const ASTContext &C, const DeclarationNameInfo &Name,709    SourceLocation StartLoc, SourceLocation EndLoc,710    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {711  return createDirective<OMPCriticalDirective>(C, Clauses, AssociatedStmt,712                                               /*NumChildren=*/0, Name,713                                               StartLoc, EndLoc);714}715 716OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C,717                                                        unsigned NumClauses,718                                                        EmptyShell) {719  return createEmptyDirective<OMPCriticalDirective>(C, NumClauses,720                                                    /*HasAssociatedStmt=*/true);721}722 723OMPParallelForDirective *OMPParallelForDirective::Create(724    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,725    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,726    const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {727  auto *Dir = createDirective<OMPParallelForDirective>(728      C, Clauses, AssociatedStmt,729      numLoopChildren(CollapsedNum, OMPD_parallel_for) + 1, StartLoc, EndLoc,730      CollapsedNum);731  Dir->setIterationVariable(Exprs.IterationVarRef);732  Dir->setLastIteration(Exprs.LastIteration);733  Dir->setCalcLastIteration(Exprs.CalcLastIteration);734  Dir->setPreCond(Exprs.PreCond);735  Dir->setCond(Exprs.Cond);736  Dir->setInit(Exprs.Init);737  Dir->setInc(Exprs.Inc);738  Dir->setIsLastIterVariable(Exprs.IL);739  Dir->setLowerBoundVariable(Exprs.LB);740  Dir->setUpperBoundVariable(Exprs.UB);741  Dir->setStrideVariable(Exprs.ST);742  Dir->setEnsureUpperBound(Exprs.EUB);743  Dir->setNextLowerBound(Exprs.NLB);744  Dir->setNextUpperBound(Exprs.NUB);745  Dir->setNumIterations(Exprs.NumIterations);746  Dir->setCounters(Exprs.Counters);747  Dir->setPrivateCounters(Exprs.PrivateCounters);748  Dir->setInits(Exprs.Inits);749  Dir->setUpdates(Exprs.Updates);750  Dir->setFinals(Exprs.Finals);751  Dir->setDependentCounters(Exprs.DependentCounters);752  Dir->setDependentInits(Exprs.DependentInits);753  Dir->setFinalsConditions(Exprs.FinalsConditions);754  Dir->setPreInits(Exprs.PreInits);755  Dir->setTaskReductionRefExpr(TaskRedRef);756  Dir->setHasCancel(HasCancel);757  return Dir;758}759 760OMPParallelForDirective *761OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,762                                     unsigned CollapsedNum, EmptyShell) {763  return createEmptyDirective<OMPParallelForDirective>(764      C, NumClauses, /*HasAssociatedStmt=*/true,765      numLoopChildren(CollapsedNum, OMPD_parallel_for) + 1, CollapsedNum);766}767 768OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create(769    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,770    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,771    const HelperExprs &Exprs) {772  auto *Dir = createDirective<OMPParallelForSimdDirective>(773      C, Clauses, AssociatedStmt,774      numLoopChildren(CollapsedNum, OMPD_parallel_for_simd), StartLoc, EndLoc,775      CollapsedNum);776  Dir->setIterationVariable(Exprs.IterationVarRef);777  Dir->setLastIteration(Exprs.LastIteration);778  Dir->setCalcLastIteration(Exprs.CalcLastIteration);779  Dir->setPreCond(Exprs.PreCond);780  Dir->setCond(Exprs.Cond);781  Dir->setInit(Exprs.Init);782  Dir->setInc(Exprs.Inc);783  Dir->setIsLastIterVariable(Exprs.IL);784  Dir->setLowerBoundVariable(Exprs.LB);785  Dir->setUpperBoundVariable(Exprs.UB);786  Dir->setStrideVariable(Exprs.ST);787  Dir->setEnsureUpperBound(Exprs.EUB);788  Dir->setNextLowerBound(Exprs.NLB);789  Dir->setNextUpperBound(Exprs.NUB);790  Dir->setNumIterations(Exprs.NumIterations);791  Dir->setCounters(Exprs.Counters);792  Dir->setPrivateCounters(Exprs.PrivateCounters);793  Dir->setInits(Exprs.Inits);794  Dir->setUpdates(Exprs.Updates);795  Dir->setFinals(Exprs.Finals);796  Dir->setDependentCounters(Exprs.DependentCounters);797  Dir->setDependentInits(Exprs.DependentInits);798  Dir->setFinalsConditions(Exprs.FinalsConditions);799  Dir->setPreInits(Exprs.PreInits);800  return Dir;801}802 803OMPParallelForSimdDirective *804OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C,805                                         unsigned NumClauses,806                                         unsigned CollapsedNum, EmptyShell) {807  return createEmptyDirective<OMPParallelForSimdDirective>(808      C, NumClauses, /*HasAssociatedStmt=*/true,809      numLoopChildren(CollapsedNum, OMPD_parallel_for_simd), CollapsedNum);810}811 812OMPParallelMasterDirective *OMPParallelMasterDirective::Create(813    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,814    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef) {815  auto *Dir = createDirective<OMPParallelMasterDirective>(816      C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);817  Dir->setTaskReductionRefExpr(TaskRedRef);818  return Dir;819}820 821OMPParallelMasterDirective *822OMPParallelMasterDirective::CreateEmpty(const ASTContext &C,823                                        unsigned NumClauses, EmptyShell) {824  return createEmptyDirective<OMPParallelMasterDirective>(825      C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);826}827 828OMPParallelMaskedDirective *OMPParallelMaskedDirective::Create(829    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,830    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef) {831  auto *Dir = createDirective<OMPParallelMaskedDirective>(832      C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);833  Dir->setTaskReductionRefExpr(TaskRedRef);834  return Dir;835}836 837OMPParallelMaskedDirective *838OMPParallelMaskedDirective::CreateEmpty(const ASTContext &C,839                                        unsigned NumClauses, EmptyShell) {840  return createEmptyDirective<OMPParallelMaskedDirective>(841      C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);842}843 844OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(845    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,846    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,847    bool HasCancel) {848  auto *Dir = createDirective<OMPParallelSectionsDirective>(849      C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);850  Dir->setTaskReductionRefExpr(TaskRedRef);851  Dir->setHasCancel(HasCancel);852  return Dir;853}854 855OMPParallelSectionsDirective *856OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,857                                          unsigned NumClauses, EmptyShell) {858  return createEmptyDirective<OMPParallelSectionsDirective>(859      C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);860}861 862OMPTaskDirective *863OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc,864                         SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,865                         Stmt *AssociatedStmt, bool HasCancel) {866  auto *Dir = createDirective<OMPTaskDirective>(867      C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);868  Dir->setHasCancel(HasCancel);869  return Dir;870}871 872OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C,873                                                unsigned NumClauses,874                                                EmptyShell) {875  return createEmptyDirective<OMPTaskDirective>(C, NumClauses,876                                                /*HasAssociatedStmt=*/true);877}878 879OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C,880                                                     SourceLocation StartLoc,881                                                     SourceLocation EndLoc) {882  return new (C) OMPTaskyieldDirective(StartLoc, EndLoc);883}884 885OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C,886                                                          EmptyShell) {887  return new (C) OMPTaskyieldDirective();888}889 890OMPAssumeDirective *OMPAssumeDirective::Create(const ASTContext &C,891                                               SourceLocation StartLoc,892                                               SourceLocation EndLoc,893                                               ArrayRef<OMPClause *> Clauses,894                                               Stmt *AStmt) {895  return createDirective<OMPAssumeDirective>(C, Clauses, AStmt,896                                             /*NumChildren=*/0, StartLoc,897                                             EndLoc);898}899 900OMPAssumeDirective *OMPAssumeDirective::CreateEmpty(const ASTContext &C,901                                                    unsigned NumClauses,902                                                    EmptyShell) {903  return createEmptyDirective<OMPAssumeDirective>(C, NumClauses,904                                                  /*HasAssociatedStmt=*/true);905}906 907OMPErrorDirective *OMPErrorDirective::Create(const ASTContext &C,908                                             SourceLocation StartLoc,909                                             SourceLocation EndLoc,910                                             ArrayRef<OMPClause *> Clauses) {911  return createDirective<OMPErrorDirective>(912      C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,913      EndLoc);914}915 916OMPErrorDirective *OMPErrorDirective::CreateEmpty(const ASTContext &C,917                                                  unsigned NumClauses,918                                                  EmptyShell) {919  return createEmptyDirective<OMPErrorDirective>(C, NumClauses);920}921 922OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,923                                                 SourceLocation StartLoc,924                                                 SourceLocation EndLoc) {925  return new (C) OMPBarrierDirective(StartLoc, EndLoc);926}927 928OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,929                                                      EmptyShell) {930  return new (C) OMPBarrierDirective();931}932 933OMPTaskwaitDirective *934OMPTaskwaitDirective::Create(const ASTContext &C, SourceLocation StartLoc,935                             SourceLocation EndLoc,936                             ArrayRef<OMPClause *> Clauses) {937  return createDirective<OMPTaskwaitDirective>(938      C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,939      EndLoc);940}941 942OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,943                                                        unsigned NumClauses,944                                                        EmptyShell) {945  return createEmptyDirective<OMPTaskwaitDirective>(C, NumClauses);946}947 948OMPTaskgroupDirective *OMPTaskgroupDirective::Create(949    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,950    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) {951  auto *Dir = createDirective<OMPTaskgroupDirective>(952      C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);953  Dir->setReductionRef(ReductionRef);954  return Dir;955}956 957OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C,958                                                          unsigned NumClauses,959                                                          EmptyShell) {960  return createEmptyDirective<OMPTaskgroupDirective>(961      C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);962}963 964OMPCancellationPointDirective *OMPCancellationPointDirective::Create(965    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,966    OpenMPDirectiveKind CancelRegion) {967  auto *Dir = new (C) OMPCancellationPointDirective(StartLoc, EndLoc);968  Dir->setCancelRegion(CancelRegion);969  return Dir;970}971 972OMPCancellationPointDirective *973OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) {974  return new (C) OMPCancellationPointDirective();975}976 977OMPCancelDirective *978OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc,979                           SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,980                           OpenMPDirectiveKind CancelRegion) {981  auto *Dir = createDirective<OMPCancelDirective>(982      C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,983      EndLoc);984  Dir->setCancelRegion(CancelRegion);985  return Dir;986}987 988OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C,989                                                    unsigned NumClauses,990                                                    EmptyShell) {991  return createEmptyDirective<OMPCancelDirective>(C, NumClauses);992}993 994OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C,995                                             SourceLocation StartLoc,996                                             SourceLocation EndLoc,997                                             ArrayRef<OMPClause *> Clauses) {998  return createDirective<OMPFlushDirective>(999      C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,1000      EndLoc);1001}1002 1003OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C,1004                                                  unsigned NumClauses,1005                                                  EmptyShell) {1006  return createEmptyDirective<OMPFlushDirective>(C, NumClauses);1007}1008 1009OMPDepobjDirective *OMPDepobjDirective::Create(const ASTContext &C,1010                                               SourceLocation StartLoc,1011                                               SourceLocation EndLoc,1012                                               ArrayRef<OMPClause *> Clauses) {1013  return createDirective<OMPDepobjDirective>(1014      C, Clauses, /*AssociatedStmt=*/nullptr,1015      /*NumChildren=*/0, StartLoc, EndLoc);1016}1017 1018OMPDepobjDirective *OMPDepobjDirective::CreateEmpty(const ASTContext &C,1019                                                    unsigned NumClauses,1020                                                    EmptyShell) {1021  return createEmptyDirective<OMPDepobjDirective>(C, NumClauses);1022}1023 1024OMPScanDirective *OMPScanDirective::Create(const ASTContext &C,1025                                           SourceLocation StartLoc,1026                                           SourceLocation EndLoc,1027                                           ArrayRef<OMPClause *> Clauses) {1028  return createDirective<OMPScanDirective>(C, Clauses,1029                                           /*AssociatedStmt=*/nullptr,1030                                           /*NumChildren=*/0, StartLoc, EndLoc);1031}1032 1033OMPScanDirective *OMPScanDirective::CreateEmpty(const ASTContext &C,1034                                                unsigned NumClauses,1035                                                EmptyShell) {1036  return createEmptyDirective<OMPScanDirective>(C, NumClauses);1037}1038 1039OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C,1040                                                 SourceLocation StartLoc,1041                                                 SourceLocation EndLoc,1042                                                 ArrayRef<OMPClause *> Clauses,1043                                                 Stmt *AssociatedStmt) {1044  return createDirective<OMPOrderedDirective>(1045      C, Clauses, cast_or_null<CapturedStmt>(AssociatedStmt),1046      /*NumChildren=*/0, StartLoc, EndLoc);1047}1048 1049OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C,1050                                                      unsigned NumClauses,1051                                                      bool IsStandalone,1052                                                      EmptyShell) {1053  return createEmptyDirective<OMPOrderedDirective>(C, NumClauses,1054                                                   !IsStandalone);1055}1056 1057OMPAtomicDirective *1058OMPAtomicDirective::Create(const ASTContext &C, SourceLocation StartLoc,1059                           SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,1060                           Stmt *AssociatedStmt, Expressions Exprs) {1061  auto *Dir = createDirective<OMPAtomicDirective>(1062      C, Clauses, AssociatedStmt, /*NumChildren=*/7, StartLoc, EndLoc);1063  Dir->setX(Exprs.X);1064  Dir->setV(Exprs.V);1065  Dir->setR(Exprs.R);1066  Dir->setExpr(Exprs.E);1067  Dir->setUpdateExpr(Exprs.UE);1068  Dir->setD(Exprs.D);1069  Dir->setCond(Exprs.Cond);1070  Dir->Flags.IsXLHSInRHSPart = Exprs.IsXLHSInRHSPart ? 1 : 0;1071  Dir->Flags.IsPostfixUpdate = Exprs.IsPostfixUpdate ? 1 : 0;1072  Dir->Flags.IsFailOnly = Exprs.IsFailOnly ? 1 : 0;1073  return Dir;1074}1075 1076OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,1077                                                    unsigned NumClauses,1078                                                    EmptyShell) {1079  return createEmptyDirective<OMPAtomicDirective>(1080      C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/7);1081}1082 1083OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,1084                                               SourceLocation StartLoc,1085                                               SourceLocation EndLoc,1086                                               ArrayRef<OMPClause *> Clauses,1087                                               Stmt *AssociatedStmt) {1088  return createDirective<OMPTargetDirective>(1089      C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);1090}1091 1092OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,1093                                                    unsigned NumClauses,1094                                                    EmptyShell) {1095  return createEmptyDirective<OMPTargetDirective>(C, NumClauses,1096                                                  /*HasAssociatedStmt=*/true);1097}1098 1099OMPTargetParallelDirective *OMPTargetParallelDirective::Create(1100    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1101    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,1102    bool HasCancel) {1103  auto *Dir = createDirective<OMPTargetParallelDirective>(1104      C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);1105  Dir->setTaskReductionRefExpr(TaskRedRef);1106  Dir->setHasCancel(HasCancel);1107  return Dir;1108}1109 1110OMPTargetParallelDirective *1111OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,1112                                        unsigned NumClauses, EmptyShell) {1113  return createEmptyDirective<OMPTargetParallelDirective>(1114      C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);1115}1116 1117OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(1118    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1119    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1120    const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {1121  auto *Dir = createDirective<OMPTargetParallelForDirective>(1122      C, Clauses, AssociatedStmt,1123      numLoopChildren(CollapsedNum, OMPD_target_parallel_for) + 1, StartLoc,1124      EndLoc, CollapsedNum);1125  Dir->setIterationVariable(Exprs.IterationVarRef);1126  Dir->setLastIteration(Exprs.LastIteration);1127  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1128  Dir->setPreCond(Exprs.PreCond);1129  Dir->setCond(Exprs.Cond);1130  Dir->setInit(Exprs.Init);1131  Dir->setInc(Exprs.Inc);1132  Dir->setIsLastIterVariable(Exprs.IL);1133  Dir->setLowerBoundVariable(Exprs.LB);1134  Dir->setUpperBoundVariable(Exprs.UB);1135  Dir->setStrideVariable(Exprs.ST);1136  Dir->setEnsureUpperBound(Exprs.EUB);1137  Dir->setNextLowerBound(Exprs.NLB);1138  Dir->setNextUpperBound(Exprs.NUB);1139  Dir->setNumIterations(Exprs.NumIterations);1140  Dir->setCounters(Exprs.Counters);1141  Dir->setPrivateCounters(Exprs.PrivateCounters);1142  Dir->setInits(Exprs.Inits);1143  Dir->setUpdates(Exprs.Updates);1144  Dir->setFinals(Exprs.Finals);1145  Dir->setDependentCounters(Exprs.DependentCounters);1146  Dir->setDependentInits(Exprs.DependentInits);1147  Dir->setFinalsConditions(Exprs.FinalsConditions);1148  Dir->setPreInits(Exprs.PreInits);1149  Dir->setTaskReductionRefExpr(TaskRedRef);1150  Dir->setHasCancel(HasCancel);1151  return Dir;1152}1153 1154OMPTargetParallelForDirective *1155OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,1156                                           unsigned NumClauses,1157                                           unsigned CollapsedNum, EmptyShell) {1158  return createEmptyDirective<OMPTargetParallelForDirective>(1159      C, NumClauses, /*HasAssociatedStmt=*/true,1160      numLoopChildren(CollapsedNum, OMPD_target_parallel_for) + 1,1161      CollapsedNum);1162}1163 1164OMPTargetDataDirective *OMPTargetDataDirective::Create(1165    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1166    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {1167  return createDirective<OMPTargetDataDirective>(1168      C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);1169}1170 1171OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,1172                                                            unsigned N,1173                                                            EmptyShell) {1174  return createEmptyDirective<OMPTargetDataDirective>(1175      C, N, /*HasAssociatedStmt=*/true);1176}1177 1178OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(1179    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1180    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {1181  return createDirective<OMPTargetEnterDataDirective>(1182      C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);1183}1184 1185OMPTargetEnterDataDirective *1186OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,1187                                         EmptyShell) {1188  return createEmptyDirective<OMPTargetEnterDataDirective>(1189      C, N, /*HasAssociatedStmt=*/true);1190}1191 1192OMPTargetExitDataDirective *OMPTargetExitDataDirective::Create(1193    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1194    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {1195  return createDirective<OMPTargetExitDataDirective>(1196      C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);1197}1198 1199OMPTargetExitDataDirective *1200OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,1201                                        EmptyShell) {1202  return createEmptyDirective<OMPTargetExitDataDirective>(1203      C, N, /*HasAssociatedStmt=*/true);1204}1205 1206OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,1207                                             SourceLocation StartLoc,1208                                             SourceLocation EndLoc,1209                                             ArrayRef<OMPClause *> Clauses,1210                                             Stmt *AssociatedStmt) {1211  return createDirective<OMPTeamsDirective>(1212      C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);1213}1214 1215OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,1216                                                  unsigned NumClauses,1217                                                  EmptyShell) {1218  return createEmptyDirective<OMPTeamsDirective>(C, NumClauses,1219                                                 /*HasAssociatedStmt=*/true);1220}1221 1222OMPTaskLoopDirective *OMPTaskLoopDirective::Create(1223    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1224    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1225    const HelperExprs &Exprs, bool HasCancel) {1226  auto *Dir = createDirective<OMPTaskLoopDirective>(1227      C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_taskloop),1228      StartLoc, EndLoc, CollapsedNum);1229  Dir->setIterationVariable(Exprs.IterationVarRef);1230  Dir->setLastIteration(Exprs.LastIteration);1231  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1232  Dir->setPreCond(Exprs.PreCond);1233  Dir->setCond(Exprs.Cond);1234  Dir->setInit(Exprs.Init);1235  Dir->setInc(Exprs.Inc);1236  Dir->setIsLastIterVariable(Exprs.IL);1237  Dir->setLowerBoundVariable(Exprs.LB);1238  Dir->setUpperBoundVariable(Exprs.UB);1239  Dir->setStrideVariable(Exprs.ST);1240  Dir->setEnsureUpperBound(Exprs.EUB);1241  Dir->setNextLowerBound(Exprs.NLB);1242  Dir->setNextUpperBound(Exprs.NUB);1243  Dir->setNumIterations(Exprs.NumIterations);1244  Dir->setCounters(Exprs.Counters);1245  Dir->setPrivateCounters(Exprs.PrivateCounters);1246  Dir->setInits(Exprs.Inits);1247  Dir->setUpdates(Exprs.Updates);1248  Dir->setFinals(Exprs.Finals);1249  Dir->setDependentCounters(Exprs.DependentCounters);1250  Dir->setDependentInits(Exprs.DependentInits);1251  Dir->setFinalsConditions(Exprs.FinalsConditions);1252  Dir->setPreInits(Exprs.PreInits);1253  Dir->setHasCancel(HasCancel);1254  return Dir;1255}1256 1257OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,1258                                                        unsigned NumClauses,1259                                                        unsigned CollapsedNum,1260                                                        EmptyShell) {1261  return createEmptyDirective<OMPTaskLoopDirective>(1262      C, NumClauses, /*HasAssociatedStmt=*/true,1263      numLoopChildren(CollapsedNum, OMPD_taskloop), CollapsedNum);1264}1265 1266OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(1267    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1268    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1269    const HelperExprs &Exprs) {1270  auto *Dir = createDirective<OMPTaskLoopSimdDirective>(1271      C, Clauses, AssociatedStmt,1272      numLoopChildren(CollapsedNum, OMPD_taskloop_simd), StartLoc, EndLoc,1273      CollapsedNum);1274  Dir->setIterationVariable(Exprs.IterationVarRef);1275  Dir->setLastIteration(Exprs.LastIteration);1276  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1277  Dir->setPreCond(Exprs.PreCond);1278  Dir->setCond(Exprs.Cond);1279  Dir->setInit(Exprs.Init);1280  Dir->setInc(Exprs.Inc);1281  Dir->setIsLastIterVariable(Exprs.IL);1282  Dir->setLowerBoundVariable(Exprs.LB);1283  Dir->setUpperBoundVariable(Exprs.UB);1284  Dir->setStrideVariable(Exprs.ST);1285  Dir->setEnsureUpperBound(Exprs.EUB);1286  Dir->setNextLowerBound(Exprs.NLB);1287  Dir->setNextUpperBound(Exprs.NUB);1288  Dir->setNumIterations(Exprs.NumIterations);1289  Dir->setCounters(Exprs.Counters);1290  Dir->setPrivateCounters(Exprs.PrivateCounters);1291  Dir->setInits(Exprs.Inits);1292  Dir->setUpdates(Exprs.Updates);1293  Dir->setFinals(Exprs.Finals);1294  Dir->setDependentCounters(Exprs.DependentCounters);1295  Dir->setDependentInits(Exprs.DependentInits);1296  Dir->setFinalsConditions(Exprs.FinalsConditions);1297  Dir->setPreInits(Exprs.PreInits);1298  return Dir;1299}1300 1301OMPTaskLoopSimdDirective *1302OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,1303                                      unsigned CollapsedNum, EmptyShell) {1304  return createEmptyDirective<OMPTaskLoopSimdDirective>(1305      C, NumClauses, /*HasAssociatedStmt=*/true,1306      numLoopChildren(CollapsedNum, OMPD_taskloop_simd), CollapsedNum);1307}1308 1309OMPMasterTaskLoopDirective *OMPMasterTaskLoopDirective::Create(1310    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1311    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1312    const HelperExprs &Exprs, bool HasCancel) {1313  auto *Dir = createDirective<OMPMasterTaskLoopDirective>(1314      C, Clauses, AssociatedStmt,1315      numLoopChildren(CollapsedNum, OMPD_master_taskloop), StartLoc, EndLoc,1316      CollapsedNum);1317  Dir->setIterationVariable(Exprs.IterationVarRef);1318  Dir->setLastIteration(Exprs.LastIteration);1319  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1320  Dir->setPreCond(Exprs.PreCond);1321  Dir->setCond(Exprs.Cond);1322  Dir->setInit(Exprs.Init);1323  Dir->setInc(Exprs.Inc);1324  Dir->setIsLastIterVariable(Exprs.IL);1325  Dir->setLowerBoundVariable(Exprs.LB);1326  Dir->setUpperBoundVariable(Exprs.UB);1327  Dir->setStrideVariable(Exprs.ST);1328  Dir->setEnsureUpperBound(Exprs.EUB);1329  Dir->setNextLowerBound(Exprs.NLB);1330  Dir->setNextUpperBound(Exprs.NUB);1331  Dir->setNumIterations(Exprs.NumIterations);1332  Dir->setCounters(Exprs.Counters);1333  Dir->setPrivateCounters(Exprs.PrivateCounters);1334  Dir->setInits(Exprs.Inits);1335  Dir->setUpdates(Exprs.Updates);1336  Dir->setFinals(Exprs.Finals);1337  Dir->setDependentCounters(Exprs.DependentCounters);1338  Dir->setDependentInits(Exprs.DependentInits);1339  Dir->setFinalsConditions(Exprs.FinalsConditions);1340  Dir->setPreInits(Exprs.PreInits);1341  Dir->setHasCancel(HasCancel);1342  return Dir;1343}1344 1345OMPMasterTaskLoopDirective *1346OMPMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,1347                                        unsigned NumClauses,1348                                        unsigned CollapsedNum, EmptyShell) {1349  return createEmptyDirective<OMPMasterTaskLoopDirective>(1350      C, NumClauses, /*HasAssociatedStmt=*/true,1351      numLoopChildren(CollapsedNum, OMPD_master_taskloop), CollapsedNum);1352}1353 1354OMPMaskedTaskLoopDirective *OMPMaskedTaskLoopDirective::Create(1355    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1356    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1357    const HelperExprs &Exprs, bool HasCancel) {1358  auto *Dir = createDirective<OMPMaskedTaskLoopDirective>(1359      C, Clauses, AssociatedStmt,1360      numLoopChildren(CollapsedNum, OMPD_masked_taskloop), StartLoc, EndLoc,1361      CollapsedNum);1362  Dir->setIterationVariable(Exprs.IterationVarRef);1363  Dir->setLastIteration(Exprs.LastIteration);1364  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1365  Dir->setPreCond(Exprs.PreCond);1366  Dir->setCond(Exprs.Cond);1367  Dir->setInit(Exprs.Init);1368  Dir->setInc(Exprs.Inc);1369  Dir->setIsLastIterVariable(Exprs.IL);1370  Dir->setLowerBoundVariable(Exprs.LB);1371  Dir->setUpperBoundVariable(Exprs.UB);1372  Dir->setStrideVariable(Exprs.ST);1373  Dir->setEnsureUpperBound(Exprs.EUB);1374  Dir->setNextLowerBound(Exprs.NLB);1375  Dir->setNextUpperBound(Exprs.NUB);1376  Dir->setNumIterations(Exprs.NumIterations);1377  Dir->setCounters(Exprs.Counters);1378  Dir->setPrivateCounters(Exprs.PrivateCounters);1379  Dir->setInits(Exprs.Inits);1380  Dir->setUpdates(Exprs.Updates);1381  Dir->setFinals(Exprs.Finals);1382  Dir->setDependentCounters(Exprs.DependentCounters);1383  Dir->setDependentInits(Exprs.DependentInits);1384  Dir->setFinalsConditions(Exprs.FinalsConditions);1385  Dir->setPreInits(Exprs.PreInits);1386  Dir->setHasCancel(HasCancel);1387  return Dir;1388}1389 1390OMPMaskedTaskLoopDirective *1391OMPMaskedTaskLoopDirective::CreateEmpty(const ASTContext &C,1392                                        unsigned NumClauses,1393                                        unsigned CollapsedNum, EmptyShell) {1394  return createEmptyDirective<OMPMaskedTaskLoopDirective>(1395      C, NumClauses, /*HasAssociatedStmt=*/true,1396      numLoopChildren(CollapsedNum, OMPD_masked_taskloop), CollapsedNum);1397}1398 1399OMPMasterTaskLoopSimdDirective *OMPMasterTaskLoopSimdDirective::Create(1400    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1401    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1402    const HelperExprs &Exprs) {1403  auto *Dir = createDirective<OMPMasterTaskLoopSimdDirective>(1404      C, Clauses, AssociatedStmt,1405      numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd), StartLoc,1406      EndLoc, CollapsedNum);1407  Dir->setIterationVariable(Exprs.IterationVarRef);1408  Dir->setLastIteration(Exprs.LastIteration);1409  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1410  Dir->setPreCond(Exprs.PreCond);1411  Dir->setCond(Exprs.Cond);1412  Dir->setInit(Exprs.Init);1413  Dir->setInc(Exprs.Inc);1414  Dir->setIsLastIterVariable(Exprs.IL);1415  Dir->setLowerBoundVariable(Exprs.LB);1416  Dir->setUpperBoundVariable(Exprs.UB);1417  Dir->setStrideVariable(Exprs.ST);1418  Dir->setEnsureUpperBound(Exprs.EUB);1419  Dir->setNextLowerBound(Exprs.NLB);1420  Dir->setNextUpperBound(Exprs.NUB);1421  Dir->setNumIterations(Exprs.NumIterations);1422  Dir->setCounters(Exprs.Counters);1423  Dir->setPrivateCounters(Exprs.PrivateCounters);1424  Dir->setInits(Exprs.Inits);1425  Dir->setUpdates(Exprs.Updates);1426  Dir->setFinals(Exprs.Finals);1427  Dir->setDependentCounters(Exprs.DependentCounters);1428  Dir->setDependentInits(Exprs.DependentInits);1429  Dir->setFinalsConditions(Exprs.FinalsConditions);1430  Dir->setPreInits(Exprs.PreInits);1431  return Dir;1432}1433 1434OMPMasterTaskLoopSimdDirective *1435OMPMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,1436                                            unsigned NumClauses,1437                                            unsigned CollapsedNum, EmptyShell) {1438  return createEmptyDirective<OMPMasterTaskLoopSimdDirective>(1439      C, NumClauses, /*HasAssociatedStmt=*/true,1440      numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd), CollapsedNum);1441}1442 1443OMPMaskedTaskLoopSimdDirective *OMPMaskedTaskLoopSimdDirective::Create(1444    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1445    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1446    const HelperExprs &Exprs) {1447  auto *Dir = createDirective<OMPMaskedTaskLoopSimdDirective>(1448      C, Clauses, AssociatedStmt,1449      numLoopChildren(CollapsedNum, OMPD_masked_taskloop_simd), StartLoc,1450      EndLoc, CollapsedNum);1451  Dir->setIterationVariable(Exprs.IterationVarRef);1452  Dir->setLastIteration(Exprs.LastIteration);1453  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1454  Dir->setPreCond(Exprs.PreCond);1455  Dir->setCond(Exprs.Cond);1456  Dir->setInit(Exprs.Init);1457  Dir->setInc(Exprs.Inc);1458  Dir->setIsLastIterVariable(Exprs.IL);1459  Dir->setLowerBoundVariable(Exprs.LB);1460  Dir->setUpperBoundVariable(Exprs.UB);1461  Dir->setStrideVariable(Exprs.ST);1462  Dir->setEnsureUpperBound(Exprs.EUB);1463  Dir->setNextLowerBound(Exprs.NLB);1464  Dir->setNextUpperBound(Exprs.NUB);1465  Dir->setNumIterations(Exprs.NumIterations);1466  Dir->setCounters(Exprs.Counters);1467  Dir->setPrivateCounters(Exprs.PrivateCounters);1468  Dir->setInits(Exprs.Inits);1469  Dir->setUpdates(Exprs.Updates);1470  Dir->setFinals(Exprs.Finals);1471  Dir->setDependentCounters(Exprs.DependentCounters);1472  Dir->setDependentInits(Exprs.DependentInits);1473  Dir->setFinalsConditions(Exprs.FinalsConditions);1474  Dir->setPreInits(Exprs.PreInits);1475  return Dir;1476}1477 1478OMPMaskedTaskLoopSimdDirective *1479OMPMaskedTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,1480                                            unsigned NumClauses,1481                                            unsigned CollapsedNum, EmptyShell) {1482  return createEmptyDirective<OMPMaskedTaskLoopSimdDirective>(1483      C, NumClauses, /*HasAssociatedStmt=*/true,1484      numLoopChildren(CollapsedNum, OMPD_masked_taskloop_simd), CollapsedNum);1485}1486 1487OMPParallelMasterTaskLoopDirective *OMPParallelMasterTaskLoopDirective::Create(1488    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1489    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1490    const HelperExprs &Exprs, bool HasCancel) {1491  auto *Dir = createDirective<OMPParallelMasterTaskLoopDirective>(1492      C, Clauses, AssociatedStmt,1493      numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop), StartLoc,1494      EndLoc, CollapsedNum);1495  Dir->setIterationVariable(Exprs.IterationVarRef);1496  Dir->setLastIteration(Exprs.LastIteration);1497  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1498  Dir->setPreCond(Exprs.PreCond);1499  Dir->setCond(Exprs.Cond);1500  Dir->setInit(Exprs.Init);1501  Dir->setInc(Exprs.Inc);1502  Dir->setIsLastIterVariable(Exprs.IL);1503  Dir->setLowerBoundVariable(Exprs.LB);1504  Dir->setUpperBoundVariable(Exprs.UB);1505  Dir->setStrideVariable(Exprs.ST);1506  Dir->setEnsureUpperBound(Exprs.EUB);1507  Dir->setNextLowerBound(Exprs.NLB);1508  Dir->setNextUpperBound(Exprs.NUB);1509  Dir->setNumIterations(Exprs.NumIterations);1510  Dir->setCounters(Exprs.Counters);1511  Dir->setPrivateCounters(Exprs.PrivateCounters);1512  Dir->setInits(Exprs.Inits);1513  Dir->setUpdates(Exprs.Updates);1514  Dir->setFinals(Exprs.Finals);1515  Dir->setDependentCounters(Exprs.DependentCounters);1516  Dir->setDependentInits(Exprs.DependentInits);1517  Dir->setFinalsConditions(Exprs.FinalsConditions);1518  Dir->setPreInits(Exprs.PreInits);1519  Dir->setHasCancel(HasCancel);1520  return Dir;1521}1522 1523OMPParallelMasterTaskLoopDirective *1524OMPParallelMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,1525                                                unsigned NumClauses,1526                                                unsigned CollapsedNum,1527                                                EmptyShell) {1528  return createEmptyDirective<OMPParallelMasterTaskLoopDirective>(1529      C, NumClauses, /*HasAssociatedStmt=*/true,1530      numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop),1531      CollapsedNum);1532}1533 1534OMPParallelMaskedTaskLoopDirective *OMPParallelMaskedTaskLoopDirective::Create(1535    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1536    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1537    const HelperExprs &Exprs, bool HasCancel) {1538  auto *Dir = createDirective<OMPParallelMaskedTaskLoopDirective>(1539      C, Clauses, AssociatedStmt,1540      numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop), StartLoc,1541      EndLoc, CollapsedNum);1542  Dir->setIterationVariable(Exprs.IterationVarRef);1543  Dir->setLastIteration(Exprs.LastIteration);1544  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1545  Dir->setPreCond(Exprs.PreCond);1546  Dir->setCond(Exprs.Cond);1547  Dir->setInit(Exprs.Init);1548  Dir->setInc(Exprs.Inc);1549  Dir->setIsLastIterVariable(Exprs.IL);1550  Dir->setLowerBoundVariable(Exprs.LB);1551  Dir->setUpperBoundVariable(Exprs.UB);1552  Dir->setStrideVariable(Exprs.ST);1553  Dir->setEnsureUpperBound(Exprs.EUB);1554  Dir->setNextLowerBound(Exprs.NLB);1555  Dir->setNextUpperBound(Exprs.NUB);1556  Dir->setNumIterations(Exprs.NumIterations);1557  Dir->setCounters(Exprs.Counters);1558  Dir->setPrivateCounters(Exprs.PrivateCounters);1559  Dir->setInits(Exprs.Inits);1560  Dir->setUpdates(Exprs.Updates);1561  Dir->setFinals(Exprs.Finals);1562  Dir->setDependentCounters(Exprs.DependentCounters);1563  Dir->setDependentInits(Exprs.DependentInits);1564  Dir->setFinalsConditions(Exprs.FinalsConditions);1565  Dir->setPreInits(Exprs.PreInits);1566  Dir->setHasCancel(HasCancel);1567  return Dir;1568}1569 1570OMPParallelMaskedTaskLoopDirective *1571OMPParallelMaskedTaskLoopDirective::CreateEmpty(const ASTContext &C,1572                                                unsigned NumClauses,1573                                                unsigned CollapsedNum,1574                                                EmptyShell) {1575  return createEmptyDirective<OMPParallelMaskedTaskLoopDirective>(1576      C, NumClauses, /*HasAssociatedStmt=*/true,1577      numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop),1578      CollapsedNum);1579}1580 1581OMPParallelMasterTaskLoopSimdDirective *1582OMPParallelMasterTaskLoopSimdDirective::Create(1583    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1584    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1585    const HelperExprs &Exprs) {1586  auto *Dir = createDirective<OMPParallelMasterTaskLoopSimdDirective>(1587      C, Clauses, AssociatedStmt,1588      numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd),1589      StartLoc, EndLoc, CollapsedNum);1590  Dir->setIterationVariable(Exprs.IterationVarRef);1591  Dir->setLastIteration(Exprs.LastIteration);1592  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1593  Dir->setPreCond(Exprs.PreCond);1594  Dir->setCond(Exprs.Cond);1595  Dir->setInit(Exprs.Init);1596  Dir->setInc(Exprs.Inc);1597  Dir->setIsLastIterVariable(Exprs.IL);1598  Dir->setLowerBoundVariable(Exprs.LB);1599  Dir->setUpperBoundVariable(Exprs.UB);1600  Dir->setStrideVariable(Exprs.ST);1601  Dir->setEnsureUpperBound(Exprs.EUB);1602  Dir->setNextLowerBound(Exprs.NLB);1603  Dir->setNextUpperBound(Exprs.NUB);1604  Dir->setNumIterations(Exprs.NumIterations);1605  Dir->setCounters(Exprs.Counters);1606  Dir->setPrivateCounters(Exprs.PrivateCounters);1607  Dir->setInits(Exprs.Inits);1608  Dir->setUpdates(Exprs.Updates);1609  Dir->setFinals(Exprs.Finals);1610  Dir->setDependentCounters(Exprs.DependentCounters);1611  Dir->setDependentInits(Exprs.DependentInits);1612  Dir->setFinalsConditions(Exprs.FinalsConditions);1613  Dir->setPreInits(Exprs.PreInits);1614  return Dir;1615}1616 1617OMPParallelMasterTaskLoopSimdDirective *1618OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,1619                                                    unsigned NumClauses,1620                                                    unsigned CollapsedNum,1621                                                    EmptyShell) {1622  return createEmptyDirective<OMPParallelMasterTaskLoopSimdDirective>(1623      C, NumClauses, /*HasAssociatedStmt=*/true,1624      numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd),1625      CollapsedNum);1626}1627 1628OMPParallelMaskedTaskLoopSimdDirective *1629OMPParallelMaskedTaskLoopSimdDirective::Create(1630    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1631    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1632    const HelperExprs &Exprs) {1633  auto *Dir = createDirective<OMPParallelMaskedTaskLoopSimdDirective>(1634      C, Clauses, AssociatedStmt,1635      numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop_simd),1636      StartLoc, EndLoc, CollapsedNum);1637  Dir->setIterationVariable(Exprs.IterationVarRef);1638  Dir->setLastIteration(Exprs.LastIteration);1639  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1640  Dir->setPreCond(Exprs.PreCond);1641  Dir->setCond(Exprs.Cond);1642  Dir->setInit(Exprs.Init);1643  Dir->setInc(Exprs.Inc);1644  Dir->setIsLastIterVariable(Exprs.IL);1645  Dir->setLowerBoundVariable(Exprs.LB);1646  Dir->setUpperBoundVariable(Exprs.UB);1647  Dir->setStrideVariable(Exprs.ST);1648  Dir->setEnsureUpperBound(Exprs.EUB);1649  Dir->setNextLowerBound(Exprs.NLB);1650  Dir->setNextUpperBound(Exprs.NUB);1651  Dir->setNumIterations(Exprs.NumIterations);1652  Dir->setCounters(Exprs.Counters);1653  Dir->setPrivateCounters(Exprs.PrivateCounters);1654  Dir->setInits(Exprs.Inits);1655  Dir->setUpdates(Exprs.Updates);1656  Dir->setFinals(Exprs.Finals);1657  Dir->setDependentCounters(Exprs.DependentCounters);1658  Dir->setDependentInits(Exprs.DependentInits);1659  Dir->setFinalsConditions(Exprs.FinalsConditions);1660  Dir->setPreInits(Exprs.PreInits);1661  return Dir;1662}1663 1664OMPParallelMaskedTaskLoopSimdDirective *1665OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,1666                                                    unsigned NumClauses,1667                                                    unsigned CollapsedNum,1668                                                    EmptyShell) {1669  return createEmptyDirective<OMPParallelMaskedTaskLoopSimdDirective>(1670      C, NumClauses, /*HasAssociatedStmt=*/true,1671      numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop_simd),1672      CollapsedNum);1673}1674 1675OMPDistributeDirective *1676OMPDistributeDirective::Create(const ASTContext &C, SourceLocation StartLoc,1677                               SourceLocation EndLoc, unsigned CollapsedNum,1678                               ArrayRef<OMPClause *> Clauses,1679                               Stmt *AssociatedStmt, const HelperExprs &Exprs) {1680  auto *Dir = createDirective<OMPDistributeDirective>(1681      C, Clauses, AssociatedStmt,1682      numLoopChildren(CollapsedNum, OMPD_distribute), StartLoc, EndLoc,1683      CollapsedNum);1684  Dir->setIterationVariable(Exprs.IterationVarRef);1685  Dir->setLastIteration(Exprs.LastIteration);1686  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1687  Dir->setPreCond(Exprs.PreCond);1688  Dir->setCond(Exprs.Cond);1689  Dir->setInit(Exprs.Init);1690  Dir->setInc(Exprs.Inc);1691  Dir->setIsLastIterVariable(Exprs.IL);1692  Dir->setLowerBoundVariable(Exprs.LB);1693  Dir->setUpperBoundVariable(Exprs.UB);1694  Dir->setStrideVariable(Exprs.ST);1695  Dir->setEnsureUpperBound(Exprs.EUB);1696  Dir->setNextLowerBound(Exprs.NLB);1697  Dir->setNextUpperBound(Exprs.NUB);1698  Dir->setNumIterations(Exprs.NumIterations);1699  Dir->setCounters(Exprs.Counters);1700  Dir->setPrivateCounters(Exprs.PrivateCounters);1701  Dir->setInits(Exprs.Inits);1702  Dir->setUpdates(Exprs.Updates);1703  Dir->setFinals(Exprs.Finals);1704  Dir->setDependentCounters(Exprs.DependentCounters);1705  Dir->setDependentInits(Exprs.DependentInits);1706  Dir->setFinalsConditions(Exprs.FinalsConditions);1707  Dir->setPreInits(Exprs.PreInits);1708  return Dir;1709}1710 1711OMPDistributeDirective *1712OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,1713                                    unsigned CollapsedNum, EmptyShell) {1714  return createEmptyDirective<OMPDistributeDirective>(1715      C, NumClauses, /*HasAssociatedStmt=*/true,1716      numLoopChildren(CollapsedNum, OMPD_distribute), CollapsedNum);1717}1718 1719OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(1720    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1721    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {1722  return createDirective<OMPTargetUpdateDirective>(C, Clauses, AssociatedStmt,1723                                                   /*NumChildren=*/0, StartLoc,1724                                                   EndLoc);1725}1726 1727OMPTargetUpdateDirective *1728OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,1729                                      EmptyShell) {1730  return createEmptyDirective<OMPTargetUpdateDirective>(1731      C, NumClauses, /*HasAssociatedStmt=*/true);1732}1733 1734OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(1735    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1736    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1737    const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {1738  auto *Dir = createDirective<OMPDistributeParallelForDirective>(1739      C, Clauses, AssociatedStmt,1740      numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for) + 1, StartLoc,1741      EndLoc, CollapsedNum);1742  Dir->setIterationVariable(Exprs.IterationVarRef);1743  Dir->setLastIteration(Exprs.LastIteration);1744  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1745  Dir->setPreCond(Exprs.PreCond);1746  Dir->setCond(Exprs.Cond);1747  Dir->setInit(Exprs.Init);1748  Dir->setInc(Exprs.Inc);1749  Dir->setIsLastIterVariable(Exprs.IL);1750  Dir->setLowerBoundVariable(Exprs.LB);1751  Dir->setUpperBoundVariable(Exprs.UB);1752  Dir->setStrideVariable(Exprs.ST);1753  Dir->setEnsureUpperBound(Exprs.EUB);1754  Dir->setNextLowerBound(Exprs.NLB);1755  Dir->setNextUpperBound(Exprs.NUB);1756  Dir->setNumIterations(Exprs.NumIterations);1757  Dir->setPrevLowerBoundVariable(Exprs.PrevLB);1758  Dir->setPrevUpperBoundVariable(Exprs.PrevUB);1759  Dir->setDistInc(Exprs.DistInc);1760  Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);1761  Dir->setCounters(Exprs.Counters);1762  Dir->setPrivateCounters(Exprs.PrivateCounters);1763  Dir->setInits(Exprs.Inits);1764  Dir->setUpdates(Exprs.Updates);1765  Dir->setFinals(Exprs.Finals);1766  Dir->setDependentCounters(Exprs.DependentCounters);1767  Dir->setDependentInits(Exprs.DependentInits);1768  Dir->setFinalsConditions(Exprs.FinalsConditions);1769  Dir->setPreInits(Exprs.PreInits);1770  Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);1771  Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);1772  Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);1773  Dir->setCombinedInit(Exprs.DistCombinedFields.Init);1774  Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);1775  Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);1776  Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);1777  Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);1778  Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);1779  Dir->setTaskReductionRefExpr(TaskRedRef);1780  Dir->HasCancel = HasCancel;1781  return Dir;1782}1783 1784OMPDistributeParallelForDirective *1785OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,1786                                               unsigned NumClauses,1787                                               unsigned CollapsedNum,1788                                               EmptyShell) {1789  return createEmptyDirective<OMPDistributeParallelForDirective>(1790      C, NumClauses, /*HasAssociatedStmt=*/true,1791      numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for) + 1,1792      CollapsedNum);1793}1794 1795OMPDistributeParallelForSimdDirective *1796OMPDistributeParallelForSimdDirective::Create(1797    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1798    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1799    const HelperExprs &Exprs) {1800  auto *Dir = createDirective<OMPDistributeParallelForSimdDirective>(1801      C, Clauses, AssociatedStmt,1802      numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd),1803      StartLoc, EndLoc, CollapsedNum);1804  Dir->setIterationVariable(Exprs.IterationVarRef);1805  Dir->setLastIteration(Exprs.LastIteration);1806  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1807  Dir->setPreCond(Exprs.PreCond);1808  Dir->setCond(Exprs.Cond);1809  Dir->setInit(Exprs.Init);1810  Dir->setInc(Exprs.Inc);1811  Dir->setIsLastIterVariable(Exprs.IL);1812  Dir->setLowerBoundVariable(Exprs.LB);1813  Dir->setUpperBoundVariable(Exprs.UB);1814  Dir->setStrideVariable(Exprs.ST);1815  Dir->setEnsureUpperBound(Exprs.EUB);1816  Dir->setNextLowerBound(Exprs.NLB);1817  Dir->setNextUpperBound(Exprs.NUB);1818  Dir->setNumIterations(Exprs.NumIterations);1819  Dir->setPrevLowerBoundVariable(Exprs.PrevLB);1820  Dir->setPrevUpperBoundVariable(Exprs.PrevUB);1821  Dir->setDistInc(Exprs.DistInc);1822  Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);1823  Dir->setCounters(Exprs.Counters);1824  Dir->setPrivateCounters(Exprs.PrivateCounters);1825  Dir->setInits(Exprs.Inits);1826  Dir->setUpdates(Exprs.Updates);1827  Dir->setFinals(Exprs.Finals);1828  Dir->setDependentCounters(Exprs.DependentCounters);1829  Dir->setDependentInits(Exprs.DependentInits);1830  Dir->setFinalsConditions(Exprs.FinalsConditions);1831  Dir->setPreInits(Exprs.PreInits);1832  Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);1833  Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);1834  Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);1835  Dir->setCombinedInit(Exprs.DistCombinedFields.Init);1836  Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);1837  Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);1838  Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);1839  Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);1840  Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);1841  return Dir;1842}1843 1844OMPDistributeParallelForSimdDirective *1845OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,1846                                                   unsigned NumClauses,1847                                                   unsigned CollapsedNum,1848                                                   EmptyShell) {1849  return createEmptyDirective<OMPDistributeParallelForSimdDirective>(1850      C, NumClauses, /*HasAssociatedStmt=*/true,1851      numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd),1852      CollapsedNum);1853}1854 1855OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(1856    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1857    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1858    const HelperExprs &Exprs) {1859  auto *Dir = createDirective<OMPDistributeSimdDirective>(1860      C, Clauses, AssociatedStmt,1861      numLoopChildren(CollapsedNum, OMPD_distribute_simd), StartLoc, EndLoc,1862      CollapsedNum);1863  Dir->setIterationVariable(Exprs.IterationVarRef);1864  Dir->setLastIteration(Exprs.LastIteration);1865  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1866  Dir->setPreCond(Exprs.PreCond);1867  Dir->setCond(Exprs.Cond);1868  Dir->setInit(Exprs.Init);1869  Dir->setInc(Exprs.Inc);1870  Dir->setIsLastIterVariable(Exprs.IL);1871  Dir->setLowerBoundVariable(Exprs.LB);1872  Dir->setUpperBoundVariable(Exprs.UB);1873  Dir->setStrideVariable(Exprs.ST);1874  Dir->setEnsureUpperBound(Exprs.EUB);1875  Dir->setNextLowerBound(Exprs.NLB);1876  Dir->setNextUpperBound(Exprs.NUB);1877  Dir->setNumIterations(Exprs.NumIterations);1878  Dir->setCounters(Exprs.Counters);1879  Dir->setPrivateCounters(Exprs.PrivateCounters);1880  Dir->setInits(Exprs.Inits);1881  Dir->setUpdates(Exprs.Updates);1882  Dir->setFinals(Exprs.Finals);1883  Dir->setDependentCounters(Exprs.DependentCounters);1884  Dir->setDependentInits(Exprs.DependentInits);1885  Dir->setFinalsConditions(Exprs.FinalsConditions);1886  Dir->setPreInits(Exprs.PreInits);1887  return Dir;1888}1889 1890OMPDistributeSimdDirective *1891OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,1892                                        unsigned NumClauses,1893                                        unsigned CollapsedNum, EmptyShell) {1894  return createEmptyDirective<OMPDistributeSimdDirective>(1895      C, NumClauses, /*HasAssociatedStmt=*/true,1896      numLoopChildren(CollapsedNum, OMPD_distribute_simd), CollapsedNum);1897}1898 1899OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(1900    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1901    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1902    const HelperExprs &Exprs) {1903  auto *Dir = createDirective<OMPTargetParallelForSimdDirective>(1904      C, Clauses, AssociatedStmt,1905      numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd), StartLoc,1906      EndLoc, CollapsedNum);1907  Dir->setIterationVariable(Exprs.IterationVarRef);1908  Dir->setLastIteration(Exprs.LastIteration);1909  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1910  Dir->setPreCond(Exprs.PreCond);1911  Dir->setCond(Exprs.Cond);1912  Dir->setInit(Exprs.Init);1913  Dir->setInc(Exprs.Inc);1914  Dir->setIsLastIterVariable(Exprs.IL);1915  Dir->setLowerBoundVariable(Exprs.LB);1916  Dir->setUpperBoundVariable(Exprs.UB);1917  Dir->setStrideVariable(Exprs.ST);1918  Dir->setEnsureUpperBound(Exprs.EUB);1919  Dir->setNextLowerBound(Exprs.NLB);1920  Dir->setNextUpperBound(Exprs.NUB);1921  Dir->setNumIterations(Exprs.NumIterations);1922  Dir->setCounters(Exprs.Counters);1923  Dir->setPrivateCounters(Exprs.PrivateCounters);1924  Dir->setInits(Exprs.Inits);1925  Dir->setUpdates(Exprs.Updates);1926  Dir->setFinals(Exprs.Finals);1927  Dir->setDependentCounters(Exprs.DependentCounters);1928  Dir->setDependentInits(Exprs.DependentInits);1929  Dir->setFinalsConditions(Exprs.FinalsConditions);1930  Dir->setPreInits(Exprs.PreInits);1931  return Dir;1932}1933 1934OMPTargetParallelForSimdDirective *1935OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,1936                                               unsigned NumClauses,1937                                               unsigned CollapsedNum,1938                                               EmptyShell) {1939  return createEmptyDirective<OMPTargetParallelForSimdDirective>(1940      C, NumClauses, /*HasAssociatedStmt=*/true,1941      numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd),1942      CollapsedNum);1943}1944 1945OMPTargetSimdDirective *1946OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,1947                               SourceLocation EndLoc, unsigned CollapsedNum,1948                               ArrayRef<OMPClause *> Clauses,1949                               Stmt *AssociatedStmt, const HelperExprs &Exprs) {1950  auto *Dir = createDirective<OMPTargetSimdDirective>(1951      C, Clauses, AssociatedStmt,1952      numLoopChildren(CollapsedNum, OMPD_target_simd), StartLoc, EndLoc,1953      CollapsedNum);1954  Dir->setIterationVariable(Exprs.IterationVarRef);1955  Dir->setLastIteration(Exprs.LastIteration);1956  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1957  Dir->setPreCond(Exprs.PreCond);1958  Dir->setCond(Exprs.Cond);1959  Dir->setInit(Exprs.Init);1960  Dir->setInc(Exprs.Inc);1961  Dir->setCounters(Exprs.Counters);1962  Dir->setPrivateCounters(Exprs.PrivateCounters);1963  Dir->setInits(Exprs.Inits);1964  Dir->setUpdates(Exprs.Updates);1965  Dir->setFinals(Exprs.Finals);1966  Dir->setDependentCounters(Exprs.DependentCounters);1967  Dir->setDependentInits(Exprs.DependentInits);1968  Dir->setFinalsConditions(Exprs.FinalsConditions);1969  Dir->setPreInits(Exprs.PreInits);1970  return Dir;1971}1972 1973OMPTargetSimdDirective *1974OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,1975                                    unsigned CollapsedNum, EmptyShell) {1976  return createEmptyDirective<OMPTargetSimdDirective>(1977      C, NumClauses, /*HasAssociatedStmt=*/true,1978      numLoopChildren(CollapsedNum, OMPD_target_simd), CollapsedNum);1979}1980 1981OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(1982    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,1983    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,1984    const HelperExprs &Exprs) {1985  auto *Dir = createDirective<OMPTeamsDistributeDirective>(1986      C, Clauses, AssociatedStmt,1987      numLoopChildren(CollapsedNum, OMPD_teams_distribute), StartLoc, EndLoc,1988      CollapsedNum);1989  Dir->setIterationVariable(Exprs.IterationVarRef);1990  Dir->setLastIteration(Exprs.LastIteration);1991  Dir->setCalcLastIteration(Exprs.CalcLastIteration);1992  Dir->setPreCond(Exprs.PreCond);1993  Dir->setCond(Exprs.Cond);1994  Dir->setInit(Exprs.Init);1995  Dir->setInc(Exprs.Inc);1996  Dir->setIsLastIterVariable(Exprs.IL);1997  Dir->setLowerBoundVariable(Exprs.LB);1998  Dir->setUpperBoundVariable(Exprs.UB);1999  Dir->setStrideVariable(Exprs.ST);2000  Dir->setEnsureUpperBound(Exprs.EUB);2001  Dir->setNextLowerBound(Exprs.NLB);2002  Dir->setNextUpperBound(Exprs.NUB);2003  Dir->setNumIterations(Exprs.NumIterations);2004  Dir->setCounters(Exprs.Counters);2005  Dir->setPrivateCounters(Exprs.PrivateCounters);2006  Dir->setInits(Exprs.Inits);2007  Dir->setUpdates(Exprs.Updates);2008  Dir->setFinals(Exprs.Finals);2009  Dir->setDependentCounters(Exprs.DependentCounters);2010  Dir->setDependentInits(Exprs.DependentInits);2011  Dir->setFinalsConditions(Exprs.FinalsConditions);2012  Dir->setPreInits(Exprs.PreInits);2013  return Dir;2014}2015 2016OMPTeamsDistributeDirective *2017OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,2018                                         unsigned NumClauses,2019                                         unsigned CollapsedNum, EmptyShell) {2020  return createEmptyDirective<OMPTeamsDistributeDirective>(2021      C, NumClauses, /*HasAssociatedStmt=*/true,2022      numLoopChildren(CollapsedNum, OMPD_teams_distribute), CollapsedNum);2023}2024 2025OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(2026    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2027    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2028    const HelperExprs &Exprs) {2029  auto *Dir = createDirective<OMPTeamsDistributeSimdDirective>(2030      C, Clauses, AssociatedStmt,2031      numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd), StartLoc,2032      EndLoc, CollapsedNum);2033  Dir->setIterationVariable(Exprs.IterationVarRef);2034  Dir->setLastIteration(Exprs.LastIteration);2035  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2036  Dir->setPreCond(Exprs.PreCond);2037  Dir->setCond(Exprs.Cond);2038  Dir->setInit(Exprs.Init);2039  Dir->setInc(Exprs.Inc);2040  Dir->setIsLastIterVariable(Exprs.IL);2041  Dir->setLowerBoundVariable(Exprs.LB);2042  Dir->setUpperBoundVariable(Exprs.UB);2043  Dir->setStrideVariable(Exprs.ST);2044  Dir->setEnsureUpperBound(Exprs.EUB);2045  Dir->setNextLowerBound(Exprs.NLB);2046  Dir->setNextUpperBound(Exprs.NUB);2047  Dir->setNumIterations(Exprs.NumIterations);2048  Dir->setCounters(Exprs.Counters);2049  Dir->setPrivateCounters(Exprs.PrivateCounters);2050  Dir->setInits(Exprs.Inits);2051  Dir->setUpdates(Exprs.Updates);2052  Dir->setFinals(Exprs.Finals);2053  Dir->setDependentCounters(Exprs.DependentCounters);2054  Dir->setDependentInits(Exprs.DependentInits);2055  Dir->setFinalsConditions(Exprs.FinalsConditions);2056  Dir->setPreInits(Exprs.PreInits);2057  return Dir;2058}2059 2060OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(2061    const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,2062    EmptyShell) {2063  return createEmptyDirective<OMPTeamsDistributeSimdDirective>(2064      C, NumClauses, /*HasAssociatedStmt=*/true,2065      numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd), CollapsedNum);2066}2067 2068OMPTeamsDistributeParallelForSimdDirective *2069OMPTeamsDistributeParallelForSimdDirective::Create(2070    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2071    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2072    const HelperExprs &Exprs) {2073  auto *Dir = createDirective<OMPTeamsDistributeParallelForSimdDirective>(2074      C, Clauses, AssociatedStmt,2075      numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for_simd),2076      StartLoc, EndLoc, CollapsedNum);2077  Dir->setIterationVariable(Exprs.IterationVarRef);2078  Dir->setLastIteration(Exprs.LastIteration);2079  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2080  Dir->setPreCond(Exprs.PreCond);2081  Dir->setCond(Exprs.Cond);2082  Dir->setInit(Exprs.Init);2083  Dir->setInc(Exprs.Inc);2084  Dir->setIsLastIterVariable(Exprs.IL);2085  Dir->setLowerBoundVariable(Exprs.LB);2086  Dir->setUpperBoundVariable(Exprs.UB);2087  Dir->setStrideVariable(Exprs.ST);2088  Dir->setEnsureUpperBound(Exprs.EUB);2089  Dir->setNextLowerBound(Exprs.NLB);2090  Dir->setNextUpperBound(Exprs.NUB);2091  Dir->setNumIterations(Exprs.NumIterations);2092  Dir->setPrevLowerBoundVariable(Exprs.PrevLB);2093  Dir->setPrevUpperBoundVariable(Exprs.PrevUB);2094  Dir->setDistInc(Exprs.DistInc);2095  Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);2096  Dir->setCounters(Exprs.Counters);2097  Dir->setPrivateCounters(Exprs.PrivateCounters);2098  Dir->setInits(Exprs.Inits);2099  Dir->setUpdates(Exprs.Updates);2100  Dir->setFinals(Exprs.Finals);2101  Dir->setDependentCounters(Exprs.DependentCounters);2102  Dir->setDependentInits(Exprs.DependentInits);2103  Dir->setFinalsConditions(Exprs.FinalsConditions);2104  Dir->setPreInits(Exprs.PreInits);2105  Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);2106  Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);2107  Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);2108  Dir->setCombinedInit(Exprs.DistCombinedFields.Init);2109  Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);2110  Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);2111  Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);2112  Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);2113  Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);2114  return Dir;2115}2116 2117OMPTeamsDistributeParallelForSimdDirective *2118OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,2119                                                        unsigned NumClauses,2120                                                        unsigned CollapsedNum,2121                                                        EmptyShell) {2122  return createEmptyDirective<OMPTeamsDistributeParallelForSimdDirective>(2123      C, NumClauses, /*HasAssociatedStmt=*/true,2124      numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for_simd),2125      CollapsedNum);2126}2127 2128OMPTeamsDistributeParallelForDirective *2129OMPTeamsDistributeParallelForDirective::Create(2130    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2131    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2132    const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {2133  auto *Dir = createDirective<OMPTeamsDistributeParallelForDirective>(2134      C, Clauses, AssociatedStmt,2135      numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for) + 1,2136      StartLoc, EndLoc, CollapsedNum);2137  Dir->setIterationVariable(Exprs.IterationVarRef);2138  Dir->setLastIteration(Exprs.LastIteration);2139  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2140  Dir->setPreCond(Exprs.PreCond);2141  Dir->setCond(Exprs.Cond);2142  Dir->setInit(Exprs.Init);2143  Dir->setInc(Exprs.Inc);2144  Dir->setIsLastIterVariable(Exprs.IL);2145  Dir->setLowerBoundVariable(Exprs.LB);2146  Dir->setUpperBoundVariable(Exprs.UB);2147  Dir->setStrideVariable(Exprs.ST);2148  Dir->setEnsureUpperBound(Exprs.EUB);2149  Dir->setNextLowerBound(Exprs.NLB);2150  Dir->setNextUpperBound(Exprs.NUB);2151  Dir->setNumIterations(Exprs.NumIterations);2152  Dir->setPrevLowerBoundVariable(Exprs.PrevLB);2153  Dir->setPrevUpperBoundVariable(Exprs.PrevUB);2154  Dir->setDistInc(Exprs.DistInc);2155  Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);2156  Dir->setCounters(Exprs.Counters);2157  Dir->setPrivateCounters(Exprs.PrivateCounters);2158  Dir->setInits(Exprs.Inits);2159  Dir->setUpdates(Exprs.Updates);2160  Dir->setFinals(Exprs.Finals);2161  Dir->setDependentCounters(Exprs.DependentCounters);2162  Dir->setDependentInits(Exprs.DependentInits);2163  Dir->setFinalsConditions(Exprs.FinalsConditions);2164  Dir->setPreInits(Exprs.PreInits);2165  Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);2166  Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);2167  Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);2168  Dir->setCombinedInit(Exprs.DistCombinedFields.Init);2169  Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);2170  Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);2171  Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);2172  Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);2173  Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);2174  Dir->setTaskReductionRefExpr(TaskRedRef);2175  Dir->HasCancel = HasCancel;2176  return Dir;2177}2178 2179OMPTeamsDistributeParallelForDirective *2180OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,2181                                                    unsigned NumClauses,2182                                                    unsigned CollapsedNum,2183                                                    EmptyShell) {2184  return createEmptyDirective<OMPTeamsDistributeParallelForDirective>(2185      C, NumClauses, /*HasAssociatedStmt=*/true,2186      numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for) + 1,2187      CollapsedNum);2188}2189 2190OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(2191    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2192    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {2193  return createDirective<OMPTargetTeamsDirective>(C, Clauses, AssociatedStmt,2194                                                  /*NumChildren=*/0, StartLoc,2195                                                  EndLoc);2196}2197 2198OMPTargetTeamsDirective *2199OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,2200                                     EmptyShell) {2201  return createEmptyDirective<OMPTargetTeamsDirective>(2202      C, NumClauses, /*HasAssociatedStmt=*/true);2203}2204 2205OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(2206    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2207    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2208    const HelperExprs &Exprs) {2209  auto *Dir = createDirective<OMPTargetTeamsDistributeDirective>(2210      C, Clauses, AssociatedStmt,2211      numLoopChildren(CollapsedNum, OMPD_target_teams_distribute), StartLoc,2212      EndLoc, CollapsedNum);2213  Dir->setIterationVariable(Exprs.IterationVarRef);2214  Dir->setLastIteration(Exprs.LastIteration);2215  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2216  Dir->setPreCond(Exprs.PreCond);2217  Dir->setCond(Exprs.Cond);2218  Dir->setInit(Exprs.Init);2219  Dir->setInc(Exprs.Inc);2220  Dir->setIsLastIterVariable(Exprs.IL);2221  Dir->setLowerBoundVariable(Exprs.LB);2222  Dir->setUpperBoundVariable(Exprs.UB);2223  Dir->setStrideVariable(Exprs.ST);2224  Dir->setEnsureUpperBound(Exprs.EUB);2225  Dir->setNextLowerBound(Exprs.NLB);2226  Dir->setNextUpperBound(Exprs.NUB);2227  Dir->setNumIterations(Exprs.NumIterations);2228  Dir->setCounters(Exprs.Counters);2229  Dir->setPrivateCounters(Exprs.PrivateCounters);2230  Dir->setInits(Exprs.Inits);2231  Dir->setUpdates(Exprs.Updates);2232  Dir->setFinals(Exprs.Finals);2233  Dir->setDependentCounters(Exprs.DependentCounters);2234  Dir->setDependentInits(Exprs.DependentInits);2235  Dir->setFinalsConditions(Exprs.FinalsConditions);2236  Dir->setPreInits(Exprs.PreInits);2237  return Dir;2238}2239 2240OMPTargetTeamsDistributeDirective *2241OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,2242                                               unsigned NumClauses,2243                                               unsigned CollapsedNum,2244                                               EmptyShell) {2245  return createEmptyDirective<OMPTargetTeamsDistributeDirective>(2246      C, NumClauses, /*HasAssociatedStmt=*/true,2247      numLoopChildren(CollapsedNum, OMPD_target_teams_distribute),2248      CollapsedNum);2249}2250 2251OMPTargetTeamsDistributeParallelForDirective *2252OMPTargetTeamsDistributeParallelForDirective::Create(2253    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2254    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2255    const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {2256  auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForDirective>(2257      C, Clauses, AssociatedStmt,2258      numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_parallel_for) +2259          1,2260      StartLoc, EndLoc, CollapsedNum);2261  Dir->setIterationVariable(Exprs.IterationVarRef);2262  Dir->setLastIteration(Exprs.LastIteration);2263  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2264  Dir->setPreCond(Exprs.PreCond);2265  Dir->setCond(Exprs.Cond);2266  Dir->setInit(Exprs.Init);2267  Dir->setInc(Exprs.Inc);2268  Dir->setIsLastIterVariable(Exprs.IL);2269  Dir->setLowerBoundVariable(Exprs.LB);2270  Dir->setUpperBoundVariable(Exprs.UB);2271  Dir->setStrideVariable(Exprs.ST);2272  Dir->setEnsureUpperBound(Exprs.EUB);2273  Dir->setNextLowerBound(Exprs.NLB);2274  Dir->setNextUpperBound(Exprs.NUB);2275  Dir->setNumIterations(Exprs.NumIterations);2276  Dir->setPrevLowerBoundVariable(Exprs.PrevLB);2277  Dir->setPrevUpperBoundVariable(Exprs.PrevUB);2278  Dir->setDistInc(Exprs.DistInc);2279  Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);2280  Dir->setCounters(Exprs.Counters);2281  Dir->setPrivateCounters(Exprs.PrivateCounters);2282  Dir->setInits(Exprs.Inits);2283  Dir->setUpdates(Exprs.Updates);2284  Dir->setFinals(Exprs.Finals);2285  Dir->setDependentCounters(Exprs.DependentCounters);2286  Dir->setDependentInits(Exprs.DependentInits);2287  Dir->setFinalsConditions(Exprs.FinalsConditions);2288  Dir->setPreInits(Exprs.PreInits);2289  Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);2290  Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);2291  Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);2292  Dir->setCombinedInit(Exprs.DistCombinedFields.Init);2293  Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);2294  Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);2295  Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);2296  Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);2297  Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);2298  Dir->setTaskReductionRefExpr(TaskRedRef);2299  Dir->HasCancel = HasCancel;2300  return Dir;2301}2302 2303OMPTargetTeamsDistributeParallelForDirective *2304OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,2305                                                          unsigned NumClauses,2306                                                          unsigned CollapsedNum,2307                                                          EmptyShell) {2308  return createEmptyDirective<OMPTargetTeamsDistributeParallelForDirective>(2309      C, NumClauses, /*HasAssociatedStmt=*/true,2310      numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_parallel_for) +2311          1,2312      CollapsedNum);2313}2314 2315OMPTargetTeamsDistributeParallelForSimdDirective *2316OMPTargetTeamsDistributeParallelForSimdDirective::Create(2317    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2318    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2319    const HelperExprs &Exprs) {2320  auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForSimdDirective>(2321      C, Clauses, AssociatedStmt,2322      numLoopChildren(CollapsedNum,2323                      OMPD_target_teams_distribute_parallel_for_simd),2324      StartLoc, EndLoc, CollapsedNum);2325  Dir->setIterationVariable(Exprs.IterationVarRef);2326  Dir->setLastIteration(Exprs.LastIteration);2327  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2328  Dir->setPreCond(Exprs.PreCond);2329  Dir->setCond(Exprs.Cond);2330  Dir->setInit(Exprs.Init);2331  Dir->setInc(Exprs.Inc);2332  Dir->setIsLastIterVariable(Exprs.IL);2333  Dir->setLowerBoundVariable(Exprs.LB);2334  Dir->setUpperBoundVariable(Exprs.UB);2335  Dir->setStrideVariable(Exprs.ST);2336  Dir->setEnsureUpperBound(Exprs.EUB);2337  Dir->setNextLowerBound(Exprs.NLB);2338  Dir->setNextUpperBound(Exprs.NUB);2339  Dir->setNumIterations(Exprs.NumIterations);2340  Dir->setPrevLowerBoundVariable(Exprs.PrevLB);2341  Dir->setPrevUpperBoundVariable(Exprs.PrevUB);2342  Dir->setDistInc(Exprs.DistInc);2343  Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);2344  Dir->setCounters(Exprs.Counters);2345  Dir->setPrivateCounters(Exprs.PrivateCounters);2346  Dir->setInits(Exprs.Inits);2347  Dir->setUpdates(Exprs.Updates);2348  Dir->setFinals(Exprs.Finals);2349  Dir->setDependentCounters(Exprs.DependentCounters);2350  Dir->setDependentInits(Exprs.DependentInits);2351  Dir->setFinalsConditions(Exprs.FinalsConditions);2352  Dir->setPreInits(Exprs.PreInits);2353  Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);2354  Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);2355  Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);2356  Dir->setCombinedInit(Exprs.DistCombinedFields.Init);2357  Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);2358  Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);2359  Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);2360  Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);2361  Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);2362  return Dir;2363}2364 2365OMPTargetTeamsDistributeParallelForSimdDirective *2366OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(2367    const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,2368    EmptyShell) {2369  return createEmptyDirective<OMPTargetTeamsDistributeParallelForSimdDirective>(2370      C, NumClauses, /*HasAssociatedStmt=*/true,2371      numLoopChildren(CollapsedNum,2372                      OMPD_target_teams_distribute_parallel_for_simd),2373      CollapsedNum);2374}2375 2376OMPTargetTeamsDistributeSimdDirective *2377OMPTargetTeamsDistributeSimdDirective::Create(2378    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2379    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2380    const HelperExprs &Exprs) {2381  auto *Dir = createDirective<OMPTargetTeamsDistributeSimdDirective>(2382      C, Clauses, AssociatedStmt,2383      numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd),2384      StartLoc, EndLoc, CollapsedNum);2385  Dir->setIterationVariable(Exprs.IterationVarRef);2386  Dir->setLastIteration(Exprs.LastIteration);2387  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2388  Dir->setPreCond(Exprs.PreCond);2389  Dir->setCond(Exprs.Cond);2390  Dir->setInit(Exprs.Init);2391  Dir->setInc(Exprs.Inc);2392  Dir->setIsLastIterVariable(Exprs.IL);2393  Dir->setLowerBoundVariable(Exprs.LB);2394  Dir->setUpperBoundVariable(Exprs.UB);2395  Dir->setStrideVariable(Exprs.ST);2396  Dir->setEnsureUpperBound(Exprs.EUB);2397  Dir->setNextLowerBound(Exprs.NLB);2398  Dir->setNextUpperBound(Exprs.NUB);2399  Dir->setNumIterations(Exprs.NumIterations);2400  Dir->setCounters(Exprs.Counters);2401  Dir->setPrivateCounters(Exprs.PrivateCounters);2402  Dir->setInits(Exprs.Inits);2403  Dir->setUpdates(Exprs.Updates);2404  Dir->setFinals(Exprs.Finals);2405  Dir->setDependentCounters(Exprs.DependentCounters);2406  Dir->setDependentInits(Exprs.DependentInits);2407  Dir->setFinalsConditions(Exprs.FinalsConditions);2408  Dir->setPreInits(Exprs.PreInits);2409  return Dir;2410}2411 2412OMPTargetTeamsDistributeSimdDirective *2413OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,2414                                                   unsigned NumClauses,2415                                                   unsigned CollapsedNum,2416                                                   EmptyShell) {2417  return createEmptyDirective<OMPTargetTeamsDistributeSimdDirective>(2418      C, NumClauses, /*HasAssociatedStmt=*/true,2419      numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd),2420      CollapsedNum);2421}2422 2423OMPInteropDirective *2424OMPInteropDirective::Create(const ASTContext &C, SourceLocation StartLoc,2425                            SourceLocation EndLoc,2426                            ArrayRef<OMPClause *> Clauses) {2427  return createDirective<OMPInteropDirective>(2428      C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,2429      EndLoc);2430}2431 2432OMPInteropDirective *OMPInteropDirective::CreateEmpty(const ASTContext &C,2433                                                      unsigned NumClauses,2434                                                      EmptyShell) {2435  return createEmptyDirective<OMPInteropDirective>(C, NumClauses);2436}2437 2438OMPDispatchDirective *OMPDispatchDirective::Create(2439    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2440    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2441    SourceLocation TargetCallLoc) {2442  auto *Dir = createDirective<OMPDispatchDirective>(2443      C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);2444  Dir->setTargetCallLoc(TargetCallLoc);2445  return Dir;2446}2447 2448OMPDispatchDirective *OMPDispatchDirective::CreateEmpty(const ASTContext &C,2449                                                        unsigned NumClauses,2450                                                        EmptyShell) {2451  return createEmptyDirective<OMPDispatchDirective>(C, NumClauses,2452                                                    /*HasAssociatedStmt=*/true,2453                                                    /*NumChildren=*/0);2454}2455 2456OMPMaskedDirective *OMPMaskedDirective::Create(const ASTContext &C,2457                                               SourceLocation StartLoc,2458                                               SourceLocation EndLoc,2459                                               ArrayRef<OMPClause *> Clauses,2460                                               Stmt *AssociatedStmt) {2461  return createDirective<OMPMaskedDirective>(C, Clauses, AssociatedStmt,2462                                             /*NumChildren=*/0, StartLoc,2463                                             EndLoc);2464}2465 2466OMPMaskedDirective *OMPMaskedDirective::CreateEmpty(const ASTContext &C,2467                                                    unsigned NumClauses,2468                                                    EmptyShell) {2469  return createEmptyDirective<OMPMaskedDirective>(C, NumClauses,2470                                                  /*HasAssociatedStmt=*/true);2471}2472 2473OMPGenericLoopDirective *OMPGenericLoopDirective::Create(2474    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2475    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2476    const HelperExprs &Exprs) {2477  auto *Dir = createDirective<OMPGenericLoopDirective>(2478      C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_loop),2479      StartLoc, EndLoc, CollapsedNum);2480  Dir->setIterationVariable(Exprs.IterationVarRef);2481  Dir->setLastIteration(Exprs.LastIteration);2482  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2483  Dir->setPreCond(Exprs.PreCond);2484  Dir->setCond(Exprs.Cond);2485  Dir->setInit(Exprs.Init);2486  Dir->setInc(Exprs.Inc);2487  Dir->setIsLastIterVariable(Exprs.IL);2488  Dir->setLowerBoundVariable(Exprs.LB);2489  Dir->setUpperBoundVariable(Exprs.UB);2490  Dir->setStrideVariable(Exprs.ST);2491  Dir->setEnsureUpperBound(Exprs.EUB);2492  Dir->setNextLowerBound(Exprs.NLB);2493  Dir->setNextUpperBound(Exprs.NUB);2494  Dir->setNumIterations(Exprs.NumIterations);2495  Dir->setCounters(Exprs.Counters);2496  Dir->setPrivateCounters(Exprs.PrivateCounters);2497  Dir->setInits(Exprs.Inits);2498  Dir->setUpdates(Exprs.Updates);2499  Dir->setFinals(Exprs.Finals);2500  Dir->setDependentCounters(Exprs.DependentCounters);2501  Dir->setDependentInits(Exprs.DependentInits);2502  Dir->setFinalsConditions(Exprs.FinalsConditions);2503  Dir->setPreInits(Exprs.PreInits);2504  return Dir;2505}2506 2507OMPGenericLoopDirective *2508OMPGenericLoopDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,2509                                     unsigned CollapsedNum, EmptyShell) {2510  return createEmptyDirective<OMPGenericLoopDirective>(2511      C, NumClauses, /*HasAssociatedStmt=*/true,2512      numLoopChildren(CollapsedNum, OMPD_loop), CollapsedNum);2513}2514 2515OMPTeamsGenericLoopDirective *OMPTeamsGenericLoopDirective::Create(2516    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2517    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2518    const HelperExprs &Exprs) {2519  auto *Dir = createDirective<OMPTeamsGenericLoopDirective>(2520      C, Clauses, AssociatedStmt,2521      numLoopChildren(CollapsedNum, OMPD_teams_loop), StartLoc, EndLoc,2522      CollapsedNum);2523  Dir->setIterationVariable(Exprs.IterationVarRef);2524  Dir->setLastIteration(Exprs.LastIteration);2525  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2526  Dir->setPreCond(Exprs.PreCond);2527  Dir->setCond(Exprs.Cond);2528  Dir->setInit(Exprs.Init);2529  Dir->setInc(Exprs.Inc);2530  Dir->setIsLastIterVariable(Exprs.IL);2531  Dir->setLowerBoundVariable(Exprs.LB);2532  Dir->setUpperBoundVariable(Exprs.UB);2533  Dir->setStrideVariable(Exprs.ST);2534  Dir->setEnsureUpperBound(Exprs.EUB);2535  Dir->setNextLowerBound(Exprs.NLB);2536  Dir->setNextUpperBound(Exprs.NUB);2537  Dir->setNumIterations(Exprs.NumIterations);2538  Dir->setPrevLowerBoundVariable(Exprs.PrevLB);2539  Dir->setPrevUpperBoundVariable(Exprs.PrevUB);2540  Dir->setDistInc(Exprs.DistInc);2541  Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);2542  Dir->setCounters(Exprs.Counters);2543  Dir->setPrivateCounters(Exprs.PrivateCounters);2544  Dir->setInits(Exprs.Inits);2545  Dir->setUpdates(Exprs.Updates);2546  Dir->setFinals(Exprs.Finals);2547  Dir->setDependentCounters(Exprs.DependentCounters);2548  Dir->setDependentInits(Exprs.DependentInits);2549  Dir->setFinalsConditions(Exprs.FinalsConditions);2550  Dir->setPreInits(Exprs.PreInits);2551  Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);2552  Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);2553  Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);2554  Dir->setCombinedInit(Exprs.DistCombinedFields.Init);2555  Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);2556  Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);2557  Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);2558  Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);2559  Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);2560  return Dir;2561}2562 2563OMPTeamsGenericLoopDirective *2564OMPTeamsGenericLoopDirective::CreateEmpty(const ASTContext &C,2565                                          unsigned NumClauses,2566                                          unsigned CollapsedNum, EmptyShell) {2567  return createEmptyDirective<OMPTeamsGenericLoopDirective>(2568      C, NumClauses, /*HasAssociatedStmt=*/true,2569      numLoopChildren(CollapsedNum, OMPD_teams_loop), CollapsedNum);2570}2571 2572OMPTargetTeamsGenericLoopDirective *OMPTargetTeamsGenericLoopDirective::Create(2573    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2574    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2575    const HelperExprs &Exprs, bool CanBeParallelFor) {2576  auto *Dir = createDirective<OMPTargetTeamsGenericLoopDirective>(2577      C, Clauses, AssociatedStmt,2578      numLoopChildren(CollapsedNum, OMPD_target_teams_loop), StartLoc, EndLoc,2579      CollapsedNum);2580  Dir->setIterationVariable(Exprs.IterationVarRef);2581  Dir->setLastIteration(Exprs.LastIteration);2582  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2583  Dir->setPreCond(Exprs.PreCond);2584  Dir->setCond(Exprs.Cond);2585  Dir->setInit(Exprs.Init);2586  Dir->setInc(Exprs.Inc);2587  Dir->setIsLastIterVariable(Exprs.IL);2588  Dir->setLowerBoundVariable(Exprs.LB);2589  Dir->setUpperBoundVariable(Exprs.UB);2590  Dir->setStrideVariable(Exprs.ST);2591  Dir->setEnsureUpperBound(Exprs.EUB);2592  Dir->setNextLowerBound(Exprs.NLB);2593  Dir->setNextUpperBound(Exprs.NUB);2594  Dir->setNumIterations(Exprs.NumIterations);2595  Dir->setPrevLowerBoundVariable(Exprs.PrevLB);2596  Dir->setPrevUpperBoundVariable(Exprs.PrevUB);2597  Dir->setDistInc(Exprs.DistInc);2598  Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);2599  Dir->setCounters(Exprs.Counters);2600  Dir->setPrivateCounters(Exprs.PrivateCounters);2601  Dir->setInits(Exprs.Inits);2602  Dir->setUpdates(Exprs.Updates);2603  Dir->setFinals(Exprs.Finals);2604  Dir->setDependentCounters(Exprs.DependentCounters);2605  Dir->setDependentInits(Exprs.DependentInits);2606  Dir->setFinalsConditions(Exprs.FinalsConditions);2607  Dir->setPreInits(Exprs.PreInits);2608  Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);2609  Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);2610  Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);2611  Dir->setCombinedInit(Exprs.DistCombinedFields.Init);2612  Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);2613  Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);2614  Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);2615  Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);2616  Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);2617  Dir->setCanBeParallelFor(CanBeParallelFor);2618  return Dir;2619}2620 2621OMPTargetTeamsGenericLoopDirective *2622OMPTargetTeamsGenericLoopDirective::CreateEmpty(const ASTContext &C,2623                                                unsigned NumClauses,2624                                                unsigned CollapsedNum,2625                                                EmptyShell) {2626  return createEmptyDirective<OMPTargetTeamsGenericLoopDirective>(2627      C, NumClauses, /*HasAssociatedStmt=*/true,2628      numLoopChildren(CollapsedNum, OMPD_target_teams_loop), CollapsedNum);2629}2630 2631OMPParallelGenericLoopDirective *OMPParallelGenericLoopDirective::Create(2632    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2633    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2634    const HelperExprs &Exprs) {2635  auto *Dir = createDirective<OMPParallelGenericLoopDirective>(2636      C, Clauses, AssociatedStmt,2637      numLoopChildren(CollapsedNum, OMPD_parallel_loop), StartLoc, EndLoc,2638      CollapsedNum);2639  Dir->setIterationVariable(Exprs.IterationVarRef);2640  Dir->setLastIteration(Exprs.LastIteration);2641  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2642  Dir->setPreCond(Exprs.PreCond);2643  Dir->setCond(Exprs.Cond);2644  Dir->setInit(Exprs.Init);2645  Dir->setInc(Exprs.Inc);2646  Dir->setIsLastIterVariable(Exprs.IL);2647  Dir->setLowerBoundVariable(Exprs.LB);2648  Dir->setUpperBoundVariable(Exprs.UB);2649  Dir->setStrideVariable(Exprs.ST);2650  Dir->setEnsureUpperBound(Exprs.EUB);2651  Dir->setNextLowerBound(Exprs.NLB);2652  Dir->setNextUpperBound(Exprs.NUB);2653  Dir->setNumIterations(Exprs.NumIterations);2654  Dir->setCounters(Exprs.Counters);2655  Dir->setPrivateCounters(Exprs.PrivateCounters);2656  Dir->setInits(Exprs.Inits);2657  Dir->setUpdates(Exprs.Updates);2658  Dir->setFinals(Exprs.Finals);2659  Dir->setDependentCounters(Exprs.DependentCounters);2660  Dir->setDependentInits(Exprs.DependentInits);2661  Dir->setFinalsConditions(Exprs.FinalsConditions);2662  Dir->setPreInits(Exprs.PreInits);2663  return Dir;2664}2665 2666OMPParallelGenericLoopDirective *OMPParallelGenericLoopDirective::CreateEmpty(2667    const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,2668    EmptyShell) {2669  return createEmptyDirective<OMPParallelGenericLoopDirective>(2670      C, NumClauses, /*HasAssociatedStmt=*/true,2671      numLoopChildren(CollapsedNum, OMPD_parallel_loop), CollapsedNum);2672}2673 2674OMPTargetParallelGenericLoopDirective *2675OMPTargetParallelGenericLoopDirective::Create(2676    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,2677    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,2678    const HelperExprs &Exprs) {2679  auto *Dir = createDirective<OMPTargetParallelGenericLoopDirective>(2680      C, Clauses, AssociatedStmt,2681      numLoopChildren(CollapsedNum, OMPD_target_parallel_loop), StartLoc,2682      EndLoc, CollapsedNum);2683  Dir->setIterationVariable(Exprs.IterationVarRef);2684  Dir->setLastIteration(Exprs.LastIteration);2685  Dir->setCalcLastIteration(Exprs.CalcLastIteration);2686  Dir->setPreCond(Exprs.PreCond);2687  Dir->setCond(Exprs.Cond);2688  Dir->setInit(Exprs.Init);2689  Dir->setInc(Exprs.Inc);2690  Dir->setIsLastIterVariable(Exprs.IL);2691  Dir->setLowerBoundVariable(Exprs.LB);2692  Dir->setUpperBoundVariable(Exprs.UB);2693  Dir->setStrideVariable(Exprs.ST);2694  Dir->setEnsureUpperBound(Exprs.EUB);2695  Dir->setNextLowerBound(Exprs.NLB);2696  Dir->setNextUpperBound(Exprs.NUB);2697  Dir->setNumIterations(Exprs.NumIterations);2698  Dir->setCounters(Exprs.Counters);2699  Dir->setPrivateCounters(Exprs.PrivateCounters);2700  Dir->setInits(Exprs.Inits);2701  Dir->setUpdates(Exprs.Updates);2702  Dir->setFinals(Exprs.Finals);2703  Dir->setDependentCounters(Exprs.DependentCounters);2704  Dir->setDependentInits(Exprs.DependentInits);2705  Dir->setFinalsConditions(Exprs.FinalsConditions);2706  Dir->setPreInits(Exprs.PreInits);2707  return Dir;2708}2709 2710OMPTargetParallelGenericLoopDirective *2711OMPTargetParallelGenericLoopDirective::CreateEmpty(const ASTContext &C,2712                                                   unsigned NumClauses,2713                                                   unsigned CollapsedNum,2714                                                   EmptyShell) {2715  return createEmptyDirective<OMPTargetParallelGenericLoopDirective>(2716      C, NumClauses, /*HasAssociatedStmt=*/true,2717      numLoopChildren(CollapsedNum, OMPD_target_parallel_loop), CollapsedNum);2718}2719