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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file implements the subclesses of Stmt class declared in StmtOpenMP.h 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "clang/AST/ASTContext.h" 14 #include "clang/AST/StmtOpenMP.h" 15 16 using namespace clang; 17 using namespace llvm::omp; 18 19 size_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 27 void 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 33 MutableArrayRef<Stmt *> OMPChildren::getChildren() { 34 return llvm::makeMutableArrayRef(getTrailingObjects<Stmt *>(), NumChildren); 35 } 36 37 OMPChildren *OMPChildren::Create(void *Mem, ArrayRef<OMPClause *> Clauses) { 38 auto *Data = CreateEmpty(Mem, Clauses.size()); 39 Data->setClauses(Clauses); 40 return Data; 41 } 42 43 OMPChildren *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 52 OMPChildren *OMPChildren::CreateEmpty(void *Mem, unsigned NumClauses, 53 bool HasAssociatedStmt, 54 unsigned NumChildren) { 55 return new (Mem) OMPChildren(NumClauses, NumChildren, HasAssociatedStmt); 56 } 57 58 bool OMPExecutableDirective::isStandaloneDirective() const { 59 // Special case: 'omp target enter data', 'omp target exit data', 60 // 'omp target update' are stand-alone directives, but for implementation 61 // 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 69 Stmt *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 77 Stmt * 78 OMPLoopBasedDirective::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 125 bool 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 NumGeneratedLoops = Dir->getNumGeneratedLoops(); 142 if (NumGeneratedLoops == 0) { 143 // May happen if the loop transformation does not result in a 144 // generated loop (such as full unrolling). 145 break; 146 } 147 if (NumGeneratedLoops > 0) { 148 // The loop transformation construct has generated loops, but these 149 // may not have been generated yet due to being in a dependent 150 // context. 151 return true; 152 } 153 } 154 155 CurStmt = TransformedStmt; 156 } 157 if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(CurStmt)) 158 CurStmt = CanonLoop->getLoopStmt(); 159 if (Callback(Cnt, CurStmt)) 160 return false; 161 // Move on to the next nested for loop, or to the loop body. 162 // OpenMP [2.8.1, simd construct, Restrictions] 163 // All loops associated with the construct must be perfectly nested; that 164 // is, there must be no intervening code nor any OpenMP directive between 165 // any two loops. 166 if (auto *For = dyn_cast<ForStmt>(CurStmt)) { 167 CurStmt = For->getBody(); 168 } else { 169 assert(isa<CXXForRangeStmt>(CurStmt) && 170 "Expected canonical for or range-based for loops."); 171 CurStmt = cast<CXXForRangeStmt>(CurStmt)->getBody(); 172 } 173 CurStmt = OMPLoopBasedDirective::tryToFindNextInnerLoop( 174 CurStmt, TryImperfectlyNestedLoops); 175 } 176 return true; 177 } 178 179 void OMPLoopBasedDirective::doForAllLoopsBodies( 180 Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, 181 llvm::function_ref<void(unsigned, Stmt *, Stmt *)> Callback) { 182 bool Res = OMPLoopBasedDirective::doForAllLoops( 183 CurStmt, TryImperfectlyNestedLoops, NumLoops, 184 [Callback](unsigned Cnt, Stmt *Loop) { 185 Stmt *Body = nullptr; 186 if (auto *For = dyn_cast<ForStmt>(Loop)) { 187 Body = For->getBody(); 188 } else { 189 assert(isa<CXXForRangeStmt>(Loop) && 190 "Expected canonical for or range-based for loops."); 191 Body = cast<CXXForRangeStmt>(Loop)->getBody(); 192 } 193 if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(Body)) 194 Body = CanonLoop->getLoopStmt(); 195 Callback(Cnt, Loop, Body); 196 return false; 197 }); 198 assert(Res && "Expected only loops"); 199 (void)Res; 200 } 201 202 Stmt *OMPLoopDirective::getBody() { 203 // This relies on the loop form is already checked by Sema. 204 Stmt *Body = nullptr; 205 OMPLoopBasedDirective::doForAllLoopsBodies( 206 Data->getRawStmt(), /*TryImperfectlyNestedLoops=*/true, 207 NumAssociatedLoops, 208 [&Body](unsigned, Stmt *, Stmt *BodyStmt) { Body = BodyStmt; }); 209 return Body; 210 } 211 212 void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) { 213 assert(A.size() == getLoopsNumber() && 214 "Number of loop counters is not the same as the collapsed number"); 215 llvm::copy(A, getCounters().begin()); 216 } 217 218 void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) { 219 assert(A.size() == getLoopsNumber() && "Number of loop private counters " 220 "is not the same as the collapsed " 221 "number"); 222 llvm::copy(A, getPrivateCounters().begin()); 223 } 224 225 void OMPLoopDirective::setInits(ArrayRef<Expr *> A) { 226 assert(A.size() == getLoopsNumber() && 227 "Number of counter inits is not the same as the collapsed number"); 228 llvm::copy(A, getInits().begin()); 229 } 230 231 void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) { 232 assert(A.size() == getLoopsNumber() && 233 "Number of counter updates is not the same as the collapsed number"); 234 llvm::copy(A, getUpdates().begin()); 235 } 236 237 void OMPLoopDirective::setFinals(ArrayRef<Expr *> A) { 238 assert(A.size() == getLoopsNumber() && 239 "Number of counter finals is not the same as the collapsed number"); 240 llvm::copy(A, getFinals().begin()); 241 } 242 243 void OMPLoopDirective::setDependentCounters(ArrayRef<Expr *> A) { 244 assert( 245 A.size() == getLoopsNumber() && 246 "Number of dependent counters is not the same as the collapsed number"); 247 llvm::copy(A, getDependentCounters().begin()); 248 } 249 250 void OMPLoopDirective::setDependentInits(ArrayRef<Expr *> A) { 251 assert(A.size() == getLoopsNumber() && 252 "Number of dependent inits is not the same as the collapsed number"); 253 llvm::copy(A, getDependentInits().begin()); 254 } 255 256 void OMPLoopDirective::setFinalsConditions(ArrayRef<Expr *> A) { 257 assert(A.size() == getLoopsNumber() && 258 "Number of finals conditions is not the same as the collapsed number"); 259 llvm::copy(A, getFinalsConditions().begin()); 260 } 261 262 OMPMetaDirective *OMPMetaDirective::Create(const ASTContext &C, 263 SourceLocation StartLoc, 264 SourceLocation EndLoc, 265 ArrayRef<OMPClause *> Clauses, 266 Stmt *AssociatedStmt, Stmt *IfStmt) { 267 auto *Dir = createDirective<OMPMetaDirective>( 268 C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc); 269 Dir->setIfStmt(IfStmt); 270 return Dir; 271 } 272 273 OMPMetaDirective *OMPMetaDirective::CreateEmpty(const ASTContext &C, 274 unsigned NumClauses, 275 EmptyShell) { 276 return createEmptyDirective<OMPMetaDirective>(C, NumClauses, 277 /*HasAssociatedStmt=*/true, 278 /*NumChildren=*/1); 279 } 280 281 OMPParallelDirective *OMPParallelDirective::Create( 282 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 283 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef, 284 bool HasCancel) { 285 auto *Dir = createDirective<OMPParallelDirective>( 286 C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc); 287 Dir->setTaskReductionRefExpr(TaskRedRef); 288 Dir->setHasCancel(HasCancel); 289 return Dir; 290 } 291 292 OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C, 293 unsigned NumClauses, 294 EmptyShell) { 295 return createEmptyDirective<OMPParallelDirective>(C, NumClauses, 296 /*HasAssociatedStmt=*/true, 297 /*NumChildren=*/1); 298 } 299 300 OMPSimdDirective * 301 OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc, 302 SourceLocation EndLoc, unsigned CollapsedNum, 303 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 304 const HelperExprs &Exprs) { 305 auto *Dir = createDirective<OMPSimdDirective>( 306 C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_simd), 307 StartLoc, EndLoc, CollapsedNum); 308 Dir->setIterationVariable(Exprs.IterationVarRef); 309 Dir->setLastIteration(Exprs.LastIteration); 310 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 311 Dir->setPreCond(Exprs.PreCond); 312 Dir->setCond(Exprs.Cond); 313 Dir->setInit(Exprs.Init); 314 Dir->setInc(Exprs.Inc); 315 Dir->setCounters(Exprs.Counters); 316 Dir->setPrivateCounters(Exprs.PrivateCounters); 317 Dir->setInits(Exprs.Inits); 318 Dir->setUpdates(Exprs.Updates); 319 Dir->setFinals(Exprs.Finals); 320 Dir->setDependentCounters(Exprs.DependentCounters); 321 Dir->setDependentInits(Exprs.DependentInits); 322 Dir->setFinalsConditions(Exprs.FinalsConditions); 323 Dir->setPreInits(Exprs.PreInits); 324 return Dir; 325 } 326 327 OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C, 328 unsigned NumClauses, 329 unsigned CollapsedNum, 330 EmptyShell) { 331 return createEmptyDirective<OMPSimdDirective>( 332 C, NumClauses, /*HasAssociatedStmt=*/true, 333 numLoopChildren(CollapsedNum, OMPD_simd), CollapsedNum); 334 } 335 336 OMPForDirective *OMPForDirective::Create( 337 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 338 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 339 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) { 340 auto *Dir = createDirective<OMPForDirective>( 341 C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_for) + 1, 342 StartLoc, EndLoc, CollapsedNum); 343 Dir->setIterationVariable(Exprs.IterationVarRef); 344 Dir->setLastIteration(Exprs.LastIteration); 345 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 346 Dir->setPreCond(Exprs.PreCond); 347 Dir->setCond(Exprs.Cond); 348 Dir->setInit(Exprs.Init); 349 Dir->setInc(Exprs.Inc); 350 Dir->setIsLastIterVariable(Exprs.IL); 351 Dir->setLowerBoundVariable(Exprs.LB); 352 Dir->setUpperBoundVariable(Exprs.UB); 353 Dir->setStrideVariable(Exprs.ST); 354 Dir->setEnsureUpperBound(Exprs.EUB); 355 Dir->setNextLowerBound(Exprs.NLB); 356 Dir->setNextUpperBound(Exprs.NUB); 357 Dir->setNumIterations(Exprs.NumIterations); 358 Dir->setCounters(Exprs.Counters); 359 Dir->setPrivateCounters(Exprs.PrivateCounters); 360 Dir->setInits(Exprs.Inits); 361 Dir->setUpdates(Exprs.Updates); 362 Dir->setFinals(Exprs.Finals); 363 Dir->setDependentCounters(Exprs.DependentCounters); 364 Dir->setDependentInits(Exprs.DependentInits); 365 Dir->setFinalsConditions(Exprs.FinalsConditions); 366 Dir->setPreInits(Exprs.PreInits); 367 Dir->setTaskReductionRefExpr(TaskRedRef); 368 Dir->setHasCancel(HasCancel); 369 return Dir; 370 } 371 372 Stmt *OMPLoopTransformationDirective::getTransformedStmt() const { 373 switch (getStmtClass()) { 374 #define STMT(CLASS, PARENT) 375 #define ABSTRACT_STMT(CLASS) 376 #define OMPLOOPTRANSFORMATIONDIRECTIVE(CLASS, PARENT) \ 377 case Stmt::CLASS##Class: \ 378 return static_cast<const CLASS *>(this)->getTransformedStmt(); 379 #include "clang/AST/StmtNodes.inc" 380 default: 381 llvm_unreachable("Not a loop transformation"); 382 } 383 } 384 385 Stmt *OMPLoopTransformationDirective::getPreInits() const { 386 switch (getStmtClass()) { 387 #define STMT(CLASS, PARENT) 388 #define ABSTRACT_STMT(CLASS) 389 #define OMPLOOPTRANSFORMATIONDIRECTIVE(CLASS, PARENT) \ 390 case Stmt::CLASS##Class: \ 391 return static_cast<const CLASS *>(this)->getPreInits(); 392 #include "clang/AST/StmtNodes.inc" 393 default: 394 llvm_unreachable("Not a loop transformation"); 395 } 396 } 397 398 OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C, 399 unsigned NumClauses, 400 unsigned CollapsedNum, 401 EmptyShell) { 402 return createEmptyDirective<OMPForDirective>( 403 C, NumClauses, /*HasAssociatedStmt=*/true, 404 numLoopChildren(CollapsedNum, OMPD_for) + 1, CollapsedNum); 405 } 406 407 OMPTileDirective * 408 OMPTileDirective::Create(const ASTContext &C, SourceLocation StartLoc, 409 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, 410 unsigned NumLoops, Stmt *AssociatedStmt, 411 Stmt *TransformedStmt, Stmt *PreInits) { 412 OMPTileDirective *Dir = createDirective<OMPTileDirective>( 413 C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc, 414 NumLoops); 415 Dir->setTransformedStmt(TransformedStmt); 416 Dir->setPreInits(PreInits); 417 return Dir; 418 } 419 420 OMPTileDirective *OMPTileDirective::CreateEmpty(const ASTContext &C, 421 unsigned NumClauses, 422 unsigned NumLoops) { 423 return createEmptyDirective<OMPTileDirective>( 424 C, NumClauses, /*HasAssociatedStmt=*/true, TransformedStmtOffset + 1, 425 SourceLocation(), SourceLocation(), NumLoops); 426 } 427 428 OMPUnrollDirective * 429 OMPUnrollDirective::Create(const ASTContext &C, SourceLocation StartLoc, 430 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, 431 Stmt *AssociatedStmt, unsigned NumGeneratedLoops, 432 Stmt *TransformedStmt, Stmt *PreInits) { 433 assert(NumGeneratedLoops <= 1 && "Unrolling generates at most one loop"); 434 435 auto *Dir = createDirective<OMPUnrollDirective>( 436 C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc); 437 Dir->setNumGeneratedLoops(NumGeneratedLoops); 438 Dir->setTransformedStmt(TransformedStmt); 439 Dir->setPreInits(PreInits); 440 return Dir; 441 } 442 443 OMPUnrollDirective *OMPUnrollDirective::CreateEmpty(const ASTContext &C, 444 unsigned NumClauses) { 445 return createEmptyDirective<OMPUnrollDirective>( 446 C, NumClauses, /*HasAssociatedStmt=*/true, TransformedStmtOffset + 1, 447 SourceLocation(), SourceLocation()); 448 } 449 450 OMPForSimdDirective * 451 OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc, 452 SourceLocation EndLoc, unsigned CollapsedNum, 453 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 454 const HelperExprs &Exprs) { 455 auto *Dir = createDirective<OMPForSimdDirective>( 456 C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_for_simd), 457 StartLoc, EndLoc, CollapsedNum); 458 Dir->setIterationVariable(Exprs.IterationVarRef); 459 Dir->setLastIteration(Exprs.LastIteration); 460 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 461 Dir->setPreCond(Exprs.PreCond); 462 Dir->setCond(Exprs.Cond); 463 Dir->setInit(Exprs.Init); 464 Dir->setInc(Exprs.Inc); 465 Dir->setIsLastIterVariable(Exprs.IL); 466 Dir->setLowerBoundVariable(Exprs.LB); 467 Dir->setUpperBoundVariable(Exprs.UB); 468 Dir->setStrideVariable(Exprs.ST); 469 Dir->setEnsureUpperBound(Exprs.EUB); 470 Dir->setNextLowerBound(Exprs.NLB); 471 Dir->setNextUpperBound(Exprs.NUB); 472 Dir->setNumIterations(Exprs.NumIterations); 473 Dir->setCounters(Exprs.Counters); 474 Dir->setPrivateCounters(Exprs.PrivateCounters); 475 Dir->setInits(Exprs.Inits); 476 Dir->setUpdates(Exprs.Updates); 477 Dir->setFinals(Exprs.Finals); 478 Dir->setDependentCounters(Exprs.DependentCounters); 479 Dir->setDependentInits(Exprs.DependentInits); 480 Dir->setFinalsConditions(Exprs.FinalsConditions); 481 Dir->setPreInits(Exprs.PreInits); 482 return Dir; 483 } 484 485 OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C, 486 unsigned NumClauses, 487 unsigned CollapsedNum, 488 EmptyShell) { 489 return createEmptyDirective<OMPForSimdDirective>( 490 C, NumClauses, /*HasAssociatedStmt=*/true, 491 numLoopChildren(CollapsedNum, OMPD_for_simd), CollapsedNum); 492 } 493 494 OMPSectionsDirective *OMPSectionsDirective::Create( 495 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 496 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef, 497 bool HasCancel) { 498 auto *Dir = createDirective<OMPSectionsDirective>(C, Clauses, AssociatedStmt, 499 /*NumChildren=*/1, StartLoc, 500 EndLoc); 501 Dir->setTaskReductionRefExpr(TaskRedRef); 502 Dir->setHasCancel(HasCancel); 503 return Dir; 504 } 505 506 OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C, 507 unsigned NumClauses, 508 EmptyShell) { 509 return createEmptyDirective<OMPSectionsDirective>(C, NumClauses, 510 /*HasAssociatedStmt=*/true, 511 /*NumChildren=*/1); 512 } 513 514 OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C, 515 SourceLocation StartLoc, 516 SourceLocation EndLoc, 517 Stmt *AssociatedStmt, 518 bool HasCancel) { 519 auto *Dir = 520 createDirective<OMPSectionDirective>(C, llvm::None, AssociatedStmt, 521 /*NumChildren=*/0, StartLoc, EndLoc); 522 Dir->setHasCancel(HasCancel); 523 return Dir; 524 } 525 526 OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C, 527 EmptyShell) { 528 return createEmptyDirective<OMPSectionDirective>(C, /*NumClauses=*/0, 529 /*HasAssociatedStmt=*/true); 530 } 531 532 OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C, 533 SourceLocation StartLoc, 534 SourceLocation EndLoc, 535 ArrayRef<OMPClause *> Clauses, 536 Stmt *AssociatedStmt) { 537 return createDirective<OMPSingleDirective>(C, Clauses, AssociatedStmt, 538 /*NumChildren=*/0, StartLoc, 539 EndLoc); 540 } 541 542 OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C, 543 unsigned NumClauses, 544 EmptyShell) { 545 return createEmptyDirective<OMPSingleDirective>(C, NumClauses, 546 /*HasAssociatedStmt=*/true); 547 } 548 549 OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C, 550 SourceLocation StartLoc, 551 SourceLocation EndLoc, 552 Stmt *AssociatedStmt) { 553 return createDirective<OMPMasterDirective>(C, llvm::None, AssociatedStmt, 554 /*NumChildren=*/0, StartLoc, 555 EndLoc); 556 } 557 558 OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C, 559 EmptyShell) { 560 return createEmptyDirective<OMPMasterDirective>(C, /*NumClauses=*/0, 561 /*HasAssociatedStmt=*/true); 562 } 563 564 OMPCriticalDirective *OMPCriticalDirective::Create( 565 const ASTContext &C, const DeclarationNameInfo &Name, 566 SourceLocation StartLoc, SourceLocation EndLoc, 567 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { 568 return createDirective<OMPCriticalDirective>(C, Clauses, AssociatedStmt, 569 /*NumChildren=*/0, Name, 570 StartLoc, EndLoc); 571 } 572 573 OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C, 574 unsigned NumClauses, 575 EmptyShell) { 576 return createEmptyDirective<OMPCriticalDirective>(C, NumClauses, 577 /*HasAssociatedStmt=*/true); 578 } 579 580 OMPParallelForDirective *OMPParallelForDirective::Create( 581 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 582 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 583 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) { 584 auto *Dir = createDirective<OMPParallelForDirective>( 585 C, Clauses, AssociatedStmt, 586 numLoopChildren(CollapsedNum, OMPD_parallel_for) + 1, StartLoc, EndLoc, 587 CollapsedNum); 588 Dir->setIterationVariable(Exprs.IterationVarRef); 589 Dir->setLastIteration(Exprs.LastIteration); 590 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 591 Dir->setPreCond(Exprs.PreCond); 592 Dir->setCond(Exprs.Cond); 593 Dir->setInit(Exprs.Init); 594 Dir->setInc(Exprs.Inc); 595 Dir->setIsLastIterVariable(Exprs.IL); 596 Dir->setLowerBoundVariable(Exprs.LB); 597 Dir->setUpperBoundVariable(Exprs.UB); 598 Dir->setStrideVariable(Exprs.ST); 599 Dir->setEnsureUpperBound(Exprs.EUB); 600 Dir->setNextLowerBound(Exprs.NLB); 601 Dir->setNextUpperBound(Exprs.NUB); 602 Dir->setNumIterations(Exprs.NumIterations); 603 Dir->setCounters(Exprs.Counters); 604 Dir->setPrivateCounters(Exprs.PrivateCounters); 605 Dir->setInits(Exprs.Inits); 606 Dir->setUpdates(Exprs.Updates); 607 Dir->setFinals(Exprs.Finals); 608 Dir->setDependentCounters(Exprs.DependentCounters); 609 Dir->setDependentInits(Exprs.DependentInits); 610 Dir->setFinalsConditions(Exprs.FinalsConditions); 611 Dir->setPreInits(Exprs.PreInits); 612 Dir->setTaskReductionRefExpr(TaskRedRef); 613 Dir->setHasCancel(HasCancel); 614 return Dir; 615 } 616 617 OMPParallelForDirective * 618 OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 619 unsigned CollapsedNum, EmptyShell) { 620 return createEmptyDirective<OMPParallelForDirective>( 621 C, NumClauses, /*HasAssociatedStmt=*/true, 622 numLoopChildren(CollapsedNum, OMPD_parallel_for) + 1, CollapsedNum); 623 } 624 625 OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create( 626 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 627 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 628 const HelperExprs &Exprs) { 629 auto *Dir = createDirective<OMPParallelForSimdDirective>( 630 C, Clauses, AssociatedStmt, 631 numLoopChildren(CollapsedNum, OMPD_parallel_for_simd), StartLoc, EndLoc, 632 CollapsedNum); 633 Dir->setIterationVariable(Exprs.IterationVarRef); 634 Dir->setLastIteration(Exprs.LastIteration); 635 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 636 Dir->setPreCond(Exprs.PreCond); 637 Dir->setCond(Exprs.Cond); 638 Dir->setInit(Exprs.Init); 639 Dir->setInc(Exprs.Inc); 640 Dir->setIsLastIterVariable(Exprs.IL); 641 Dir->setLowerBoundVariable(Exprs.LB); 642 Dir->setUpperBoundVariable(Exprs.UB); 643 Dir->setStrideVariable(Exprs.ST); 644 Dir->setEnsureUpperBound(Exprs.EUB); 645 Dir->setNextLowerBound(Exprs.NLB); 646 Dir->setNextUpperBound(Exprs.NUB); 647 Dir->setNumIterations(Exprs.NumIterations); 648 Dir->setCounters(Exprs.Counters); 649 Dir->setPrivateCounters(Exprs.PrivateCounters); 650 Dir->setInits(Exprs.Inits); 651 Dir->setUpdates(Exprs.Updates); 652 Dir->setFinals(Exprs.Finals); 653 Dir->setDependentCounters(Exprs.DependentCounters); 654 Dir->setDependentInits(Exprs.DependentInits); 655 Dir->setFinalsConditions(Exprs.FinalsConditions); 656 Dir->setPreInits(Exprs.PreInits); 657 return Dir; 658 } 659 660 OMPParallelForSimdDirective * 661 OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C, 662 unsigned NumClauses, 663 unsigned CollapsedNum, EmptyShell) { 664 return createEmptyDirective<OMPParallelForSimdDirective>( 665 C, NumClauses, /*HasAssociatedStmt=*/true, 666 numLoopChildren(CollapsedNum, OMPD_parallel_for_simd), CollapsedNum); 667 } 668 669 OMPParallelMasterDirective *OMPParallelMasterDirective::Create( 670 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 671 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef) { 672 auto *Dir = createDirective<OMPParallelMasterDirective>( 673 C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc); 674 Dir->setTaskReductionRefExpr(TaskRedRef); 675 return Dir; 676 } 677 678 OMPParallelMasterDirective * 679 OMPParallelMasterDirective::CreateEmpty(const ASTContext &C, 680 unsigned NumClauses, EmptyShell) { 681 return createEmptyDirective<OMPParallelMasterDirective>( 682 C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1); 683 } 684 685 OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create( 686 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 687 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef, 688 bool HasCancel) { 689 auto *Dir = createDirective<OMPParallelSectionsDirective>( 690 C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc); 691 Dir->setTaskReductionRefExpr(TaskRedRef); 692 Dir->setHasCancel(HasCancel); 693 return Dir; 694 } 695 696 OMPParallelSectionsDirective * 697 OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C, 698 unsigned NumClauses, EmptyShell) { 699 return createEmptyDirective<OMPParallelSectionsDirective>( 700 C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1); 701 } 702 703 OMPTaskDirective * 704 OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc, 705 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, 706 Stmt *AssociatedStmt, bool HasCancel) { 707 auto *Dir = createDirective<OMPTaskDirective>( 708 C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc); 709 Dir->setHasCancel(HasCancel); 710 return Dir; 711 } 712 713 OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C, 714 unsigned NumClauses, 715 EmptyShell) { 716 return createEmptyDirective<OMPTaskDirective>(C, NumClauses, 717 /*HasAssociatedStmt=*/true); 718 } 719 720 OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C, 721 SourceLocation StartLoc, 722 SourceLocation EndLoc) { 723 return new (C) OMPTaskyieldDirective(StartLoc, EndLoc); 724 } 725 726 OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C, 727 EmptyShell) { 728 return new (C) OMPTaskyieldDirective(); 729 } 730 731 OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C, 732 SourceLocation StartLoc, 733 SourceLocation EndLoc) { 734 return new (C) OMPBarrierDirective(StartLoc, EndLoc); 735 } 736 737 OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C, 738 EmptyShell) { 739 return new (C) OMPBarrierDirective(); 740 } 741 742 OMPTaskwaitDirective * 743 OMPTaskwaitDirective::Create(const ASTContext &C, SourceLocation StartLoc, 744 SourceLocation EndLoc, 745 ArrayRef<OMPClause *> Clauses) { 746 return createDirective<OMPTaskwaitDirective>( 747 C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc, 748 EndLoc); 749 } 750 751 OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C, 752 unsigned NumClauses, 753 EmptyShell) { 754 return createEmptyDirective<OMPTaskwaitDirective>(C, NumClauses); 755 } 756 757 OMPTaskgroupDirective *OMPTaskgroupDirective::Create( 758 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 759 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) { 760 auto *Dir = createDirective<OMPTaskgroupDirective>( 761 C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc); 762 Dir->setReductionRef(ReductionRef); 763 return Dir; 764 } 765 766 OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C, 767 unsigned NumClauses, 768 EmptyShell) { 769 return createEmptyDirective<OMPTaskgroupDirective>( 770 C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1); 771 } 772 773 OMPCancellationPointDirective *OMPCancellationPointDirective::Create( 774 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 775 OpenMPDirectiveKind CancelRegion) { 776 auto *Dir = new (C) OMPCancellationPointDirective(StartLoc, EndLoc); 777 Dir->setCancelRegion(CancelRegion); 778 return Dir; 779 } 780 781 OMPCancellationPointDirective * 782 OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) { 783 return new (C) OMPCancellationPointDirective(); 784 } 785 786 OMPCancelDirective * 787 OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc, 788 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, 789 OpenMPDirectiveKind CancelRegion) { 790 auto *Dir = createDirective<OMPCancelDirective>( 791 C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc, 792 EndLoc); 793 Dir->setCancelRegion(CancelRegion); 794 return Dir; 795 } 796 797 OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C, 798 unsigned NumClauses, 799 EmptyShell) { 800 return createEmptyDirective<OMPCancelDirective>(C, NumClauses); 801 } 802 803 OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C, 804 SourceLocation StartLoc, 805 SourceLocation EndLoc, 806 ArrayRef<OMPClause *> Clauses) { 807 return createDirective<OMPFlushDirective>( 808 C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc, 809 EndLoc); 810 } 811 812 OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C, 813 unsigned NumClauses, 814 EmptyShell) { 815 return createEmptyDirective<OMPFlushDirective>(C, NumClauses); 816 } 817 818 OMPDepobjDirective *OMPDepobjDirective::Create(const ASTContext &C, 819 SourceLocation StartLoc, 820 SourceLocation EndLoc, 821 ArrayRef<OMPClause *> Clauses) { 822 return createDirective<OMPDepobjDirective>( 823 C, Clauses, /*AssociatedStmt=*/nullptr, 824 /*NumChildren=*/0, StartLoc, EndLoc); 825 } 826 827 OMPDepobjDirective *OMPDepobjDirective::CreateEmpty(const ASTContext &C, 828 unsigned NumClauses, 829 EmptyShell) { 830 return createEmptyDirective<OMPDepobjDirective>(C, NumClauses); 831 } 832 833 OMPScanDirective *OMPScanDirective::Create(const ASTContext &C, 834 SourceLocation StartLoc, 835 SourceLocation EndLoc, 836 ArrayRef<OMPClause *> Clauses) { 837 return createDirective<OMPScanDirective>(C, Clauses, 838 /*AssociatedStmt=*/nullptr, 839 /*NumChildren=*/0, StartLoc, EndLoc); 840 } 841 842 OMPScanDirective *OMPScanDirective::CreateEmpty(const ASTContext &C, 843 unsigned NumClauses, 844 EmptyShell) { 845 return createEmptyDirective<OMPScanDirective>(C, NumClauses); 846 } 847 848 OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C, 849 SourceLocation StartLoc, 850 SourceLocation EndLoc, 851 ArrayRef<OMPClause *> Clauses, 852 Stmt *AssociatedStmt) { 853 return createDirective<OMPOrderedDirective>( 854 C, Clauses, cast_or_null<CapturedStmt>(AssociatedStmt), 855 /*NumChildren=*/0, StartLoc, EndLoc); 856 } 857 858 OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C, 859 unsigned NumClauses, 860 bool IsStandalone, 861 EmptyShell) { 862 return createEmptyDirective<OMPOrderedDirective>(C, NumClauses, 863 !IsStandalone); 864 } 865 866 OMPAtomicDirective *OMPAtomicDirective::Create( 867 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 868 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V, 869 Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) { 870 auto *Dir = createDirective<OMPAtomicDirective>( 871 C, Clauses, AssociatedStmt, /*NumChildren=*/4, StartLoc, EndLoc); 872 Dir->setX(X); 873 Dir->setV(V); 874 Dir->setExpr(E); 875 Dir->setUpdateExpr(UE); 876 Dir->IsXLHSInRHSPart = IsXLHSInRHSPart; 877 Dir->IsPostfixUpdate = IsPostfixUpdate; 878 return Dir; 879 } 880 881 OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C, 882 unsigned NumClauses, 883 EmptyShell) { 884 return createEmptyDirective<OMPAtomicDirective>( 885 C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/4); 886 } 887 888 OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C, 889 SourceLocation StartLoc, 890 SourceLocation EndLoc, 891 ArrayRef<OMPClause *> Clauses, 892 Stmt *AssociatedStmt) { 893 return createDirective<OMPTargetDirective>( 894 C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc); 895 } 896 897 OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C, 898 unsigned NumClauses, 899 EmptyShell) { 900 return createEmptyDirective<OMPTargetDirective>(C, NumClauses, 901 /*HasAssociatedStmt=*/true); 902 } 903 904 OMPTargetParallelDirective *OMPTargetParallelDirective::Create( 905 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 906 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef, 907 bool HasCancel) { 908 auto *Dir = createDirective<OMPTargetParallelDirective>( 909 C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc); 910 Dir->setTaskReductionRefExpr(TaskRedRef); 911 Dir->setHasCancel(HasCancel); 912 return Dir; 913 } 914 915 OMPTargetParallelDirective * 916 OMPTargetParallelDirective::CreateEmpty(const ASTContext &C, 917 unsigned NumClauses, EmptyShell) { 918 return createEmptyDirective<OMPTargetParallelDirective>( 919 C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1); 920 } 921 922 OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create( 923 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 924 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 925 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) { 926 auto *Dir = createDirective<OMPTargetParallelForDirective>( 927 C, Clauses, AssociatedStmt, 928 numLoopChildren(CollapsedNum, OMPD_target_parallel_for) + 1, StartLoc, 929 EndLoc, CollapsedNum); 930 Dir->setIterationVariable(Exprs.IterationVarRef); 931 Dir->setLastIteration(Exprs.LastIteration); 932 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 933 Dir->setPreCond(Exprs.PreCond); 934 Dir->setCond(Exprs.Cond); 935 Dir->setInit(Exprs.Init); 936 Dir->setInc(Exprs.Inc); 937 Dir->setIsLastIterVariable(Exprs.IL); 938 Dir->setLowerBoundVariable(Exprs.LB); 939 Dir->setUpperBoundVariable(Exprs.UB); 940 Dir->setStrideVariable(Exprs.ST); 941 Dir->setEnsureUpperBound(Exprs.EUB); 942 Dir->setNextLowerBound(Exprs.NLB); 943 Dir->setNextUpperBound(Exprs.NUB); 944 Dir->setNumIterations(Exprs.NumIterations); 945 Dir->setCounters(Exprs.Counters); 946 Dir->setPrivateCounters(Exprs.PrivateCounters); 947 Dir->setInits(Exprs.Inits); 948 Dir->setUpdates(Exprs.Updates); 949 Dir->setFinals(Exprs.Finals); 950 Dir->setDependentCounters(Exprs.DependentCounters); 951 Dir->setDependentInits(Exprs.DependentInits); 952 Dir->setFinalsConditions(Exprs.FinalsConditions); 953 Dir->setPreInits(Exprs.PreInits); 954 Dir->setTaskReductionRefExpr(TaskRedRef); 955 Dir->setHasCancel(HasCancel); 956 return Dir; 957 } 958 959 OMPTargetParallelForDirective * 960 OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C, 961 unsigned NumClauses, 962 unsigned CollapsedNum, EmptyShell) { 963 return createEmptyDirective<OMPTargetParallelForDirective>( 964 C, NumClauses, /*HasAssociatedStmt=*/true, 965 numLoopChildren(CollapsedNum, OMPD_target_parallel_for) + 1, 966 CollapsedNum); 967 } 968 969 OMPTargetDataDirective *OMPTargetDataDirective::Create( 970 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 971 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { 972 return createDirective<OMPTargetDataDirective>( 973 C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc); 974 } 975 976 OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C, 977 unsigned N, 978 EmptyShell) { 979 return createEmptyDirective<OMPTargetDataDirective>( 980 C, N, /*HasAssociatedStmt=*/true); 981 } 982 983 OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create( 984 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 985 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { 986 return createDirective<OMPTargetEnterDataDirective>( 987 C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc); 988 } 989 990 OMPTargetEnterDataDirective * 991 OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N, 992 EmptyShell) { 993 return createEmptyDirective<OMPTargetEnterDataDirective>( 994 C, N, /*HasAssociatedStmt=*/true); 995 } 996 997 OMPTargetExitDataDirective *OMPTargetExitDataDirective::Create( 998 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 999 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { 1000 return createDirective<OMPTargetExitDataDirective>( 1001 C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc); 1002 } 1003 1004 OMPTargetExitDataDirective * 1005 OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N, 1006 EmptyShell) { 1007 return createEmptyDirective<OMPTargetExitDataDirective>( 1008 C, N, /*HasAssociatedStmt=*/true); 1009 } 1010 1011 OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C, 1012 SourceLocation StartLoc, 1013 SourceLocation EndLoc, 1014 ArrayRef<OMPClause *> Clauses, 1015 Stmt *AssociatedStmt) { 1016 return createDirective<OMPTeamsDirective>( 1017 C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc); 1018 } 1019 1020 OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C, 1021 unsigned NumClauses, 1022 EmptyShell) { 1023 return createEmptyDirective<OMPTeamsDirective>(C, NumClauses, 1024 /*HasAssociatedStmt=*/true); 1025 } 1026 1027 OMPTaskLoopDirective *OMPTaskLoopDirective::Create( 1028 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1029 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1030 const HelperExprs &Exprs, bool HasCancel) { 1031 auto *Dir = createDirective<OMPTaskLoopDirective>( 1032 C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_taskloop), 1033 StartLoc, EndLoc, CollapsedNum); 1034 Dir->setIterationVariable(Exprs.IterationVarRef); 1035 Dir->setLastIteration(Exprs.LastIteration); 1036 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1037 Dir->setPreCond(Exprs.PreCond); 1038 Dir->setCond(Exprs.Cond); 1039 Dir->setInit(Exprs.Init); 1040 Dir->setInc(Exprs.Inc); 1041 Dir->setIsLastIterVariable(Exprs.IL); 1042 Dir->setLowerBoundVariable(Exprs.LB); 1043 Dir->setUpperBoundVariable(Exprs.UB); 1044 Dir->setStrideVariable(Exprs.ST); 1045 Dir->setEnsureUpperBound(Exprs.EUB); 1046 Dir->setNextLowerBound(Exprs.NLB); 1047 Dir->setNextUpperBound(Exprs.NUB); 1048 Dir->setNumIterations(Exprs.NumIterations); 1049 Dir->setCounters(Exprs.Counters); 1050 Dir->setPrivateCounters(Exprs.PrivateCounters); 1051 Dir->setInits(Exprs.Inits); 1052 Dir->setUpdates(Exprs.Updates); 1053 Dir->setFinals(Exprs.Finals); 1054 Dir->setDependentCounters(Exprs.DependentCounters); 1055 Dir->setDependentInits(Exprs.DependentInits); 1056 Dir->setFinalsConditions(Exprs.FinalsConditions); 1057 Dir->setPreInits(Exprs.PreInits); 1058 Dir->setHasCancel(HasCancel); 1059 return Dir; 1060 } 1061 1062 OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C, 1063 unsigned NumClauses, 1064 unsigned CollapsedNum, 1065 EmptyShell) { 1066 return createEmptyDirective<OMPTaskLoopDirective>( 1067 C, NumClauses, /*HasAssociatedStmt=*/true, 1068 numLoopChildren(CollapsedNum, OMPD_taskloop), CollapsedNum); 1069 } 1070 1071 OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create( 1072 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1073 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1074 const HelperExprs &Exprs) { 1075 auto *Dir = createDirective<OMPTaskLoopSimdDirective>( 1076 C, Clauses, AssociatedStmt, 1077 numLoopChildren(CollapsedNum, OMPD_taskloop_simd), StartLoc, EndLoc, 1078 CollapsedNum); 1079 Dir->setIterationVariable(Exprs.IterationVarRef); 1080 Dir->setLastIteration(Exprs.LastIteration); 1081 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1082 Dir->setPreCond(Exprs.PreCond); 1083 Dir->setCond(Exprs.Cond); 1084 Dir->setInit(Exprs.Init); 1085 Dir->setInc(Exprs.Inc); 1086 Dir->setIsLastIterVariable(Exprs.IL); 1087 Dir->setLowerBoundVariable(Exprs.LB); 1088 Dir->setUpperBoundVariable(Exprs.UB); 1089 Dir->setStrideVariable(Exprs.ST); 1090 Dir->setEnsureUpperBound(Exprs.EUB); 1091 Dir->setNextLowerBound(Exprs.NLB); 1092 Dir->setNextUpperBound(Exprs.NUB); 1093 Dir->setNumIterations(Exprs.NumIterations); 1094 Dir->setCounters(Exprs.Counters); 1095 Dir->setPrivateCounters(Exprs.PrivateCounters); 1096 Dir->setInits(Exprs.Inits); 1097 Dir->setUpdates(Exprs.Updates); 1098 Dir->setFinals(Exprs.Finals); 1099 Dir->setDependentCounters(Exprs.DependentCounters); 1100 Dir->setDependentInits(Exprs.DependentInits); 1101 Dir->setFinalsConditions(Exprs.FinalsConditions); 1102 Dir->setPreInits(Exprs.PreInits); 1103 return Dir; 1104 } 1105 1106 OMPTaskLoopSimdDirective * 1107 OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 1108 unsigned CollapsedNum, EmptyShell) { 1109 return createEmptyDirective<OMPTaskLoopSimdDirective>( 1110 C, NumClauses, /*HasAssociatedStmt=*/true, 1111 numLoopChildren(CollapsedNum, OMPD_taskloop_simd), CollapsedNum); 1112 } 1113 1114 OMPMasterTaskLoopDirective *OMPMasterTaskLoopDirective::Create( 1115 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1116 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1117 const HelperExprs &Exprs, bool HasCancel) { 1118 auto *Dir = createDirective<OMPMasterTaskLoopDirective>( 1119 C, Clauses, AssociatedStmt, 1120 numLoopChildren(CollapsedNum, OMPD_master_taskloop), StartLoc, EndLoc, 1121 CollapsedNum); 1122 Dir->setIterationVariable(Exprs.IterationVarRef); 1123 Dir->setLastIteration(Exprs.LastIteration); 1124 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1125 Dir->setPreCond(Exprs.PreCond); 1126 Dir->setCond(Exprs.Cond); 1127 Dir->setInit(Exprs.Init); 1128 Dir->setInc(Exprs.Inc); 1129 Dir->setIsLastIterVariable(Exprs.IL); 1130 Dir->setLowerBoundVariable(Exprs.LB); 1131 Dir->setUpperBoundVariable(Exprs.UB); 1132 Dir->setStrideVariable(Exprs.ST); 1133 Dir->setEnsureUpperBound(Exprs.EUB); 1134 Dir->setNextLowerBound(Exprs.NLB); 1135 Dir->setNextUpperBound(Exprs.NUB); 1136 Dir->setNumIterations(Exprs.NumIterations); 1137 Dir->setCounters(Exprs.Counters); 1138 Dir->setPrivateCounters(Exprs.PrivateCounters); 1139 Dir->setInits(Exprs.Inits); 1140 Dir->setUpdates(Exprs.Updates); 1141 Dir->setFinals(Exprs.Finals); 1142 Dir->setDependentCounters(Exprs.DependentCounters); 1143 Dir->setDependentInits(Exprs.DependentInits); 1144 Dir->setFinalsConditions(Exprs.FinalsConditions); 1145 Dir->setPreInits(Exprs.PreInits); 1146 Dir->setHasCancel(HasCancel); 1147 return Dir; 1148 } 1149 1150 OMPMasterTaskLoopDirective * 1151 OMPMasterTaskLoopDirective::CreateEmpty(const ASTContext &C, 1152 unsigned NumClauses, 1153 unsigned CollapsedNum, EmptyShell) { 1154 return createEmptyDirective<OMPMasterTaskLoopDirective>( 1155 C, NumClauses, /*HasAssociatedStmt=*/true, 1156 numLoopChildren(CollapsedNum, OMPD_master_taskloop), CollapsedNum); 1157 } 1158 1159 OMPMasterTaskLoopSimdDirective *OMPMasterTaskLoopSimdDirective::Create( 1160 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1161 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1162 const HelperExprs &Exprs) { 1163 auto *Dir = createDirective<OMPMasterTaskLoopSimdDirective>( 1164 C, Clauses, AssociatedStmt, 1165 numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd), StartLoc, 1166 EndLoc, CollapsedNum); 1167 Dir->setIterationVariable(Exprs.IterationVarRef); 1168 Dir->setLastIteration(Exprs.LastIteration); 1169 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1170 Dir->setPreCond(Exprs.PreCond); 1171 Dir->setCond(Exprs.Cond); 1172 Dir->setInit(Exprs.Init); 1173 Dir->setInc(Exprs.Inc); 1174 Dir->setIsLastIterVariable(Exprs.IL); 1175 Dir->setLowerBoundVariable(Exprs.LB); 1176 Dir->setUpperBoundVariable(Exprs.UB); 1177 Dir->setStrideVariable(Exprs.ST); 1178 Dir->setEnsureUpperBound(Exprs.EUB); 1179 Dir->setNextLowerBound(Exprs.NLB); 1180 Dir->setNextUpperBound(Exprs.NUB); 1181 Dir->setNumIterations(Exprs.NumIterations); 1182 Dir->setCounters(Exprs.Counters); 1183 Dir->setPrivateCounters(Exprs.PrivateCounters); 1184 Dir->setInits(Exprs.Inits); 1185 Dir->setUpdates(Exprs.Updates); 1186 Dir->setFinals(Exprs.Finals); 1187 Dir->setDependentCounters(Exprs.DependentCounters); 1188 Dir->setDependentInits(Exprs.DependentInits); 1189 Dir->setFinalsConditions(Exprs.FinalsConditions); 1190 Dir->setPreInits(Exprs.PreInits); 1191 return Dir; 1192 } 1193 1194 OMPMasterTaskLoopSimdDirective * 1195 OMPMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, 1196 unsigned NumClauses, 1197 unsigned CollapsedNum, EmptyShell) { 1198 return createEmptyDirective<OMPMasterTaskLoopSimdDirective>( 1199 C, NumClauses, /*HasAssociatedStmt=*/true, 1200 numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd), CollapsedNum); 1201 } 1202 1203 OMPParallelMasterTaskLoopDirective *OMPParallelMasterTaskLoopDirective::Create( 1204 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1205 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1206 const HelperExprs &Exprs, bool HasCancel) { 1207 auto *Dir = createDirective<OMPParallelMasterTaskLoopDirective>( 1208 C, Clauses, AssociatedStmt, 1209 numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop), StartLoc, 1210 EndLoc, CollapsedNum); 1211 Dir->setIterationVariable(Exprs.IterationVarRef); 1212 Dir->setLastIteration(Exprs.LastIteration); 1213 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1214 Dir->setPreCond(Exprs.PreCond); 1215 Dir->setCond(Exprs.Cond); 1216 Dir->setInit(Exprs.Init); 1217 Dir->setInc(Exprs.Inc); 1218 Dir->setIsLastIterVariable(Exprs.IL); 1219 Dir->setLowerBoundVariable(Exprs.LB); 1220 Dir->setUpperBoundVariable(Exprs.UB); 1221 Dir->setStrideVariable(Exprs.ST); 1222 Dir->setEnsureUpperBound(Exprs.EUB); 1223 Dir->setNextLowerBound(Exprs.NLB); 1224 Dir->setNextUpperBound(Exprs.NUB); 1225 Dir->setNumIterations(Exprs.NumIterations); 1226 Dir->setCounters(Exprs.Counters); 1227 Dir->setPrivateCounters(Exprs.PrivateCounters); 1228 Dir->setInits(Exprs.Inits); 1229 Dir->setUpdates(Exprs.Updates); 1230 Dir->setFinals(Exprs.Finals); 1231 Dir->setDependentCounters(Exprs.DependentCounters); 1232 Dir->setDependentInits(Exprs.DependentInits); 1233 Dir->setFinalsConditions(Exprs.FinalsConditions); 1234 Dir->setPreInits(Exprs.PreInits); 1235 Dir->setHasCancel(HasCancel); 1236 return Dir; 1237 } 1238 1239 OMPParallelMasterTaskLoopDirective * 1240 OMPParallelMasterTaskLoopDirective::CreateEmpty(const ASTContext &C, 1241 unsigned NumClauses, 1242 unsigned CollapsedNum, 1243 EmptyShell) { 1244 return createEmptyDirective<OMPParallelMasterTaskLoopDirective>( 1245 C, NumClauses, /*HasAssociatedStmt=*/true, 1246 numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop), 1247 CollapsedNum); 1248 } 1249 1250 OMPParallelMasterTaskLoopSimdDirective * 1251 OMPParallelMasterTaskLoopSimdDirective::Create( 1252 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1253 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1254 const HelperExprs &Exprs) { 1255 auto *Dir = createDirective<OMPParallelMasterTaskLoopSimdDirective>( 1256 C, Clauses, AssociatedStmt, 1257 numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd), 1258 StartLoc, EndLoc, CollapsedNum); 1259 Dir->setIterationVariable(Exprs.IterationVarRef); 1260 Dir->setLastIteration(Exprs.LastIteration); 1261 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1262 Dir->setPreCond(Exprs.PreCond); 1263 Dir->setCond(Exprs.Cond); 1264 Dir->setInit(Exprs.Init); 1265 Dir->setInc(Exprs.Inc); 1266 Dir->setIsLastIterVariable(Exprs.IL); 1267 Dir->setLowerBoundVariable(Exprs.LB); 1268 Dir->setUpperBoundVariable(Exprs.UB); 1269 Dir->setStrideVariable(Exprs.ST); 1270 Dir->setEnsureUpperBound(Exprs.EUB); 1271 Dir->setNextLowerBound(Exprs.NLB); 1272 Dir->setNextUpperBound(Exprs.NUB); 1273 Dir->setNumIterations(Exprs.NumIterations); 1274 Dir->setCounters(Exprs.Counters); 1275 Dir->setPrivateCounters(Exprs.PrivateCounters); 1276 Dir->setInits(Exprs.Inits); 1277 Dir->setUpdates(Exprs.Updates); 1278 Dir->setFinals(Exprs.Finals); 1279 Dir->setDependentCounters(Exprs.DependentCounters); 1280 Dir->setDependentInits(Exprs.DependentInits); 1281 Dir->setFinalsConditions(Exprs.FinalsConditions); 1282 Dir->setPreInits(Exprs.PreInits); 1283 return Dir; 1284 } 1285 1286 OMPParallelMasterTaskLoopSimdDirective * 1287 OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, 1288 unsigned NumClauses, 1289 unsigned CollapsedNum, 1290 EmptyShell) { 1291 return createEmptyDirective<OMPParallelMasterTaskLoopSimdDirective>( 1292 C, NumClauses, /*HasAssociatedStmt=*/true, 1293 numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd), 1294 CollapsedNum); 1295 } 1296 1297 OMPDistributeDirective *OMPDistributeDirective::Create( 1298 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1299 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1300 const HelperExprs &Exprs) { 1301 auto *Dir = createDirective<OMPDistributeDirective>( 1302 C, Clauses, AssociatedStmt, 1303 numLoopChildren(CollapsedNum, OMPD_distribute), StartLoc, EndLoc, 1304 CollapsedNum); 1305 Dir->setIterationVariable(Exprs.IterationVarRef); 1306 Dir->setLastIteration(Exprs.LastIteration); 1307 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1308 Dir->setPreCond(Exprs.PreCond); 1309 Dir->setCond(Exprs.Cond); 1310 Dir->setInit(Exprs.Init); 1311 Dir->setInc(Exprs.Inc); 1312 Dir->setIsLastIterVariable(Exprs.IL); 1313 Dir->setLowerBoundVariable(Exprs.LB); 1314 Dir->setUpperBoundVariable(Exprs.UB); 1315 Dir->setStrideVariable(Exprs.ST); 1316 Dir->setEnsureUpperBound(Exprs.EUB); 1317 Dir->setNextLowerBound(Exprs.NLB); 1318 Dir->setNextUpperBound(Exprs.NUB); 1319 Dir->setNumIterations(Exprs.NumIterations); 1320 Dir->setCounters(Exprs.Counters); 1321 Dir->setPrivateCounters(Exprs.PrivateCounters); 1322 Dir->setInits(Exprs.Inits); 1323 Dir->setUpdates(Exprs.Updates); 1324 Dir->setFinals(Exprs.Finals); 1325 Dir->setDependentCounters(Exprs.DependentCounters); 1326 Dir->setDependentInits(Exprs.DependentInits); 1327 Dir->setFinalsConditions(Exprs.FinalsConditions); 1328 Dir->setPreInits(Exprs.PreInits); 1329 return Dir; 1330 } 1331 1332 OMPDistributeDirective * 1333 OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 1334 unsigned CollapsedNum, EmptyShell) { 1335 return createEmptyDirective<OMPDistributeDirective>( 1336 C, NumClauses, /*HasAssociatedStmt=*/true, 1337 numLoopChildren(CollapsedNum, OMPD_distribute), CollapsedNum); 1338 } 1339 1340 OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create( 1341 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1342 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { 1343 return createDirective<OMPTargetUpdateDirective>(C, Clauses, AssociatedStmt, 1344 /*NumChildren=*/0, StartLoc, 1345 EndLoc); 1346 } 1347 1348 OMPTargetUpdateDirective * 1349 OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 1350 EmptyShell) { 1351 return createEmptyDirective<OMPTargetUpdateDirective>( 1352 C, NumClauses, /*HasAssociatedStmt=*/true); 1353 } 1354 1355 OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create( 1356 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1357 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1358 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) { 1359 auto *Dir = createDirective<OMPDistributeParallelForDirective>( 1360 C, Clauses, AssociatedStmt, 1361 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for) + 1, StartLoc, 1362 EndLoc, CollapsedNum); 1363 Dir->setIterationVariable(Exprs.IterationVarRef); 1364 Dir->setLastIteration(Exprs.LastIteration); 1365 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1366 Dir->setPreCond(Exprs.PreCond); 1367 Dir->setCond(Exprs.Cond); 1368 Dir->setInit(Exprs.Init); 1369 Dir->setInc(Exprs.Inc); 1370 Dir->setIsLastIterVariable(Exprs.IL); 1371 Dir->setLowerBoundVariable(Exprs.LB); 1372 Dir->setUpperBoundVariable(Exprs.UB); 1373 Dir->setStrideVariable(Exprs.ST); 1374 Dir->setEnsureUpperBound(Exprs.EUB); 1375 Dir->setNextLowerBound(Exprs.NLB); 1376 Dir->setNextUpperBound(Exprs.NUB); 1377 Dir->setNumIterations(Exprs.NumIterations); 1378 Dir->setPrevLowerBoundVariable(Exprs.PrevLB); 1379 Dir->setPrevUpperBoundVariable(Exprs.PrevUB); 1380 Dir->setDistInc(Exprs.DistInc); 1381 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB); 1382 Dir->setCounters(Exprs.Counters); 1383 Dir->setPrivateCounters(Exprs.PrivateCounters); 1384 Dir->setInits(Exprs.Inits); 1385 Dir->setUpdates(Exprs.Updates); 1386 Dir->setFinals(Exprs.Finals); 1387 Dir->setDependentCounters(Exprs.DependentCounters); 1388 Dir->setDependentInits(Exprs.DependentInits); 1389 Dir->setFinalsConditions(Exprs.FinalsConditions); 1390 Dir->setPreInits(Exprs.PreInits); 1391 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB); 1392 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB); 1393 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB); 1394 Dir->setCombinedInit(Exprs.DistCombinedFields.Init); 1395 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond); 1396 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB); 1397 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB); 1398 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond); 1399 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond); 1400 Dir->setTaskReductionRefExpr(TaskRedRef); 1401 Dir->HasCancel = HasCancel; 1402 return Dir; 1403 } 1404 1405 OMPDistributeParallelForDirective * 1406 OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C, 1407 unsigned NumClauses, 1408 unsigned CollapsedNum, 1409 EmptyShell) { 1410 return createEmptyDirective<OMPDistributeParallelForDirective>( 1411 C, NumClauses, /*HasAssociatedStmt=*/true, 1412 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for) + 1, 1413 CollapsedNum); 1414 } 1415 1416 OMPDistributeParallelForSimdDirective * 1417 OMPDistributeParallelForSimdDirective::Create( 1418 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1419 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1420 const HelperExprs &Exprs) { 1421 auto *Dir = createDirective<OMPDistributeParallelForSimdDirective>( 1422 C, Clauses, AssociatedStmt, 1423 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd), 1424 StartLoc, EndLoc, CollapsedNum); 1425 Dir->setIterationVariable(Exprs.IterationVarRef); 1426 Dir->setLastIteration(Exprs.LastIteration); 1427 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1428 Dir->setPreCond(Exprs.PreCond); 1429 Dir->setCond(Exprs.Cond); 1430 Dir->setInit(Exprs.Init); 1431 Dir->setInc(Exprs.Inc); 1432 Dir->setIsLastIterVariable(Exprs.IL); 1433 Dir->setLowerBoundVariable(Exprs.LB); 1434 Dir->setUpperBoundVariable(Exprs.UB); 1435 Dir->setStrideVariable(Exprs.ST); 1436 Dir->setEnsureUpperBound(Exprs.EUB); 1437 Dir->setNextLowerBound(Exprs.NLB); 1438 Dir->setNextUpperBound(Exprs.NUB); 1439 Dir->setNumIterations(Exprs.NumIterations); 1440 Dir->setPrevLowerBoundVariable(Exprs.PrevLB); 1441 Dir->setPrevUpperBoundVariable(Exprs.PrevUB); 1442 Dir->setDistInc(Exprs.DistInc); 1443 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB); 1444 Dir->setCounters(Exprs.Counters); 1445 Dir->setPrivateCounters(Exprs.PrivateCounters); 1446 Dir->setInits(Exprs.Inits); 1447 Dir->setUpdates(Exprs.Updates); 1448 Dir->setFinals(Exprs.Finals); 1449 Dir->setDependentCounters(Exprs.DependentCounters); 1450 Dir->setDependentInits(Exprs.DependentInits); 1451 Dir->setFinalsConditions(Exprs.FinalsConditions); 1452 Dir->setPreInits(Exprs.PreInits); 1453 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB); 1454 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB); 1455 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB); 1456 Dir->setCombinedInit(Exprs.DistCombinedFields.Init); 1457 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond); 1458 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB); 1459 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB); 1460 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond); 1461 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond); 1462 return Dir; 1463 } 1464 1465 OMPDistributeParallelForSimdDirective * 1466 OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C, 1467 unsigned NumClauses, 1468 unsigned CollapsedNum, 1469 EmptyShell) { 1470 return createEmptyDirective<OMPDistributeParallelForSimdDirective>( 1471 C, NumClauses, /*HasAssociatedStmt=*/true, 1472 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd), 1473 CollapsedNum); 1474 } 1475 1476 OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create( 1477 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1478 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1479 const HelperExprs &Exprs) { 1480 auto *Dir = createDirective<OMPDistributeSimdDirective>( 1481 C, Clauses, AssociatedStmt, 1482 numLoopChildren(CollapsedNum, OMPD_distribute_simd), StartLoc, EndLoc, 1483 CollapsedNum); 1484 Dir->setIterationVariable(Exprs.IterationVarRef); 1485 Dir->setLastIteration(Exprs.LastIteration); 1486 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1487 Dir->setPreCond(Exprs.PreCond); 1488 Dir->setCond(Exprs.Cond); 1489 Dir->setInit(Exprs.Init); 1490 Dir->setInc(Exprs.Inc); 1491 Dir->setIsLastIterVariable(Exprs.IL); 1492 Dir->setLowerBoundVariable(Exprs.LB); 1493 Dir->setUpperBoundVariable(Exprs.UB); 1494 Dir->setStrideVariable(Exprs.ST); 1495 Dir->setEnsureUpperBound(Exprs.EUB); 1496 Dir->setNextLowerBound(Exprs.NLB); 1497 Dir->setNextUpperBound(Exprs.NUB); 1498 Dir->setNumIterations(Exprs.NumIterations); 1499 Dir->setCounters(Exprs.Counters); 1500 Dir->setPrivateCounters(Exprs.PrivateCounters); 1501 Dir->setInits(Exprs.Inits); 1502 Dir->setUpdates(Exprs.Updates); 1503 Dir->setFinals(Exprs.Finals); 1504 Dir->setDependentCounters(Exprs.DependentCounters); 1505 Dir->setDependentInits(Exprs.DependentInits); 1506 Dir->setFinalsConditions(Exprs.FinalsConditions); 1507 Dir->setPreInits(Exprs.PreInits); 1508 return Dir; 1509 } 1510 1511 OMPDistributeSimdDirective * 1512 OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C, 1513 unsigned NumClauses, 1514 unsigned CollapsedNum, EmptyShell) { 1515 return createEmptyDirective<OMPDistributeSimdDirective>( 1516 C, NumClauses, /*HasAssociatedStmt=*/true, 1517 numLoopChildren(CollapsedNum, OMPD_distribute_simd), CollapsedNum); 1518 } 1519 1520 OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create( 1521 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1522 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1523 const HelperExprs &Exprs) { 1524 auto *Dir = createDirective<OMPTargetParallelForSimdDirective>( 1525 C, Clauses, AssociatedStmt, 1526 numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd), StartLoc, 1527 EndLoc, CollapsedNum); 1528 Dir->setIterationVariable(Exprs.IterationVarRef); 1529 Dir->setLastIteration(Exprs.LastIteration); 1530 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1531 Dir->setPreCond(Exprs.PreCond); 1532 Dir->setCond(Exprs.Cond); 1533 Dir->setInit(Exprs.Init); 1534 Dir->setInc(Exprs.Inc); 1535 Dir->setIsLastIterVariable(Exprs.IL); 1536 Dir->setLowerBoundVariable(Exprs.LB); 1537 Dir->setUpperBoundVariable(Exprs.UB); 1538 Dir->setStrideVariable(Exprs.ST); 1539 Dir->setEnsureUpperBound(Exprs.EUB); 1540 Dir->setNextLowerBound(Exprs.NLB); 1541 Dir->setNextUpperBound(Exprs.NUB); 1542 Dir->setNumIterations(Exprs.NumIterations); 1543 Dir->setCounters(Exprs.Counters); 1544 Dir->setPrivateCounters(Exprs.PrivateCounters); 1545 Dir->setInits(Exprs.Inits); 1546 Dir->setUpdates(Exprs.Updates); 1547 Dir->setFinals(Exprs.Finals); 1548 Dir->setDependentCounters(Exprs.DependentCounters); 1549 Dir->setDependentInits(Exprs.DependentInits); 1550 Dir->setFinalsConditions(Exprs.FinalsConditions); 1551 Dir->setPreInits(Exprs.PreInits); 1552 return Dir; 1553 } 1554 1555 OMPTargetParallelForSimdDirective * 1556 OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C, 1557 unsigned NumClauses, 1558 unsigned CollapsedNum, 1559 EmptyShell) { 1560 return createEmptyDirective<OMPTargetParallelForSimdDirective>( 1561 C, NumClauses, /*HasAssociatedStmt=*/true, 1562 numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd), 1563 CollapsedNum); 1564 } 1565 1566 OMPTargetSimdDirective * 1567 OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc, 1568 SourceLocation EndLoc, unsigned CollapsedNum, 1569 ArrayRef<OMPClause *> Clauses, 1570 Stmt *AssociatedStmt, const HelperExprs &Exprs) { 1571 auto *Dir = createDirective<OMPTargetSimdDirective>( 1572 C, Clauses, AssociatedStmt, 1573 numLoopChildren(CollapsedNum, OMPD_target_simd), StartLoc, EndLoc, 1574 CollapsedNum); 1575 Dir->setIterationVariable(Exprs.IterationVarRef); 1576 Dir->setLastIteration(Exprs.LastIteration); 1577 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1578 Dir->setPreCond(Exprs.PreCond); 1579 Dir->setCond(Exprs.Cond); 1580 Dir->setInit(Exprs.Init); 1581 Dir->setInc(Exprs.Inc); 1582 Dir->setCounters(Exprs.Counters); 1583 Dir->setPrivateCounters(Exprs.PrivateCounters); 1584 Dir->setInits(Exprs.Inits); 1585 Dir->setUpdates(Exprs.Updates); 1586 Dir->setFinals(Exprs.Finals); 1587 Dir->setDependentCounters(Exprs.DependentCounters); 1588 Dir->setDependentInits(Exprs.DependentInits); 1589 Dir->setFinalsConditions(Exprs.FinalsConditions); 1590 Dir->setPreInits(Exprs.PreInits); 1591 return Dir; 1592 } 1593 1594 OMPTargetSimdDirective * 1595 OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 1596 unsigned CollapsedNum, EmptyShell) { 1597 return createEmptyDirective<OMPTargetSimdDirective>( 1598 C, NumClauses, /*HasAssociatedStmt=*/true, 1599 numLoopChildren(CollapsedNum, OMPD_target_simd), CollapsedNum); 1600 } 1601 1602 OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create( 1603 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1604 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1605 const HelperExprs &Exprs) { 1606 auto *Dir = createDirective<OMPTeamsDistributeDirective>( 1607 C, Clauses, AssociatedStmt, 1608 numLoopChildren(CollapsedNum, OMPD_teams_distribute), StartLoc, EndLoc, 1609 CollapsedNum); 1610 Dir->setIterationVariable(Exprs.IterationVarRef); 1611 Dir->setLastIteration(Exprs.LastIteration); 1612 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1613 Dir->setPreCond(Exprs.PreCond); 1614 Dir->setCond(Exprs.Cond); 1615 Dir->setInit(Exprs.Init); 1616 Dir->setInc(Exprs.Inc); 1617 Dir->setIsLastIterVariable(Exprs.IL); 1618 Dir->setLowerBoundVariable(Exprs.LB); 1619 Dir->setUpperBoundVariable(Exprs.UB); 1620 Dir->setStrideVariable(Exprs.ST); 1621 Dir->setEnsureUpperBound(Exprs.EUB); 1622 Dir->setNextLowerBound(Exprs.NLB); 1623 Dir->setNextUpperBound(Exprs.NUB); 1624 Dir->setNumIterations(Exprs.NumIterations); 1625 Dir->setCounters(Exprs.Counters); 1626 Dir->setPrivateCounters(Exprs.PrivateCounters); 1627 Dir->setInits(Exprs.Inits); 1628 Dir->setUpdates(Exprs.Updates); 1629 Dir->setFinals(Exprs.Finals); 1630 Dir->setDependentCounters(Exprs.DependentCounters); 1631 Dir->setDependentInits(Exprs.DependentInits); 1632 Dir->setFinalsConditions(Exprs.FinalsConditions); 1633 Dir->setPreInits(Exprs.PreInits); 1634 return Dir; 1635 } 1636 1637 OMPTeamsDistributeDirective * 1638 OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C, 1639 unsigned NumClauses, 1640 unsigned CollapsedNum, EmptyShell) { 1641 return createEmptyDirective<OMPTeamsDistributeDirective>( 1642 C, NumClauses, /*HasAssociatedStmt=*/true, 1643 numLoopChildren(CollapsedNum, OMPD_teams_distribute), CollapsedNum); 1644 } 1645 1646 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create( 1647 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1648 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1649 const HelperExprs &Exprs) { 1650 auto *Dir = createDirective<OMPTeamsDistributeSimdDirective>( 1651 C, Clauses, AssociatedStmt, 1652 numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd), StartLoc, 1653 EndLoc, CollapsedNum); 1654 Dir->setIterationVariable(Exprs.IterationVarRef); 1655 Dir->setLastIteration(Exprs.LastIteration); 1656 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1657 Dir->setPreCond(Exprs.PreCond); 1658 Dir->setCond(Exprs.Cond); 1659 Dir->setInit(Exprs.Init); 1660 Dir->setInc(Exprs.Inc); 1661 Dir->setIsLastIterVariable(Exprs.IL); 1662 Dir->setLowerBoundVariable(Exprs.LB); 1663 Dir->setUpperBoundVariable(Exprs.UB); 1664 Dir->setStrideVariable(Exprs.ST); 1665 Dir->setEnsureUpperBound(Exprs.EUB); 1666 Dir->setNextLowerBound(Exprs.NLB); 1667 Dir->setNextUpperBound(Exprs.NUB); 1668 Dir->setNumIterations(Exprs.NumIterations); 1669 Dir->setCounters(Exprs.Counters); 1670 Dir->setPrivateCounters(Exprs.PrivateCounters); 1671 Dir->setInits(Exprs.Inits); 1672 Dir->setUpdates(Exprs.Updates); 1673 Dir->setFinals(Exprs.Finals); 1674 Dir->setDependentCounters(Exprs.DependentCounters); 1675 Dir->setDependentInits(Exprs.DependentInits); 1676 Dir->setFinalsConditions(Exprs.FinalsConditions); 1677 Dir->setPreInits(Exprs.PreInits); 1678 return Dir; 1679 } 1680 1681 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty( 1682 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, 1683 EmptyShell) { 1684 return createEmptyDirective<OMPTeamsDistributeSimdDirective>( 1685 C, NumClauses, /*HasAssociatedStmt=*/true, 1686 numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd), CollapsedNum); 1687 } 1688 1689 OMPTeamsDistributeParallelForSimdDirective * 1690 OMPTeamsDistributeParallelForSimdDirective::Create( 1691 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1692 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1693 const HelperExprs &Exprs) { 1694 auto *Dir = createDirective<OMPTeamsDistributeParallelForSimdDirective>( 1695 C, Clauses, AssociatedStmt, 1696 numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for_simd), 1697 StartLoc, EndLoc, CollapsedNum); 1698 Dir->setIterationVariable(Exprs.IterationVarRef); 1699 Dir->setLastIteration(Exprs.LastIteration); 1700 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1701 Dir->setPreCond(Exprs.PreCond); 1702 Dir->setCond(Exprs.Cond); 1703 Dir->setInit(Exprs.Init); 1704 Dir->setInc(Exprs.Inc); 1705 Dir->setIsLastIterVariable(Exprs.IL); 1706 Dir->setLowerBoundVariable(Exprs.LB); 1707 Dir->setUpperBoundVariable(Exprs.UB); 1708 Dir->setStrideVariable(Exprs.ST); 1709 Dir->setEnsureUpperBound(Exprs.EUB); 1710 Dir->setNextLowerBound(Exprs.NLB); 1711 Dir->setNextUpperBound(Exprs.NUB); 1712 Dir->setNumIterations(Exprs.NumIterations); 1713 Dir->setPrevLowerBoundVariable(Exprs.PrevLB); 1714 Dir->setPrevUpperBoundVariable(Exprs.PrevUB); 1715 Dir->setDistInc(Exprs.DistInc); 1716 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB); 1717 Dir->setCounters(Exprs.Counters); 1718 Dir->setPrivateCounters(Exprs.PrivateCounters); 1719 Dir->setInits(Exprs.Inits); 1720 Dir->setUpdates(Exprs.Updates); 1721 Dir->setFinals(Exprs.Finals); 1722 Dir->setDependentCounters(Exprs.DependentCounters); 1723 Dir->setDependentInits(Exprs.DependentInits); 1724 Dir->setFinalsConditions(Exprs.FinalsConditions); 1725 Dir->setPreInits(Exprs.PreInits); 1726 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB); 1727 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB); 1728 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB); 1729 Dir->setCombinedInit(Exprs.DistCombinedFields.Init); 1730 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond); 1731 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB); 1732 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB); 1733 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond); 1734 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond); 1735 return Dir; 1736 } 1737 1738 OMPTeamsDistributeParallelForSimdDirective * 1739 OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C, 1740 unsigned NumClauses, 1741 unsigned CollapsedNum, 1742 EmptyShell) { 1743 return createEmptyDirective<OMPTeamsDistributeParallelForSimdDirective>( 1744 C, NumClauses, /*HasAssociatedStmt=*/true, 1745 numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for_simd), 1746 CollapsedNum); 1747 } 1748 1749 OMPTeamsDistributeParallelForDirective * 1750 OMPTeamsDistributeParallelForDirective::Create( 1751 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1752 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1753 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) { 1754 auto *Dir = createDirective<OMPTeamsDistributeParallelForDirective>( 1755 C, Clauses, AssociatedStmt, 1756 numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for) + 1, 1757 StartLoc, EndLoc, CollapsedNum); 1758 Dir->setIterationVariable(Exprs.IterationVarRef); 1759 Dir->setLastIteration(Exprs.LastIteration); 1760 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1761 Dir->setPreCond(Exprs.PreCond); 1762 Dir->setCond(Exprs.Cond); 1763 Dir->setInit(Exprs.Init); 1764 Dir->setInc(Exprs.Inc); 1765 Dir->setIsLastIterVariable(Exprs.IL); 1766 Dir->setLowerBoundVariable(Exprs.LB); 1767 Dir->setUpperBoundVariable(Exprs.UB); 1768 Dir->setStrideVariable(Exprs.ST); 1769 Dir->setEnsureUpperBound(Exprs.EUB); 1770 Dir->setNextLowerBound(Exprs.NLB); 1771 Dir->setNextUpperBound(Exprs.NUB); 1772 Dir->setNumIterations(Exprs.NumIterations); 1773 Dir->setPrevLowerBoundVariable(Exprs.PrevLB); 1774 Dir->setPrevUpperBoundVariable(Exprs.PrevUB); 1775 Dir->setDistInc(Exprs.DistInc); 1776 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB); 1777 Dir->setCounters(Exprs.Counters); 1778 Dir->setPrivateCounters(Exprs.PrivateCounters); 1779 Dir->setInits(Exprs.Inits); 1780 Dir->setUpdates(Exprs.Updates); 1781 Dir->setFinals(Exprs.Finals); 1782 Dir->setDependentCounters(Exprs.DependentCounters); 1783 Dir->setDependentInits(Exprs.DependentInits); 1784 Dir->setFinalsConditions(Exprs.FinalsConditions); 1785 Dir->setPreInits(Exprs.PreInits); 1786 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB); 1787 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB); 1788 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB); 1789 Dir->setCombinedInit(Exprs.DistCombinedFields.Init); 1790 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond); 1791 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB); 1792 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB); 1793 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond); 1794 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond); 1795 Dir->setTaskReductionRefExpr(TaskRedRef); 1796 Dir->HasCancel = HasCancel; 1797 return Dir; 1798 } 1799 1800 OMPTeamsDistributeParallelForDirective * 1801 OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C, 1802 unsigned NumClauses, 1803 unsigned CollapsedNum, 1804 EmptyShell) { 1805 return createEmptyDirective<OMPTeamsDistributeParallelForDirective>( 1806 C, NumClauses, /*HasAssociatedStmt=*/true, 1807 numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for) + 1, 1808 CollapsedNum); 1809 } 1810 1811 OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create( 1812 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1813 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { 1814 return createDirective<OMPTargetTeamsDirective>(C, Clauses, AssociatedStmt, 1815 /*NumChildren=*/0, StartLoc, 1816 EndLoc); 1817 } 1818 1819 OMPTargetTeamsDirective * 1820 OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 1821 EmptyShell) { 1822 return createEmptyDirective<OMPTargetTeamsDirective>( 1823 C, NumClauses, /*HasAssociatedStmt=*/true); 1824 } 1825 1826 OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create( 1827 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1828 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1829 const HelperExprs &Exprs) { 1830 auto *Dir = createDirective<OMPTargetTeamsDistributeDirective>( 1831 C, Clauses, AssociatedStmt, 1832 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute), StartLoc, 1833 EndLoc, CollapsedNum); 1834 Dir->setIterationVariable(Exprs.IterationVarRef); 1835 Dir->setLastIteration(Exprs.LastIteration); 1836 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1837 Dir->setPreCond(Exprs.PreCond); 1838 Dir->setCond(Exprs.Cond); 1839 Dir->setInit(Exprs.Init); 1840 Dir->setInc(Exprs.Inc); 1841 Dir->setIsLastIterVariable(Exprs.IL); 1842 Dir->setLowerBoundVariable(Exprs.LB); 1843 Dir->setUpperBoundVariable(Exprs.UB); 1844 Dir->setStrideVariable(Exprs.ST); 1845 Dir->setEnsureUpperBound(Exprs.EUB); 1846 Dir->setNextLowerBound(Exprs.NLB); 1847 Dir->setNextUpperBound(Exprs.NUB); 1848 Dir->setNumIterations(Exprs.NumIterations); 1849 Dir->setCounters(Exprs.Counters); 1850 Dir->setPrivateCounters(Exprs.PrivateCounters); 1851 Dir->setInits(Exprs.Inits); 1852 Dir->setUpdates(Exprs.Updates); 1853 Dir->setFinals(Exprs.Finals); 1854 Dir->setDependentCounters(Exprs.DependentCounters); 1855 Dir->setDependentInits(Exprs.DependentInits); 1856 Dir->setFinalsConditions(Exprs.FinalsConditions); 1857 Dir->setPreInits(Exprs.PreInits); 1858 return Dir; 1859 } 1860 1861 OMPTargetTeamsDistributeDirective * 1862 OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C, 1863 unsigned NumClauses, 1864 unsigned CollapsedNum, 1865 EmptyShell) { 1866 return createEmptyDirective<OMPTargetTeamsDistributeDirective>( 1867 C, NumClauses, /*HasAssociatedStmt=*/true, 1868 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute), 1869 CollapsedNum); 1870 } 1871 1872 OMPTargetTeamsDistributeParallelForDirective * 1873 OMPTargetTeamsDistributeParallelForDirective::Create( 1874 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1875 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1876 const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) { 1877 auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForDirective>( 1878 C, Clauses, AssociatedStmt, 1879 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_parallel_for) + 1880 1, 1881 StartLoc, EndLoc, CollapsedNum); 1882 Dir->setIterationVariable(Exprs.IterationVarRef); 1883 Dir->setLastIteration(Exprs.LastIteration); 1884 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1885 Dir->setPreCond(Exprs.PreCond); 1886 Dir->setCond(Exprs.Cond); 1887 Dir->setInit(Exprs.Init); 1888 Dir->setInc(Exprs.Inc); 1889 Dir->setIsLastIterVariable(Exprs.IL); 1890 Dir->setLowerBoundVariable(Exprs.LB); 1891 Dir->setUpperBoundVariable(Exprs.UB); 1892 Dir->setStrideVariable(Exprs.ST); 1893 Dir->setEnsureUpperBound(Exprs.EUB); 1894 Dir->setNextLowerBound(Exprs.NLB); 1895 Dir->setNextUpperBound(Exprs.NUB); 1896 Dir->setNumIterations(Exprs.NumIterations); 1897 Dir->setPrevLowerBoundVariable(Exprs.PrevLB); 1898 Dir->setPrevUpperBoundVariable(Exprs.PrevUB); 1899 Dir->setDistInc(Exprs.DistInc); 1900 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB); 1901 Dir->setCounters(Exprs.Counters); 1902 Dir->setPrivateCounters(Exprs.PrivateCounters); 1903 Dir->setInits(Exprs.Inits); 1904 Dir->setUpdates(Exprs.Updates); 1905 Dir->setFinals(Exprs.Finals); 1906 Dir->setDependentCounters(Exprs.DependentCounters); 1907 Dir->setDependentInits(Exprs.DependentInits); 1908 Dir->setFinalsConditions(Exprs.FinalsConditions); 1909 Dir->setPreInits(Exprs.PreInits); 1910 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB); 1911 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB); 1912 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB); 1913 Dir->setCombinedInit(Exprs.DistCombinedFields.Init); 1914 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond); 1915 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB); 1916 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB); 1917 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond); 1918 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond); 1919 Dir->setTaskReductionRefExpr(TaskRedRef); 1920 Dir->HasCancel = HasCancel; 1921 return Dir; 1922 } 1923 1924 OMPTargetTeamsDistributeParallelForDirective * 1925 OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C, 1926 unsigned NumClauses, 1927 unsigned CollapsedNum, 1928 EmptyShell) { 1929 return createEmptyDirective<OMPTargetTeamsDistributeParallelForDirective>( 1930 C, NumClauses, /*HasAssociatedStmt=*/true, 1931 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_parallel_for) + 1932 1, 1933 CollapsedNum); 1934 } 1935 1936 OMPTargetTeamsDistributeParallelForSimdDirective * 1937 OMPTargetTeamsDistributeParallelForSimdDirective::Create( 1938 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 1939 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 1940 const HelperExprs &Exprs) { 1941 auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForSimdDirective>( 1942 C, Clauses, AssociatedStmt, 1943 numLoopChildren(CollapsedNum, 1944 OMPD_target_teams_distribute_parallel_for_simd), 1945 StartLoc, EndLoc, CollapsedNum); 1946 Dir->setIterationVariable(Exprs.IterationVarRef); 1947 Dir->setLastIteration(Exprs.LastIteration); 1948 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 1949 Dir->setPreCond(Exprs.PreCond); 1950 Dir->setCond(Exprs.Cond); 1951 Dir->setInit(Exprs.Init); 1952 Dir->setInc(Exprs.Inc); 1953 Dir->setIsLastIterVariable(Exprs.IL); 1954 Dir->setLowerBoundVariable(Exprs.LB); 1955 Dir->setUpperBoundVariable(Exprs.UB); 1956 Dir->setStrideVariable(Exprs.ST); 1957 Dir->setEnsureUpperBound(Exprs.EUB); 1958 Dir->setNextLowerBound(Exprs.NLB); 1959 Dir->setNextUpperBound(Exprs.NUB); 1960 Dir->setNumIterations(Exprs.NumIterations); 1961 Dir->setPrevLowerBoundVariable(Exprs.PrevLB); 1962 Dir->setPrevUpperBoundVariable(Exprs.PrevUB); 1963 Dir->setDistInc(Exprs.DistInc); 1964 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB); 1965 Dir->setCounters(Exprs.Counters); 1966 Dir->setPrivateCounters(Exprs.PrivateCounters); 1967 Dir->setInits(Exprs.Inits); 1968 Dir->setUpdates(Exprs.Updates); 1969 Dir->setFinals(Exprs.Finals); 1970 Dir->setDependentCounters(Exprs.DependentCounters); 1971 Dir->setDependentInits(Exprs.DependentInits); 1972 Dir->setFinalsConditions(Exprs.FinalsConditions); 1973 Dir->setPreInits(Exprs.PreInits); 1974 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB); 1975 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB); 1976 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB); 1977 Dir->setCombinedInit(Exprs.DistCombinedFields.Init); 1978 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond); 1979 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB); 1980 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB); 1981 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond); 1982 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond); 1983 return Dir; 1984 } 1985 1986 OMPTargetTeamsDistributeParallelForSimdDirective * 1987 OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty( 1988 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, 1989 EmptyShell) { 1990 return createEmptyDirective<OMPTargetTeamsDistributeParallelForSimdDirective>( 1991 C, NumClauses, /*HasAssociatedStmt=*/true, 1992 numLoopChildren(CollapsedNum, 1993 OMPD_target_teams_distribute_parallel_for_simd), 1994 CollapsedNum); 1995 } 1996 1997 OMPTargetTeamsDistributeSimdDirective * 1998 OMPTargetTeamsDistributeSimdDirective::Create( 1999 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 2000 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 2001 const HelperExprs &Exprs) { 2002 auto *Dir = createDirective<OMPTargetTeamsDistributeSimdDirective>( 2003 C, Clauses, AssociatedStmt, 2004 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd), 2005 StartLoc, EndLoc, CollapsedNum); 2006 Dir->setIterationVariable(Exprs.IterationVarRef); 2007 Dir->setLastIteration(Exprs.LastIteration); 2008 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 2009 Dir->setPreCond(Exprs.PreCond); 2010 Dir->setCond(Exprs.Cond); 2011 Dir->setInit(Exprs.Init); 2012 Dir->setInc(Exprs.Inc); 2013 Dir->setIsLastIterVariable(Exprs.IL); 2014 Dir->setLowerBoundVariable(Exprs.LB); 2015 Dir->setUpperBoundVariable(Exprs.UB); 2016 Dir->setStrideVariable(Exprs.ST); 2017 Dir->setEnsureUpperBound(Exprs.EUB); 2018 Dir->setNextLowerBound(Exprs.NLB); 2019 Dir->setNextUpperBound(Exprs.NUB); 2020 Dir->setNumIterations(Exprs.NumIterations); 2021 Dir->setCounters(Exprs.Counters); 2022 Dir->setPrivateCounters(Exprs.PrivateCounters); 2023 Dir->setInits(Exprs.Inits); 2024 Dir->setUpdates(Exprs.Updates); 2025 Dir->setFinals(Exprs.Finals); 2026 Dir->setDependentCounters(Exprs.DependentCounters); 2027 Dir->setDependentInits(Exprs.DependentInits); 2028 Dir->setFinalsConditions(Exprs.FinalsConditions); 2029 Dir->setPreInits(Exprs.PreInits); 2030 return Dir; 2031 } 2032 2033 OMPTargetTeamsDistributeSimdDirective * 2034 OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C, 2035 unsigned NumClauses, 2036 unsigned CollapsedNum, 2037 EmptyShell) { 2038 return createEmptyDirective<OMPTargetTeamsDistributeSimdDirective>( 2039 C, NumClauses, /*HasAssociatedStmt=*/true, 2040 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd), 2041 CollapsedNum); 2042 } 2043 2044 OMPInteropDirective * 2045 OMPInteropDirective::Create(const ASTContext &C, SourceLocation StartLoc, 2046 SourceLocation EndLoc, 2047 ArrayRef<OMPClause *> Clauses) { 2048 return createDirective<OMPInteropDirective>( 2049 C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc, 2050 EndLoc); 2051 } 2052 2053 OMPInteropDirective *OMPInteropDirective::CreateEmpty(const ASTContext &C, 2054 unsigned NumClauses, 2055 EmptyShell) { 2056 return createEmptyDirective<OMPInteropDirective>(C, NumClauses); 2057 } 2058 2059 OMPDispatchDirective *OMPDispatchDirective::Create( 2060 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 2061 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 2062 SourceLocation TargetCallLoc) { 2063 auto *Dir = createDirective<OMPDispatchDirective>( 2064 C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc); 2065 Dir->setTargetCallLoc(TargetCallLoc); 2066 return Dir; 2067 } 2068 2069 OMPDispatchDirective *OMPDispatchDirective::CreateEmpty(const ASTContext &C, 2070 unsigned NumClauses, 2071 EmptyShell) { 2072 return createEmptyDirective<OMPDispatchDirective>(C, NumClauses, 2073 /*HasAssociatedStmt=*/true, 2074 /*NumChildren=*/0); 2075 } 2076 2077 OMPMaskedDirective *OMPMaskedDirective::Create(const ASTContext &C, 2078 SourceLocation StartLoc, 2079 SourceLocation EndLoc, 2080 ArrayRef<OMPClause *> Clauses, 2081 Stmt *AssociatedStmt) { 2082 return createDirective<OMPMaskedDirective>(C, Clauses, AssociatedStmt, 2083 /*NumChildren=*/0, StartLoc, 2084 EndLoc); 2085 } 2086 2087 OMPMaskedDirective *OMPMaskedDirective::CreateEmpty(const ASTContext &C, 2088 unsigned NumClauses, 2089 EmptyShell) { 2090 return createEmptyDirective<OMPMaskedDirective>(C, NumClauses, 2091 /*HasAssociatedStmt=*/true); 2092 } 2093 2094 OMPGenericLoopDirective *OMPGenericLoopDirective::Create( 2095 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 2096 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 2097 const HelperExprs &Exprs) { 2098 auto *Dir = createDirective<OMPGenericLoopDirective>( 2099 C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_loop), 2100 StartLoc, EndLoc, CollapsedNum); 2101 Dir->setIterationVariable(Exprs.IterationVarRef); 2102 Dir->setLastIteration(Exprs.LastIteration); 2103 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 2104 Dir->setPreCond(Exprs.PreCond); 2105 Dir->setCond(Exprs.Cond); 2106 Dir->setInit(Exprs.Init); 2107 Dir->setInc(Exprs.Inc); 2108 Dir->setIsLastIterVariable(Exprs.IL); 2109 Dir->setLowerBoundVariable(Exprs.LB); 2110 Dir->setUpperBoundVariable(Exprs.UB); 2111 Dir->setStrideVariable(Exprs.ST); 2112 Dir->setEnsureUpperBound(Exprs.EUB); 2113 Dir->setNextLowerBound(Exprs.NLB); 2114 Dir->setNextUpperBound(Exprs.NUB); 2115 Dir->setNumIterations(Exprs.NumIterations); 2116 Dir->setCounters(Exprs.Counters); 2117 Dir->setPrivateCounters(Exprs.PrivateCounters); 2118 Dir->setInits(Exprs.Inits); 2119 Dir->setUpdates(Exprs.Updates); 2120 Dir->setFinals(Exprs.Finals); 2121 Dir->setDependentCounters(Exprs.DependentCounters); 2122 Dir->setDependentInits(Exprs.DependentInits); 2123 Dir->setFinalsConditions(Exprs.FinalsConditions); 2124 Dir->setPreInits(Exprs.PreInits); 2125 return Dir; 2126 } 2127 2128 OMPGenericLoopDirective * 2129 OMPGenericLoopDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 2130 unsigned CollapsedNum, EmptyShell) { 2131 return createEmptyDirective<OMPGenericLoopDirective>( 2132 C, NumClauses, /*HasAssociatedStmt=*/true, 2133 numLoopChildren(CollapsedNum, OMPD_loop), CollapsedNum); 2134 } 2135