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); |
Alexey Bataev | 5a3af13 | 2016-03-29 08:58:54 +0000 | [diff] [blame] | 108 | Dir->setPreInits(Exprs.PreInits); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 109 | return Dir; |
| 110 | } |
| 111 | |
| 112 | OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C, |
| 113 | unsigned NumClauses, |
| 114 | unsigned CollapsedNum, |
| 115 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 116 | unsigned Size = |
| 117 | llvm::alignTo(sizeof(OMPSimdDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 129 | unsigned Size = |
| 130 | llvm::alignTo(sizeof(OMPForDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 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); |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 152 | Dir->setNumIterations(Exprs.NumIterations); |
Carlo Bertolli | 9925f15 | 2016-06-27 14:55:37 +0000 | [diff] [blame] | 153 | Dir->setPrevLowerBoundVariable(Exprs.PrevLB); |
| 154 | Dir->setPrevUpperBoundVariable(Exprs.PrevUB); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 155 | Dir->setCounters(Exprs.Counters); |
| 156 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 157 | Dir->setInits(Exprs.Inits); |
| 158 | Dir->setUpdates(Exprs.Updates); |
| 159 | Dir->setFinals(Exprs.Finals); |
Alexey Bataev | 5a3af13 | 2016-03-29 08:58:54 +0000 | [diff] [blame] | 160 | Dir->setPreInits(Exprs.PreInits); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 161 | Dir->setHasCancel(HasCancel); |
| 162 | return Dir; |
| 163 | } |
| 164 | |
| 165 | OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C, |
| 166 | unsigned NumClauses, |
| 167 | unsigned CollapsedNum, |
| 168 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 169 | unsigned Size = |
| 170 | llvm::alignTo(sizeof(OMPForDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 171 | void *Mem = |
| 172 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + |
| 173 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for)); |
| 174 | return new (Mem) OMPForDirective(CollapsedNum, NumClauses); |
| 175 | } |
| 176 | |
| 177 | OMPForSimdDirective * |
| 178 | OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc, |
| 179 | SourceLocation EndLoc, unsigned CollapsedNum, |
| 180 | ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 181 | const HelperExprs &Exprs) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 182 | unsigned Size = |
| 183 | llvm::alignTo(sizeof(OMPForSimdDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 184 | void *Mem = |
| 185 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + |
| 186 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd)); |
| 187 | OMPForSimdDirective *Dir = new (Mem) |
| 188 | OMPForSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 189 | Dir->setClauses(Clauses); |
| 190 | Dir->setAssociatedStmt(AssociatedStmt); |
| 191 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 192 | Dir->setLastIteration(Exprs.LastIteration); |
| 193 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 194 | Dir->setPreCond(Exprs.PreCond); |
| 195 | Dir->setCond(Exprs.Cond); |
| 196 | Dir->setInit(Exprs.Init); |
| 197 | Dir->setInc(Exprs.Inc); |
| 198 | Dir->setIsLastIterVariable(Exprs.IL); |
| 199 | Dir->setLowerBoundVariable(Exprs.LB); |
| 200 | Dir->setUpperBoundVariable(Exprs.UB); |
| 201 | Dir->setStrideVariable(Exprs.ST); |
| 202 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 203 | Dir->setNextLowerBound(Exprs.NLB); |
| 204 | Dir->setNextUpperBound(Exprs.NUB); |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 205 | Dir->setNumIterations(Exprs.NumIterations); |
Carlo Bertolli | 9925f15 | 2016-06-27 14:55:37 +0000 | [diff] [blame] | 206 | Dir->setPrevLowerBoundVariable(Exprs.PrevLB); |
| 207 | Dir->setPrevUpperBoundVariable(Exprs.PrevUB); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 208 | Dir->setCounters(Exprs.Counters); |
| 209 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 210 | Dir->setInits(Exprs.Inits); |
| 211 | Dir->setUpdates(Exprs.Updates); |
| 212 | Dir->setFinals(Exprs.Finals); |
Alexey Bataev | 5a3af13 | 2016-03-29 08:58:54 +0000 | [diff] [blame] | 213 | Dir->setPreInits(Exprs.PreInits); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 214 | return Dir; |
| 215 | } |
| 216 | |
| 217 | OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C, |
| 218 | unsigned NumClauses, |
| 219 | unsigned CollapsedNum, |
| 220 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 221 | unsigned Size = |
| 222 | llvm::alignTo(sizeof(OMPForSimdDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 223 | void *Mem = |
| 224 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + |
| 225 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd)); |
| 226 | return new (Mem) OMPForSimdDirective(CollapsedNum, NumClauses); |
| 227 | } |
| 228 | |
| 229 | OMPSectionsDirective *OMPSectionsDirective::Create( |
| 230 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 231 | ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 232 | unsigned Size = |
| 233 | llvm::alignTo(sizeof(OMPSectionsDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 234 | void *Mem = |
| 235 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
| 236 | OMPSectionsDirective *Dir = |
| 237 | new (Mem) OMPSectionsDirective(StartLoc, EndLoc, Clauses.size()); |
| 238 | Dir->setClauses(Clauses); |
| 239 | Dir->setAssociatedStmt(AssociatedStmt); |
| 240 | Dir->setHasCancel(HasCancel); |
| 241 | return Dir; |
| 242 | } |
| 243 | |
| 244 | OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C, |
| 245 | unsigned NumClauses, |
| 246 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 247 | unsigned Size = |
| 248 | llvm::alignTo(sizeof(OMPSectionsDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 249 | void *Mem = |
| 250 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 251 | return new (Mem) OMPSectionsDirective(NumClauses); |
| 252 | } |
| 253 | |
| 254 | OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C, |
| 255 | SourceLocation StartLoc, |
| 256 | SourceLocation EndLoc, |
| 257 | Stmt *AssociatedStmt, |
| 258 | bool HasCancel) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 259 | unsigned Size = |
| 260 | llvm::alignTo(sizeof(OMPSectionDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 261 | void *Mem = C.Allocate(Size + sizeof(Stmt *)); |
| 262 | OMPSectionDirective *Dir = new (Mem) OMPSectionDirective(StartLoc, EndLoc); |
| 263 | Dir->setAssociatedStmt(AssociatedStmt); |
| 264 | Dir->setHasCancel(HasCancel); |
| 265 | return Dir; |
| 266 | } |
| 267 | |
| 268 | OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C, |
| 269 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 270 | unsigned Size = |
| 271 | llvm::alignTo(sizeof(OMPSectionDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 272 | void *Mem = C.Allocate(Size + sizeof(Stmt *)); |
| 273 | return new (Mem) OMPSectionDirective(); |
| 274 | } |
| 275 | |
| 276 | OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C, |
| 277 | SourceLocation StartLoc, |
| 278 | SourceLocation EndLoc, |
| 279 | ArrayRef<OMPClause *> Clauses, |
| 280 | Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 281 | unsigned Size = |
| 282 | llvm::alignTo(sizeof(OMPSingleDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 283 | void *Mem = |
| 284 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
| 285 | OMPSingleDirective *Dir = |
| 286 | new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size()); |
| 287 | Dir->setClauses(Clauses); |
| 288 | Dir->setAssociatedStmt(AssociatedStmt); |
| 289 | return Dir; |
| 290 | } |
| 291 | |
| 292 | OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C, |
| 293 | unsigned NumClauses, |
| 294 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 295 | unsigned Size = |
| 296 | llvm::alignTo(sizeof(OMPSingleDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 297 | void *Mem = |
| 298 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 299 | return new (Mem) OMPSingleDirective(NumClauses); |
| 300 | } |
| 301 | |
| 302 | OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C, |
| 303 | SourceLocation StartLoc, |
| 304 | SourceLocation EndLoc, |
| 305 | Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 306 | unsigned Size = |
| 307 | llvm::alignTo(sizeof(OMPMasterDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 308 | void *Mem = C.Allocate(Size + sizeof(Stmt *)); |
| 309 | OMPMasterDirective *Dir = new (Mem) OMPMasterDirective(StartLoc, EndLoc); |
| 310 | Dir->setAssociatedStmt(AssociatedStmt); |
| 311 | return Dir; |
| 312 | } |
| 313 | |
| 314 | OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C, |
| 315 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 316 | unsigned Size = |
| 317 | llvm::alignTo(sizeof(OMPMasterDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 318 | void *Mem = C.Allocate(Size + sizeof(Stmt *)); |
| 319 | return new (Mem) OMPMasterDirective(); |
| 320 | } |
| 321 | |
| 322 | OMPCriticalDirective *OMPCriticalDirective::Create( |
| 323 | const ASTContext &C, const DeclarationNameInfo &Name, |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 324 | SourceLocation StartLoc, SourceLocation EndLoc, |
| 325 | ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 326 | unsigned Size = |
| 327 | llvm::alignTo(sizeof(OMPCriticalDirective), llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 328 | void *Mem = |
| 329 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 330 | OMPCriticalDirective *Dir = |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 331 | new (Mem) OMPCriticalDirective(Name, StartLoc, EndLoc, Clauses.size()); |
| 332 | Dir->setClauses(Clauses); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 333 | Dir->setAssociatedStmt(AssociatedStmt); |
| 334 | return Dir; |
| 335 | } |
| 336 | |
| 337 | OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C, |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 338 | unsigned NumClauses, |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 339 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 340 | unsigned Size = |
| 341 | llvm::alignTo(sizeof(OMPCriticalDirective), llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 342 | void *Mem = |
| 343 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 344 | return new (Mem) OMPCriticalDirective(NumClauses); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | OMPParallelForDirective *OMPParallelForDirective::Create( |
| 348 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 349 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 350 | const HelperExprs &Exprs, bool HasCancel) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 351 | unsigned Size = llvm::alignTo(sizeof(OMPParallelForDirective), |
| 352 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 353 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + |
| 354 | sizeof(Stmt *) * |
| 355 | numLoopChildren(CollapsedNum, OMPD_parallel_for)); |
| 356 | OMPParallelForDirective *Dir = new (Mem) |
| 357 | OMPParallelForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 358 | Dir->setClauses(Clauses); |
| 359 | Dir->setAssociatedStmt(AssociatedStmt); |
| 360 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 361 | Dir->setLastIteration(Exprs.LastIteration); |
| 362 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 363 | Dir->setPreCond(Exprs.PreCond); |
| 364 | Dir->setCond(Exprs.Cond); |
| 365 | Dir->setInit(Exprs.Init); |
| 366 | Dir->setInc(Exprs.Inc); |
| 367 | Dir->setIsLastIterVariable(Exprs.IL); |
| 368 | Dir->setLowerBoundVariable(Exprs.LB); |
| 369 | Dir->setUpperBoundVariable(Exprs.UB); |
| 370 | Dir->setStrideVariable(Exprs.ST); |
| 371 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 372 | Dir->setNextLowerBound(Exprs.NLB); |
| 373 | Dir->setNextUpperBound(Exprs.NUB); |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 374 | Dir->setNumIterations(Exprs.NumIterations); |
Carlo Bertolli | 9925f15 | 2016-06-27 14:55:37 +0000 | [diff] [blame] | 375 | Dir->setPrevLowerBoundVariable(Exprs.PrevLB); |
| 376 | Dir->setPrevUpperBoundVariable(Exprs.PrevUB); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 377 | Dir->setCounters(Exprs.Counters); |
| 378 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 379 | Dir->setInits(Exprs.Inits); |
| 380 | Dir->setUpdates(Exprs.Updates); |
| 381 | Dir->setFinals(Exprs.Finals); |
Alexey Bataev | 5a3af13 | 2016-03-29 08:58:54 +0000 | [diff] [blame] | 382 | Dir->setPreInits(Exprs.PreInits); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 383 | Dir->setHasCancel(HasCancel); |
| 384 | return Dir; |
| 385 | } |
| 386 | |
| 387 | OMPParallelForDirective * |
| 388 | OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, |
| 389 | unsigned CollapsedNum, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 390 | unsigned Size = llvm::alignTo(sizeof(OMPParallelForDirective), |
| 391 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 392 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses + |
| 393 | sizeof(Stmt *) * |
| 394 | numLoopChildren(CollapsedNum, OMPD_parallel_for)); |
| 395 | return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses); |
| 396 | } |
| 397 | |
| 398 | OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create( |
| 399 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 400 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 401 | const HelperExprs &Exprs) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 402 | unsigned Size = llvm::alignTo(sizeof(OMPParallelForSimdDirective), |
| 403 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 404 | void *Mem = C.Allocate( |
| 405 | Size + sizeof(OMPClause *) * Clauses.size() + |
| 406 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd)); |
| 407 | OMPParallelForSimdDirective *Dir = new (Mem) OMPParallelForSimdDirective( |
| 408 | StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 409 | Dir->setClauses(Clauses); |
| 410 | Dir->setAssociatedStmt(AssociatedStmt); |
| 411 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 412 | Dir->setLastIteration(Exprs.LastIteration); |
| 413 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 414 | Dir->setPreCond(Exprs.PreCond); |
| 415 | Dir->setCond(Exprs.Cond); |
| 416 | Dir->setInit(Exprs.Init); |
| 417 | Dir->setInc(Exprs.Inc); |
| 418 | Dir->setIsLastIterVariable(Exprs.IL); |
| 419 | Dir->setLowerBoundVariable(Exprs.LB); |
| 420 | Dir->setUpperBoundVariable(Exprs.UB); |
| 421 | Dir->setStrideVariable(Exprs.ST); |
| 422 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 423 | Dir->setNextLowerBound(Exprs.NLB); |
| 424 | Dir->setNextUpperBound(Exprs.NUB); |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 425 | Dir->setNumIterations(Exprs.NumIterations); |
Carlo Bertolli | 9925f15 | 2016-06-27 14:55:37 +0000 | [diff] [blame] | 426 | Dir->setPrevLowerBoundVariable(Exprs.PrevLB); |
| 427 | Dir->setPrevUpperBoundVariable(Exprs.PrevUB); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 428 | Dir->setCounters(Exprs.Counters); |
| 429 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 430 | Dir->setInits(Exprs.Inits); |
| 431 | Dir->setUpdates(Exprs.Updates); |
| 432 | Dir->setFinals(Exprs.Finals); |
Alexey Bataev | 5a3af13 | 2016-03-29 08:58:54 +0000 | [diff] [blame] | 433 | Dir->setPreInits(Exprs.PreInits); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 434 | return Dir; |
| 435 | } |
| 436 | |
| 437 | OMPParallelForSimdDirective * |
| 438 | OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C, |
| 439 | unsigned NumClauses, |
| 440 | unsigned CollapsedNum, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 441 | unsigned Size = llvm::alignTo(sizeof(OMPParallelForSimdDirective), |
| 442 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 443 | void *Mem = C.Allocate( |
| 444 | Size + sizeof(OMPClause *) * NumClauses + |
| 445 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd)); |
| 446 | return new (Mem) OMPParallelForSimdDirective(CollapsedNum, NumClauses); |
| 447 | } |
| 448 | |
| 449 | OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create( |
| 450 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 451 | ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 452 | unsigned Size = llvm::alignTo(sizeof(OMPParallelSectionsDirective), |
| 453 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 454 | void *Mem = |
| 455 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
| 456 | OMPParallelSectionsDirective *Dir = |
| 457 | new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size()); |
| 458 | Dir->setClauses(Clauses); |
| 459 | Dir->setAssociatedStmt(AssociatedStmt); |
| 460 | Dir->setHasCancel(HasCancel); |
| 461 | return Dir; |
| 462 | } |
| 463 | |
| 464 | OMPParallelSectionsDirective * |
| 465 | OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C, |
| 466 | unsigned NumClauses, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 467 | unsigned Size = llvm::alignTo(sizeof(OMPParallelSectionsDirective), |
| 468 | llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 469 | void *Mem = |
| 470 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 471 | return new (Mem) OMPParallelSectionsDirective(NumClauses); |
| 472 | } |
| 473 | |
| 474 | OMPTaskDirective * |
| 475 | OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc, |
| 476 | SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, |
| 477 | Stmt *AssociatedStmt, bool HasCancel) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 478 | unsigned Size = |
| 479 | llvm::alignTo(sizeof(OMPTaskDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 480 | void *Mem = |
| 481 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
| 482 | OMPTaskDirective *Dir = |
| 483 | new (Mem) OMPTaskDirective(StartLoc, EndLoc, Clauses.size()); |
| 484 | Dir->setClauses(Clauses); |
| 485 | Dir->setAssociatedStmt(AssociatedStmt); |
| 486 | Dir->setHasCancel(HasCancel); |
| 487 | return Dir; |
| 488 | } |
| 489 | |
| 490 | OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C, |
| 491 | unsigned NumClauses, |
| 492 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 493 | unsigned Size = |
| 494 | llvm::alignTo(sizeof(OMPTaskDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 495 | void *Mem = |
| 496 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 497 | return new (Mem) OMPTaskDirective(NumClauses); |
| 498 | } |
| 499 | |
| 500 | OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C, |
| 501 | SourceLocation StartLoc, |
| 502 | SourceLocation EndLoc) { |
| 503 | void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective)); |
| 504 | OMPTaskyieldDirective *Dir = |
| 505 | new (Mem) OMPTaskyieldDirective(StartLoc, EndLoc); |
| 506 | return Dir; |
| 507 | } |
| 508 | |
| 509 | OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C, |
| 510 | EmptyShell) { |
| 511 | void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective)); |
| 512 | return new (Mem) OMPTaskyieldDirective(); |
| 513 | } |
| 514 | |
| 515 | OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C, |
| 516 | SourceLocation StartLoc, |
| 517 | SourceLocation EndLoc) { |
| 518 | void *Mem = C.Allocate(sizeof(OMPBarrierDirective)); |
| 519 | OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc); |
| 520 | return Dir; |
| 521 | } |
| 522 | |
| 523 | OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C, |
| 524 | EmptyShell) { |
| 525 | void *Mem = C.Allocate(sizeof(OMPBarrierDirective)); |
| 526 | return new (Mem) OMPBarrierDirective(); |
| 527 | } |
| 528 | |
| 529 | OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C, |
| 530 | SourceLocation StartLoc, |
| 531 | SourceLocation EndLoc) { |
| 532 | void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective)); |
| 533 | OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc); |
| 534 | return Dir; |
| 535 | } |
| 536 | |
| 537 | OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C, |
| 538 | EmptyShell) { |
| 539 | void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective)); |
| 540 | return new (Mem) OMPTaskwaitDirective(); |
| 541 | } |
| 542 | |
| 543 | OMPTaskgroupDirective *OMPTaskgroupDirective::Create(const ASTContext &C, |
| 544 | SourceLocation StartLoc, |
| 545 | SourceLocation EndLoc, |
| 546 | Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 547 | unsigned Size = |
| 548 | llvm::alignTo(sizeof(OMPTaskgroupDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 549 | void *Mem = C.Allocate(Size + sizeof(Stmt *)); |
| 550 | OMPTaskgroupDirective *Dir = |
| 551 | new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc); |
| 552 | Dir->setAssociatedStmt(AssociatedStmt); |
| 553 | return Dir; |
| 554 | } |
| 555 | |
| 556 | OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C, |
| 557 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 558 | unsigned Size = |
| 559 | llvm::alignTo(sizeof(OMPTaskgroupDirective), llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 560 | void *Mem = C.Allocate(Size + sizeof(Stmt *)); |
| 561 | return new (Mem) OMPTaskgroupDirective(); |
| 562 | } |
| 563 | |
| 564 | OMPCancellationPointDirective *OMPCancellationPointDirective::Create( |
| 565 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 566 | OpenMPDirectiveKind CancelRegion) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 567 | unsigned Size = llvm::alignTo(sizeof(OMPCancellationPointDirective), |
| 568 | llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 569 | void *Mem = C.Allocate(Size); |
| 570 | OMPCancellationPointDirective *Dir = |
| 571 | new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc); |
| 572 | Dir->setCancelRegion(CancelRegion); |
| 573 | return Dir; |
| 574 | } |
| 575 | |
| 576 | OMPCancellationPointDirective * |
| 577 | OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 578 | unsigned Size = llvm::alignTo(sizeof(OMPCancellationPointDirective), |
| 579 | llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 580 | void *Mem = C.Allocate(Size); |
| 581 | return new (Mem) OMPCancellationPointDirective(); |
| 582 | } |
| 583 | |
| 584 | OMPCancelDirective * |
| 585 | OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc, |
| 586 | SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, |
| 587 | OpenMPDirectiveKind CancelRegion) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 588 | unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) + |
| 589 | sizeof(OMPClause *) * Clauses.size(), |
| 590 | llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 591 | void *Mem = C.Allocate(Size); |
| 592 | OMPCancelDirective *Dir = |
| 593 | new (Mem) OMPCancelDirective(StartLoc, EndLoc, Clauses.size()); |
| 594 | Dir->setClauses(Clauses); |
| 595 | Dir->setCancelRegion(CancelRegion); |
| 596 | return Dir; |
| 597 | } |
| 598 | |
| 599 | OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C, |
| 600 | unsigned NumClauses, |
| 601 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 602 | unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) + |
| 603 | sizeof(OMPClause *) * NumClauses, |
| 604 | llvm::alignOf<Stmt *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 605 | void *Mem = C.Allocate(Size); |
| 606 | return new (Mem) OMPCancelDirective(NumClauses); |
| 607 | } |
| 608 | |
| 609 | OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C, |
| 610 | SourceLocation StartLoc, |
| 611 | SourceLocation EndLoc, |
| 612 | ArrayRef<OMPClause *> Clauses) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 613 | unsigned Size = |
| 614 | llvm::alignTo(sizeof(OMPFlushDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 615 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size()); |
| 616 | OMPFlushDirective *Dir = |
| 617 | new (Mem) OMPFlushDirective(StartLoc, EndLoc, Clauses.size()); |
| 618 | Dir->setClauses(Clauses); |
| 619 | return Dir; |
| 620 | } |
| 621 | |
| 622 | OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C, |
| 623 | unsigned NumClauses, |
| 624 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 625 | unsigned Size = |
| 626 | llvm::alignTo(sizeof(OMPFlushDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 627 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses); |
| 628 | return new (Mem) OMPFlushDirective(NumClauses); |
| 629 | } |
| 630 | |
| 631 | OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C, |
| 632 | SourceLocation StartLoc, |
| 633 | SourceLocation EndLoc, |
| 634 | ArrayRef<OMPClause *> Clauses, |
| 635 | Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 636 | unsigned Size = |
| 637 | llvm::alignTo(sizeof(OMPOrderedDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 638 | void *Mem = |
| 639 | C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * Clauses.size()); |
| 640 | OMPOrderedDirective *Dir = |
| 641 | new (Mem) OMPOrderedDirective(StartLoc, EndLoc, Clauses.size()); |
| 642 | Dir->setClauses(Clauses); |
| 643 | Dir->setAssociatedStmt(AssociatedStmt); |
| 644 | return Dir; |
| 645 | } |
| 646 | |
| 647 | OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C, |
| 648 | unsigned NumClauses, |
| 649 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 650 | unsigned Size = |
| 651 | llvm::alignTo(sizeof(OMPOrderedDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 652 | void *Mem = |
| 653 | C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * NumClauses); |
| 654 | return new (Mem) OMPOrderedDirective(NumClauses); |
| 655 | } |
| 656 | |
| 657 | OMPAtomicDirective *OMPAtomicDirective::Create( |
| 658 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 659 | ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V, |
| 660 | Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 661 | unsigned Size = |
| 662 | llvm::alignTo(sizeof(OMPAtomicDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 663 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + |
| 664 | 5 * sizeof(Stmt *)); |
| 665 | OMPAtomicDirective *Dir = |
| 666 | new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size()); |
| 667 | Dir->setClauses(Clauses); |
| 668 | Dir->setAssociatedStmt(AssociatedStmt); |
| 669 | Dir->setX(X); |
| 670 | Dir->setV(V); |
| 671 | Dir->setExpr(E); |
| 672 | Dir->setUpdateExpr(UE); |
| 673 | Dir->IsXLHSInRHSPart = IsXLHSInRHSPart; |
| 674 | Dir->IsPostfixUpdate = IsPostfixUpdate; |
| 675 | return Dir; |
| 676 | } |
| 677 | |
| 678 | OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C, |
| 679 | unsigned NumClauses, |
| 680 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 681 | unsigned Size = |
| 682 | llvm::alignTo(sizeof(OMPAtomicDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 683 | void *Mem = |
| 684 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *)); |
| 685 | return new (Mem) OMPAtomicDirective(NumClauses); |
| 686 | } |
| 687 | |
| 688 | OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C, |
| 689 | SourceLocation StartLoc, |
| 690 | SourceLocation EndLoc, |
| 691 | ArrayRef<OMPClause *> Clauses, |
| 692 | Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 693 | unsigned Size = |
| 694 | llvm::alignTo(sizeof(OMPTargetDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 695 | void *Mem = |
| 696 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
| 697 | OMPTargetDirective *Dir = |
| 698 | new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size()); |
| 699 | Dir->setClauses(Clauses); |
| 700 | Dir->setAssociatedStmt(AssociatedStmt); |
| 701 | return Dir; |
| 702 | } |
| 703 | |
| 704 | OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C, |
| 705 | unsigned NumClauses, |
| 706 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 707 | unsigned Size = |
| 708 | llvm::alignTo(sizeof(OMPTargetDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 709 | void *Mem = |
| 710 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 711 | return new (Mem) OMPTargetDirective(NumClauses); |
| 712 | } |
| 713 | |
Arpith Chacko Jacob | e955b3d | 2016-01-26 18:48:41 +0000 | [diff] [blame] | 714 | OMPTargetParallelDirective *OMPTargetParallelDirective::Create( |
| 715 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 716 | ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { |
| 717 | unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelDirective), |
| 718 | llvm::alignOf<OMPClause *>()); |
| 719 | void *Mem = |
| 720 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
| 721 | OMPTargetParallelDirective *Dir = |
| 722 | new (Mem) OMPTargetParallelDirective(StartLoc, EndLoc, Clauses.size()); |
| 723 | Dir->setClauses(Clauses); |
| 724 | Dir->setAssociatedStmt(AssociatedStmt); |
| 725 | return Dir; |
| 726 | } |
| 727 | |
| 728 | OMPTargetParallelDirective * |
| 729 | OMPTargetParallelDirective::CreateEmpty(const ASTContext &C, |
| 730 | unsigned NumClauses, EmptyShell) { |
| 731 | unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelDirective), |
| 732 | llvm::alignOf<OMPClause *>()); |
| 733 | void *Mem = |
| 734 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 735 | return new (Mem) OMPTargetParallelDirective(NumClauses); |
| 736 | } |
| 737 | |
Arpith Chacko Jacob | 05bebb5 | 2016-02-03 15:46:42 +0000 | [diff] [blame] | 738 | OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create( |
| 739 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 740 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 741 | const HelperExprs &Exprs, bool HasCancel) { |
| 742 | unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective), |
| 743 | llvm::alignOf<OMPClause *>()); |
| 744 | void *Mem = C.Allocate( |
| 745 | Size + sizeof(OMPClause *) * Clauses.size() + |
| 746 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for)); |
| 747 | OMPTargetParallelForDirective *Dir = new (Mem) OMPTargetParallelForDirective( |
| 748 | StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 749 | Dir->setClauses(Clauses); |
| 750 | Dir->setAssociatedStmt(AssociatedStmt); |
| 751 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 752 | Dir->setLastIteration(Exprs.LastIteration); |
| 753 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 754 | Dir->setPreCond(Exprs.PreCond); |
| 755 | Dir->setCond(Exprs.Cond); |
| 756 | Dir->setInit(Exprs.Init); |
| 757 | Dir->setInc(Exprs.Inc); |
| 758 | Dir->setIsLastIterVariable(Exprs.IL); |
| 759 | Dir->setLowerBoundVariable(Exprs.LB); |
| 760 | Dir->setUpperBoundVariable(Exprs.UB); |
| 761 | Dir->setStrideVariable(Exprs.ST); |
| 762 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 763 | Dir->setNextLowerBound(Exprs.NLB); |
| 764 | Dir->setNextUpperBound(Exprs.NUB); |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 765 | Dir->setNumIterations(Exprs.NumIterations); |
Carlo Bertolli | 9925f15 | 2016-06-27 14:55:37 +0000 | [diff] [blame] | 766 | Dir->setPrevLowerBoundVariable(Exprs.PrevLB); |
| 767 | Dir->setPrevUpperBoundVariable(Exprs.PrevUB); |
Arpith Chacko Jacob | 05bebb5 | 2016-02-03 15:46:42 +0000 | [diff] [blame] | 768 | Dir->setCounters(Exprs.Counters); |
| 769 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 770 | Dir->setInits(Exprs.Inits); |
| 771 | Dir->setUpdates(Exprs.Updates); |
| 772 | Dir->setFinals(Exprs.Finals); |
Alexey Bataev | 5a3af13 | 2016-03-29 08:58:54 +0000 | [diff] [blame] | 773 | Dir->setPreInits(Exprs.PreInits); |
Arpith Chacko Jacob | 05bebb5 | 2016-02-03 15:46:42 +0000 | [diff] [blame] | 774 | Dir->setHasCancel(HasCancel); |
| 775 | return Dir; |
| 776 | } |
| 777 | |
| 778 | OMPTargetParallelForDirective * |
| 779 | OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C, |
| 780 | unsigned NumClauses, |
| 781 | unsigned CollapsedNum, EmptyShell) { |
| 782 | unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective), |
| 783 | llvm::alignOf<OMPClause *>()); |
| 784 | void *Mem = C.Allocate( |
| 785 | Size + sizeof(OMPClause *) * NumClauses + |
| 786 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for)); |
| 787 | return new (Mem) OMPTargetParallelForDirective(CollapsedNum, NumClauses); |
| 788 | } |
| 789 | |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 790 | OMPTargetDataDirective *OMPTargetDataDirective::Create( |
| 791 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 792 | ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 793 | void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetDataDirective), |
| 794 | llvm::alignOf<OMPClause *>()) + |
| 795 | sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 796 | OMPTargetDataDirective *Dir = |
| 797 | new (Mem) OMPTargetDataDirective(StartLoc, EndLoc, Clauses.size()); |
| 798 | Dir->setClauses(Clauses); |
| 799 | Dir->setAssociatedStmt(AssociatedStmt); |
| 800 | return Dir; |
| 801 | } |
| 802 | |
| 803 | OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C, |
| 804 | unsigned N, |
| 805 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 806 | void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetDataDirective), |
| 807 | llvm::alignOf<OMPClause *>()) + |
| 808 | sizeof(OMPClause *) * N + sizeof(Stmt *)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 809 | return new (Mem) OMPTargetDataDirective(N); |
| 810 | } |
| 811 | |
Samuel Antao | df67fc4 | 2016-01-19 19:15:56 +0000 | [diff] [blame] | 812 | OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create( |
| 813 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 814 | ArrayRef<OMPClause *> Clauses) { |
| 815 | void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetEnterDataDirective), |
| 816 | llvm::alignOf<OMPClause *>()) + |
| 817 | sizeof(OMPClause *) * Clauses.size()); |
| 818 | OMPTargetEnterDataDirective *Dir = |
| 819 | new (Mem) OMPTargetEnterDataDirective(StartLoc, EndLoc, Clauses.size()); |
| 820 | Dir->setClauses(Clauses); |
| 821 | return Dir; |
| 822 | } |
| 823 | |
| 824 | OMPTargetEnterDataDirective * |
| 825 | OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N, |
| 826 | EmptyShell) { |
| 827 | void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetEnterDataDirective), |
| 828 | llvm::alignOf<OMPClause *>()) + |
| 829 | sizeof(OMPClause *) * N); |
| 830 | return new (Mem) OMPTargetEnterDataDirective(N); |
| 831 | } |
| 832 | |
Samuel Antao | 7259076 | 2016-01-19 20:04:50 +0000 | [diff] [blame] | 833 | OMPTargetExitDataDirective * |
| 834 | OMPTargetExitDataDirective::Create(const ASTContext &C, SourceLocation StartLoc, |
| 835 | SourceLocation EndLoc, |
| 836 | ArrayRef<OMPClause *> Clauses) { |
| 837 | void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetExitDataDirective), |
| 838 | llvm::alignOf<OMPClause *>()) + |
| 839 | sizeof(OMPClause *) * Clauses.size()); |
| 840 | OMPTargetExitDataDirective *Dir = |
| 841 | new (Mem) OMPTargetExitDataDirective(StartLoc, EndLoc, Clauses.size()); |
| 842 | Dir->setClauses(Clauses); |
| 843 | return Dir; |
| 844 | } |
| 845 | |
| 846 | OMPTargetExitDataDirective * |
| 847 | OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N, |
| 848 | EmptyShell) { |
| 849 | void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetExitDataDirective), |
| 850 | llvm::alignOf<OMPClause *>()) + |
| 851 | sizeof(OMPClause *) * N); |
| 852 | return new (Mem) OMPTargetExitDataDirective(N); |
| 853 | } |
| 854 | |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 855 | OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C, |
| 856 | SourceLocation StartLoc, |
| 857 | SourceLocation EndLoc, |
| 858 | ArrayRef<OMPClause *> Clauses, |
| 859 | Stmt *AssociatedStmt) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 860 | unsigned Size = |
| 861 | llvm::alignTo(sizeof(OMPTeamsDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 862 | void *Mem = |
| 863 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *)); |
| 864 | OMPTeamsDirective *Dir = |
| 865 | new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size()); |
| 866 | Dir->setClauses(Clauses); |
| 867 | Dir->setAssociatedStmt(AssociatedStmt); |
| 868 | return Dir; |
| 869 | } |
| 870 | |
| 871 | OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C, |
| 872 | unsigned NumClauses, |
| 873 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 874 | unsigned Size = |
| 875 | llvm::alignTo(sizeof(OMPTeamsDirective), llvm::alignOf<OMPClause *>()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 876 | void *Mem = |
| 877 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *)); |
| 878 | return new (Mem) OMPTeamsDirective(NumClauses); |
| 879 | } |
Alexey Bataev | 49f6e78 | 2015-12-01 04:18:41 +0000 | [diff] [blame] | 880 | |
| 881 | OMPTaskLoopDirective *OMPTaskLoopDirective::Create( |
| 882 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 883 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 884 | const HelperExprs &Exprs) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 885 | unsigned Size = |
| 886 | llvm::alignTo(sizeof(OMPTaskLoopDirective), llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 49f6e78 | 2015-12-01 04:18:41 +0000 | [diff] [blame] | 887 | void *Mem = |
| 888 | C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + |
| 889 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop)); |
| 890 | OMPTaskLoopDirective *Dir = new (Mem) |
| 891 | OMPTaskLoopDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 892 | Dir->setClauses(Clauses); |
| 893 | Dir->setAssociatedStmt(AssociatedStmt); |
| 894 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 895 | Dir->setLastIteration(Exprs.LastIteration); |
| 896 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 897 | Dir->setPreCond(Exprs.PreCond); |
| 898 | Dir->setCond(Exprs.Cond); |
| 899 | Dir->setInit(Exprs.Init); |
| 900 | Dir->setInc(Exprs.Inc); |
| 901 | Dir->setIsLastIterVariable(Exprs.IL); |
| 902 | Dir->setLowerBoundVariable(Exprs.LB); |
| 903 | Dir->setUpperBoundVariable(Exprs.UB); |
| 904 | Dir->setStrideVariable(Exprs.ST); |
| 905 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 906 | Dir->setNextLowerBound(Exprs.NLB); |
| 907 | Dir->setNextUpperBound(Exprs.NUB); |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 908 | Dir->setNumIterations(Exprs.NumIterations); |
Carlo Bertolli | 9925f15 | 2016-06-27 14:55:37 +0000 | [diff] [blame] | 909 | Dir->setPrevLowerBoundVariable(Exprs.PrevLB); |
| 910 | Dir->setPrevUpperBoundVariable(Exprs.PrevUB); |
Alexey Bataev | 49f6e78 | 2015-12-01 04:18:41 +0000 | [diff] [blame] | 911 | Dir->setCounters(Exprs.Counters); |
| 912 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 913 | Dir->setInits(Exprs.Inits); |
| 914 | Dir->setUpdates(Exprs.Updates); |
| 915 | Dir->setFinals(Exprs.Finals); |
Alexey Bataev | 5a3af13 | 2016-03-29 08:58:54 +0000 | [diff] [blame] | 916 | Dir->setPreInits(Exprs.PreInits); |
Alexey Bataev | 49f6e78 | 2015-12-01 04:18:41 +0000 | [diff] [blame] | 917 | return Dir; |
| 918 | } |
| 919 | |
| 920 | OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C, |
| 921 | unsigned NumClauses, |
| 922 | unsigned CollapsedNum, |
| 923 | EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 924 | unsigned Size = |
| 925 | llvm::alignTo(sizeof(OMPTaskLoopDirective), llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 49f6e78 | 2015-12-01 04:18:41 +0000 | [diff] [blame] | 926 | void *Mem = |
| 927 | C.Allocate(Size + sizeof(OMPClause *) * NumClauses + |
| 928 | sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop)); |
| 929 | return new (Mem) OMPTaskLoopDirective(CollapsedNum, NumClauses); |
| 930 | } |
| 931 | |
Alexey Bataev | 0a6ed84 | 2015-12-03 09:40:15 +0000 | [diff] [blame] | 932 | OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create( |
| 933 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 934 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 935 | const HelperExprs &Exprs) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 936 | unsigned Size = llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), |
| 937 | llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 0a6ed84 | 2015-12-03 09:40:15 +0000 | [diff] [blame] | 938 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + |
| 939 | sizeof(Stmt *) * |
| 940 | numLoopChildren(CollapsedNum, OMPD_taskloop_simd)); |
| 941 | OMPTaskLoopSimdDirective *Dir = new (Mem) |
| 942 | OMPTaskLoopSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 943 | Dir->setClauses(Clauses); |
| 944 | Dir->setAssociatedStmt(AssociatedStmt); |
| 945 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 946 | Dir->setLastIteration(Exprs.LastIteration); |
| 947 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 948 | Dir->setPreCond(Exprs.PreCond); |
| 949 | Dir->setCond(Exprs.Cond); |
| 950 | Dir->setInit(Exprs.Init); |
| 951 | Dir->setInc(Exprs.Inc); |
| 952 | Dir->setIsLastIterVariable(Exprs.IL); |
| 953 | Dir->setLowerBoundVariable(Exprs.LB); |
| 954 | Dir->setUpperBoundVariable(Exprs.UB); |
| 955 | Dir->setStrideVariable(Exprs.ST); |
| 956 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 957 | Dir->setNextLowerBound(Exprs.NLB); |
| 958 | Dir->setNextUpperBound(Exprs.NUB); |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 959 | Dir->setNumIterations(Exprs.NumIterations); |
Carlo Bertolli | 9925f15 | 2016-06-27 14:55:37 +0000 | [diff] [blame] | 960 | Dir->setPrevLowerBoundVariable(Exprs.PrevLB); |
| 961 | Dir->setPrevUpperBoundVariable(Exprs.PrevUB); |
Alexey Bataev | 0a6ed84 | 2015-12-03 09:40:15 +0000 | [diff] [blame] | 962 | Dir->setCounters(Exprs.Counters); |
| 963 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 964 | Dir->setInits(Exprs.Inits); |
| 965 | Dir->setUpdates(Exprs.Updates); |
| 966 | Dir->setFinals(Exprs.Finals); |
Alexey Bataev | 5a3af13 | 2016-03-29 08:58:54 +0000 | [diff] [blame] | 967 | Dir->setPreInits(Exprs.PreInits); |
Alexey Bataev | 0a6ed84 | 2015-12-03 09:40:15 +0000 | [diff] [blame] | 968 | return Dir; |
| 969 | } |
| 970 | |
| 971 | OMPTaskLoopSimdDirective * |
| 972 | OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, |
| 973 | unsigned CollapsedNum, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 974 | unsigned Size = llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), |
| 975 | llvm::alignOf<OMPClause *>()); |
Alexey Bataev | 0a6ed84 | 2015-12-03 09:40:15 +0000 | [diff] [blame] | 976 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses + |
| 977 | sizeof(Stmt *) * |
| 978 | numLoopChildren(CollapsedNum, OMPD_taskloop_simd)); |
| 979 | return new (Mem) OMPTaskLoopSimdDirective(CollapsedNum, NumClauses); |
| 980 | } |
| 981 | |
Carlo Bertolli | 6200a3d | 2015-12-14 14:51:25 +0000 | [diff] [blame] | 982 | OMPDistributeDirective *OMPDistributeDirective::Create( |
| 983 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 984 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 985 | const HelperExprs &Exprs) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 986 | unsigned Size = llvm::alignTo(sizeof(OMPDistributeDirective), |
| 987 | llvm::alignOf<OMPClause *>()); |
Carlo Bertolli | 6200a3d | 2015-12-14 14:51:25 +0000 | [diff] [blame] | 988 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + |
| 989 | sizeof(Stmt *) * |
| 990 | numLoopChildren(CollapsedNum, OMPD_distribute)); |
| 991 | OMPDistributeDirective *Dir = new (Mem) |
| 992 | OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 993 | Dir->setClauses(Clauses); |
| 994 | Dir->setAssociatedStmt(AssociatedStmt); |
| 995 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 996 | Dir->setLastIteration(Exprs.LastIteration); |
| 997 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 998 | Dir->setPreCond(Exprs.PreCond); |
| 999 | Dir->setCond(Exprs.Cond); |
| 1000 | Dir->setInit(Exprs.Init); |
| 1001 | Dir->setInc(Exprs.Inc); |
| 1002 | Dir->setIsLastIterVariable(Exprs.IL); |
| 1003 | Dir->setLowerBoundVariable(Exprs.LB); |
| 1004 | Dir->setUpperBoundVariable(Exprs.UB); |
| 1005 | Dir->setStrideVariable(Exprs.ST); |
| 1006 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 1007 | Dir->setNextLowerBound(Exprs.NLB); |
| 1008 | Dir->setNextUpperBound(Exprs.NUB); |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 1009 | Dir->setNumIterations(Exprs.NumIterations); |
Carlo Bertolli | 9925f15 | 2016-06-27 14:55:37 +0000 | [diff] [blame] | 1010 | Dir->setPrevLowerBoundVariable(Exprs.PrevLB); |
| 1011 | Dir->setPrevUpperBoundVariable(Exprs.PrevUB); |
Carlo Bertolli | 6200a3d | 2015-12-14 14:51:25 +0000 | [diff] [blame] | 1012 | Dir->setCounters(Exprs.Counters); |
| 1013 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 1014 | Dir->setInits(Exprs.Inits); |
| 1015 | Dir->setUpdates(Exprs.Updates); |
| 1016 | Dir->setFinals(Exprs.Finals); |
Alexey Bataev | 5a3af13 | 2016-03-29 08:58:54 +0000 | [diff] [blame] | 1017 | Dir->setPreInits(Exprs.PreInits); |
Carlo Bertolli | 6200a3d | 2015-12-14 14:51:25 +0000 | [diff] [blame] | 1018 | return Dir; |
| 1019 | } |
| 1020 | |
| 1021 | OMPDistributeDirective * |
| 1022 | OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, |
| 1023 | unsigned CollapsedNum, EmptyShell) { |
Rui Ueyama | 83aa979 | 2016-01-14 21:00:27 +0000 | [diff] [blame] | 1024 | unsigned Size = llvm::alignTo(sizeof(OMPDistributeDirective), |
| 1025 | llvm::alignOf<OMPClause *>()); |
Carlo Bertolli | 6200a3d | 2015-12-14 14:51:25 +0000 | [diff] [blame] | 1026 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses + |
| 1027 | sizeof(Stmt *) * |
| 1028 | numLoopChildren(CollapsedNum, OMPD_distribute)); |
| 1029 | return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses); |
| 1030 | } |
Samuel Antao | 686c70c | 2016-05-26 17:30:50 +0000 | [diff] [blame] | 1031 | |
| 1032 | OMPTargetUpdateDirective * |
| 1033 | OMPTargetUpdateDirective::Create(const ASTContext &C, SourceLocation StartLoc, |
| 1034 | SourceLocation EndLoc, |
| 1035 | ArrayRef<OMPClause *> Clauses) { |
| 1036 | unsigned Size = llvm::alignTo(sizeof(OMPTargetUpdateDirective), |
| 1037 | llvm::alignOf<OMPClause *>()); |
| 1038 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size()); |
| 1039 | OMPTargetUpdateDirective *Dir = |
| 1040 | new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size()); |
| 1041 | Dir->setClauses(Clauses); |
| 1042 | return Dir; |
| 1043 | } |
| 1044 | |
| 1045 | OMPTargetUpdateDirective * |
| 1046 | OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, |
| 1047 | EmptyShell) { |
| 1048 | unsigned Size = llvm::alignTo(sizeof(OMPTargetUpdateDirective), |
| 1049 | llvm::alignOf<OMPClause *>()); |
| 1050 | void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses); |
| 1051 | return new (Mem) OMPTargetUpdateDirective(NumClauses); |
| 1052 | } |
Carlo Bertolli | 9925f15 | 2016-06-27 14:55:37 +0000 | [diff] [blame] | 1053 | |
| 1054 | OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create( |
| 1055 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 1056 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 1057 | const HelperExprs &Exprs) { |
| 1058 | unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective), |
| 1059 | llvm::alignOf<OMPClause *>()); |
| 1060 | void *Mem = C.Allocate( |
| 1061 | Size + sizeof(OMPClause *) * Clauses.size() + |
| 1062 | sizeof(Stmt *) * |
| 1063 | numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for)); |
| 1064 | OMPDistributeParallelForDirective *Dir = |
| 1065 | new (Mem) OMPDistributeParallelForDirective(StartLoc, EndLoc, |
| 1066 | CollapsedNum, Clauses.size()); |
| 1067 | Dir->setClauses(Clauses); |
| 1068 | Dir->setAssociatedStmt(AssociatedStmt); |
| 1069 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 1070 | Dir->setLastIteration(Exprs.LastIteration); |
| 1071 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 1072 | Dir->setPreCond(Exprs.PreCond); |
| 1073 | Dir->setCond(Exprs.Cond); |
| 1074 | Dir->setInit(Exprs.Init); |
| 1075 | Dir->setInc(Exprs.Inc); |
| 1076 | Dir->setIsLastIterVariable(Exprs.IL); |
| 1077 | Dir->setLowerBoundVariable(Exprs.LB); |
| 1078 | Dir->setUpperBoundVariable(Exprs.UB); |
| 1079 | Dir->setStrideVariable(Exprs.ST); |
| 1080 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 1081 | Dir->setNextLowerBound(Exprs.NLB); |
| 1082 | Dir->setNextUpperBound(Exprs.NUB); |
| 1083 | Dir->setNumIterations(Exprs.NumIterations); |
| 1084 | Dir->setPrevLowerBoundVariable(Exprs.PrevLB); |
| 1085 | Dir->setPrevUpperBoundVariable(Exprs.PrevUB); |
| 1086 | Dir->setCounters(Exprs.Counters); |
| 1087 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 1088 | Dir->setInits(Exprs.Inits); |
| 1089 | Dir->setUpdates(Exprs.Updates); |
| 1090 | Dir->setFinals(Exprs.Finals); |
| 1091 | Dir->setPreInits(Exprs.PreInits); |
| 1092 | return Dir; |
| 1093 | } |
| 1094 | |
| 1095 | OMPDistributeParallelForDirective * |
| 1096 | OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C, |
| 1097 | unsigned NumClauses, |
| 1098 | unsigned CollapsedNum, |
| 1099 | EmptyShell) { |
| 1100 | unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective), |
| 1101 | llvm::alignOf<OMPClause *>()); |
| 1102 | void *Mem = C.Allocate( |
| 1103 | Size + sizeof(OMPClause *) * NumClauses + |
| 1104 | sizeof(Stmt *) * |
| 1105 | numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for)); |
| 1106 | return new (Mem) OMPDistributeParallelForDirective(CollapsedNum, NumClauses); |
| 1107 | } |
Kelvin Li | 4a39add | 2016-07-05 05:00:15 +0000 | [diff] [blame] | 1108 | |
| 1109 | OMPDistributeParallelForSimdDirective * |
| 1110 | OMPDistributeParallelForSimdDirective::Create( |
| 1111 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 1112 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 1113 | const HelperExprs &Exprs) { |
| 1114 | unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective), |
| 1115 | llvm::alignOf<OMPClause *>()); |
| 1116 | void *Mem = C.Allocate( |
| 1117 | Size + sizeof(OMPClause *) * Clauses.size() + |
| 1118 | sizeof(Stmt *) * |
| 1119 | numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd)); |
| 1120 | OMPDistributeParallelForSimdDirective *Dir = new (Mem) |
| 1121 | OMPDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum, |
| 1122 | Clauses.size()); |
| 1123 | Dir->setClauses(Clauses); |
| 1124 | Dir->setAssociatedStmt(AssociatedStmt); |
| 1125 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 1126 | Dir->setLastIteration(Exprs.LastIteration); |
| 1127 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 1128 | Dir->setPreCond(Exprs.PreCond); |
| 1129 | Dir->setCond(Exprs.Cond); |
| 1130 | Dir->setInit(Exprs.Init); |
| 1131 | Dir->setInc(Exprs.Inc); |
| 1132 | Dir->setIsLastIterVariable(Exprs.IL); |
| 1133 | Dir->setLowerBoundVariable(Exprs.LB); |
| 1134 | Dir->setUpperBoundVariable(Exprs.UB); |
| 1135 | Dir->setStrideVariable(Exprs.ST); |
| 1136 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 1137 | Dir->setNextLowerBound(Exprs.NLB); |
| 1138 | Dir->setNextUpperBound(Exprs.NUB); |
| 1139 | Dir->setNumIterations(Exprs.NumIterations); |
| 1140 | Dir->setPrevLowerBoundVariable(Exprs.PrevLB); |
| 1141 | Dir->setPrevUpperBoundVariable(Exprs.PrevUB); |
| 1142 | Dir->setCounters(Exprs.Counters); |
| 1143 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 1144 | Dir->setInits(Exprs.Inits); |
| 1145 | Dir->setUpdates(Exprs.Updates); |
| 1146 | Dir->setFinals(Exprs.Finals); |
| 1147 | Dir->setPreInits(Exprs.PreInits); |
| 1148 | return Dir; |
| 1149 | } |
| 1150 | |
| 1151 | OMPDistributeParallelForSimdDirective * |
| 1152 | OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C, |
| 1153 | unsigned NumClauses, |
| 1154 | unsigned CollapsedNum, |
| 1155 | EmptyShell) { |
| 1156 | unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective), |
| 1157 | llvm::alignOf<OMPClause *>()); |
| 1158 | void *Mem = C.Allocate( |
| 1159 | Size + sizeof(OMPClause *) * NumClauses + |
| 1160 | sizeof(Stmt *) * |
| 1161 | numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd)); |
| 1162 | return new (Mem) |
| 1163 | OMPDistributeParallelForSimdDirective(CollapsedNum, NumClauses); |
| 1164 | } |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame^] | 1165 | |
| 1166 | OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create( |
| 1167 | const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, |
| 1168 | unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, |
| 1169 | const HelperExprs &Exprs) { |
| 1170 | unsigned Size = llvm::alignTo(sizeof(OMPDistributeSimdDirective), |
| 1171 | llvm::alignOf<OMPClause *>()); |
| 1172 | void *Mem = C.Allocate( |
| 1173 | Size + sizeof(OMPClause *) * Clauses.size() + |
| 1174 | sizeof(Stmt *) * |
| 1175 | numLoopChildren(CollapsedNum, OMPD_distribute_simd)); |
| 1176 | OMPDistributeSimdDirective *Dir = new (Mem) OMPDistributeSimdDirective( |
| 1177 | StartLoc, EndLoc, CollapsedNum, Clauses.size()); |
| 1178 | Dir->setClauses(Clauses); |
| 1179 | Dir->setAssociatedStmt(AssociatedStmt); |
| 1180 | Dir->setIterationVariable(Exprs.IterationVarRef); |
| 1181 | Dir->setLastIteration(Exprs.LastIteration); |
| 1182 | Dir->setCalcLastIteration(Exprs.CalcLastIteration); |
| 1183 | Dir->setPreCond(Exprs.PreCond); |
| 1184 | Dir->setCond(Exprs.Cond); |
| 1185 | Dir->setInit(Exprs.Init); |
| 1186 | Dir->setInc(Exprs.Inc); |
| 1187 | Dir->setIsLastIterVariable(Exprs.IL); |
| 1188 | Dir->setLowerBoundVariable(Exprs.LB); |
| 1189 | Dir->setUpperBoundVariable(Exprs.UB); |
| 1190 | Dir->setStrideVariable(Exprs.ST); |
| 1191 | Dir->setEnsureUpperBound(Exprs.EUB); |
| 1192 | Dir->setNextLowerBound(Exprs.NLB); |
| 1193 | Dir->setNextUpperBound(Exprs.NUB); |
| 1194 | Dir->setNumIterations(Exprs.NumIterations); |
| 1195 | Dir->setPrevLowerBoundVariable(Exprs.PrevLB); |
| 1196 | Dir->setPrevUpperBoundVariable(Exprs.PrevUB); |
| 1197 | Dir->setCounters(Exprs.Counters); |
| 1198 | Dir->setPrivateCounters(Exprs.PrivateCounters); |
| 1199 | Dir->setInits(Exprs.Inits); |
| 1200 | Dir->setUpdates(Exprs.Updates); |
| 1201 | Dir->setFinals(Exprs.Finals); |
| 1202 | Dir->setPreInits(Exprs.PreInits); |
| 1203 | return Dir; |
| 1204 | } |
| 1205 | |
| 1206 | OMPDistributeSimdDirective * |
| 1207 | OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C, |
| 1208 | unsigned NumClauses, |
| 1209 | unsigned CollapsedNum, EmptyShell) { |
| 1210 | unsigned Size = llvm::alignTo(sizeof(OMPDistributeSimdDirective), |
| 1211 | llvm::alignOf<OMPClause *>()); |
| 1212 | void *Mem = C.Allocate( |
| 1213 | Size + sizeof(OMPClause *) * NumClauses + |
| 1214 | sizeof(Stmt *) * |
| 1215 | numLoopChildren(CollapsedNum, OMPD_distribute_simd)); |
| 1216 | return new (Mem) OMPDistributeSimdDirective(CollapsedNum, NumClauses); |
| 1217 | } |