James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 60 | unsigned Size = |
| 61 | llvm::alignTo(sizeof(OMPParallelDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 75 | unsigned Size = |
| 76 | llvm::alignTo(sizeof(OMPParallelDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 87 | unsigned Size = |
| 88 | llvm::alignTo(sizeof(OMPSimdDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 115 | unsigned Size = |
| 116 | llvm::alignTo(sizeof(OMPSimdDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 128 | unsigned Size = |
| 129 | llvm::alignTo(sizeof(OMPForDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 164 | unsigned Size = |
| 165 | llvm::alignTo(sizeof(OMPForDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 177 | unsigned Size = |
| 178 | llvm::alignTo(sizeof(OMPForSimdDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 212 | unsigned Size = |
| 213 | llvm::alignTo(sizeof(OMPForSimdDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 223 | unsigned Size = |
| 224 | llvm::alignTo(sizeof(OMPSectionsDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 238 | unsigned Size = |
| 239 | llvm::alignTo(sizeof(OMPSectionsDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 250 | unsigned Size = |
| 251 | llvm::alignTo(sizeof(OMPSectionDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 261 | unsigned Size = |
| 262 | llvm::alignTo(sizeof(OMPSectionDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 272 | unsigned Size = |
| 273 | llvm::alignTo(sizeof(OMPSingleDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 286 | unsigned Size = |
| 287 | llvm::alignTo(sizeof(OMPSingleDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 297 | unsigned Size = |
| 298 | llvm::alignTo(sizeof(OMPMasterDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 307 | unsigned Size = |
| 308 | llvm::alignTo(sizeof(OMPMasterDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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, |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 315 | SourceLocation StartLoc, SourceLocation EndLoc, |
| 316 | ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 317 | unsigned Size = |
| 318 | llvm::alignTo(sizeof(OMPCriticalDirective), llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 319 | void *Mem = |
| 320 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 321 | OMPCriticalDirective *Dir = |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 322 | new (Mem) OMPCriticalDirective(Name, StartLoc, EndLoc, Clauses.size()); |
| 323 | Dir->setClauses(Clauses); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 324 | Dir->setAssociatedStmt(AssociatedStmt); |
| 325 | return Dir; |
| 326 | } |
| 327 | |
| 328 | OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C, |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 329 | unsigned NumClauses, |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 330 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 331 | unsigned Size = |
| 332 | llvm::alignTo(sizeof(OMPCriticalDirective), llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 333 | void *Mem = |
| 334 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 335 | return new (Mem) OMPCriticalDirective(NumClauses); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | OMPParallelForDirective *OMPParallelForDirective::Create( |
| 339 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 340 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 341 | const HelperExprs &Exprs, bool HasCancel) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 342 | unsigned Size = llvm::alignTo(sizeof(OMPParallelForDirective), |
| 343 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 344 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + |
| 345 | sizeof(Stmt *) * |
| 346 | numLoopChildren(CollapsedNum, OMPD_parallel_for)); |
| 347 | OMPParallelForDirective *Dir = new (Mem) |
| 348 | OMPParallelForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 349 | Dir->setClauses(Clauses); |
| 350 | Dir->setAssociatedStmt(AssociatedStmt); |
| 351 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 352 | Dir->setLastIteration(Exprs.LastIteration); |
| 353 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 354 | Dir->setPreCond(Exprs.PreCond); |
| 355 | Dir->setCond(Exprs.Cond); |
| 356 | Dir->setInit(Exprs.Init); |
| 357 | Dir->setInc(Exprs.Inc); |
| 358 | Dir->setIsLastIterVariable(Exprs.IL); |
| 359 | Dir->setLowerBoundVariable(Exprs.LB); |
| 360 | Dir->setUpperBoundVariable(Exprs.UB); |
| 361 | Dir->setStrideVariable(Exprs.ST); |
| 362 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 363 | Dir->setNextLowerBound(Exprs.NLB); |
| 364 | Dir->setNextUpperBound(Exprs.NUB); |
| 365 | Dir->setCounters(Exprs.Counters); |
| 366 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 367 | Dir->setInits(Exprs.Inits); |
| 368 | Dir->setUpdates(Exprs.Updates); |
| 369 | Dir->setFinals(Exprs.Finals); |
| 370 | Dir->setHasCancel(HasCancel); |
| 371 | return Dir; |
| 372 | } |
| 373 | |
| 374 | OMPParallelForDirective * |
| 375 | OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, |
| 376 | unsigned CollapsedNum, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 377 | unsigned Size = llvm::alignTo(sizeof(OMPParallelForDirective), |
| 378 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 379 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses + |
| 380 | sizeof(Stmt *) * |
| 381 | numLoopChildren(CollapsedNum, OMPD_parallel_for)); |
| 382 | return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses); |
| 383 | } |
| 384 | |
| 385 | OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create( |
| 386 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 387 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 388 | const HelperExprs &Exprs) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 389 | unsigned Size = llvm::alignTo(sizeof(OMPParallelForSimdDirective), |
| 390 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 391 | void *Mem = C.Allocate( |
| 392 | Size + sizeof(OMPClause *) * Clauses.size() + |
| 393 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd)); |
| 394 | OMPParallelForSimdDirective *Dir = new (Mem) OMPParallelForSimdDirective( |
| 395 | StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 396 | Dir->setClauses(Clauses); |
| 397 | Dir->setAssociatedStmt(AssociatedStmt); |
| 398 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 399 | Dir->setLastIteration(Exprs.LastIteration); |
| 400 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 401 | Dir->setPreCond(Exprs.PreCond); |
| 402 | Dir->setCond(Exprs.Cond); |
| 403 | Dir->setInit(Exprs.Init); |
| 404 | Dir->setInc(Exprs.Inc); |
| 405 | Dir->setIsLastIterVariable(Exprs.IL); |
| 406 | Dir->setLowerBoundVariable(Exprs.LB); |
| 407 | Dir->setUpperBoundVariable(Exprs.UB); |
| 408 | Dir->setStrideVariable(Exprs.ST); |
| 409 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 410 | Dir->setNextLowerBound(Exprs.NLB); |
| 411 | Dir->setNextUpperBound(Exprs.NUB); |
| 412 | Dir->setCounters(Exprs.Counters); |
| 413 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 414 | Dir->setInits(Exprs.Inits); |
| 415 | Dir->setUpdates(Exprs.Updates); |
| 416 | Dir->setFinals(Exprs.Finals); |
| 417 | return Dir; |
| 418 | } |
| 419 | |
| 420 | OMPParallelForSimdDirective * |
| 421 | OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C, |
| 422 | unsigned NumClauses, |
| 423 | unsigned CollapsedNum, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 424 | unsigned Size = llvm::alignTo(sizeof(OMPParallelForSimdDirective), |
| 425 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 426 | void *Mem = C.Allocate( |
| 427 | Size + sizeof(OMPClause *) * NumClauses + |
| 428 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd)); |
| 429 | return new (Mem) OMPParallelForSimdDirective(CollapsedNum, NumClauses); |
| 430 | } |
| 431 | |
| 432 | OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create( |
| 433 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 434 | ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 435 | unsigned Size = llvm::alignTo(sizeof(OMPParallelSectionsDirective), |
| 436 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 437 | void *Mem = |
| 438 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
| 439 | OMPParallelSectionsDirective *Dir = |
| 440 | new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size()); |
| 441 | Dir->setClauses(Clauses); |
| 442 | Dir->setAssociatedStmt(AssociatedStmt); |
| 443 | Dir->setHasCancel(HasCancel); |
| 444 | return Dir; |
| 445 | } |
| 446 | |
| 447 | OMPParallelSectionsDirective * |
| 448 | OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C, |
| 449 | unsigned NumClauses, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 450 | unsigned Size = llvm::alignTo(sizeof(OMPParallelSectionsDirective), |
| 451 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 452 | void *Mem = |
| 453 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 454 | return new (Mem) OMPParallelSectionsDirective(NumClauses); |
| 455 | } |
| 456 | |
| 457 | OMPTaskDirective * |
| 458 | OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc, |
| 459 | SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, |
| 460 | Stmt *AssociatedStmt, bool HasCancel) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 461 | unsigned Size = |
| 462 | llvm::alignTo(sizeof(OMPTaskDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 463 | void *Mem = |
| 464 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
| 465 | OMPTaskDirective *Dir = |
| 466 | new (Mem) OMPTaskDirective(StartLoc, EndLoc, Clauses.size()); |
| 467 | Dir->setClauses(Clauses); |
| 468 | Dir->setAssociatedStmt(AssociatedStmt); |
| 469 | Dir->setHasCancel(HasCancel); |
| 470 | return Dir; |
| 471 | } |
| 472 | |
| 473 | OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C, |
| 474 | unsigned NumClauses, |
| 475 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 476 | unsigned Size = |
| 477 | llvm::alignTo(sizeof(OMPTaskDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 478 | void *Mem = |
| 479 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 480 | return new (Mem) OMPTaskDirective(NumClauses); |
| 481 | } |
| 482 | |
| 483 | OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C, |
| 484 | SourceLocation StartLoc, |
| 485 | SourceLocation EndLoc) { |
| 486 | void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective)); |
| 487 | OMPTaskyieldDirective *Dir = |
| 488 | new (Mem) OMPTaskyieldDirective(StartLoc, EndLoc); |
| 489 | return Dir; |
| 490 | } |
| 491 | |
| 492 | OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C, |
| 493 | EmptyShell) { |
| 494 | void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective)); |
| 495 | return new (Mem) OMPTaskyieldDirective(); |
| 496 | } |
| 497 | |
| 498 | OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C, |
| 499 | SourceLocation StartLoc, |
| 500 | SourceLocation EndLoc) { |
| 501 | void *Mem = C.Allocate(sizeof(OMPBarrierDirective)); |
| 502 | OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc); |
| 503 | return Dir; |
| 504 | } |
| 505 | |
| 506 | OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C, |
| 507 | EmptyShell) { |
| 508 | void *Mem = C.Allocate(sizeof(OMPBarrierDirective)); |
| 509 | return new (Mem) OMPBarrierDirective(); |
| 510 | } |
| 511 | |
| 512 | OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C, |
| 513 | SourceLocation StartLoc, |
| 514 | SourceLocation EndLoc) { |
| 515 | void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective)); |
| 516 | OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc); |
| 517 | return Dir; |
| 518 | } |
| 519 | |
| 520 | OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C, |
| 521 | EmptyShell) { |
| 522 | void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective)); |
| 523 | return new (Mem) OMPTaskwaitDirective(); |
| 524 | } |
| 525 | |
| 526 | OMPTaskgroupDirective *OMPTaskgroupDirective::Create(const ASTContext &C, |
| 527 | SourceLocation StartLoc, |
| 528 | SourceLocation EndLoc, |
| 529 | Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 530 | unsigned Size = |
| 531 | llvm::alignTo(sizeof(OMPTaskgroupDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 532 | void *Mem = C.Allocate(Size + sizeof(Stmt *)); |
| 533 | OMPTaskgroupDirective *Dir = |
| 534 | new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc); |
| 535 | Dir->setAssociatedStmt(AssociatedStmt); |
| 536 | return Dir; |
| 537 | } |
| 538 | |
| 539 | OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C, |
| 540 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 541 | unsigned Size = |
| 542 | llvm::alignTo(sizeof(OMPTaskgroupDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 543 | void *Mem = C.Allocate(Size + sizeof(Stmt *)); |
| 544 | return new (Mem) OMPTaskgroupDirective(); |
| 545 | } |
| 546 | |
| 547 | OMPCancellationPointDirective *OMPCancellationPointDirective::Create( |
| 548 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 549 | OpenMPDirectiveKind CancelRegion) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 550 | unsigned Size = llvm::alignTo(sizeof(OMPCancellationPointDirective), |
| 551 | llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 552 | void *Mem = C.Allocate(Size); |
| 553 | OMPCancellationPointDirective *Dir = |
| 554 | new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc); |
| 555 | Dir->setCancelRegion(CancelRegion); |
| 556 | return Dir; |
| 557 | } |
| 558 | |
| 559 | OMPCancellationPointDirective * |
| 560 | OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 561 | unsigned Size = llvm::alignTo(sizeof(OMPCancellationPointDirective), |
| 562 | llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 563 | void *Mem = C.Allocate(Size); |
| 564 | return new (Mem) OMPCancellationPointDirective(); |
| 565 | } |
| 566 | |
| 567 | OMPCancelDirective * |
| 568 | OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc, |
| 569 | SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, |
| 570 | OpenMPDirectiveKind CancelRegion) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 571 | unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) + |
| 572 | sizeof(OMPClause *) * Clauses.size(), |
| 573 | llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 574 | void *Mem = C.Allocate(Size); |
| 575 | OMPCancelDirective *Dir = |
| 576 | new (Mem) OMPCancelDirective(StartLoc, EndLoc, Clauses.size()); |
| 577 | Dir->setClauses(Clauses); |
| 578 | Dir->setCancelRegion(CancelRegion); |
| 579 | return Dir; |
| 580 | } |
| 581 | |
| 582 | OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C, |
| 583 | unsigned NumClauses, |
| 584 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 585 | unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) + |
| 586 | sizeof(OMPClause *) * NumClauses, |
| 587 | llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 588 | void *Mem = C.Allocate(Size); |
| 589 | return new (Mem) OMPCancelDirective(NumClauses); |
| 590 | } |
| 591 | |
| 592 | OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C, |
| 593 | SourceLocation StartLoc, |
| 594 | SourceLocation EndLoc, |
| 595 | ArrayRef<OMPClause *> Clauses) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 596 | unsigned Size = |
| 597 | llvm::alignTo(sizeof(OMPFlushDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 598 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size()); |
| 599 | OMPFlushDirective *Dir = |
| 600 | new (Mem) OMPFlushDirective(StartLoc, EndLoc, Clauses.size()); |
| 601 | Dir->setClauses(Clauses); |
| 602 | return Dir; |
| 603 | } |
| 604 | |
| 605 | OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C, |
| 606 | unsigned NumClauses, |
| 607 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 608 | unsigned Size = |
| 609 | llvm::alignTo(sizeof(OMPFlushDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 610 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses); |
| 611 | return new (Mem) OMPFlushDirective(NumClauses); |
| 612 | } |
| 613 | |
| 614 | OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C, |
| 615 | SourceLocation StartLoc, |
| 616 | SourceLocation EndLoc, |
| 617 | ArrayRef<OMPClause *> Clauses, |
| 618 | Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 619 | unsigned Size = |
| 620 | llvm::alignTo(sizeof(OMPOrderedDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 621 | void *Mem = |
| 622 | C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * Clauses.size()); |
| 623 | OMPOrderedDirective *Dir = |
| 624 | new (Mem) OMPOrderedDirective(StartLoc, EndLoc, Clauses.size()); |
| 625 | Dir->setClauses(Clauses); |
| 626 | Dir->setAssociatedStmt(AssociatedStmt); |
| 627 | return Dir; |
| 628 | } |
| 629 | |
| 630 | OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C, |
| 631 | unsigned NumClauses, |
| 632 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 633 | unsigned Size = |
| 634 | llvm::alignTo(sizeof(OMPOrderedDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 635 | void *Mem = |
| 636 | C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * NumClauses); |
| 637 | return new (Mem) OMPOrderedDirective(NumClauses); |
| 638 | } |
| 639 | |
| 640 | OMPAtomicDirective *OMPAtomicDirective::Create( |
| 641 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 642 | ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V, |
| 643 | Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 644 | unsigned Size = |
| 645 | llvm::alignTo(sizeof(OMPAtomicDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 646 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + |
| 647 | 5 * sizeof(Stmt *)); |
| 648 | OMPAtomicDirective *Dir = |
| 649 | new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size()); |
| 650 | Dir->setClauses(Clauses); |
| 651 | Dir->setAssociatedStmt(AssociatedStmt); |
| 652 | Dir->setX(X); |
| 653 | Dir->setV(V); |
| 654 | Dir->setExpr(E); |
| 655 | Dir->setUpdateExpr(UE); |
| 656 | Dir->IsXLHSInRHSPart = IsXLHSInRHSPart; |
| 657 | Dir->IsPostfixUpdate = IsPostfixUpdate; |
| 658 | return Dir; |
| 659 | } |
| 660 | |
| 661 | OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C, |
| 662 | unsigned NumClauses, |
| 663 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 664 | unsigned Size = |
| 665 | llvm::alignTo(sizeof(OMPAtomicDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 666 | void *Mem = |
| 667 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *)); |
| 668 | return new (Mem) OMPAtomicDirective(NumClauses); |
| 669 | } |
| 670 | |
| 671 | OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C, |
| 672 | SourceLocation StartLoc, |
| 673 | SourceLocation EndLoc, |
| 674 | ArrayRef<OMPClause *> Clauses, |
| 675 | Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 676 | unsigned Size = |
| 677 | llvm::alignTo(sizeof(OMPTargetDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 678 | void *Mem = |
| 679 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
| 680 | OMPTargetDirective *Dir = |
| 681 | new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size()); |
| 682 | Dir->setClauses(Clauses); |
| 683 | Dir->setAssociatedStmt(AssociatedStmt); |
| 684 | return Dir; |
| 685 | } |
| 686 | |
| 687 | OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C, |
| 688 | unsigned NumClauses, |
| 689 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 690 | unsigned Size = |
| 691 | llvm::alignTo(sizeof(OMPTargetDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 692 | void *Mem = |
| 693 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 694 | return new (Mem) OMPTargetDirective(NumClauses); |
| 695 | } |
| 696 | |
| 697 | OMPTargetDataDirective *OMPTargetDataDirective::Create( |
| 698 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 699 | ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 700 | void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetDataDirective), |
| 701 | llvm::alignOf<OMPClause *>()) + |
| 702 | sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 703 | OMPTargetDataDirective *Dir = |
| 704 | new (Mem) OMPTargetDataDirective(StartLoc, EndLoc, Clauses.size()); |
| 705 | Dir->setClauses(Clauses); |
| 706 | Dir->setAssociatedStmt(AssociatedStmt); |
| 707 | return Dir; |
| 708 | } |
| 709 | |
| 710 | OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C, |
| 711 | unsigned N, |
| 712 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 713 | void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetDataDirective), |
| 714 | llvm::alignOf<OMPClause *>()) + |
| 715 | sizeof(OMPClause *) * N + sizeof(Stmt *)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 716 | return new (Mem) OMPTargetDataDirective(N); |
| 717 | } |
| 718 | |
Samuel Antao | df67fc4 | 2016-01-19 19:15:56 +0000 | [diff] [blame^] | 719 | OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create( |
| 720 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 721 | ArrayRef<OMPClause *> Clauses) { |
| 722 | void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetEnterDataDirective), |
| 723 | llvm::alignOf<OMPClause *>()) + |
| 724 | sizeof(OMPClause *) * Clauses.size()); |
| 725 | OMPTargetEnterDataDirective *Dir = |
| 726 | new (Mem) OMPTargetEnterDataDirective(StartLoc, EndLoc, Clauses.size()); |
| 727 | Dir->setClauses(Clauses); |
| 728 | return Dir; |
| 729 | } |
| 730 | |
| 731 | OMPTargetEnterDataDirective * |
| 732 | OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N, |
| 733 | EmptyShell) { |
| 734 | void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetEnterDataDirective), |
| 735 | llvm::alignOf<OMPClause *>()) + |
| 736 | sizeof(OMPClause *) * N); |
| 737 | return new (Mem) OMPTargetEnterDataDirective(N); |
| 738 | } |
| 739 | |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 740 | OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C, |
| 741 | SourceLocation StartLoc, |
| 742 | SourceLocation EndLoc, |
| 743 | ArrayRef<OMPClause *> Clauses, |
| 744 | Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 745 | unsigned Size = |
| 746 | llvm::alignTo(sizeof(OMPTeamsDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 747 | void *Mem = |
| 748 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
| 749 | OMPTeamsDirective *Dir = |
| 750 | new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size()); |
| 751 | Dir->setClauses(Clauses); |
| 752 | Dir->setAssociatedStmt(AssociatedStmt); |
| 753 | return Dir; |
| 754 | } |
| 755 | |
| 756 | OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C, |
| 757 | unsigned NumClauses, |
| 758 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 759 | unsigned Size = |
| 760 | llvm::alignTo(sizeof(OMPTeamsDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 761 | void *Mem = |
| 762 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 763 | return new (Mem) OMPTeamsDirective(NumClauses); |
| 764 | } |
Alexey Bataev | 49f6e78 | 2015-12-01 04:18:41 +0000 | [diff] [blame] | 765 | |
| 766 | OMPTaskLoopDirective *OMPTaskLoopDirective::Create( |
| 767 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 768 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 769 | const HelperExprs &Exprs) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 770 | unsigned Size = |
| 771 | llvm::alignTo(sizeof(OMPTaskLoopDirective), llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 49f6e78 | 2015-12-01 04:18:41 +0000 | [diff] [blame] | 772 | void *Mem = |
| 773 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + |
| 774 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop)); |
| 775 | OMPTaskLoopDirective *Dir = new (Mem) |
| 776 | OMPTaskLoopDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 777 | Dir->setClauses(Clauses); |
| 778 | Dir->setAssociatedStmt(AssociatedStmt); |
| 779 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 780 | Dir->setLastIteration(Exprs.LastIteration); |
| 781 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 782 | Dir->setPreCond(Exprs.PreCond); |
| 783 | Dir->setCond(Exprs.Cond); |
| 784 | Dir->setInit(Exprs.Init); |
| 785 | Dir->setInc(Exprs.Inc); |
| 786 | Dir->setIsLastIterVariable(Exprs.IL); |
| 787 | Dir->setLowerBoundVariable(Exprs.LB); |
| 788 | Dir->setUpperBoundVariable(Exprs.UB); |
| 789 | Dir->setStrideVariable(Exprs.ST); |
| 790 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 791 | Dir->setNextLowerBound(Exprs.NLB); |
| 792 | Dir->setNextUpperBound(Exprs.NUB); |
| 793 | Dir->setCounters(Exprs.Counters); |
| 794 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 795 | Dir->setInits(Exprs.Inits); |
| 796 | Dir->setUpdates(Exprs.Updates); |
| 797 | Dir->setFinals(Exprs.Finals); |
| 798 | return Dir; |
| 799 | } |
| 800 | |
| 801 | OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C, |
| 802 | unsigned NumClauses, |
| 803 | unsigned CollapsedNum, |
| 804 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 805 | unsigned Size = |
| 806 | llvm::alignTo(sizeof(OMPTaskLoopDirective), llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 49f6e78 | 2015-12-01 04:18:41 +0000 | [diff] [blame] | 807 | void *Mem = |
| 808 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + |
| 809 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop)); |
| 810 | return new (Mem) OMPTaskLoopDirective(CollapsedNum, NumClauses); |
| 811 | } |
| 812 | |
Alexey Bataev | 0a6ed84 | 2015-12-03 09:40:15 +0000 | [diff] [blame] | 813 | OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create( |
| 814 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 815 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 816 | const HelperExprs &Exprs) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 817 | unsigned Size = llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), |
| 818 | llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 0a6ed84 | 2015-12-03 09:40:15 +0000 | [diff] [blame] | 819 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + |
| 820 | sizeof(Stmt *) * |
| 821 | numLoopChildren(CollapsedNum, OMPD_taskloop_simd)); |
| 822 | OMPTaskLoopSimdDirective *Dir = new (Mem) |
| 823 | OMPTaskLoopSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 824 | Dir->setClauses(Clauses); |
| 825 | Dir->setAssociatedStmt(AssociatedStmt); |
| 826 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 827 | Dir->setLastIteration(Exprs.LastIteration); |
| 828 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 829 | Dir->setPreCond(Exprs.PreCond); |
| 830 | Dir->setCond(Exprs.Cond); |
| 831 | Dir->setInit(Exprs.Init); |
| 832 | Dir->setInc(Exprs.Inc); |
| 833 | Dir->setIsLastIterVariable(Exprs.IL); |
| 834 | Dir->setLowerBoundVariable(Exprs.LB); |
| 835 | Dir->setUpperBoundVariable(Exprs.UB); |
| 836 | Dir->setStrideVariable(Exprs.ST); |
| 837 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 838 | Dir->setNextLowerBound(Exprs.NLB); |
| 839 | Dir->setNextUpperBound(Exprs.NUB); |
| 840 | Dir->setCounters(Exprs.Counters); |
| 841 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 842 | Dir->setInits(Exprs.Inits); |
| 843 | Dir->setUpdates(Exprs.Updates); |
| 844 | Dir->setFinals(Exprs.Finals); |
| 845 | return Dir; |
| 846 | } |
| 847 | |
| 848 | OMPTaskLoopSimdDirective * |
| 849 | OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, |
| 850 | unsigned CollapsedNum, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 851 | unsigned Size = llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), |
| 852 | llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 0a6ed84 | 2015-12-03 09:40:15 +0000 | [diff] [blame] | 853 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses + |
| 854 | sizeof(Stmt *) * |
| 855 | numLoopChildren(CollapsedNum, OMPD_taskloop_simd)); |
| 856 | return new (Mem) OMPTaskLoopSimdDirective(CollapsedNum, NumClauses); |
| 857 | } |
| 858 | |
Carlo Bertolli | 6200a3d | 2015-12-14 14:51:25 +0000 | [diff] [blame] | 859 | OMPDistributeDirective *OMPDistributeDirective::Create( |
| 860 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 861 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 862 | const HelperExprs &Exprs) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 863 | unsigned Size = llvm::alignTo(sizeof(OMPDistributeDirective), |
| 864 | llvm::alignOf<OMPClause *>()); |
Carlo Bertolli | 6200a3d | 2015-12-14 14:51:25 +0000 | [diff] [blame] | 865 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + |
| 866 | sizeof(Stmt *) * |
| 867 | numLoopChildren(CollapsedNum, OMPD_distribute)); |
| 868 | OMPDistributeDirective *Dir = new (Mem) |
| 869 | OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 870 | Dir->setClauses(Clauses); |
| 871 | Dir->setAssociatedStmt(AssociatedStmt); |
| 872 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 873 | Dir->setLastIteration(Exprs.LastIteration); |
| 874 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 875 | Dir->setPreCond(Exprs.PreCond); |
| 876 | Dir->setCond(Exprs.Cond); |
| 877 | Dir->setInit(Exprs.Init); |
| 878 | Dir->setInc(Exprs.Inc); |
| 879 | Dir->setIsLastIterVariable(Exprs.IL); |
| 880 | Dir->setLowerBoundVariable(Exprs.LB); |
| 881 | Dir->setUpperBoundVariable(Exprs.UB); |
| 882 | Dir->setStrideVariable(Exprs.ST); |
| 883 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 884 | Dir->setNextLowerBound(Exprs.NLB); |
| 885 | Dir->setNextUpperBound(Exprs.NUB); |
| 886 | Dir->setCounters(Exprs.Counters); |
| 887 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 888 | Dir->setInits(Exprs.Inits); |
| 889 | Dir->setUpdates(Exprs.Updates); |
| 890 | Dir->setFinals(Exprs.Finals); |
| 891 | return Dir; |
| 892 | } |
| 893 | |
| 894 | OMPDistributeDirective * |
| 895 | OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, |
| 896 | unsigned CollapsedNum, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 897 | unsigned Size = llvm::alignTo(sizeof(OMPDistributeDirective), |
| 898 | llvm::alignOf<OMPClause *>()); |
Carlo Bertolli | 6200a3d | 2015-12-14 14:51:25 +0000 | [diff] [blame] | 899 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses + |
| 900 | sizeof(Stmt *) * |
| 901 | numLoopChildren(CollapsedNum, OMPD_distribute)); |
| 902 | return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses); |
| 903 | } |