1 //===--- StmtOpenMP.cpp - Classes for OpenMP directives -------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file implements the subclesses of Stmt class declared in StmtOpenMP.h 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "clang/AST/StmtOpenMP.h" 15 16 #include "clang/AST/ASTContext.h" 17 18 using namespace clang; 19 20 void OMPExecutableDirective::setClauses(ArrayRef<OMPClause *> Clauses) { 21 assert(Clauses.size() == getNumClauses() && 22 "Number of clauses is not the same as the preallocated buffer"); 23 std::copy(Clauses.begin(), Clauses.end(), getClauses().begin()); 24 } 25 26 void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) { 27 assert(A.size() == getCollapsedNumber() && 28 "Number of loop counters is not the same as the collapsed number"); 29 std::copy(A.begin(), A.end(), getCounters().begin()); 30 } 31 32 void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) { 33 assert(A.size() == getCollapsedNumber() && "Number of loop private counters " 34 "is not the same as the collapsed " 35 "number"); 36 std::copy(A.begin(), A.end(), getPrivateCounters().begin()); 37 } 38 39 void OMPLoopDirective::setInits(ArrayRef<Expr *> A) { 40 assert(A.size() == getCollapsedNumber() && 41 "Number of counter inits is not the same as the collapsed number"); 42 std::copy(A.begin(), A.end(), getInits().begin()); 43 } 44 45 void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) { 46 assert(A.size() == getCollapsedNumber() && 47 "Number of counter updates is not the same as the collapsed number"); 48 std::copy(A.begin(), A.end(), getUpdates().begin()); 49 } 50 51 void OMPLoopDirective::setFinals(ArrayRef<Expr *> A) { 52 assert(A.size() == getCollapsedNumber() && 53 "Number of counter finals is not the same as the collapsed number"); 54 std::copy(A.begin(), A.end(), getFinals().begin()); 55 } 56 57 OMPParallelDirective *OMPParallelDirective::Create( 58 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 59 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) { 60 unsigned Size = 61 llvm::alignTo(sizeof(OMPParallelDirective), llvm::alignOf<OMPClause *>()); 62 void *Mem = 63 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 64 OMPParallelDirective *Dir = 65 new (Mem) OMPParallelDirective(StartLoc, EndLoc, Clauses.size()); 66 Dir->setClauses(Clauses); 67 Dir->setAssociatedStmt(AssociatedStmt); 68 Dir->setHasCancel(HasCancel); 69 return Dir; 70 } 71 72 OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C, 73 unsigned NumClauses, 74 EmptyShell) { 75 unsigned Size = 76 llvm::alignTo(sizeof(OMPParallelDirective), llvm::alignOf<OMPClause *>()); 77 void *Mem = 78 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 79 return new (Mem) OMPParallelDirective(NumClauses); 80 } 81 82 OMPSimdDirective * 83 OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc, 84 SourceLocation EndLoc, unsigned CollapsedNum, 85 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 86 const HelperExprs &Exprs) { 87 unsigned Size = 88 llvm::alignTo(sizeof(OMPSimdDirective), llvm::alignOf<OMPClause *>()); 89 void *Mem = 90 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 91 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd)); 92 OMPSimdDirective *Dir = new (Mem) 93 OMPSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); 94 Dir->setClauses(Clauses); 95 Dir->setAssociatedStmt(AssociatedStmt); 96 Dir->setIterationVariable(Exprs.IterationVarRef); 97 Dir->setLastIteration(Exprs.LastIteration); 98 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 99 Dir->setPreCond(Exprs.PreCond); 100 Dir->setCond(Exprs.Cond); 101 Dir->setInit(Exprs.Init); 102 Dir->setInc(Exprs.Inc); 103 Dir->setCounters(Exprs.Counters); 104 Dir->setPrivateCounters(Exprs.PrivateCounters); 105 Dir->setInits(Exprs.Inits); 106 Dir->setUpdates(Exprs.Updates); 107 Dir->setFinals(Exprs.Finals); 108 Dir->setPreInits(Exprs.PreInits); 109 return Dir; 110 } 111 112 OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C, 113 unsigned NumClauses, 114 unsigned CollapsedNum, 115 EmptyShell) { 116 unsigned Size = 117 llvm::alignTo(sizeof(OMPSimdDirective), llvm::alignOf<OMPClause *>()); 118 void *Mem = 119 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 120 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd)); 121 return new (Mem) OMPSimdDirective(CollapsedNum, NumClauses); 122 } 123 124 OMPForDirective * 125 OMPForDirective::Create(const ASTContext &C, SourceLocation StartLoc, 126 SourceLocation EndLoc, unsigned CollapsedNum, 127 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 128 const HelperExprs &Exprs, bool HasCancel) { 129 unsigned Size = 130 llvm::alignTo(sizeof(OMPForDirective), llvm::alignOf<OMPClause *>()); 131 void *Mem = 132 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 133 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for)); 134 OMPForDirective *Dir = 135 new (Mem) OMPForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); 136 Dir->setClauses(Clauses); 137 Dir->setAssociatedStmt(AssociatedStmt); 138 Dir->setIterationVariable(Exprs.IterationVarRef); 139 Dir->setLastIteration(Exprs.LastIteration); 140 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 141 Dir->setPreCond(Exprs.PreCond); 142 Dir->setCond(Exprs.Cond); 143 Dir->setInit(Exprs.Init); 144 Dir->setInc(Exprs.Inc); 145 Dir->setIsLastIterVariable(Exprs.IL); 146 Dir->setLowerBoundVariable(Exprs.LB); 147 Dir->setUpperBoundVariable(Exprs.UB); 148 Dir->setStrideVariable(Exprs.ST); 149 Dir->setEnsureUpperBound(Exprs.EUB); 150 Dir->setNextLowerBound(Exprs.NLB); 151 Dir->setNextUpperBound(Exprs.NUB); 152 Dir->setNumIterations(Exprs.NumIterations); 153 Dir->setCounters(Exprs.Counters); 154 Dir->setPrivateCounters(Exprs.PrivateCounters); 155 Dir->setInits(Exprs.Inits); 156 Dir->setUpdates(Exprs.Updates); 157 Dir->setFinals(Exprs.Finals); 158 Dir->setPreInits(Exprs.PreInits); 159 Dir->setHasCancel(HasCancel); 160 return Dir; 161 } 162 163 OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C, 164 unsigned NumClauses, 165 unsigned CollapsedNum, 166 EmptyShell) { 167 unsigned Size = 168 llvm::alignTo(sizeof(OMPForDirective), llvm::alignOf<OMPClause *>()); 169 void *Mem = 170 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 171 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for)); 172 return new (Mem) OMPForDirective(CollapsedNum, NumClauses); 173 } 174 175 OMPForSimdDirective * 176 OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc, 177 SourceLocation EndLoc, unsigned CollapsedNum, 178 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 179 const HelperExprs &Exprs) { 180 unsigned Size = 181 llvm::alignTo(sizeof(OMPForSimdDirective), llvm::alignOf<OMPClause *>()); 182 void *Mem = 183 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 184 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd)); 185 OMPForSimdDirective *Dir = new (Mem) 186 OMPForSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); 187 Dir->setClauses(Clauses); 188 Dir->setAssociatedStmt(AssociatedStmt); 189 Dir->setIterationVariable(Exprs.IterationVarRef); 190 Dir->setLastIteration(Exprs.LastIteration); 191 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 192 Dir->setPreCond(Exprs.PreCond); 193 Dir->setCond(Exprs.Cond); 194 Dir->setInit(Exprs.Init); 195 Dir->setInc(Exprs.Inc); 196 Dir->setIsLastIterVariable(Exprs.IL); 197 Dir->setLowerBoundVariable(Exprs.LB); 198 Dir->setUpperBoundVariable(Exprs.UB); 199 Dir->setStrideVariable(Exprs.ST); 200 Dir->setEnsureUpperBound(Exprs.EUB); 201 Dir->setNextLowerBound(Exprs.NLB); 202 Dir->setNextUpperBound(Exprs.NUB); 203 Dir->setNumIterations(Exprs.NumIterations); 204 Dir->setCounters(Exprs.Counters); 205 Dir->setPrivateCounters(Exprs.PrivateCounters); 206 Dir->setInits(Exprs.Inits); 207 Dir->setUpdates(Exprs.Updates); 208 Dir->setFinals(Exprs.Finals); 209 Dir->setPreInits(Exprs.PreInits); 210 return Dir; 211 } 212 213 OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C, 214 unsigned NumClauses, 215 unsigned CollapsedNum, 216 EmptyShell) { 217 unsigned Size = 218 llvm::alignTo(sizeof(OMPForSimdDirective), llvm::alignOf<OMPClause *>()); 219 void *Mem = 220 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 221 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd)); 222 return new (Mem) OMPForSimdDirective(CollapsedNum, NumClauses); 223 } 224 225 OMPSectionsDirective *OMPSectionsDirective::Create( 226 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 227 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) { 228 unsigned Size = 229 llvm::alignTo(sizeof(OMPSectionsDirective), llvm::alignOf<OMPClause *>()); 230 void *Mem = 231 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 232 OMPSectionsDirective *Dir = 233 new (Mem) OMPSectionsDirective(StartLoc, EndLoc, Clauses.size()); 234 Dir->setClauses(Clauses); 235 Dir->setAssociatedStmt(AssociatedStmt); 236 Dir->setHasCancel(HasCancel); 237 return Dir; 238 } 239 240 OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C, 241 unsigned NumClauses, 242 EmptyShell) { 243 unsigned Size = 244 llvm::alignTo(sizeof(OMPSectionsDirective), llvm::alignOf<OMPClause *>()); 245 void *Mem = 246 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 247 return new (Mem) OMPSectionsDirective(NumClauses); 248 } 249 250 OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C, 251 SourceLocation StartLoc, 252 SourceLocation EndLoc, 253 Stmt *AssociatedStmt, 254 bool HasCancel) { 255 unsigned Size = 256 llvm::alignTo(sizeof(OMPSectionDirective), llvm::alignOf<Stmt *>()); 257 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 258 OMPSectionDirective *Dir = new (Mem) OMPSectionDirective(StartLoc, EndLoc); 259 Dir->setAssociatedStmt(AssociatedStmt); 260 Dir->setHasCancel(HasCancel); 261 return Dir; 262 } 263 264 OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C, 265 EmptyShell) { 266 unsigned Size = 267 llvm::alignTo(sizeof(OMPSectionDirective), llvm::alignOf<Stmt *>()); 268 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 269 return new (Mem) OMPSectionDirective(); 270 } 271 272 OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C, 273 SourceLocation StartLoc, 274 SourceLocation EndLoc, 275 ArrayRef<OMPClause *> Clauses, 276 Stmt *AssociatedStmt) { 277 unsigned Size = 278 llvm::alignTo(sizeof(OMPSingleDirective), llvm::alignOf<OMPClause *>()); 279 void *Mem = 280 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 281 OMPSingleDirective *Dir = 282 new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size()); 283 Dir->setClauses(Clauses); 284 Dir->setAssociatedStmt(AssociatedStmt); 285 return Dir; 286 } 287 288 OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C, 289 unsigned NumClauses, 290 EmptyShell) { 291 unsigned Size = 292 llvm::alignTo(sizeof(OMPSingleDirective), llvm::alignOf<OMPClause *>()); 293 void *Mem = 294 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 295 return new (Mem) OMPSingleDirective(NumClauses); 296 } 297 298 OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C, 299 SourceLocation StartLoc, 300 SourceLocation EndLoc, 301 Stmt *AssociatedStmt) { 302 unsigned Size = 303 llvm::alignTo(sizeof(OMPMasterDirective), llvm::alignOf<Stmt *>()); 304 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 305 OMPMasterDirective *Dir = new (Mem) OMPMasterDirective(StartLoc, EndLoc); 306 Dir->setAssociatedStmt(AssociatedStmt); 307 return Dir; 308 } 309 310 OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C, 311 EmptyShell) { 312 unsigned Size = 313 llvm::alignTo(sizeof(OMPMasterDirective), llvm::alignOf<Stmt *>()); 314 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 315 return new (Mem) OMPMasterDirective(); 316 } 317 318 OMPCriticalDirective *OMPCriticalDirective::Create( 319 const ASTContext &C, const DeclarationNameInfo &Name, 320 SourceLocation StartLoc, SourceLocation EndLoc, 321 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { 322 unsigned Size = 323 llvm::alignTo(sizeof(OMPCriticalDirective), llvm::alignOf<OMPClause *>()); 324 void *Mem = 325 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 326 OMPCriticalDirective *Dir = 327 new (Mem) OMPCriticalDirective(Name, StartLoc, EndLoc, Clauses.size()); 328 Dir->setClauses(Clauses); 329 Dir->setAssociatedStmt(AssociatedStmt); 330 return Dir; 331 } 332 333 OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C, 334 unsigned NumClauses, 335 EmptyShell) { 336 unsigned Size = 337 llvm::alignTo(sizeof(OMPCriticalDirective), llvm::alignOf<OMPClause *>()); 338 void *Mem = 339 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 340 return new (Mem) OMPCriticalDirective(NumClauses); 341 } 342 343 OMPParallelForDirective *OMPParallelForDirective::Create( 344 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 345 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 346 const HelperExprs &Exprs, bool HasCancel) { 347 unsigned Size = llvm::alignTo(sizeof(OMPParallelForDirective), 348 llvm::alignOf<OMPClause *>()); 349 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 350 sizeof(Stmt *) * 351 numLoopChildren(CollapsedNum, OMPD_parallel_for)); 352 OMPParallelForDirective *Dir = new (Mem) 353 OMPParallelForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); 354 Dir->setClauses(Clauses); 355 Dir->setAssociatedStmt(AssociatedStmt); 356 Dir->setIterationVariable(Exprs.IterationVarRef); 357 Dir->setLastIteration(Exprs.LastIteration); 358 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 359 Dir->setPreCond(Exprs.PreCond); 360 Dir->setCond(Exprs.Cond); 361 Dir->setInit(Exprs.Init); 362 Dir->setInc(Exprs.Inc); 363 Dir->setIsLastIterVariable(Exprs.IL); 364 Dir->setLowerBoundVariable(Exprs.LB); 365 Dir->setUpperBoundVariable(Exprs.UB); 366 Dir->setStrideVariable(Exprs.ST); 367 Dir->setEnsureUpperBound(Exprs.EUB); 368 Dir->setNextLowerBound(Exprs.NLB); 369 Dir->setNextUpperBound(Exprs.NUB); 370 Dir->setNumIterations(Exprs.NumIterations); 371 Dir->setCounters(Exprs.Counters); 372 Dir->setPrivateCounters(Exprs.PrivateCounters); 373 Dir->setInits(Exprs.Inits); 374 Dir->setUpdates(Exprs.Updates); 375 Dir->setFinals(Exprs.Finals); 376 Dir->setPreInits(Exprs.PreInits); 377 Dir->setHasCancel(HasCancel); 378 return Dir; 379 } 380 381 OMPParallelForDirective * 382 OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 383 unsigned CollapsedNum, EmptyShell) { 384 unsigned Size = llvm::alignTo(sizeof(OMPParallelForDirective), 385 llvm::alignOf<OMPClause *>()); 386 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 387 sizeof(Stmt *) * 388 numLoopChildren(CollapsedNum, OMPD_parallel_for)); 389 return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses); 390 } 391 392 OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create( 393 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 394 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 395 const HelperExprs &Exprs) { 396 unsigned Size = llvm::alignTo(sizeof(OMPParallelForSimdDirective), 397 llvm::alignOf<OMPClause *>()); 398 void *Mem = C.Allocate( 399 Size + sizeof(OMPClause *) * Clauses.size() + 400 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd)); 401 OMPParallelForSimdDirective *Dir = new (Mem) OMPParallelForSimdDirective( 402 StartLoc, EndLoc, CollapsedNum, Clauses.size()); 403 Dir->setClauses(Clauses); 404 Dir->setAssociatedStmt(AssociatedStmt); 405 Dir->setIterationVariable(Exprs.IterationVarRef); 406 Dir->setLastIteration(Exprs.LastIteration); 407 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 408 Dir->setPreCond(Exprs.PreCond); 409 Dir->setCond(Exprs.Cond); 410 Dir->setInit(Exprs.Init); 411 Dir->setInc(Exprs.Inc); 412 Dir->setIsLastIterVariable(Exprs.IL); 413 Dir->setLowerBoundVariable(Exprs.LB); 414 Dir->setUpperBoundVariable(Exprs.UB); 415 Dir->setStrideVariable(Exprs.ST); 416 Dir->setEnsureUpperBound(Exprs.EUB); 417 Dir->setNextLowerBound(Exprs.NLB); 418 Dir->setNextUpperBound(Exprs.NUB); 419 Dir->setNumIterations(Exprs.NumIterations); 420 Dir->setCounters(Exprs.Counters); 421 Dir->setPrivateCounters(Exprs.PrivateCounters); 422 Dir->setInits(Exprs.Inits); 423 Dir->setUpdates(Exprs.Updates); 424 Dir->setFinals(Exprs.Finals); 425 Dir->setPreInits(Exprs.PreInits); 426 return Dir; 427 } 428 429 OMPParallelForSimdDirective * 430 OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C, 431 unsigned NumClauses, 432 unsigned CollapsedNum, EmptyShell) { 433 unsigned Size = llvm::alignTo(sizeof(OMPParallelForSimdDirective), 434 llvm::alignOf<OMPClause *>()); 435 void *Mem = C.Allocate( 436 Size + sizeof(OMPClause *) * NumClauses + 437 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd)); 438 return new (Mem) OMPParallelForSimdDirective(CollapsedNum, NumClauses); 439 } 440 441 OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create( 442 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 443 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) { 444 unsigned Size = llvm::alignTo(sizeof(OMPParallelSectionsDirective), 445 llvm::alignOf<OMPClause *>()); 446 void *Mem = 447 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 448 OMPParallelSectionsDirective *Dir = 449 new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size()); 450 Dir->setClauses(Clauses); 451 Dir->setAssociatedStmt(AssociatedStmt); 452 Dir->setHasCancel(HasCancel); 453 return Dir; 454 } 455 456 OMPParallelSectionsDirective * 457 OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C, 458 unsigned NumClauses, EmptyShell) { 459 unsigned Size = llvm::alignTo(sizeof(OMPParallelSectionsDirective), 460 llvm::alignOf<OMPClause *>()); 461 void *Mem = 462 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 463 return new (Mem) OMPParallelSectionsDirective(NumClauses); 464 } 465 466 OMPTaskDirective * 467 OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc, 468 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, 469 Stmt *AssociatedStmt, bool HasCancel) { 470 unsigned Size = 471 llvm::alignTo(sizeof(OMPTaskDirective), llvm::alignOf<OMPClause *>()); 472 void *Mem = 473 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 474 OMPTaskDirective *Dir = 475 new (Mem) OMPTaskDirective(StartLoc, EndLoc, Clauses.size()); 476 Dir->setClauses(Clauses); 477 Dir->setAssociatedStmt(AssociatedStmt); 478 Dir->setHasCancel(HasCancel); 479 return Dir; 480 } 481 482 OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C, 483 unsigned NumClauses, 484 EmptyShell) { 485 unsigned Size = 486 llvm::alignTo(sizeof(OMPTaskDirective), llvm::alignOf<OMPClause *>()); 487 void *Mem = 488 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 489 return new (Mem) OMPTaskDirective(NumClauses); 490 } 491 492 OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C, 493 SourceLocation StartLoc, 494 SourceLocation EndLoc) { 495 void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective)); 496 OMPTaskyieldDirective *Dir = 497 new (Mem) OMPTaskyieldDirective(StartLoc, EndLoc); 498 return Dir; 499 } 500 501 OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C, 502 EmptyShell) { 503 void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective)); 504 return new (Mem) OMPTaskyieldDirective(); 505 } 506 507 OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C, 508 SourceLocation StartLoc, 509 SourceLocation EndLoc) { 510 void *Mem = C.Allocate(sizeof(OMPBarrierDirective)); 511 OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc); 512 return Dir; 513 } 514 515 OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C, 516 EmptyShell) { 517 void *Mem = C.Allocate(sizeof(OMPBarrierDirective)); 518 return new (Mem) OMPBarrierDirective(); 519 } 520 521 OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C, 522 SourceLocation StartLoc, 523 SourceLocation EndLoc) { 524 void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective)); 525 OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc); 526 return Dir; 527 } 528 529 OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C, 530 EmptyShell) { 531 void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective)); 532 return new (Mem) OMPTaskwaitDirective(); 533 } 534 535 OMPTaskgroupDirective *OMPTaskgroupDirective::Create(const ASTContext &C, 536 SourceLocation StartLoc, 537 SourceLocation EndLoc, 538 Stmt *AssociatedStmt) { 539 unsigned Size = 540 llvm::alignTo(sizeof(OMPTaskgroupDirective), llvm::alignOf<Stmt *>()); 541 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 542 OMPTaskgroupDirective *Dir = 543 new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc); 544 Dir->setAssociatedStmt(AssociatedStmt); 545 return Dir; 546 } 547 548 OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C, 549 EmptyShell) { 550 unsigned Size = 551 llvm::alignTo(sizeof(OMPTaskgroupDirective), llvm::alignOf<Stmt *>()); 552 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 553 return new (Mem) OMPTaskgroupDirective(); 554 } 555 556 OMPCancellationPointDirective *OMPCancellationPointDirective::Create( 557 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 558 OpenMPDirectiveKind CancelRegion) { 559 unsigned Size = llvm::alignTo(sizeof(OMPCancellationPointDirective), 560 llvm::alignOf<Stmt *>()); 561 void *Mem = C.Allocate(Size); 562 OMPCancellationPointDirective *Dir = 563 new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc); 564 Dir->setCancelRegion(CancelRegion); 565 return Dir; 566 } 567 568 OMPCancellationPointDirective * 569 OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) { 570 unsigned Size = llvm::alignTo(sizeof(OMPCancellationPointDirective), 571 llvm::alignOf<Stmt *>()); 572 void *Mem = C.Allocate(Size); 573 return new (Mem) OMPCancellationPointDirective(); 574 } 575 576 OMPCancelDirective * 577 OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc, 578 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, 579 OpenMPDirectiveKind CancelRegion) { 580 unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) + 581 sizeof(OMPClause *) * Clauses.size(), 582 llvm::alignOf<Stmt *>()); 583 void *Mem = C.Allocate(Size); 584 OMPCancelDirective *Dir = 585 new (Mem) OMPCancelDirective(StartLoc, EndLoc, Clauses.size()); 586 Dir->setClauses(Clauses); 587 Dir->setCancelRegion(CancelRegion); 588 return Dir; 589 } 590 591 OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C, 592 unsigned NumClauses, 593 EmptyShell) { 594 unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) + 595 sizeof(OMPClause *) * NumClauses, 596 llvm::alignOf<Stmt *>()); 597 void *Mem = C.Allocate(Size); 598 return new (Mem) OMPCancelDirective(NumClauses); 599 } 600 601 OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C, 602 SourceLocation StartLoc, 603 SourceLocation EndLoc, 604 ArrayRef<OMPClause *> Clauses) { 605 unsigned Size = 606 llvm::alignTo(sizeof(OMPFlushDirective), llvm::alignOf<OMPClause *>()); 607 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size()); 608 OMPFlushDirective *Dir = 609 new (Mem) OMPFlushDirective(StartLoc, EndLoc, Clauses.size()); 610 Dir->setClauses(Clauses); 611 return Dir; 612 } 613 614 OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C, 615 unsigned NumClauses, 616 EmptyShell) { 617 unsigned Size = 618 llvm::alignTo(sizeof(OMPFlushDirective), llvm::alignOf<OMPClause *>()); 619 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses); 620 return new (Mem) OMPFlushDirective(NumClauses); 621 } 622 623 OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C, 624 SourceLocation StartLoc, 625 SourceLocation EndLoc, 626 ArrayRef<OMPClause *> Clauses, 627 Stmt *AssociatedStmt) { 628 unsigned Size = 629 llvm::alignTo(sizeof(OMPOrderedDirective), llvm::alignOf<OMPClause *>()); 630 void *Mem = 631 C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * Clauses.size()); 632 OMPOrderedDirective *Dir = 633 new (Mem) OMPOrderedDirective(StartLoc, EndLoc, Clauses.size()); 634 Dir->setClauses(Clauses); 635 Dir->setAssociatedStmt(AssociatedStmt); 636 return Dir; 637 } 638 639 OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C, 640 unsigned NumClauses, 641 EmptyShell) { 642 unsigned Size = 643 llvm::alignTo(sizeof(OMPOrderedDirective), llvm::alignOf<OMPClause *>()); 644 void *Mem = 645 C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * NumClauses); 646 return new (Mem) OMPOrderedDirective(NumClauses); 647 } 648 649 OMPAtomicDirective *OMPAtomicDirective::Create( 650 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 651 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V, 652 Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) { 653 unsigned Size = 654 llvm::alignTo(sizeof(OMPAtomicDirective), llvm::alignOf<OMPClause *>()); 655 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 656 5 * sizeof(Stmt *)); 657 OMPAtomicDirective *Dir = 658 new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size()); 659 Dir->setClauses(Clauses); 660 Dir->setAssociatedStmt(AssociatedStmt); 661 Dir->setX(X); 662 Dir->setV(V); 663 Dir->setExpr(E); 664 Dir->setUpdateExpr(UE); 665 Dir->IsXLHSInRHSPart = IsXLHSInRHSPart; 666 Dir->IsPostfixUpdate = IsPostfixUpdate; 667 return Dir; 668 } 669 670 OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C, 671 unsigned NumClauses, 672 EmptyShell) { 673 unsigned Size = 674 llvm::alignTo(sizeof(OMPAtomicDirective), llvm::alignOf<OMPClause *>()); 675 void *Mem = 676 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *)); 677 return new (Mem) OMPAtomicDirective(NumClauses); 678 } 679 680 OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C, 681 SourceLocation StartLoc, 682 SourceLocation EndLoc, 683 ArrayRef<OMPClause *> Clauses, 684 Stmt *AssociatedStmt) { 685 unsigned Size = 686 llvm::alignTo(sizeof(OMPTargetDirective), llvm::alignOf<OMPClause *>()); 687 void *Mem = 688 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 689 OMPTargetDirective *Dir = 690 new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size()); 691 Dir->setClauses(Clauses); 692 Dir->setAssociatedStmt(AssociatedStmt); 693 return Dir; 694 } 695 696 OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C, 697 unsigned NumClauses, 698 EmptyShell) { 699 unsigned Size = 700 llvm::alignTo(sizeof(OMPTargetDirective), llvm::alignOf<OMPClause *>()); 701 void *Mem = 702 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 703 return new (Mem) OMPTargetDirective(NumClauses); 704 } 705 706 OMPTargetParallelDirective *OMPTargetParallelDirective::Create( 707 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 708 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { 709 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelDirective), 710 llvm::alignOf<OMPClause *>()); 711 void *Mem = 712 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 713 OMPTargetParallelDirective *Dir = 714 new (Mem) OMPTargetParallelDirective(StartLoc, EndLoc, Clauses.size()); 715 Dir->setClauses(Clauses); 716 Dir->setAssociatedStmt(AssociatedStmt); 717 return Dir; 718 } 719 720 OMPTargetParallelDirective * 721 OMPTargetParallelDirective::CreateEmpty(const ASTContext &C, 722 unsigned NumClauses, EmptyShell) { 723 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelDirective), 724 llvm::alignOf<OMPClause *>()); 725 void *Mem = 726 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 727 return new (Mem) OMPTargetParallelDirective(NumClauses); 728 } 729 730 OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create( 731 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 732 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 733 const HelperExprs &Exprs, bool HasCancel) { 734 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective), 735 llvm::alignOf<OMPClause *>()); 736 void *Mem = C.Allocate( 737 Size + sizeof(OMPClause *) * Clauses.size() + 738 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for)); 739 OMPTargetParallelForDirective *Dir = new (Mem) OMPTargetParallelForDirective( 740 StartLoc, EndLoc, CollapsedNum, Clauses.size()); 741 Dir->setClauses(Clauses); 742 Dir->setAssociatedStmt(AssociatedStmt); 743 Dir->setIterationVariable(Exprs.IterationVarRef); 744 Dir->setLastIteration(Exprs.LastIteration); 745 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 746 Dir->setPreCond(Exprs.PreCond); 747 Dir->setCond(Exprs.Cond); 748 Dir->setInit(Exprs.Init); 749 Dir->setInc(Exprs.Inc); 750 Dir->setIsLastIterVariable(Exprs.IL); 751 Dir->setLowerBoundVariable(Exprs.LB); 752 Dir->setUpperBoundVariable(Exprs.UB); 753 Dir->setStrideVariable(Exprs.ST); 754 Dir->setEnsureUpperBound(Exprs.EUB); 755 Dir->setNextLowerBound(Exprs.NLB); 756 Dir->setNextUpperBound(Exprs.NUB); 757 Dir->setNumIterations(Exprs.NumIterations); 758 Dir->setCounters(Exprs.Counters); 759 Dir->setPrivateCounters(Exprs.PrivateCounters); 760 Dir->setInits(Exprs.Inits); 761 Dir->setUpdates(Exprs.Updates); 762 Dir->setFinals(Exprs.Finals); 763 Dir->setPreInits(Exprs.PreInits); 764 Dir->setHasCancel(HasCancel); 765 return Dir; 766 } 767 768 OMPTargetParallelForDirective * 769 OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C, 770 unsigned NumClauses, 771 unsigned CollapsedNum, EmptyShell) { 772 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective), 773 llvm::alignOf<OMPClause *>()); 774 void *Mem = C.Allocate( 775 Size + sizeof(OMPClause *) * NumClauses + 776 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for)); 777 return new (Mem) OMPTargetParallelForDirective(CollapsedNum, NumClauses); 778 } 779 780 OMPTargetDataDirective *OMPTargetDataDirective::Create( 781 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 782 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { 783 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetDataDirective), 784 llvm::alignOf<OMPClause *>()) + 785 sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 786 OMPTargetDataDirective *Dir = 787 new (Mem) OMPTargetDataDirective(StartLoc, EndLoc, Clauses.size()); 788 Dir->setClauses(Clauses); 789 Dir->setAssociatedStmt(AssociatedStmt); 790 return Dir; 791 } 792 793 OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C, 794 unsigned N, 795 EmptyShell) { 796 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetDataDirective), 797 llvm::alignOf<OMPClause *>()) + 798 sizeof(OMPClause *) * N + sizeof(Stmt *)); 799 return new (Mem) OMPTargetDataDirective(N); 800 } 801 802 OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create( 803 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 804 ArrayRef<OMPClause *> Clauses) { 805 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetEnterDataDirective), 806 llvm::alignOf<OMPClause *>()) + 807 sizeof(OMPClause *) * Clauses.size()); 808 OMPTargetEnterDataDirective *Dir = 809 new (Mem) OMPTargetEnterDataDirective(StartLoc, EndLoc, Clauses.size()); 810 Dir->setClauses(Clauses); 811 return Dir; 812 } 813 814 OMPTargetEnterDataDirective * 815 OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N, 816 EmptyShell) { 817 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetEnterDataDirective), 818 llvm::alignOf<OMPClause *>()) + 819 sizeof(OMPClause *) * N); 820 return new (Mem) OMPTargetEnterDataDirective(N); 821 } 822 823 OMPTargetExitDataDirective * 824 OMPTargetExitDataDirective::Create(const ASTContext &C, SourceLocation StartLoc, 825 SourceLocation EndLoc, 826 ArrayRef<OMPClause *> Clauses) { 827 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetExitDataDirective), 828 llvm::alignOf<OMPClause *>()) + 829 sizeof(OMPClause *) * Clauses.size()); 830 OMPTargetExitDataDirective *Dir = 831 new (Mem) OMPTargetExitDataDirective(StartLoc, EndLoc, Clauses.size()); 832 Dir->setClauses(Clauses); 833 return Dir; 834 } 835 836 OMPTargetExitDataDirective * 837 OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N, 838 EmptyShell) { 839 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetExitDataDirective), 840 llvm::alignOf<OMPClause *>()) + 841 sizeof(OMPClause *) * N); 842 return new (Mem) OMPTargetExitDataDirective(N); 843 } 844 845 OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C, 846 SourceLocation StartLoc, 847 SourceLocation EndLoc, 848 ArrayRef<OMPClause *> Clauses, 849 Stmt *AssociatedStmt) { 850 unsigned Size = 851 llvm::alignTo(sizeof(OMPTeamsDirective), llvm::alignOf<OMPClause *>()); 852 void *Mem = 853 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 854 OMPTeamsDirective *Dir = 855 new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size()); 856 Dir->setClauses(Clauses); 857 Dir->setAssociatedStmt(AssociatedStmt); 858 return Dir; 859 } 860 861 OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C, 862 unsigned NumClauses, 863 EmptyShell) { 864 unsigned Size = 865 llvm::alignTo(sizeof(OMPTeamsDirective), llvm::alignOf<OMPClause *>()); 866 void *Mem = 867 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 868 return new (Mem) OMPTeamsDirective(NumClauses); 869 } 870 871 OMPTaskLoopDirective *OMPTaskLoopDirective::Create( 872 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 873 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 874 const HelperExprs &Exprs) { 875 unsigned Size = 876 llvm::alignTo(sizeof(OMPTaskLoopDirective), llvm::alignOf<OMPClause *>()); 877 void *Mem = 878 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 879 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop)); 880 OMPTaskLoopDirective *Dir = new (Mem) 881 OMPTaskLoopDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); 882 Dir->setClauses(Clauses); 883 Dir->setAssociatedStmt(AssociatedStmt); 884 Dir->setIterationVariable(Exprs.IterationVarRef); 885 Dir->setLastIteration(Exprs.LastIteration); 886 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 887 Dir->setPreCond(Exprs.PreCond); 888 Dir->setCond(Exprs.Cond); 889 Dir->setInit(Exprs.Init); 890 Dir->setInc(Exprs.Inc); 891 Dir->setIsLastIterVariable(Exprs.IL); 892 Dir->setLowerBoundVariable(Exprs.LB); 893 Dir->setUpperBoundVariable(Exprs.UB); 894 Dir->setStrideVariable(Exprs.ST); 895 Dir->setEnsureUpperBound(Exprs.EUB); 896 Dir->setNextLowerBound(Exprs.NLB); 897 Dir->setNextUpperBound(Exprs.NUB); 898 Dir->setNumIterations(Exprs.NumIterations); 899 Dir->setCounters(Exprs.Counters); 900 Dir->setPrivateCounters(Exprs.PrivateCounters); 901 Dir->setInits(Exprs.Inits); 902 Dir->setUpdates(Exprs.Updates); 903 Dir->setFinals(Exprs.Finals); 904 Dir->setPreInits(Exprs.PreInits); 905 return Dir; 906 } 907 908 OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C, 909 unsigned NumClauses, 910 unsigned CollapsedNum, 911 EmptyShell) { 912 unsigned Size = 913 llvm::alignTo(sizeof(OMPTaskLoopDirective), llvm::alignOf<OMPClause *>()); 914 void *Mem = 915 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 916 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop)); 917 return new (Mem) OMPTaskLoopDirective(CollapsedNum, NumClauses); 918 } 919 920 OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create( 921 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 922 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 923 const HelperExprs &Exprs) { 924 unsigned Size = llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), 925 llvm::alignOf<OMPClause *>()); 926 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 927 sizeof(Stmt *) * 928 numLoopChildren(CollapsedNum, OMPD_taskloop_simd)); 929 OMPTaskLoopSimdDirective *Dir = new (Mem) 930 OMPTaskLoopSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); 931 Dir->setClauses(Clauses); 932 Dir->setAssociatedStmt(AssociatedStmt); 933 Dir->setIterationVariable(Exprs.IterationVarRef); 934 Dir->setLastIteration(Exprs.LastIteration); 935 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 936 Dir->setPreCond(Exprs.PreCond); 937 Dir->setCond(Exprs.Cond); 938 Dir->setInit(Exprs.Init); 939 Dir->setInc(Exprs.Inc); 940 Dir->setIsLastIterVariable(Exprs.IL); 941 Dir->setLowerBoundVariable(Exprs.LB); 942 Dir->setUpperBoundVariable(Exprs.UB); 943 Dir->setStrideVariable(Exprs.ST); 944 Dir->setEnsureUpperBound(Exprs.EUB); 945 Dir->setNextLowerBound(Exprs.NLB); 946 Dir->setNextUpperBound(Exprs.NUB); 947 Dir->setNumIterations(Exprs.NumIterations); 948 Dir->setCounters(Exprs.Counters); 949 Dir->setPrivateCounters(Exprs.PrivateCounters); 950 Dir->setInits(Exprs.Inits); 951 Dir->setUpdates(Exprs.Updates); 952 Dir->setFinals(Exprs.Finals); 953 Dir->setPreInits(Exprs.PreInits); 954 return Dir; 955 } 956 957 OMPTaskLoopSimdDirective * 958 OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 959 unsigned CollapsedNum, EmptyShell) { 960 unsigned Size = llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), 961 llvm::alignOf<OMPClause *>()); 962 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 963 sizeof(Stmt *) * 964 numLoopChildren(CollapsedNum, OMPD_taskloop_simd)); 965 return new (Mem) OMPTaskLoopSimdDirective(CollapsedNum, NumClauses); 966 } 967 968 OMPDistributeDirective *OMPDistributeDirective::Create( 969 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 970 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 971 const HelperExprs &Exprs) { 972 unsigned Size = llvm::alignTo(sizeof(OMPDistributeDirective), 973 llvm::alignOf<OMPClause *>()); 974 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 975 sizeof(Stmt *) * 976 numLoopChildren(CollapsedNum, OMPD_distribute)); 977 OMPDistributeDirective *Dir = new (Mem) 978 OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); 979 Dir->setClauses(Clauses); 980 Dir->setAssociatedStmt(AssociatedStmt); 981 Dir->setIterationVariable(Exprs.IterationVarRef); 982 Dir->setLastIteration(Exprs.LastIteration); 983 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 984 Dir->setPreCond(Exprs.PreCond); 985 Dir->setCond(Exprs.Cond); 986 Dir->setInit(Exprs.Init); 987 Dir->setInc(Exprs.Inc); 988 Dir->setIsLastIterVariable(Exprs.IL); 989 Dir->setLowerBoundVariable(Exprs.LB); 990 Dir->setUpperBoundVariable(Exprs.UB); 991 Dir->setStrideVariable(Exprs.ST); 992 Dir->setEnsureUpperBound(Exprs.EUB); 993 Dir->setNextLowerBound(Exprs.NLB); 994 Dir->setNextUpperBound(Exprs.NUB); 995 Dir->setNumIterations(Exprs.NumIterations); 996 Dir->setCounters(Exprs.Counters); 997 Dir->setPrivateCounters(Exprs.PrivateCounters); 998 Dir->setInits(Exprs.Inits); 999 Dir->setUpdates(Exprs.Updates); 1000 Dir->setFinals(Exprs.Finals); 1001 Dir->setPreInits(Exprs.PreInits); 1002 return Dir; 1003 } 1004 1005 OMPDistributeDirective * 1006 OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 1007 unsigned CollapsedNum, EmptyShell) { 1008 unsigned Size = llvm::alignTo(sizeof(OMPDistributeDirective), 1009 llvm::alignOf<OMPClause *>()); 1010 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 1011 sizeof(Stmt *) * 1012 numLoopChildren(CollapsedNum, OMPD_distribute)); 1013 return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses); 1014 } 1015 1016 OMPTargetUpdateDirective * 1017 OMPTargetUpdateDirective::Create(const ASTContext &C, SourceLocation StartLoc, 1018 SourceLocation EndLoc, 1019 ArrayRef<OMPClause *> Clauses) { 1020 unsigned Size = llvm::alignTo(sizeof(OMPTargetUpdateDirective), 1021 llvm::alignOf<OMPClause *>()); 1022 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size()); 1023 OMPTargetUpdateDirective *Dir = 1024 new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size()); 1025 Dir->setClauses(Clauses); 1026 return Dir; 1027 } 1028 1029 OMPTargetUpdateDirective * 1030 OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 1031 EmptyShell) { 1032 unsigned Size = llvm::alignTo(sizeof(OMPTargetUpdateDirective), 1033 llvm::alignOf<OMPClause *>()); 1034 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses); 1035 return new (Mem) OMPTargetUpdateDirective(NumClauses); 1036 } 1037