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 = llvm::RoundUpToAlignment(sizeof(OMPParallelDirective), 61 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 = llvm::RoundUpToAlignment(sizeof(OMPParallelDirective), 76 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 = llvm::RoundUpToAlignment(sizeof(OMPSimdDirective), 88 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 return Dir; 109 } 110 111 OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C, 112 unsigned NumClauses, 113 unsigned CollapsedNum, 114 EmptyShell) { 115 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSimdDirective), 116 llvm::alignOf<OMPClause *>()); 117 void *Mem = 118 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 119 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd)); 120 return new (Mem) OMPSimdDirective(CollapsedNum, NumClauses); 121 } 122 123 OMPForDirective * 124 OMPForDirective::Create(const ASTContext &C, SourceLocation StartLoc, 125 SourceLocation EndLoc, unsigned CollapsedNum, 126 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 127 const HelperExprs &Exprs, bool HasCancel) { 128 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPForDirective), 129 llvm::alignOf<OMPClause *>()); 130 void *Mem = 131 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 132 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for)); 133 OMPForDirective *Dir = 134 new (Mem) OMPForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); 135 Dir->setClauses(Clauses); 136 Dir->setAssociatedStmt(AssociatedStmt); 137 Dir->setIterationVariable(Exprs.IterationVarRef); 138 Dir->setLastIteration(Exprs.LastIteration); 139 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 140 Dir->setPreCond(Exprs.PreCond); 141 Dir->setCond(Exprs.Cond); 142 Dir->setInit(Exprs.Init); 143 Dir->setInc(Exprs.Inc); 144 Dir->setIsLastIterVariable(Exprs.IL); 145 Dir->setLowerBoundVariable(Exprs.LB); 146 Dir->setUpperBoundVariable(Exprs.UB); 147 Dir->setStrideVariable(Exprs.ST); 148 Dir->setEnsureUpperBound(Exprs.EUB); 149 Dir->setNextLowerBound(Exprs.NLB); 150 Dir->setNextUpperBound(Exprs.NUB); 151 Dir->setCounters(Exprs.Counters); 152 Dir->setPrivateCounters(Exprs.PrivateCounters); 153 Dir->setInits(Exprs.Inits); 154 Dir->setUpdates(Exprs.Updates); 155 Dir->setFinals(Exprs.Finals); 156 Dir->setHasCancel(HasCancel); 157 return Dir; 158 } 159 160 OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C, 161 unsigned NumClauses, 162 unsigned CollapsedNum, 163 EmptyShell) { 164 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPForDirective), 165 llvm::alignOf<OMPClause *>()); 166 void *Mem = 167 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 168 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for)); 169 return new (Mem) OMPForDirective(CollapsedNum, NumClauses); 170 } 171 172 OMPForSimdDirective * 173 OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc, 174 SourceLocation EndLoc, unsigned CollapsedNum, 175 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 176 const HelperExprs &Exprs) { 177 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPForSimdDirective), 178 llvm::alignOf<OMPClause *>()); 179 void *Mem = 180 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 181 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd)); 182 OMPForSimdDirective *Dir = new (Mem) 183 OMPForSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); 184 Dir->setClauses(Clauses); 185 Dir->setAssociatedStmt(AssociatedStmt); 186 Dir->setIterationVariable(Exprs.IterationVarRef); 187 Dir->setLastIteration(Exprs.LastIteration); 188 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 189 Dir->setPreCond(Exprs.PreCond); 190 Dir->setCond(Exprs.Cond); 191 Dir->setInit(Exprs.Init); 192 Dir->setInc(Exprs.Inc); 193 Dir->setIsLastIterVariable(Exprs.IL); 194 Dir->setLowerBoundVariable(Exprs.LB); 195 Dir->setUpperBoundVariable(Exprs.UB); 196 Dir->setStrideVariable(Exprs.ST); 197 Dir->setEnsureUpperBound(Exprs.EUB); 198 Dir->setNextLowerBound(Exprs.NLB); 199 Dir->setNextUpperBound(Exprs.NUB); 200 Dir->setCounters(Exprs.Counters); 201 Dir->setPrivateCounters(Exprs.PrivateCounters); 202 Dir->setInits(Exprs.Inits); 203 Dir->setUpdates(Exprs.Updates); 204 Dir->setFinals(Exprs.Finals); 205 return Dir; 206 } 207 208 OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C, 209 unsigned NumClauses, 210 unsigned CollapsedNum, 211 EmptyShell) { 212 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPForSimdDirective), 213 llvm::alignOf<OMPClause *>()); 214 void *Mem = 215 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 216 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd)); 217 return new (Mem) OMPForSimdDirective(CollapsedNum, NumClauses); 218 } 219 220 OMPSectionsDirective *OMPSectionsDirective::Create( 221 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 222 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) { 223 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSectionsDirective), 224 llvm::alignOf<OMPClause *>()); 225 void *Mem = 226 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 227 OMPSectionsDirective *Dir = 228 new (Mem) OMPSectionsDirective(StartLoc, EndLoc, Clauses.size()); 229 Dir->setClauses(Clauses); 230 Dir->setAssociatedStmt(AssociatedStmt); 231 Dir->setHasCancel(HasCancel); 232 return Dir; 233 } 234 235 OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C, 236 unsigned NumClauses, 237 EmptyShell) { 238 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSectionsDirective), 239 llvm::alignOf<OMPClause *>()); 240 void *Mem = 241 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 242 return new (Mem) OMPSectionsDirective(NumClauses); 243 } 244 245 OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C, 246 SourceLocation StartLoc, 247 SourceLocation EndLoc, 248 Stmt *AssociatedStmt, 249 bool HasCancel) { 250 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSectionDirective), 251 llvm::alignOf<Stmt *>()); 252 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 253 OMPSectionDirective *Dir = new (Mem) OMPSectionDirective(StartLoc, EndLoc); 254 Dir->setAssociatedStmt(AssociatedStmt); 255 Dir->setHasCancel(HasCancel); 256 return Dir; 257 } 258 259 OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C, 260 EmptyShell) { 261 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSectionDirective), 262 llvm::alignOf<Stmt *>()); 263 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 264 return new (Mem) OMPSectionDirective(); 265 } 266 267 OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C, 268 SourceLocation StartLoc, 269 SourceLocation EndLoc, 270 ArrayRef<OMPClause *> Clauses, 271 Stmt *AssociatedStmt) { 272 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSingleDirective), 273 llvm::alignOf<OMPClause *>()); 274 void *Mem = 275 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 276 OMPSingleDirective *Dir = 277 new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size()); 278 Dir->setClauses(Clauses); 279 Dir->setAssociatedStmt(AssociatedStmt); 280 return Dir; 281 } 282 283 OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C, 284 unsigned NumClauses, 285 EmptyShell) { 286 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSingleDirective), 287 llvm::alignOf<OMPClause *>()); 288 void *Mem = 289 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 290 return new (Mem) OMPSingleDirective(NumClauses); 291 } 292 293 OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C, 294 SourceLocation StartLoc, 295 SourceLocation EndLoc, 296 Stmt *AssociatedStmt) { 297 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPMasterDirective), 298 llvm::alignOf<Stmt *>()); 299 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 300 OMPMasterDirective *Dir = new (Mem) OMPMasterDirective(StartLoc, EndLoc); 301 Dir->setAssociatedStmt(AssociatedStmt); 302 return Dir; 303 } 304 305 OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C, 306 EmptyShell) { 307 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPMasterDirective), 308 llvm::alignOf<Stmt *>()); 309 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 310 return new (Mem) OMPMasterDirective(); 311 } 312 313 OMPCriticalDirective *OMPCriticalDirective::Create( 314 const ASTContext &C, const DeclarationNameInfo &Name, 315 SourceLocation StartLoc, SourceLocation EndLoc, Stmt *AssociatedStmt) { 316 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPCriticalDirective), 317 llvm::alignOf<Stmt *>()); 318 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 319 OMPCriticalDirective *Dir = 320 new (Mem) OMPCriticalDirective(Name, StartLoc, EndLoc); 321 Dir->setAssociatedStmt(AssociatedStmt); 322 return Dir; 323 } 324 325 OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C, 326 EmptyShell) { 327 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPCriticalDirective), 328 llvm::alignOf<Stmt *>()); 329 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 330 return new (Mem) OMPCriticalDirective(); 331 } 332 333 OMPParallelForDirective *OMPParallelForDirective::Create( 334 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 335 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 336 const HelperExprs &Exprs, bool HasCancel) { 337 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelForDirective), 338 llvm::alignOf<OMPClause *>()); 339 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 340 sizeof(Stmt *) * 341 numLoopChildren(CollapsedNum, OMPD_parallel_for)); 342 OMPParallelForDirective *Dir = new (Mem) 343 OMPParallelForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); 344 Dir->setClauses(Clauses); 345 Dir->setAssociatedStmt(AssociatedStmt); 346 Dir->setIterationVariable(Exprs.IterationVarRef); 347 Dir->setLastIteration(Exprs.LastIteration); 348 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 349 Dir->setPreCond(Exprs.PreCond); 350 Dir->setCond(Exprs.Cond); 351 Dir->setInit(Exprs.Init); 352 Dir->setInc(Exprs.Inc); 353 Dir->setIsLastIterVariable(Exprs.IL); 354 Dir->setLowerBoundVariable(Exprs.LB); 355 Dir->setUpperBoundVariable(Exprs.UB); 356 Dir->setStrideVariable(Exprs.ST); 357 Dir->setEnsureUpperBound(Exprs.EUB); 358 Dir->setNextLowerBound(Exprs.NLB); 359 Dir->setNextUpperBound(Exprs.NUB); 360 Dir->setCounters(Exprs.Counters); 361 Dir->setPrivateCounters(Exprs.PrivateCounters); 362 Dir->setInits(Exprs.Inits); 363 Dir->setUpdates(Exprs.Updates); 364 Dir->setFinals(Exprs.Finals); 365 Dir->setHasCancel(HasCancel); 366 return Dir; 367 } 368 369 OMPParallelForDirective * 370 OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, 371 unsigned CollapsedNum, EmptyShell) { 372 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelForDirective), 373 llvm::alignOf<OMPClause *>()); 374 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 375 sizeof(Stmt *) * 376 numLoopChildren(CollapsedNum, OMPD_parallel_for)); 377 return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses); 378 } 379 380 OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create( 381 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 382 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, 383 const HelperExprs &Exprs) { 384 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelForSimdDirective), 385 llvm::alignOf<OMPClause *>()); 386 void *Mem = C.Allocate( 387 Size + sizeof(OMPClause *) * Clauses.size() + 388 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd)); 389 OMPParallelForSimdDirective *Dir = new (Mem) OMPParallelForSimdDirective( 390 StartLoc, EndLoc, CollapsedNum, Clauses.size()); 391 Dir->setClauses(Clauses); 392 Dir->setAssociatedStmt(AssociatedStmt); 393 Dir->setIterationVariable(Exprs.IterationVarRef); 394 Dir->setLastIteration(Exprs.LastIteration); 395 Dir->setCalcLastIteration(Exprs.CalcLastIteration); 396 Dir->setPreCond(Exprs.PreCond); 397 Dir->setCond(Exprs.Cond); 398 Dir->setInit(Exprs.Init); 399 Dir->setInc(Exprs.Inc); 400 Dir->setIsLastIterVariable(Exprs.IL); 401 Dir->setLowerBoundVariable(Exprs.LB); 402 Dir->setUpperBoundVariable(Exprs.UB); 403 Dir->setStrideVariable(Exprs.ST); 404 Dir->setEnsureUpperBound(Exprs.EUB); 405 Dir->setNextLowerBound(Exprs.NLB); 406 Dir->setNextUpperBound(Exprs.NUB); 407 Dir->setCounters(Exprs.Counters); 408 Dir->setPrivateCounters(Exprs.PrivateCounters); 409 Dir->setInits(Exprs.Inits); 410 Dir->setUpdates(Exprs.Updates); 411 Dir->setFinals(Exprs.Finals); 412 return Dir; 413 } 414 415 OMPParallelForSimdDirective * 416 OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C, 417 unsigned NumClauses, 418 unsigned CollapsedNum, EmptyShell) { 419 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelForSimdDirective), 420 llvm::alignOf<OMPClause *>()); 421 void *Mem = C.Allocate( 422 Size + sizeof(OMPClause *) * NumClauses + 423 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd)); 424 return new (Mem) OMPParallelForSimdDirective(CollapsedNum, NumClauses); 425 } 426 427 OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create( 428 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 429 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) { 430 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelSectionsDirective), 431 llvm::alignOf<OMPClause *>()); 432 void *Mem = 433 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 434 OMPParallelSectionsDirective *Dir = 435 new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size()); 436 Dir->setClauses(Clauses); 437 Dir->setAssociatedStmt(AssociatedStmt); 438 Dir->setHasCancel(HasCancel); 439 return Dir; 440 } 441 442 OMPParallelSectionsDirective * 443 OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C, 444 unsigned NumClauses, EmptyShell) { 445 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelSectionsDirective), 446 llvm::alignOf<OMPClause *>()); 447 void *Mem = 448 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 449 return new (Mem) OMPParallelSectionsDirective(NumClauses); 450 } 451 452 OMPTaskDirective * 453 OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc, 454 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, 455 Stmt *AssociatedStmt, bool HasCancel) { 456 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTaskDirective), 457 llvm::alignOf<OMPClause *>()); 458 void *Mem = 459 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 460 OMPTaskDirective *Dir = 461 new (Mem) OMPTaskDirective(StartLoc, EndLoc, Clauses.size()); 462 Dir->setClauses(Clauses); 463 Dir->setAssociatedStmt(AssociatedStmt); 464 Dir->setHasCancel(HasCancel); 465 return Dir; 466 } 467 468 OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C, 469 unsigned NumClauses, 470 EmptyShell) { 471 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTaskDirective), 472 llvm::alignOf<OMPClause *>()); 473 void *Mem = 474 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 475 return new (Mem) OMPTaskDirective(NumClauses); 476 } 477 478 OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C, 479 SourceLocation StartLoc, 480 SourceLocation EndLoc) { 481 void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective)); 482 OMPTaskyieldDirective *Dir = 483 new (Mem) OMPTaskyieldDirective(StartLoc, EndLoc); 484 return Dir; 485 } 486 487 OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C, 488 EmptyShell) { 489 void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective)); 490 return new (Mem) OMPTaskyieldDirective(); 491 } 492 493 OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C, 494 SourceLocation StartLoc, 495 SourceLocation EndLoc) { 496 void *Mem = C.Allocate(sizeof(OMPBarrierDirective)); 497 OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc); 498 return Dir; 499 } 500 501 OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C, 502 EmptyShell) { 503 void *Mem = C.Allocate(sizeof(OMPBarrierDirective)); 504 return new (Mem) OMPBarrierDirective(); 505 } 506 507 OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C, 508 SourceLocation StartLoc, 509 SourceLocation EndLoc) { 510 void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective)); 511 OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc); 512 return Dir; 513 } 514 515 OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C, 516 EmptyShell) { 517 void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective)); 518 return new (Mem) OMPTaskwaitDirective(); 519 } 520 521 OMPTaskgroupDirective *OMPTaskgroupDirective::Create(const ASTContext &C, 522 SourceLocation StartLoc, 523 SourceLocation EndLoc, 524 Stmt *AssociatedStmt) { 525 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTaskgroupDirective), 526 llvm::alignOf<Stmt *>()); 527 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 528 OMPTaskgroupDirective *Dir = 529 new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc); 530 Dir->setAssociatedStmt(AssociatedStmt); 531 return Dir; 532 } 533 534 OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C, 535 EmptyShell) { 536 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTaskgroupDirective), 537 llvm::alignOf<Stmt *>()); 538 void *Mem = C.Allocate(Size + sizeof(Stmt *)); 539 return new (Mem) OMPTaskgroupDirective(); 540 } 541 542 OMPCancellationPointDirective *OMPCancellationPointDirective::Create( 543 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 544 OpenMPDirectiveKind CancelRegion) { 545 unsigned Size = llvm::RoundUpToAlignment( 546 sizeof(OMPCancellationPointDirective), llvm::alignOf<Stmt *>()); 547 void *Mem = C.Allocate(Size); 548 OMPCancellationPointDirective *Dir = 549 new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc); 550 Dir->setCancelRegion(CancelRegion); 551 return Dir; 552 } 553 554 OMPCancellationPointDirective * 555 OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) { 556 unsigned Size = llvm::RoundUpToAlignment( 557 sizeof(OMPCancellationPointDirective), llvm::alignOf<Stmt *>()); 558 void *Mem = C.Allocate(Size); 559 return new (Mem) OMPCancellationPointDirective(); 560 } 561 562 OMPCancelDirective * 563 OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc, 564 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, 565 OpenMPDirectiveKind CancelRegion) { 566 unsigned Size = llvm::RoundUpToAlignment( 567 sizeof(OMPCancelDirective) + sizeof(OMPClause *) * Clauses.size(), 568 llvm::alignOf<Stmt *>()); 569 void *Mem = C.Allocate(Size); 570 OMPCancelDirective *Dir = 571 new (Mem) OMPCancelDirective(StartLoc, EndLoc, Clauses.size()); 572 Dir->setClauses(Clauses); 573 Dir->setCancelRegion(CancelRegion); 574 return Dir; 575 } 576 577 OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C, 578 unsigned NumClauses, 579 EmptyShell) { 580 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPCancelDirective) + 581 sizeof(OMPClause *) * NumClauses, 582 llvm::alignOf<Stmt *>()); 583 void *Mem = C.Allocate(Size); 584 return new (Mem) OMPCancelDirective(NumClauses); 585 } 586 587 OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C, 588 SourceLocation StartLoc, 589 SourceLocation EndLoc, 590 ArrayRef<OMPClause *> Clauses) { 591 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPFlushDirective), 592 llvm::alignOf<OMPClause *>()); 593 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size()); 594 OMPFlushDirective *Dir = 595 new (Mem) OMPFlushDirective(StartLoc, EndLoc, Clauses.size()); 596 Dir->setClauses(Clauses); 597 return Dir; 598 } 599 600 OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C, 601 unsigned NumClauses, 602 EmptyShell) { 603 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPFlushDirective), 604 llvm::alignOf<OMPClause *>()); 605 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses); 606 return new (Mem) OMPFlushDirective(NumClauses); 607 } 608 609 OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C, 610 SourceLocation StartLoc, 611 SourceLocation EndLoc, 612 ArrayRef<OMPClause *> Clauses, 613 Stmt *AssociatedStmt) { 614 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPOrderedDirective), 615 llvm::alignOf<OMPClause *>()); 616 void *Mem = 617 C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * Clauses.size()); 618 OMPOrderedDirective *Dir = 619 new (Mem) OMPOrderedDirective(StartLoc, EndLoc, Clauses.size()); 620 Dir->setClauses(Clauses); 621 Dir->setAssociatedStmt(AssociatedStmt); 622 return Dir; 623 } 624 625 OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C, 626 unsigned NumClauses, 627 EmptyShell) { 628 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPOrderedDirective), 629 llvm::alignOf<OMPClause *>()); 630 void *Mem = 631 C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * NumClauses); 632 return new (Mem) OMPOrderedDirective(NumClauses); 633 } 634 635 OMPAtomicDirective *OMPAtomicDirective::Create( 636 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 637 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V, 638 Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) { 639 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPAtomicDirective), 640 llvm::alignOf<OMPClause *>()); 641 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + 642 5 * sizeof(Stmt *)); 643 OMPAtomicDirective *Dir = 644 new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size()); 645 Dir->setClauses(Clauses); 646 Dir->setAssociatedStmt(AssociatedStmt); 647 Dir->setX(X); 648 Dir->setV(V); 649 Dir->setExpr(E); 650 Dir->setUpdateExpr(UE); 651 Dir->IsXLHSInRHSPart = IsXLHSInRHSPart; 652 Dir->IsPostfixUpdate = IsPostfixUpdate; 653 return Dir; 654 } 655 656 OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C, 657 unsigned NumClauses, 658 EmptyShell) { 659 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPAtomicDirective), 660 llvm::alignOf<OMPClause *>()); 661 void *Mem = 662 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *)); 663 return new (Mem) OMPAtomicDirective(NumClauses); 664 } 665 666 OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C, 667 SourceLocation StartLoc, 668 SourceLocation EndLoc, 669 ArrayRef<OMPClause *> Clauses, 670 Stmt *AssociatedStmt) { 671 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTargetDirective), 672 llvm::alignOf<OMPClause *>()); 673 void *Mem = 674 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 675 OMPTargetDirective *Dir = 676 new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size()); 677 Dir->setClauses(Clauses); 678 Dir->setAssociatedStmt(AssociatedStmt); 679 return Dir; 680 } 681 682 OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C, 683 unsigned NumClauses, 684 EmptyShell) { 685 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTargetDirective), 686 llvm::alignOf<OMPClause *>()); 687 void *Mem = 688 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 689 return new (Mem) OMPTargetDirective(NumClauses); 690 } 691 692 OMPTargetDataDirective *OMPTargetDataDirective::Create( 693 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, 694 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { 695 void *Mem = 696 C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPTargetDataDirective), 697 llvm::alignOf<OMPClause *>()) + 698 sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 699 OMPTargetDataDirective *Dir = 700 new (Mem) OMPTargetDataDirective(StartLoc, EndLoc, Clauses.size()); 701 Dir->setClauses(Clauses); 702 Dir->setAssociatedStmt(AssociatedStmt); 703 return Dir; 704 } 705 706 OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C, 707 unsigned N, 708 EmptyShell) { 709 void *Mem = 710 C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPTargetDataDirective), 711 llvm::alignOf<OMPClause *>()) + 712 sizeof(OMPClause *) * N + sizeof(Stmt *)); 713 return new (Mem) OMPTargetDataDirective(N); 714 } 715 716 OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C, 717 SourceLocation StartLoc, 718 SourceLocation EndLoc, 719 ArrayRef<OMPClause *> Clauses, 720 Stmt *AssociatedStmt) { 721 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTeamsDirective), 722 llvm::alignOf<OMPClause *>()); 723 void *Mem = 724 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); 725 OMPTeamsDirective *Dir = 726 new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size()); 727 Dir->setClauses(Clauses); 728 Dir->setAssociatedStmt(AssociatedStmt); 729 return Dir; 730 } 731 732 OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C, 733 unsigned NumClauses, 734 EmptyShell) { 735 unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTeamsDirective), 736 llvm::alignOf<OMPClause *>()); 737 void *Mem = 738 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); 739 return new (Mem) OMPTeamsDirective(NumClauses); 740 } 741