StmtOpenMP.cpp 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983
  1. //===--- StmtOpenMP.cpp - Classes for OpenMP directives -------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file implements the subclesses of Stmt class declared in StmtOpenMP.h
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "clang/AST/StmtOpenMP.h"
  13. #include "clang/AST/ASTContext.h"
  14. using namespace clang;
  15. void OMPExecutableDirective::setClauses(ArrayRef<OMPClause *> Clauses) {
  16. assert(Clauses.size() == getNumClauses() &&
  17. "Number of clauses is not the same as the preallocated buffer");
  18. std::copy(Clauses.begin(), Clauses.end(), getClauses().begin());
  19. }
  20. bool OMPExecutableDirective::isStandaloneDirective() const {
  21. // Special case: 'omp target enter data', 'omp target exit data',
  22. // 'omp target update' are stand-alone directives, but for implementation
  23. // reasons they have empty synthetic structured block, to simplify codegen.
  24. if (isa<OMPTargetEnterDataDirective>(this) ||
  25. isa<OMPTargetExitDataDirective>(this) ||
  26. isa<OMPTargetUpdateDirective>(this))
  27. return true;
  28. return !hasAssociatedStmt() || !getAssociatedStmt();
  29. }
  30. const Stmt *OMPExecutableDirective::getStructuredBlock() const {
  31. assert(!isStandaloneDirective() &&
  32. "Standalone Executable Directives don't have Structured Blocks.");
  33. if (auto *LD = dyn_cast<OMPLoopDirective>(this))
  34. return LD->getBody();
  35. return getInnermostCapturedStmt()->getCapturedStmt();
  36. }
  37. void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) {
  38. assert(A.size() == getCollapsedNumber() &&
  39. "Number of loop counters is not the same as the collapsed number");
  40. std::copy(A.begin(), A.end(), getCounters().begin());
  41. }
  42. void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) {
  43. assert(A.size() == getCollapsedNumber() && "Number of loop private counters "
  44. "is not the same as the collapsed "
  45. "number");
  46. std::copy(A.begin(), A.end(), getPrivateCounters().begin());
  47. }
  48. void OMPLoopDirective::setInits(ArrayRef<Expr *> A) {
  49. assert(A.size() == getCollapsedNumber() &&
  50. "Number of counter inits is not the same as the collapsed number");
  51. std::copy(A.begin(), A.end(), getInits().begin());
  52. }
  53. void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) {
  54. assert(A.size() == getCollapsedNumber() &&
  55. "Number of counter updates is not the same as the collapsed number");
  56. std::copy(A.begin(), A.end(), getUpdates().begin());
  57. }
  58. void OMPLoopDirective::setFinals(ArrayRef<Expr *> A) {
  59. assert(A.size() == getCollapsedNumber() &&
  60. "Number of counter finals is not the same as the collapsed number");
  61. std::copy(A.begin(), A.end(), getFinals().begin());
  62. }
  63. void OMPLoopDirective::setDependentCounters(ArrayRef<Expr *> A) {
  64. assert(
  65. A.size() == getCollapsedNumber() &&
  66. "Number of dependent counters is not the same as the collapsed number");
  67. llvm::copy(A, getDependentCounters().begin());
  68. }
  69. void OMPLoopDirective::setDependentInits(ArrayRef<Expr *> A) {
  70. assert(A.size() == getCollapsedNumber() &&
  71. "Number of dependent inits is not the same as the collapsed number");
  72. llvm::copy(A, getDependentInits().begin());
  73. }
  74. void OMPLoopDirective::setFinalsConditions(ArrayRef<Expr *> A) {
  75. assert(A.size() == getCollapsedNumber() &&
  76. "Number of finals conditions is not the same as the collapsed number");
  77. llvm::copy(A, getFinalsConditions().begin());
  78. }
  79. OMPParallelDirective *OMPParallelDirective::Create(
  80. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  81. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
  82. unsigned Size =
  83. llvm::alignTo(sizeof(OMPParallelDirective), alignof(OMPClause *));
  84. void *Mem =
  85. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  86. OMPParallelDirective *Dir =
  87. new (Mem) OMPParallelDirective(StartLoc, EndLoc, Clauses.size());
  88. Dir->setClauses(Clauses);
  89. Dir->setAssociatedStmt(AssociatedStmt);
  90. Dir->setHasCancel(HasCancel);
  91. return Dir;
  92. }
  93. OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C,
  94. unsigned NumClauses,
  95. EmptyShell) {
  96. unsigned Size =
  97. llvm::alignTo(sizeof(OMPParallelDirective), alignof(OMPClause *));
  98. void *Mem =
  99. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  100. return new (Mem) OMPParallelDirective(NumClauses);
  101. }
  102. OMPSimdDirective *
  103. OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  104. SourceLocation EndLoc, unsigned CollapsedNum,
  105. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  106. const HelperExprs &Exprs) {
  107. unsigned Size = llvm::alignTo(sizeof(OMPSimdDirective), alignof(OMPClause *));
  108. void *Mem =
  109. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  110. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
  111. OMPSimdDirective *Dir = new (Mem)
  112. OMPSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
  113. Dir->setClauses(Clauses);
  114. Dir->setAssociatedStmt(AssociatedStmt);
  115. Dir->setIterationVariable(Exprs.IterationVarRef);
  116. Dir->setLastIteration(Exprs.LastIteration);
  117. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  118. Dir->setPreCond(Exprs.PreCond);
  119. Dir->setCond(Exprs.Cond);
  120. Dir->setInit(Exprs.Init);
  121. Dir->setInc(Exprs.Inc);
  122. Dir->setCounters(Exprs.Counters);
  123. Dir->setPrivateCounters(Exprs.PrivateCounters);
  124. Dir->setInits(Exprs.Inits);
  125. Dir->setUpdates(Exprs.Updates);
  126. Dir->setFinals(Exprs.Finals);
  127. Dir->setDependentCounters(Exprs.DependentCounters);
  128. Dir->setDependentInits(Exprs.DependentInits);
  129. Dir->setFinalsConditions(Exprs.FinalsConditions);
  130. Dir->setPreInits(Exprs.PreInits);
  131. return Dir;
  132. }
  133. OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C,
  134. unsigned NumClauses,
  135. unsigned CollapsedNum,
  136. EmptyShell) {
  137. unsigned Size = llvm::alignTo(sizeof(OMPSimdDirective), alignof(OMPClause *));
  138. void *Mem =
  139. C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  140. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
  141. return new (Mem) OMPSimdDirective(CollapsedNum, NumClauses);
  142. }
  143. OMPForDirective *
  144. OMPForDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  145. SourceLocation EndLoc, unsigned CollapsedNum,
  146. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  147. const HelperExprs &Exprs, bool HasCancel) {
  148. unsigned Size = llvm::alignTo(sizeof(OMPForDirective), alignof(OMPClause *));
  149. void *Mem =
  150. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  151. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
  152. OMPForDirective *Dir =
  153. new (Mem) OMPForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
  154. Dir->setClauses(Clauses);
  155. Dir->setAssociatedStmt(AssociatedStmt);
  156. Dir->setIterationVariable(Exprs.IterationVarRef);
  157. Dir->setLastIteration(Exprs.LastIteration);
  158. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  159. Dir->setPreCond(Exprs.PreCond);
  160. Dir->setCond(Exprs.Cond);
  161. Dir->setInit(Exprs.Init);
  162. Dir->setInc(Exprs.Inc);
  163. Dir->setIsLastIterVariable(Exprs.IL);
  164. Dir->setLowerBoundVariable(Exprs.LB);
  165. Dir->setUpperBoundVariable(Exprs.UB);
  166. Dir->setStrideVariable(Exprs.ST);
  167. Dir->setEnsureUpperBound(Exprs.EUB);
  168. Dir->setNextLowerBound(Exprs.NLB);
  169. Dir->setNextUpperBound(Exprs.NUB);
  170. Dir->setNumIterations(Exprs.NumIterations);
  171. Dir->setCounters(Exprs.Counters);
  172. Dir->setPrivateCounters(Exprs.PrivateCounters);
  173. Dir->setInits(Exprs.Inits);
  174. Dir->setUpdates(Exprs.Updates);
  175. Dir->setFinals(Exprs.Finals);
  176. Dir->setDependentCounters(Exprs.DependentCounters);
  177. Dir->setDependentInits(Exprs.DependentInits);
  178. Dir->setFinalsConditions(Exprs.FinalsConditions);
  179. Dir->setPreInits(Exprs.PreInits);
  180. Dir->setHasCancel(HasCancel);
  181. return Dir;
  182. }
  183. OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C,
  184. unsigned NumClauses,
  185. unsigned CollapsedNum,
  186. EmptyShell) {
  187. unsigned Size = llvm::alignTo(sizeof(OMPForDirective), alignof(OMPClause *));
  188. void *Mem =
  189. C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  190. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
  191. return new (Mem) OMPForDirective(CollapsedNum, NumClauses);
  192. }
  193. OMPForSimdDirective *
  194. OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  195. SourceLocation EndLoc, unsigned CollapsedNum,
  196. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  197. const HelperExprs &Exprs) {
  198. unsigned Size =
  199. llvm::alignTo(sizeof(OMPForSimdDirective), alignof(OMPClause *));
  200. void *Mem =
  201. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  202. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
  203. OMPForSimdDirective *Dir = new (Mem)
  204. OMPForSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
  205. Dir->setClauses(Clauses);
  206. Dir->setAssociatedStmt(AssociatedStmt);
  207. Dir->setIterationVariable(Exprs.IterationVarRef);
  208. Dir->setLastIteration(Exprs.LastIteration);
  209. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  210. Dir->setPreCond(Exprs.PreCond);
  211. Dir->setCond(Exprs.Cond);
  212. Dir->setInit(Exprs.Init);
  213. Dir->setInc(Exprs.Inc);
  214. Dir->setIsLastIterVariable(Exprs.IL);
  215. Dir->setLowerBoundVariable(Exprs.LB);
  216. Dir->setUpperBoundVariable(Exprs.UB);
  217. Dir->setStrideVariable(Exprs.ST);
  218. Dir->setEnsureUpperBound(Exprs.EUB);
  219. Dir->setNextLowerBound(Exprs.NLB);
  220. Dir->setNextUpperBound(Exprs.NUB);
  221. Dir->setNumIterations(Exprs.NumIterations);
  222. Dir->setCounters(Exprs.Counters);
  223. Dir->setPrivateCounters(Exprs.PrivateCounters);
  224. Dir->setInits(Exprs.Inits);
  225. Dir->setUpdates(Exprs.Updates);
  226. Dir->setFinals(Exprs.Finals);
  227. Dir->setDependentCounters(Exprs.DependentCounters);
  228. Dir->setDependentInits(Exprs.DependentInits);
  229. Dir->setFinalsConditions(Exprs.FinalsConditions);
  230. Dir->setPreInits(Exprs.PreInits);
  231. return Dir;
  232. }
  233. OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C,
  234. unsigned NumClauses,
  235. unsigned CollapsedNum,
  236. EmptyShell) {
  237. unsigned Size =
  238. llvm::alignTo(sizeof(OMPForSimdDirective), alignof(OMPClause *));
  239. void *Mem =
  240. C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  241. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
  242. return new (Mem) OMPForSimdDirective(CollapsedNum, NumClauses);
  243. }
  244. OMPSectionsDirective *OMPSectionsDirective::Create(
  245. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  246. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
  247. unsigned Size =
  248. llvm::alignTo(sizeof(OMPSectionsDirective), alignof(OMPClause *));
  249. void *Mem =
  250. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  251. OMPSectionsDirective *Dir =
  252. new (Mem) OMPSectionsDirective(StartLoc, EndLoc, Clauses.size());
  253. Dir->setClauses(Clauses);
  254. Dir->setAssociatedStmt(AssociatedStmt);
  255. Dir->setHasCancel(HasCancel);
  256. return Dir;
  257. }
  258. OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C,
  259. unsigned NumClauses,
  260. EmptyShell) {
  261. unsigned Size =
  262. llvm::alignTo(sizeof(OMPSectionsDirective), alignof(OMPClause *));
  263. void *Mem =
  264. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  265. return new (Mem) OMPSectionsDirective(NumClauses);
  266. }
  267. OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C,
  268. SourceLocation StartLoc,
  269. SourceLocation EndLoc,
  270. Stmt *AssociatedStmt,
  271. bool HasCancel) {
  272. unsigned Size = llvm::alignTo(sizeof(OMPSectionDirective), alignof(Stmt *));
  273. void *Mem = C.Allocate(Size + sizeof(Stmt *));
  274. OMPSectionDirective *Dir = new (Mem) OMPSectionDirective(StartLoc, EndLoc);
  275. Dir->setAssociatedStmt(AssociatedStmt);
  276. Dir->setHasCancel(HasCancel);
  277. return Dir;
  278. }
  279. OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,
  280. EmptyShell) {
  281. unsigned Size = llvm::alignTo(sizeof(OMPSectionDirective), alignof(Stmt *));
  282. void *Mem = C.Allocate(Size + sizeof(Stmt *));
  283. return new (Mem) OMPSectionDirective();
  284. }
  285. OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,
  286. SourceLocation StartLoc,
  287. SourceLocation EndLoc,
  288. ArrayRef<OMPClause *> Clauses,
  289. Stmt *AssociatedStmt) {
  290. unsigned Size =
  291. llvm::alignTo(sizeof(OMPSingleDirective), alignof(OMPClause *));
  292. void *Mem =
  293. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  294. OMPSingleDirective *Dir =
  295. new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size());
  296. Dir->setClauses(Clauses);
  297. Dir->setAssociatedStmt(AssociatedStmt);
  298. return Dir;
  299. }
  300. OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,
  301. unsigned NumClauses,
  302. EmptyShell) {
  303. unsigned Size =
  304. llvm::alignTo(sizeof(OMPSingleDirective), alignof(OMPClause *));
  305. void *Mem =
  306. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  307. return new (Mem) OMPSingleDirective(NumClauses);
  308. }
  309. OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C,
  310. SourceLocation StartLoc,
  311. SourceLocation EndLoc,
  312. Stmt *AssociatedStmt) {
  313. unsigned Size = llvm::alignTo(sizeof(OMPMasterDirective), alignof(Stmt *));
  314. void *Mem = C.Allocate(Size + sizeof(Stmt *));
  315. OMPMasterDirective *Dir = new (Mem) OMPMasterDirective(StartLoc, EndLoc);
  316. Dir->setAssociatedStmt(AssociatedStmt);
  317. return Dir;
  318. }
  319. OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C,
  320. EmptyShell) {
  321. unsigned Size = llvm::alignTo(sizeof(OMPMasterDirective), alignof(Stmt *));
  322. void *Mem = C.Allocate(Size + sizeof(Stmt *));
  323. return new (Mem) OMPMasterDirective();
  324. }
  325. OMPCriticalDirective *OMPCriticalDirective::Create(
  326. const ASTContext &C, const DeclarationNameInfo &Name,
  327. SourceLocation StartLoc, SourceLocation EndLoc,
  328. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  329. unsigned Size =
  330. llvm::alignTo(sizeof(OMPCriticalDirective), alignof(OMPClause *));
  331. void *Mem =
  332. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  333. OMPCriticalDirective *Dir =
  334. new (Mem) OMPCriticalDirective(Name, StartLoc, EndLoc, Clauses.size());
  335. Dir->setClauses(Clauses);
  336. Dir->setAssociatedStmt(AssociatedStmt);
  337. return Dir;
  338. }
  339. OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C,
  340. unsigned NumClauses,
  341. EmptyShell) {
  342. unsigned Size =
  343. llvm::alignTo(sizeof(OMPCriticalDirective), alignof(OMPClause *));
  344. void *Mem =
  345. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  346. return new (Mem) OMPCriticalDirective(NumClauses);
  347. }
  348. OMPParallelForDirective *OMPParallelForDirective::Create(
  349. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  350. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  351. const HelperExprs &Exprs, bool HasCancel) {
  352. unsigned Size =
  353. llvm::alignTo(sizeof(OMPParallelForDirective), alignof(OMPClause *));
  354. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  355. sizeof(Stmt *) *
  356. numLoopChildren(CollapsedNum, OMPD_parallel_for));
  357. OMPParallelForDirective *Dir = new (Mem)
  358. OMPParallelForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
  359. Dir->setClauses(Clauses);
  360. Dir->setAssociatedStmt(AssociatedStmt);
  361. Dir->setIterationVariable(Exprs.IterationVarRef);
  362. Dir->setLastIteration(Exprs.LastIteration);
  363. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  364. Dir->setPreCond(Exprs.PreCond);
  365. Dir->setCond(Exprs.Cond);
  366. Dir->setInit(Exprs.Init);
  367. Dir->setInc(Exprs.Inc);
  368. Dir->setIsLastIterVariable(Exprs.IL);
  369. Dir->setLowerBoundVariable(Exprs.LB);
  370. Dir->setUpperBoundVariable(Exprs.UB);
  371. Dir->setStrideVariable(Exprs.ST);
  372. Dir->setEnsureUpperBound(Exprs.EUB);
  373. Dir->setNextLowerBound(Exprs.NLB);
  374. Dir->setNextUpperBound(Exprs.NUB);
  375. Dir->setNumIterations(Exprs.NumIterations);
  376. Dir->setCounters(Exprs.Counters);
  377. Dir->setPrivateCounters(Exprs.PrivateCounters);
  378. Dir->setInits(Exprs.Inits);
  379. Dir->setUpdates(Exprs.Updates);
  380. Dir->setFinals(Exprs.Finals);
  381. Dir->setDependentCounters(Exprs.DependentCounters);
  382. Dir->setDependentInits(Exprs.DependentInits);
  383. Dir->setFinalsConditions(Exprs.FinalsConditions);
  384. Dir->setPreInits(Exprs.PreInits);
  385. Dir->setHasCancel(HasCancel);
  386. return Dir;
  387. }
  388. OMPParallelForDirective *
  389. OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  390. unsigned CollapsedNum, EmptyShell) {
  391. unsigned Size =
  392. llvm::alignTo(sizeof(OMPParallelForDirective), alignof(OMPClause *));
  393. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  394. sizeof(Stmt *) *
  395. numLoopChildren(CollapsedNum, OMPD_parallel_for));
  396. return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses);
  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) {
  402. unsigned Size =
  403. llvm::alignTo(sizeof(OMPParallelForSimdDirective), alignof(OMPClause *));
  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);
  425. Dir->setNumIterations(Exprs.NumIterations);
  426. Dir->setCounters(Exprs.Counters);
  427. Dir->setPrivateCounters(Exprs.PrivateCounters);
  428. Dir->setInits(Exprs.Inits);
  429. Dir->setUpdates(Exprs.Updates);
  430. Dir->setFinals(Exprs.Finals);
  431. Dir->setDependentCounters(Exprs.DependentCounters);
  432. Dir->setDependentInits(Exprs.DependentInits);
  433. Dir->setFinalsConditions(Exprs.FinalsConditions);
  434. Dir->setPreInits(Exprs.PreInits);
  435. return Dir;
  436. }
  437. OMPParallelForSimdDirective *
  438. OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C,
  439. unsigned NumClauses,
  440. unsigned CollapsedNum, EmptyShell) {
  441. unsigned Size =
  442. llvm::alignTo(sizeof(OMPParallelForSimdDirective), alignof(OMPClause *));
  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. OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(
  449. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  450. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
  451. unsigned Size =
  452. llvm::alignTo(sizeof(OMPParallelSectionsDirective), alignof(OMPClause *));
  453. void *Mem =
  454. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  455. OMPParallelSectionsDirective *Dir =
  456. new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size());
  457. Dir->setClauses(Clauses);
  458. Dir->setAssociatedStmt(AssociatedStmt);
  459. Dir->setHasCancel(HasCancel);
  460. return Dir;
  461. }
  462. OMPParallelSectionsDirective *
  463. OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,
  464. unsigned NumClauses, EmptyShell) {
  465. unsigned Size =
  466. llvm::alignTo(sizeof(OMPParallelSectionsDirective), alignof(OMPClause *));
  467. void *Mem =
  468. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  469. return new (Mem) OMPParallelSectionsDirective(NumClauses);
  470. }
  471. OMPTaskDirective *
  472. OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  473. SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
  474. Stmt *AssociatedStmt, bool HasCancel) {
  475. unsigned Size = llvm::alignTo(sizeof(OMPTaskDirective), alignof(OMPClause *));
  476. void *Mem =
  477. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  478. OMPTaskDirective *Dir =
  479. new (Mem) OMPTaskDirective(StartLoc, EndLoc, Clauses.size());
  480. Dir->setClauses(Clauses);
  481. Dir->setAssociatedStmt(AssociatedStmt);
  482. Dir->setHasCancel(HasCancel);
  483. return Dir;
  484. }
  485. OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C,
  486. unsigned NumClauses,
  487. EmptyShell) {
  488. unsigned Size = llvm::alignTo(sizeof(OMPTaskDirective), alignof(OMPClause *));
  489. void *Mem =
  490. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  491. return new (Mem) OMPTaskDirective(NumClauses);
  492. }
  493. OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C,
  494. SourceLocation StartLoc,
  495. SourceLocation EndLoc) {
  496. void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
  497. OMPTaskyieldDirective *Dir =
  498. new (Mem) OMPTaskyieldDirective(StartLoc, EndLoc);
  499. return Dir;
  500. }
  501. OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C,
  502. EmptyShell) {
  503. void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
  504. return new (Mem) OMPTaskyieldDirective();
  505. }
  506. OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,
  507. SourceLocation StartLoc,
  508. SourceLocation EndLoc) {
  509. void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
  510. OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc);
  511. return Dir;
  512. }
  513. OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,
  514. EmptyShell) {
  515. void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
  516. return new (Mem) OMPBarrierDirective();
  517. }
  518. OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C,
  519. SourceLocation StartLoc,
  520. SourceLocation EndLoc) {
  521. void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
  522. OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc);
  523. return Dir;
  524. }
  525. OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,
  526. EmptyShell) {
  527. void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
  528. return new (Mem) OMPTaskwaitDirective();
  529. }
  530. OMPTaskgroupDirective *OMPTaskgroupDirective::Create(
  531. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  532. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) {
  533. unsigned Size = llvm::alignTo(sizeof(OMPTaskgroupDirective) +
  534. sizeof(OMPClause *) * Clauses.size(),
  535. alignof(Stmt *));
  536. void *Mem = C.Allocate(Size + sizeof(Stmt *) + sizeof(Expr *));
  537. OMPTaskgroupDirective *Dir =
  538. new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc, Clauses.size());
  539. Dir->setAssociatedStmt(AssociatedStmt);
  540. Dir->setReductionRef(ReductionRef);
  541. Dir->setClauses(Clauses);
  542. return Dir;
  543. }
  544. OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C,
  545. unsigned NumClauses,
  546. EmptyShell) {
  547. unsigned Size = llvm::alignTo(sizeof(OMPTaskgroupDirective) +
  548. sizeof(OMPClause *) * NumClauses,
  549. alignof(Stmt *));
  550. void *Mem = C.Allocate(Size + sizeof(Stmt *) + sizeof(Expr *));
  551. return new (Mem) OMPTaskgroupDirective(NumClauses);
  552. }
  553. OMPCancellationPointDirective *OMPCancellationPointDirective::Create(
  554. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  555. OpenMPDirectiveKind CancelRegion) {
  556. unsigned Size =
  557. llvm::alignTo(sizeof(OMPCancellationPointDirective), alignof(Stmt *));
  558. void *Mem = C.Allocate(Size);
  559. OMPCancellationPointDirective *Dir =
  560. new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc);
  561. Dir->setCancelRegion(CancelRegion);
  562. return Dir;
  563. }
  564. OMPCancellationPointDirective *
  565. OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) {
  566. unsigned Size =
  567. llvm::alignTo(sizeof(OMPCancellationPointDirective), alignof(Stmt *));
  568. void *Mem = C.Allocate(Size);
  569. return new (Mem) OMPCancellationPointDirective();
  570. }
  571. OMPCancelDirective *
  572. OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  573. SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
  574. OpenMPDirectiveKind CancelRegion) {
  575. unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
  576. sizeof(OMPClause *) * Clauses.size(),
  577. alignof(Stmt *));
  578. void *Mem = C.Allocate(Size);
  579. OMPCancelDirective *Dir =
  580. new (Mem) OMPCancelDirective(StartLoc, EndLoc, Clauses.size());
  581. Dir->setClauses(Clauses);
  582. Dir->setCancelRegion(CancelRegion);
  583. return Dir;
  584. }
  585. OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C,
  586. unsigned NumClauses,
  587. EmptyShell) {
  588. unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
  589. sizeof(OMPClause *) * NumClauses,
  590. alignof(Stmt *));
  591. void *Mem = C.Allocate(Size);
  592. return new (Mem) OMPCancelDirective(NumClauses);
  593. }
  594. OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C,
  595. SourceLocation StartLoc,
  596. SourceLocation EndLoc,
  597. ArrayRef<OMPClause *> Clauses) {
  598. unsigned Size =
  599. llvm::alignTo(sizeof(OMPFlushDirective), alignof(OMPClause *));
  600. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size());
  601. OMPFlushDirective *Dir =
  602. new (Mem) OMPFlushDirective(StartLoc, EndLoc, Clauses.size());
  603. Dir->setClauses(Clauses);
  604. return Dir;
  605. }
  606. OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C,
  607. unsigned NumClauses,
  608. EmptyShell) {
  609. unsigned Size =
  610. llvm::alignTo(sizeof(OMPFlushDirective), alignof(OMPClause *));
  611. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses);
  612. return new (Mem) OMPFlushDirective(NumClauses);
  613. }
  614. OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C,
  615. SourceLocation StartLoc,
  616. SourceLocation EndLoc,
  617. ArrayRef<OMPClause *> Clauses,
  618. Stmt *AssociatedStmt) {
  619. unsigned Size =
  620. llvm::alignTo(sizeof(OMPOrderedDirective), alignof(OMPClause *));
  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. OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C,
  630. unsigned NumClauses,
  631. EmptyShell) {
  632. unsigned Size =
  633. llvm::alignTo(sizeof(OMPOrderedDirective), alignof(OMPClause *));
  634. void *Mem =
  635. C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * NumClauses);
  636. return new (Mem) OMPOrderedDirective(NumClauses);
  637. }
  638. OMPAtomicDirective *OMPAtomicDirective::Create(
  639. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  640. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
  641. Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) {
  642. unsigned Size =
  643. llvm::alignTo(sizeof(OMPAtomicDirective), alignof(OMPClause *));
  644. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  645. 5 * sizeof(Stmt *));
  646. OMPAtomicDirective *Dir =
  647. new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size());
  648. Dir->setClauses(Clauses);
  649. Dir->setAssociatedStmt(AssociatedStmt);
  650. Dir->setX(X);
  651. Dir->setV(V);
  652. Dir->setExpr(E);
  653. Dir->setUpdateExpr(UE);
  654. Dir->IsXLHSInRHSPart = IsXLHSInRHSPart;
  655. Dir->IsPostfixUpdate = IsPostfixUpdate;
  656. return Dir;
  657. }
  658. OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,
  659. unsigned NumClauses,
  660. EmptyShell) {
  661. unsigned Size =
  662. llvm::alignTo(sizeof(OMPAtomicDirective), alignof(OMPClause *));
  663. void *Mem =
  664. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *));
  665. return new (Mem) OMPAtomicDirective(NumClauses);
  666. }
  667. OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,
  668. SourceLocation StartLoc,
  669. SourceLocation EndLoc,
  670. ArrayRef<OMPClause *> Clauses,
  671. Stmt *AssociatedStmt) {
  672. unsigned Size =
  673. llvm::alignTo(sizeof(OMPTargetDirective), alignof(OMPClause *));
  674. void *Mem =
  675. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  676. OMPTargetDirective *Dir =
  677. new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size());
  678. Dir->setClauses(Clauses);
  679. Dir->setAssociatedStmt(AssociatedStmt);
  680. return Dir;
  681. }
  682. OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,
  683. unsigned NumClauses,
  684. EmptyShell) {
  685. unsigned Size =
  686. llvm::alignTo(sizeof(OMPTargetDirective), alignof(OMPClause *));
  687. void *Mem =
  688. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  689. return new (Mem) OMPTargetDirective(NumClauses);
  690. }
  691. OMPTargetParallelDirective *OMPTargetParallelDirective::Create(
  692. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  693. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  694. unsigned Size =
  695. llvm::alignTo(sizeof(OMPTargetParallelDirective), alignof(OMPClause *));
  696. void *Mem =
  697. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  698. OMPTargetParallelDirective *Dir =
  699. new (Mem) OMPTargetParallelDirective(StartLoc, EndLoc, Clauses.size());
  700. Dir->setClauses(Clauses);
  701. Dir->setAssociatedStmt(AssociatedStmt);
  702. return Dir;
  703. }
  704. OMPTargetParallelDirective *
  705. OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,
  706. unsigned NumClauses, EmptyShell) {
  707. unsigned Size =
  708. llvm::alignTo(sizeof(OMPTargetParallelDirective), alignof(OMPClause *));
  709. void *Mem =
  710. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  711. return new (Mem) OMPTargetParallelDirective(NumClauses);
  712. }
  713. OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(
  714. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  715. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  716. const HelperExprs &Exprs, bool HasCancel) {
  717. unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
  718. alignof(OMPClause *));
  719. void *Mem = C.Allocate(
  720. Size + sizeof(OMPClause *) * Clauses.size() +
  721. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
  722. OMPTargetParallelForDirective *Dir = new (Mem) OMPTargetParallelForDirective(
  723. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  724. Dir->setClauses(Clauses);
  725. Dir->setAssociatedStmt(AssociatedStmt);
  726. Dir->setIterationVariable(Exprs.IterationVarRef);
  727. Dir->setLastIteration(Exprs.LastIteration);
  728. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  729. Dir->setPreCond(Exprs.PreCond);
  730. Dir->setCond(Exprs.Cond);
  731. Dir->setInit(Exprs.Init);
  732. Dir->setInc(Exprs.Inc);
  733. Dir->setIsLastIterVariable(Exprs.IL);
  734. Dir->setLowerBoundVariable(Exprs.LB);
  735. Dir->setUpperBoundVariable(Exprs.UB);
  736. Dir->setStrideVariable(Exprs.ST);
  737. Dir->setEnsureUpperBound(Exprs.EUB);
  738. Dir->setNextLowerBound(Exprs.NLB);
  739. Dir->setNextUpperBound(Exprs.NUB);
  740. Dir->setNumIterations(Exprs.NumIterations);
  741. Dir->setCounters(Exprs.Counters);
  742. Dir->setPrivateCounters(Exprs.PrivateCounters);
  743. Dir->setInits(Exprs.Inits);
  744. Dir->setUpdates(Exprs.Updates);
  745. Dir->setFinals(Exprs.Finals);
  746. Dir->setDependentCounters(Exprs.DependentCounters);
  747. Dir->setDependentInits(Exprs.DependentInits);
  748. Dir->setFinalsConditions(Exprs.FinalsConditions);
  749. Dir->setPreInits(Exprs.PreInits);
  750. Dir->setHasCancel(HasCancel);
  751. return Dir;
  752. }
  753. OMPTargetParallelForDirective *
  754. OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,
  755. unsigned NumClauses,
  756. unsigned CollapsedNum, EmptyShell) {
  757. unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
  758. alignof(OMPClause *));
  759. void *Mem = C.Allocate(
  760. Size + sizeof(OMPClause *) * NumClauses +
  761. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
  762. return new (Mem) OMPTargetParallelForDirective(CollapsedNum, NumClauses);
  763. }
  764. OMPTargetDataDirective *OMPTargetDataDirective::Create(
  765. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  766. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  767. void *Mem = C.Allocate(
  768. llvm::alignTo(sizeof(OMPTargetDataDirective), alignof(OMPClause *)) +
  769. sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  770. OMPTargetDataDirective *Dir =
  771. new (Mem) OMPTargetDataDirective(StartLoc, EndLoc, Clauses.size());
  772. Dir->setClauses(Clauses);
  773. Dir->setAssociatedStmt(AssociatedStmt);
  774. return Dir;
  775. }
  776. OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,
  777. unsigned N,
  778. EmptyShell) {
  779. void *Mem = C.Allocate(
  780. llvm::alignTo(sizeof(OMPTargetDataDirective), alignof(OMPClause *)) +
  781. sizeof(OMPClause *) * N + sizeof(Stmt *));
  782. return new (Mem) OMPTargetDataDirective(N);
  783. }
  784. OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(
  785. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  786. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  787. void *Mem = C.Allocate(
  788. llvm::alignTo(sizeof(OMPTargetEnterDataDirective), alignof(OMPClause *)) +
  789. sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  790. OMPTargetEnterDataDirective *Dir =
  791. new (Mem) OMPTargetEnterDataDirective(StartLoc, EndLoc, Clauses.size());
  792. Dir->setClauses(Clauses);
  793. Dir->setAssociatedStmt(AssociatedStmt);
  794. return Dir;
  795. }
  796. OMPTargetEnterDataDirective *
  797. OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
  798. EmptyShell) {
  799. void *Mem = C.Allocate(
  800. llvm::alignTo(sizeof(OMPTargetEnterDataDirective), alignof(OMPClause *)) +
  801. sizeof(OMPClause *) * N + sizeof(Stmt *));
  802. return new (Mem) OMPTargetEnterDataDirective(N);
  803. }
  804. OMPTargetExitDataDirective *OMPTargetExitDataDirective::Create(
  805. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  806. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  807. void *Mem = C.Allocate(
  808. llvm::alignTo(sizeof(OMPTargetExitDataDirective), alignof(OMPClause *)) +
  809. sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  810. OMPTargetExitDataDirective *Dir =
  811. new (Mem) OMPTargetExitDataDirective(StartLoc, EndLoc, Clauses.size());
  812. Dir->setClauses(Clauses);
  813. Dir->setAssociatedStmt(AssociatedStmt);
  814. return Dir;
  815. }
  816. OMPTargetExitDataDirective *
  817. OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
  818. EmptyShell) {
  819. void *Mem = C.Allocate(
  820. llvm::alignTo(sizeof(OMPTargetExitDataDirective), alignof(OMPClause *)) +
  821. sizeof(OMPClause *) * N + sizeof(Stmt *));
  822. return new (Mem) OMPTargetExitDataDirective(N);
  823. }
  824. OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
  825. SourceLocation StartLoc,
  826. SourceLocation EndLoc,
  827. ArrayRef<OMPClause *> Clauses,
  828. Stmt *AssociatedStmt) {
  829. unsigned Size =
  830. llvm::alignTo(sizeof(OMPTeamsDirective), alignof(OMPClause *));
  831. void *Mem =
  832. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  833. OMPTeamsDirective *Dir =
  834. new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size());
  835. Dir->setClauses(Clauses);
  836. Dir->setAssociatedStmt(AssociatedStmt);
  837. return Dir;
  838. }
  839. OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
  840. unsigned NumClauses,
  841. EmptyShell) {
  842. unsigned Size =
  843. llvm::alignTo(sizeof(OMPTeamsDirective), alignof(OMPClause *));
  844. void *Mem =
  845. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  846. return new (Mem) OMPTeamsDirective(NumClauses);
  847. }
  848. OMPTaskLoopDirective *OMPTaskLoopDirective::Create(
  849. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  850. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  851. const HelperExprs &Exprs) {
  852. unsigned Size =
  853. llvm::alignTo(sizeof(OMPTaskLoopDirective), alignof(OMPClause *));
  854. void *Mem =
  855. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  856. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
  857. OMPTaskLoopDirective *Dir = new (Mem)
  858. OMPTaskLoopDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
  859. Dir->setClauses(Clauses);
  860. Dir->setAssociatedStmt(AssociatedStmt);
  861. Dir->setIterationVariable(Exprs.IterationVarRef);
  862. Dir->setLastIteration(Exprs.LastIteration);
  863. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  864. Dir->setPreCond(Exprs.PreCond);
  865. Dir->setCond(Exprs.Cond);
  866. Dir->setInit(Exprs.Init);
  867. Dir->setInc(Exprs.Inc);
  868. Dir->setIsLastIterVariable(Exprs.IL);
  869. Dir->setLowerBoundVariable(Exprs.LB);
  870. Dir->setUpperBoundVariable(Exprs.UB);
  871. Dir->setStrideVariable(Exprs.ST);
  872. Dir->setEnsureUpperBound(Exprs.EUB);
  873. Dir->setNextLowerBound(Exprs.NLB);
  874. Dir->setNextUpperBound(Exprs.NUB);
  875. Dir->setNumIterations(Exprs.NumIterations);
  876. Dir->setCounters(Exprs.Counters);
  877. Dir->setPrivateCounters(Exprs.PrivateCounters);
  878. Dir->setInits(Exprs.Inits);
  879. Dir->setUpdates(Exprs.Updates);
  880. Dir->setFinals(Exprs.Finals);
  881. Dir->setDependentCounters(Exprs.DependentCounters);
  882. Dir->setDependentInits(Exprs.DependentInits);
  883. Dir->setFinalsConditions(Exprs.FinalsConditions);
  884. Dir->setPreInits(Exprs.PreInits);
  885. return Dir;
  886. }
  887. OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,
  888. unsigned NumClauses,
  889. unsigned CollapsedNum,
  890. EmptyShell) {
  891. unsigned Size =
  892. llvm::alignTo(sizeof(OMPTaskLoopDirective), alignof(OMPClause *));
  893. void *Mem =
  894. C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  895. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
  896. return new (Mem) OMPTaskLoopDirective(CollapsedNum, NumClauses);
  897. }
  898. OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(
  899. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  900. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  901. const HelperExprs &Exprs) {
  902. unsigned Size =
  903. llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), alignof(OMPClause *));
  904. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  905. sizeof(Stmt *) *
  906. numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
  907. OMPTaskLoopSimdDirective *Dir = new (Mem)
  908. OMPTaskLoopSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
  909. Dir->setClauses(Clauses);
  910. Dir->setAssociatedStmt(AssociatedStmt);
  911. Dir->setIterationVariable(Exprs.IterationVarRef);
  912. Dir->setLastIteration(Exprs.LastIteration);
  913. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  914. Dir->setPreCond(Exprs.PreCond);
  915. Dir->setCond(Exprs.Cond);
  916. Dir->setInit(Exprs.Init);
  917. Dir->setInc(Exprs.Inc);
  918. Dir->setIsLastIterVariable(Exprs.IL);
  919. Dir->setLowerBoundVariable(Exprs.LB);
  920. Dir->setUpperBoundVariable(Exprs.UB);
  921. Dir->setStrideVariable(Exprs.ST);
  922. Dir->setEnsureUpperBound(Exprs.EUB);
  923. Dir->setNextLowerBound(Exprs.NLB);
  924. Dir->setNextUpperBound(Exprs.NUB);
  925. Dir->setNumIterations(Exprs.NumIterations);
  926. Dir->setCounters(Exprs.Counters);
  927. Dir->setPrivateCounters(Exprs.PrivateCounters);
  928. Dir->setInits(Exprs.Inits);
  929. Dir->setUpdates(Exprs.Updates);
  930. Dir->setFinals(Exprs.Finals);
  931. Dir->setDependentCounters(Exprs.DependentCounters);
  932. Dir->setDependentInits(Exprs.DependentInits);
  933. Dir->setFinalsConditions(Exprs.FinalsConditions);
  934. Dir->setPreInits(Exprs.PreInits);
  935. return Dir;
  936. }
  937. OMPTaskLoopSimdDirective *
  938. OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  939. unsigned CollapsedNum, EmptyShell) {
  940. unsigned Size =
  941. llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), alignof(OMPClause *));
  942. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  943. sizeof(Stmt *) *
  944. numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
  945. return new (Mem) OMPTaskLoopSimdDirective(CollapsedNum, NumClauses);
  946. }
  947. OMPMasterTaskLoopDirective *OMPMasterTaskLoopDirective::Create(
  948. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  949. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  950. const HelperExprs &Exprs) {
  951. unsigned Size =
  952. llvm::alignTo(sizeof(OMPMasterTaskLoopDirective), alignof(OMPClause *));
  953. void *Mem = C.Allocate(
  954. Size + sizeof(OMPClause *) * Clauses.size() +
  955. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_master_taskloop));
  956. OMPMasterTaskLoopDirective *Dir = new (Mem) OMPMasterTaskLoopDirective(
  957. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  958. Dir->setClauses(Clauses);
  959. Dir->setAssociatedStmt(AssociatedStmt);
  960. Dir->setIterationVariable(Exprs.IterationVarRef);
  961. Dir->setLastIteration(Exprs.LastIteration);
  962. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  963. Dir->setPreCond(Exprs.PreCond);
  964. Dir->setCond(Exprs.Cond);
  965. Dir->setInit(Exprs.Init);
  966. Dir->setInc(Exprs.Inc);
  967. Dir->setIsLastIterVariable(Exprs.IL);
  968. Dir->setLowerBoundVariable(Exprs.LB);
  969. Dir->setUpperBoundVariable(Exprs.UB);
  970. Dir->setStrideVariable(Exprs.ST);
  971. Dir->setEnsureUpperBound(Exprs.EUB);
  972. Dir->setNextLowerBound(Exprs.NLB);
  973. Dir->setNextUpperBound(Exprs.NUB);
  974. Dir->setNumIterations(Exprs.NumIterations);
  975. Dir->setCounters(Exprs.Counters);
  976. Dir->setPrivateCounters(Exprs.PrivateCounters);
  977. Dir->setInits(Exprs.Inits);
  978. Dir->setUpdates(Exprs.Updates);
  979. Dir->setFinals(Exprs.Finals);
  980. Dir->setDependentCounters(Exprs.DependentCounters);
  981. Dir->setDependentInits(Exprs.DependentInits);
  982. Dir->setFinalsConditions(Exprs.FinalsConditions);
  983. Dir->setPreInits(Exprs.PreInits);
  984. return Dir;
  985. }
  986. OMPMasterTaskLoopDirective *
  987. OMPMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
  988. unsigned NumClauses,
  989. unsigned CollapsedNum, EmptyShell) {
  990. unsigned Size =
  991. llvm::alignTo(sizeof(OMPMasterTaskLoopDirective), alignof(OMPClause *));
  992. void *Mem = C.Allocate(
  993. Size + sizeof(OMPClause *) * NumClauses +
  994. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_master_taskloop));
  995. return new (Mem) OMPMasterTaskLoopDirective(CollapsedNum, NumClauses);
  996. }
  997. OMPDistributeDirective *OMPDistributeDirective::Create(
  998. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  999. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1000. const HelperExprs &Exprs) {
  1001. unsigned Size =
  1002. llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
  1003. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  1004. sizeof(Stmt *) *
  1005. numLoopChildren(CollapsedNum, OMPD_distribute));
  1006. OMPDistributeDirective *Dir = new (Mem)
  1007. OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1008. Dir->setClauses(Clauses);
  1009. Dir->setAssociatedStmt(AssociatedStmt);
  1010. Dir->setIterationVariable(Exprs.IterationVarRef);
  1011. Dir->setLastIteration(Exprs.LastIteration);
  1012. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1013. Dir->setPreCond(Exprs.PreCond);
  1014. Dir->setCond(Exprs.Cond);
  1015. Dir->setInit(Exprs.Init);
  1016. Dir->setInc(Exprs.Inc);
  1017. Dir->setIsLastIterVariable(Exprs.IL);
  1018. Dir->setLowerBoundVariable(Exprs.LB);
  1019. Dir->setUpperBoundVariable(Exprs.UB);
  1020. Dir->setStrideVariable(Exprs.ST);
  1021. Dir->setEnsureUpperBound(Exprs.EUB);
  1022. Dir->setNextLowerBound(Exprs.NLB);
  1023. Dir->setNextUpperBound(Exprs.NUB);
  1024. Dir->setNumIterations(Exprs.NumIterations);
  1025. Dir->setCounters(Exprs.Counters);
  1026. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1027. Dir->setInits(Exprs.Inits);
  1028. Dir->setUpdates(Exprs.Updates);
  1029. Dir->setFinals(Exprs.Finals);
  1030. Dir->setDependentCounters(Exprs.DependentCounters);
  1031. Dir->setDependentInits(Exprs.DependentInits);
  1032. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1033. Dir->setPreInits(Exprs.PreInits);
  1034. return Dir;
  1035. }
  1036. OMPDistributeDirective *
  1037. OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1038. unsigned CollapsedNum, EmptyShell) {
  1039. unsigned Size =
  1040. llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
  1041. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  1042. sizeof(Stmt *) *
  1043. numLoopChildren(CollapsedNum, OMPD_distribute));
  1044. return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses);
  1045. }
  1046. OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(
  1047. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1048. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  1049. unsigned Size =
  1050. llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
  1051. void *Mem =
  1052. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  1053. OMPTargetUpdateDirective *Dir =
  1054. new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size());
  1055. Dir->setClauses(Clauses);
  1056. Dir->setAssociatedStmt(AssociatedStmt);
  1057. return Dir;
  1058. }
  1059. OMPTargetUpdateDirective *
  1060. OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1061. EmptyShell) {
  1062. unsigned Size =
  1063. llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
  1064. void *Mem =
  1065. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  1066. return new (Mem) OMPTargetUpdateDirective(NumClauses);
  1067. }
  1068. OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
  1069. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1070. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1071. const HelperExprs &Exprs, bool HasCancel) {
  1072. unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
  1073. alignof(OMPClause *));
  1074. void *Mem = C.Allocate(
  1075. Size + sizeof(OMPClause *) * Clauses.size() +
  1076. sizeof(Stmt *) *
  1077. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
  1078. OMPDistributeParallelForDirective *Dir =
  1079. new (Mem) OMPDistributeParallelForDirective(StartLoc, EndLoc,
  1080. CollapsedNum, Clauses.size());
  1081. Dir->setClauses(Clauses);
  1082. Dir->setAssociatedStmt(AssociatedStmt);
  1083. Dir->setIterationVariable(Exprs.IterationVarRef);
  1084. Dir->setLastIteration(Exprs.LastIteration);
  1085. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1086. Dir->setPreCond(Exprs.PreCond);
  1087. Dir->setCond(Exprs.Cond);
  1088. Dir->setInit(Exprs.Init);
  1089. Dir->setInc(Exprs.Inc);
  1090. Dir->setIsLastIterVariable(Exprs.IL);
  1091. Dir->setLowerBoundVariable(Exprs.LB);
  1092. Dir->setUpperBoundVariable(Exprs.UB);
  1093. Dir->setStrideVariable(Exprs.ST);
  1094. Dir->setEnsureUpperBound(Exprs.EUB);
  1095. Dir->setNextLowerBound(Exprs.NLB);
  1096. Dir->setNextUpperBound(Exprs.NUB);
  1097. Dir->setNumIterations(Exprs.NumIterations);
  1098. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1099. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1100. Dir->setDistInc(Exprs.DistInc);
  1101. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1102. Dir->setCounters(Exprs.Counters);
  1103. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1104. Dir->setInits(Exprs.Inits);
  1105. Dir->setUpdates(Exprs.Updates);
  1106. Dir->setFinals(Exprs.Finals);
  1107. Dir->setDependentCounters(Exprs.DependentCounters);
  1108. Dir->setDependentInits(Exprs.DependentInits);
  1109. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1110. Dir->setPreInits(Exprs.PreInits);
  1111. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1112. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1113. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1114. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1115. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1116. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1117. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1118. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1119. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1120. Dir->HasCancel = HasCancel;
  1121. return Dir;
  1122. }
  1123. OMPDistributeParallelForDirective *
  1124. OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
  1125. unsigned NumClauses,
  1126. unsigned CollapsedNum,
  1127. EmptyShell) {
  1128. unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
  1129. alignof(OMPClause *));
  1130. void *Mem = C.Allocate(
  1131. Size + sizeof(OMPClause *) * NumClauses +
  1132. sizeof(Stmt *) *
  1133. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
  1134. return new (Mem) OMPDistributeParallelForDirective(CollapsedNum, NumClauses);
  1135. }
  1136. OMPDistributeParallelForSimdDirective *
  1137. OMPDistributeParallelForSimdDirective::Create(
  1138. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1139. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1140. const HelperExprs &Exprs) {
  1141. unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
  1142. alignof(OMPClause *));
  1143. void *Mem = C.Allocate(
  1144. Size + sizeof(OMPClause *) * Clauses.size() +
  1145. sizeof(Stmt *) *
  1146. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
  1147. OMPDistributeParallelForSimdDirective *Dir = new (Mem)
  1148. OMPDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
  1149. Clauses.size());
  1150. Dir->setClauses(Clauses);
  1151. Dir->setAssociatedStmt(AssociatedStmt);
  1152. Dir->setIterationVariable(Exprs.IterationVarRef);
  1153. Dir->setLastIteration(Exprs.LastIteration);
  1154. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1155. Dir->setPreCond(Exprs.PreCond);
  1156. Dir->setCond(Exprs.Cond);
  1157. Dir->setInit(Exprs.Init);
  1158. Dir->setInc(Exprs.Inc);
  1159. Dir->setIsLastIterVariable(Exprs.IL);
  1160. Dir->setLowerBoundVariable(Exprs.LB);
  1161. Dir->setUpperBoundVariable(Exprs.UB);
  1162. Dir->setStrideVariable(Exprs.ST);
  1163. Dir->setEnsureUpperBound(Exprs.EUB);
  1164. Dir->setNextLowerBound(Exprs.NLB);
  1165. Dir->setNextUpperBound(Exprs.NUB);
  1166. Dir->setNumIterations(Exprs.NumIterations);
  1167. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1168. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1169. Dir->setDistInc(Exprs.DistInc);
  1170. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1171. Dir->setCounters(Exprs.Counters);
  1172. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1173. Dir->setInits(Exprs.Inits);
  1174. Dir->setUpdates(Exprs.Updates);
  1175. Dir->setFinals(Exprs.Finals);
  1176. Dir->setDependentCounters(Exprs.DependentCounters);
  1177. Dir->setDependentInits(Exprs.DependentInits);
  1178. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1179. Dir->setPreInits(Exprs.PreInits);
  1180. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1181. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1182. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1183. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1184. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1185. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1186. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1187. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1188. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1189. return Dir;
  1190. }
  1191. OMPDistributeParallelForSimdDirective *
  1192. OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
  1193. unsigned NumClauses,
  1194. unsigned CollapsedNum,
  1195. EmptyShell) {
  1196. unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
  1197. alignof(OMPClause *));
  1198. void *Mem = C.Allocate(
  1199. Size + sizeof(OMPClause *) * NumClauses +
  1200. sizeof(Stmt *) *
  1201. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
  1202. return new (Mem)
  1203. OMPDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
  1204. }
  1205. OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
  1206. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1207. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1208. const HelperExprs &Exprs) {
  1209. unsigned Size =
  1210. llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
  1211. void *Mem = C.Allocate(
  1212. Size + sizeof(OMPClause *) * Clauses.size() +
  1213. sizeof(Stmt *) *
  1214. numLoopChildren(CollapsedNum, OMPD_distribute_simd));
  1215. OMPDistributeSimdDirective *Dir = new (Mem) OMPDistributeSimdDirective(
  1216. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1217. Dir->setClauses(Clauses);
  1218. Dir->setAssociatedStmt(AssociatedStmt);
  1219. Dir->setIterationVariable(Exprs.IterationVarRef);
  1220. Dir->setLastIteration(Exprs.LastIteration);
  1221. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1222. Dir->setPreCond(Exprs.PreCond);
  1223. Dir->setCond(Exprs.Cond);
  1224. Dir->setInit(Exprs.Init);
  1225. Dir->setInc(Exprs.Inc);
  1226. Dir->setIsLastIterVariable(Exprs.IL);
  1227. Dir->setLowerBoundVariable(Exprs.LB);
  1228. Dir->setUpperBoundVariable(Exprs.UB);
  1229. Dir->setStrideVariable(Exprs.ST);
  1230. Dir->setEnsureUpperBound(Exprs.EUB);
  1231. Dir->setNextLowerBound(Exprs.NLB);
  1232. Dir->setNextUpperBound(Exprs.NUB);
  1233. Dir->setNumIterations(Exprs.NumIterations);
  1234. Dir->setCounters(Exprs.Counters);
  1235. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1236. Dir->setInits(Exprs.Inits);
  1237. Dir->setUpdates(Exprs.Updates);
  1238. Dir->setFinals(Exprs.Finals);
  1239. Dir->setDependentCounters(Exprs.DependentCounters);
  1240. Dir->setDependentInits(Exprs.DependentInits);
  1241. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1242. Dir->setPreInits(Exprs.PreInits);
  1243. return Dir;
  1244. }
  1245. OMPDistributeSimdDirective *
  1246. OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
  1247. unsigned NumClauses,
  1248. unsigned CollapsedNum, EmptyShell) {
  1249. unsigned Size =
  1250. llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
  1251. void *Mem = C.Allocate(
  1252. Size + sizeof(OMPClause *) * NumClauses +
  1253. sizeof(Stmt *) *
  1254. numLoopChildren(CollapsedNum, OMPD_distribute_simd));
  1255. return new (Mem) OMPDistributeSimdDirective(CollapsedNum, NumClauses);
  1256. }
  1257. OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
  1258. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1259. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1260. const HelperExprs &Exprs) {
  1261. unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
  1262. alignof(OMPClause *));
  1263. void *Mem = C.Allocate(
  1264. Size + sizeof(OMPClause *) * Clauses.size() +
  1265. sizeof(Stmt *) *
  1266. numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
  1267. OMPTargetParallelForSimdDirective *Dir =
  1268. new (Mem) OMPTargetParallelForSimdDirective(StartLoc, EndLoc,
  1269. CollapsedNum, Clauses.size());
  1270. Dir->setClauses(Clauses);
  1271. Dir->setAssociatedStmt(AssociatedStmt);
  1272. Dir->setIterationVariable(Exprs.IterationVarRef);
  1273. Dir->setLastIteration(Exprs.LastIteration);
  1274. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1275. Dir->setPreCond(Exprs.PreCond);
  1276. Dir->setCond(Exprs.Cond);
  1277. Dir->setInit(Exprs.Init);
  1278. Dir->setInc(Exprs.Inc);
  1279. Dir->setIsLastIterVariable(Exprs.IL);
  1280. Dir->setLowerBoundVariable(Exprs.LB);
  1281. Dir->setUpperBoundVariable(Exprs.UB);
  1282. Dir->setStrideVariable(Exprs.ST);
  1283. Dir->setEnsureUpperBound(Exprs.EUB);
  1284. Dir->setNextLowerBound(Exprs.NLB);
  1285. Dir->setNextUpperBound(Exprs.NUB);
  1286. Dir->setNumIterations(Exprs.NumIterations);
  1287. Dir->setCounters(Exprs.Counters);
  1288. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1289. Dir->setInits(Exprs.Inits);
  1290. Dir->setUpdates(Exprs.Updates);
  1291. Dir->setFinals(Exprs.Finals);
  1292. Dir->setDependentCounters(Exprs.DependentCounters);
  1293. Dir->setDependentInits(Exprs.DependentInits);
  1294. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1295. Dir->setPreInits(Exprs.PreInits);
  1296. return Dir;
  1297. }
  1298. OMPTargetParallelForSimdDirective *
  1299. OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
  1300. unsigned NumClauses,
  1301. unsigned CollapsedNum,
  1302. EmptyShell) {
  1303. unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
  1304. alignof(OMPClause *));
  1305. void *Mem = C.Allocate(
  1306. Size + sizeof(OMPClause *) * NumClauses +
  1307. sizeof(Stmt *) *
  1308. numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
  1309. return new (Mem) OMPTargetParallelForSimdDirective(CollapsedNum, NumClauses);
  1310. }
  1311. OMPTargetSimdDirective *
  1312. OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  1313. SourceLocation EndLoc, unsigned CollapsedNum,
  1314. ArrayRef<OMPClause *> Clauses,
  1315. Stmt *AssociatedStmt, const HelperExprs &Exprs) {
  1316. unsigned Size =
  1317. llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
  1318. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  1319. sizeof(Stmt *) *
  1320. numLoopChildren(CollapsedNum, OMPD_target_simd));
  1321. OMPTargetSimdDirective *Dir = new (Mem)
  1322. OMPTargetSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1323. Dir->setClauses(Clauses);
  1324. Dir->setAssociatedStmt(AssociatedStmt);
  1325. Dir->setIterationVariable(Exprs.IterationVarRef);
  1326. Dir->setLastIteration(Exprs.LastIteration);
  1327. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1328. Dir->setPreCond(Exprs.PreCond);
  1329. Dir->setCond(Exprs.Cond);
  1330. Dir->setInit(Exprs.Init);
  1331. Dir->setInc(Exprs.Inc);
  1332. Dir->setCounters(Exprs.Counters);
  1333. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1334. Dir->setInits(Exprs.Inits);
  1335. Dir->setUpdates(Exprs.Updates);
  1336. Dir->setFinals(Exprs.Finals);
  1337. Dir->setDependentCounters(Exprs.DependentCounters);
  1338. Dir->setDependentInits(Exprs.DependentInits);
  1339. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1340. Dir->setPreInits(Exprs.PreInits);
  1341. return Dir;
  1342. }
  1343. OMPTargetSimdDirective *
  1344. OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1345. unsigned CollapsedNum, EmptyShell) {
  1346. unsigned Size =
  1347. llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
  1348. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  1349. sizeof(Stmt *) *
  1350. numLoopChildren(CollapsedNum, OMPD_target_simd));
  1351. return new (Mem) OMPTargetSimdDirective(CollapsedNum, NumClauses);
  1352. }
  1353. OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
  1354. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1355. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1356. const HelperExprs &Exprs) {
  1357. unsigned Size =
  1358. llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
  1359. void *Mem = C.Allocate(
  1360. Size + sizeof(OMPClause *) * Clauses.size() +
  1361. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
  1362. OMPTeamsDistributeDirective *Dir = new (Mem) OMPTeamsDistributeDirective(
  1363. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1364. Dir->setClauses(Clauses);
  1365. Dir->setAssociatedStmt(AssociatedStmt);
  1366. Dir->setIterationVariable(Exprs.IterationVarRef);
  1367. Dir->setLastIteration(Exprs.LastIteration);
  1368. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1369. Dir->setPreCond(Exprs.PreCond);
  1370. Dir->setCond(Exprs.Cond);
  1371. Dir->setInit(Exprs.Init);
  1372. Dir->setInc(Exprs.Inc);
  1373. Dir->setIsLastIterVariable(Exprs.IL);
  1374. Dir->setLowerBoundVariable(Exprs.LB);
  1375. Dir->setUpperBoundVariable(Exprs.UB);
  1376. Dir->setStrideVariable(Exprs.ST);
  1377. Dir->setEnsureUpperBound(Exprs.EUB);
  1378. Dir->setNextLowerBound(Exprs.NLB);
  1379. Dir->setNextUpperBound(Exprs.NUB);
  1380. Dir->setNumIterations(Exprs.NumIterations);
  1381. Dir->setCounters(Exprs.Counters);
  1382. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1383. Dir->setInits(Exprs.Inits);
  1384. Dir->setUpdates(Exprs.Updates);
  1385. Dir->setFinals(Exprs.Finals);
  1386. Dir->setDependentCounters(Exprs.DependentCounters);
  1387. Dir->setDependentInits(Exprs.DependentInits);
  1388. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1389. Dir->setPreInits(Exprs.PreInits);
  1390. return Dir;
  1391. }
  1392. OMPTeamsDistributeDirective *
  1393. OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
  1394. unsigned NumClauses,
  1395. unsigned CollapsedNum, EmptyShell) {
  1396. unsigned Size =
  1397. llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
  1398. void *Mem = C.Allocate(
  1399. Size + sizeof(OMPClause *) * NumClauses +
  1400. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
  1401. return new (Mem) OMPTeamsDistributeDirective(CollapsedNum, NumClauses);
  1402. }
  1403. OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
  1404. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1405. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1406. const HelperExprs &Exprs) {
  1407. unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
  1408. alignof(OMPClause *));
  1409. void *Mem =
  1410. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  1411. sizeof(Stmt *) *
  1412. numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
  1413. OMPTeamsDistributeSimdDirective *Dir =
  1414. new (Mem) OMPTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
  1415. Clauses.size());
  1416. Dir->setClauses(Clauses);
  1417. Dir->setAssociatedStmt(AssociatedStmt);
  1418. Dir->setIterationVariable(Exprs.IterationVarRef);
  1419. Dir->setLastIteration(Exprs.LastIteration);
  1420. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1421. Dir->setPreCond(Exprs.PreCond);
  1422. Dir->setCond(Exprs.Cond);
  1423. Dir->setInit(Exprs.Init);
  1424. Dir->setInc(Exprs.Inc);
  1425. Dir->setIsLastIterVariable(Exprs.IL);
  1426. Dir->setLowerBoundVariable(Exprs.LB);
  1427. Dir->setUpperBoundVariable(Exprs.UB);
  1428. Dir->setStrideVariable(Exprs.ST);
  1429. Dir->setEnsureUpperBound(Exprs.EUB);
  1430. Dir->setNextLowerBound(Exprs.NLB);
  1431. Dir->setNextUpperBound(Exprs.NUB);
  1432. Dir->setNumIterations(Exprs.NumIterations);
  1433. Dir->setCounters(Exprs.Counters);
  1434. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1435. Dir->setInits(Exprs.Inits);
  1436. Dir->setUpdates(Exprs.Updates);
  1437. Dir->setFinals(Exprs.Finals);
  1438. Dir->setDependentCounters(Exprs.DependentCounters);
  1439. Dir->setDependentInits(Exprs.DependentInits);
  1440. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1441. Dir->setPreInits(Exprs.PreInits);
  1442. return Dir;
  1443. }
  1444. OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
  1445. const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
  1446. EmptyShell) {
  1447. unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
  1448. alignof(OMPClause *));
  1449. void *Mem =
  1450. C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  1451. sizeof(Stmt *) *
  1452. numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
  1453. return new (Mem) OMPTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
  1454. }
  1455. OMPTeamsDistributeParallelForSimdDirective *
  1456. OMPTeamsDistributeParallelForSimdDirective::Create(
  1457. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1458. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1459. const HelperExprs &Exprs) {
  1460. auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
  1461. alignof(OMPClause *));
  1462. void *Mem =
  1463. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  1464. sizeof(Stmt *) *
  1465. numLoopChildren(CollapsedNum,
  1466. OMPD_teams_distribute_parallel_for_simd));
  1467. OMPTeamsDistributeParallelForSimdDirective *Dir = new (Mem)
  1468. OMPTeamsDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
  1469. Clauses.size());
  1470. Dir->setClauses(Clauses);
  1471. Dir->setAssociatedStmt(AssociatedStmt);
  1472. Dir->setIterationVariable(Exprs.IterationVarRef);
  1473. Dir->setLastIteration(Exprs.LastIteration);
  1474. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1475. Dir->setPreCond(Exprs.PreCond);
  1476. Dir->setCond(Exprs.Cond);
  1477. Dir->setInit(Exprs.Init);
  1478. Dir->setInc(Exprs.Inc);
  1479. Dir->setIsLastIterVariable(Exprs.IL);
  1480. Dir->setLowerBoundVariable(Exprs.LB);
  1481. Dir->setUpperBoundVariable(Exprs.UB);
  1482. Dir->setStrideVariable(Exprs.ST);
  1483. Dir->setEnsureUpperBound(Exprs.EUB);
  1484. Dir->setNextLowerBound(Exprs.NLB);
  1485. Dir->setNextUpperBound(Exprs.NUB);
  1486. Dir->setNumIterations(Exprs.NumIterations);
  1487. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1488. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1489. Dir->setDistInc(Exprs.DistInc);
  1490. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1491. Dir->setCounters(Exprs.Counters);
  1492. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1493. Dir->setInits(Exprs.Inits);
  1494. Dir->setUpdates(Exprs.Updates);
  1495. Dir->setFinals(Exprs.Finals);
  1496. Dir->setDependentCounters(Exprs.DependentCounters);
  1497. Dir->setDependentInits(Exprs.DependentInits);
  1498. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1499. Dir->setPreInits(Exprs.PreInits);
  1500. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1501. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1502. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1503. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1504. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1505. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1506. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1507. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1508. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1509. return Dir;
  1510. }
  1511. OMPTeamsDistributeParallelForSimdDirective *
  1512. OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
  1513. unsigned NumClauses,
  1514. unsigned CollapsedNum,
  1515. EmptyShell) {
  1516. auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
  1517. alignof(OMPClause *));
  1518. void *Mem =
  1519. C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  1520. sizeof(Stmt *) *
  1521. numLoopChildren(CollapsedNum,
  1522. OMPD_teams_distribute_parallel_for_simd));
  1523. return new (Mem)
  1524. OMPTeamsDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
  1525. }
  1526. OMPTeamsDistributeParallelForDirective *
  1527. OMPTeamsDistributeParallelForDirective::Create(
  1528. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1529. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1530. const HelperExprs &Exprs, bool HasCancel) {
  1531. auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
  1532. alignof(OMPClause *));
  1533. void *Mem = C.Allocate(
  1534. Size + sizeof(OMPClause *) * Clauses.size() +
  1535. sizeof(Stmt *) *
  1536. numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
  1537. OMPTeamsDistributeParallelForDirective *Dir = new (Mem)
  1538. OMPTeamsDistributeParallelForDirective(StartLoc, EndLoc, CollapsedNum,
  1539. Clauses.size());
  1540. Dir->setClauses(Clauses);
  1541. Dir->setAssociatedStmt(AssociatedStmt);
  1542. Dir->setIterationVariable(Exprs.IterationVarRef);
  1543. Dir->setLastIteration(Exprs.LastIteration);
  1544. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1545. Dir->setPreCond(Exprs.PreCond);
  1546. Dir->setCond(Exprs.Cond);
  1547. Dir->setInit(Exprs.Init);
  1548. Dir->setInc(Exprs.Inc);
  1549. Dir->setIsLastIterVariable(Exprs.IL);
  1550. Dir->setLowerBoundVariable(Exprs.LB);
  1551. Dir->setUpperBoundVariable(Exprs.UB);
  1552. Dir->setStrideVariable(Exprs.ST);
  1553. Dir->setEnsureUpperBound(Exprs.EUB);
  1554. Dir->setNextLowerBound(Exprs.NLB);
  1555. Dir->setNextUpperBound(Exprs.NUB);
  1556. Dir->setNumIterations(Exprs.NumIterations);
  1557. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1558. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1559. Dir->setDistInc(Exprs.DistInc);
  1560. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1561. Dir->setCounters(Exprs.Counters);
  1562. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1563. Dir->setInits(Exprs.Inits);
  1564. Dir->setUpdates(Exprs.Updates);
  1565. Dir->setFinals(Exprs.Finals);
  1566. Dir->setDependentCounters(Exprs.DependentCounters);
  1567. Dir->setDependentInits(Exprs.DependentInits);
  1568. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1569. Dir->setPreInits(Exprs.PreInits);
  1570. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1571. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1572. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1573. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1574. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1575. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1576. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1577. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1578. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1579. Dir->HasCancel = HasCancel;
  1580. return Dir;
  1581. }
  1582. OMPTeamsDistributeParallelForDirective *
  1583. OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
  1584. unsigned NumClauses,
  1585. unsigned CollapsedNum,
  1586. EmptyShell) {
  1587. auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
  1588. alignof(OMPClause *));
  1589. void *Mem = C.Allocate(
  1590. Size + sizeof(OMPClause *) * NumClauses +
  1591. sizeof(Stmt *) *
  1592. numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
  1593. return new (Mem)
  1594. OMPTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
  1595. }
  1596. OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
  1597. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1598. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  1599. auto Size =
  1600. llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
  1601. void *Mem =
  1602. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  1603. OMPTargetTeamsDirective *Dir =
  1604. new (Mem) OMPTargetTeamsDirective(StartLoc, EndLoc, Clauses.size());
  1605. Dir->setClauses(Clauses);
  1606. Dir->setAssociatedStmt(AssociatedStmt);
  1607. return Dir;
  1608. }
  1609. OMPTargetTeamsDirective *
  1610. OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1611. EmptyShell) {
  1612. auto Size =
  1613. llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
  1614. void *Mem =
  1615. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  1616. return new (Mem) OMPTargetTeamsDirective(NumClauses);
  1617. }
  1618. OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
  1619. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1620. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1621. const HelperExprs &Exprs) {
  1622. auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
  1623. alignof(OMPClause *));
  1624. void *Mem = C.Allocate(
  1625. Size + sizeof(OMPClause *) * Clauses.size() +
  1626. sizeof(Stmt *) *
  1627. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
  1628. OMPTargetTeamsDistributeDirective *Dir =
  1629. new (Mem) OMPTargetTeamsDistributeDirective(StartLoc, EndLoc, CollapsedNum,
  1630. Clauses.size());
  1631. Dir->setClauses(Clauses);
  1632. Dir->setAssociatedStmt(AssociatedStmt);
  1633. Dir->setIterationVariable(Exprs.IterationVarRef);
  1634. Dir->setLastIteration(Exprs.LastIteration);
  1635. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1636. Dir->setPreCond(Exprs.PreCond);
  1637. Dir->setCond(Exprs.Cond);
  1638. Dir->setInit(Exprs.Init);
  1639. Dir->setInc(Exprs.Inc);
  1640. Dir->setIsLastIterVariable(Exprs.IL);
  1641. Dir->setLowerBoundVariable(Exprs.LB);
  1642. Dir->setUpperBoundVariable(Exprs.UB);
  1643. Dir->setStrideVariable(Exprs.ST);
  1644. Dir->setEnsureUpperBound(Exprs.EUB);
  1645. Dir->setNextLowerBound(Exprs.NLB);
  1646. Dir->setNextUpperBound(Exprs.NUB);
  1647. Dir->setNumIterations(Exprs.NumIterations);
  1648. Dir->setCounters(Exprs.Counters);
  1649. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1650. Dir->setInits(Exprs.Inits);
  1651. Dir->setUpdates(Exprs.Updates);
  1652. Dir->setFinals(Exprs.Finals);
  1653. Dir->setDependentCounters(Exprs.DependentCounters);
  1654. Dir->setDependentInits(Exprs.DependentInits);
  1655. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1656. Dir->setPreInits(Exprs.PreInits);
  1657. return Dir;
  1658. }
  1659. OMPTargetTeamsDistributeDirective *
  1660. OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
  1661. unsigned NumClauses,
  1662. unsigned CollapsedNum,
  1663. EmptyShell) {
  1664. auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
  1665. alignof(OMPClause *));
  1666. void *Mem = C.Allocate(
  1667. Size + sizeof(OMPClause *) * NumClauses +
  1668. sizeof(Stmt *) *
  1669. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
  1670. return new (Mem) OMPTargetTeamsDistributeDirective(CollapsedNum, NumClauses);
  1671. }
  1672. OMPTargetTeamsDistributeParallelForDirective *
  1673. OMPTargetTeamsDistributeParallelForDirective::Create(
  1674. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1675. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1676. const HelperExprs &Exprs, bool HasCancel) {
  1677. auto Size =
  1678. llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
  1679. alignof(OMPClause *));
  1680. void *Mem = C.Allocate(
  1681. Size + sizeof(OMPClause *) * Clauses.size() +
  1682. sizeof(Stmt *) *
  1683. numLoopChildren(CollapsedNum,
  1684. OMPD_target_teams_distribute_parallel_for));
  1685. OMPTargetTeamsDistributeParallelForDirective *Dir =
  1686. new (Mem) OMPTargetTeamsDistributeParallelForDirective(
  1687. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1688. Dir->setClauses(Clauses);
  1689. Dir->setAssociatedStmt(AssociatedStmt);
  1690. Dir->setIterationVariable(Exprs.IterationVarRef);
  1691. Dir->setLastIteration(Exprs.LastIteration);
  1692. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1693. Dir->setPreCond(Exprs.PreCond);
  1694. Dir->setCond(Exprs.Cond);
  1695. Dir->setInit(Exprs.Init);
  1696. Dir->setInc(Exprs.Inc);
  1697. Dir->setIsLastIterVariable(Exprs.IL);
  1698. Dir->setLowerBoundVariable(Exprs.LB);
  1699. Dir->setUpperBoundVariable(Exprs.UB);
  1700. Dir->setStrideVariable(Exprs.ST);
  1701. Dir->setEnsureUpperBound(Exprs.EUB);
  1702. Dir->setNextLowerBound(Exprs.NLB);
  1703. Dir->setNextUpperBound(Exprs.NUB);
  1704. Dir->setNumIterations(Exprs.NumIterations);
  1705. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1706. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1707. Dir->setDistInc(Exprs.DistInc);
  1708. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1709. Dir->setCounters(Exprs.Counters);
  1710. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1711. Dir->setInits(Exprs.Inits);
  1712. Dir->setUpdates(Exprs.Updates);
  1713. Dir->setFinals(Exprs.Finals);
  1714. Dir->setDependentCounters(Exprs.DependentCounters);
  1715. Dir->setDependentInits(Exprs.DependentInits);
  1716. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1717. Dir->setPreInits(Exprs.PreInits);
  1718. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1719. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1720. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1721. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1722. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1723. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1724. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1725. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1726. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1727. Dir->HasCancel = HasCancel;
  1728. return Dir;
  1729. }
  1730. OMPTargetTeamsDistributeParallelForDirective *
  1731. OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
  1732. unsigned NumClauses,
  1733. unsigned CollapsedNum,
  1734. EmptyShell) {
  1735. auto Size =
  1736. llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
  1737. alignof(OMPClause *));
  1738. void *Mem = C.Allocate(
  1739. Size + sizeof(OMPClause *) * NumClauses +
  1740. sizeof(Stmt *) *
  1741. numLoopChildren(CollapsedNum,
  1742. OMPD_target_teams_distribute_parallel_for));
  1743. return new (Mem)
  1744. OMPTargetTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
  1745. }
  1746. OMPTargetTeamsDistributeParallelForSimdDirective *
  1747. OMPTargetTeamsDistributeParallelForSimdDirective::Create(
  1748. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1749. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1750. const HelperExprs &Exprs) {
  1751. auto Size =
  1752. llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
  1753. alignof(OMPClause *));
  1754. void *Mem = C.Allocate(
  1755. Size + sizeof(OMPClause *) * Clauses.size() +
  1756. sizeof(Stmt *) *
  1757. numLoopChildren(CollapsedNum,
  1758. OMPD_target_teams_distribute_parallel_for_simd));
  1759. OMPTargetTeamsDistributeParallelForSimdDirective *Dir =
  1760. new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
  1761. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1762. Dir->setClauses(Clauses);
  1763. Dir->setAssociatedStmt(AssociatedStmt);
  1764. Dir->setIterationVariable(Exprs.IterationVarRef);
  1765. Dir->setLastIteration(Exprs.LastIteration);
  1766. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1767. Dir->setPreCond(Exprs.PreCond);
  1768. Dir->setCond(Exprs.Cond);
  1769. Dir->setInit(Exprs.Init);
  1770. Dir->setInc(Exprs.Inc);
  1771. Dir->setIsLastIterVariable(Exprs.IL);
  1772. Dir->setLowerBoundVariable(Exprs.LB);
  1773. Dir->setUpperBoundVariable(Exprs.UB);
  1774. Dir->setStrideVariable(Exprs.ST);
  1775. Dir->setEnsureUpperBound(Exprs.EUB);
  1776. Dir->setNextLowerBound(Exprs.NLB);
  1777. Dir->setNextUpperBound(Exprs.NUB);
  1778. Dir->setNumIterations(Exprs.NumIterations);
  1779. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1780. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1781. Dir->setDistInc(Exprs.DistInc);
  1782. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1783. Dir->setCounters(Exprs.Counters);
  1784. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1785. Dir->setInits(Exprs.Inits);
  1786. Dir->setUpdates(Exprs.Updates);
  1787. Dir->setFinals(Exprs.Finals);
  1788. Dir->setDependentCounters(Exprs.DependentCounters);
  1789. Dir->setDependentInits(Exprs.DependentInits);
  1790. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1791. Dir->setPreInits(Exprs.PreInits);
  1792. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1793. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1794. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1795. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1796. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1797. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1798. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1799. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1800. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1801. return Dir;
  1802. }
  1803. OMPTargetTeamsDistributeParallelForSimdDirective *
  1804. OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
  1805. const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
  1806. EmptyShell) {
  1807. auto Size =
  1808. llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
  1809. alignof(OMPClause *));
  1810. void *Mem = C.Allocate(
  1811. Size + sizeof(OMPClause *) * NumClauses +
  1812. sizeof(Stmt *) *
  1813. numLoopChildren(CollapsedNum,
  1814. OMPD_target_teams_distribute_parallel_for_simd));
  1815. return new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
  1816. CollapsedNum, NumClauses);
  1817. }
  1818. OMPTargetTeamsDistributeSimdDirective *
  1819. OMPTargetTeamsDistributeSimdDirective::Create(
  1820. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1821. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1822. const HelperExprs &Exprs) {
  1823. auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
  1824. alignof(OMPClause *));
  1825. void *Mem = C.Allocate(
  1826. Size + sizeof(OMPClause *) * Clauses.size() +
  1827. sizeof(Stmt *) *
  1828. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
  1829. OMPTargetTeamsDistributeSimdDirective *Dir = new (Mem)
  1830. OMPTargetTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
  1831. Clauses.size());
  1832. Dir->setClauses(Clauses);
  1833. Dir->setAssociatedStmt(AssociatedStmt);
  1834. Dir->setIterationVariable(Exprs.IterationVarRef);
  1835. Dir->setLastIteration(Exprs.LastIteration);
  1836. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1837. Dir->setPreCond(Exprs.PreCond);
  1838. Dir->setCond(Exprs.Cond);
  1839. Dir->setInit(Exprs.Init);
  1840. Dir->setInc(Exprs.Inc);
  1841. Dir->setIsLastIterVariable(Exprs.IL);
  1842. Dir->setLowerBoundVariable(Exprs.LB);
  1843. Dir->setUpperBoundVariable(Exprs.UB);
  1844. Dir->setStrideVariable(Exprs.ST);
  1845. Dir->setEnsureUpperBound(Exprs.EUB);
  1846. Dir->setNextLowerBound(Exprs.NLB);
  1847. Dir->setNextUpperBound(Exprs.NUB);
  1848. Dir->setNumIterations(Exprs.NumIterations);
  1849. Dir->setCounters(Exprs.Counters);
  1850. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1851. Dir->setInits(Exprs.Inits);
  1852. Dir->setUpdates(Exprs.Updates);
  1853. Dir->setFinals(Exprs.Finals);
  1854. Dir->setDependentCounters(Exprs.DependentCounters);
  1855. Dir->setDependentInits(Exprs.DependentInits);
  1856. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1857. Dir->setPreInits(Exprs.PreInits);
  1858. return Dir;
  1859. }
  1860. OMPTargetTeamsDistributeSimdDirective *
  1861. OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
  1862. unsigned NumClauses,
  1863. unsigned CollapsedNum,
  1864. EmptyShell) {
  1865. auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
  1866. alignof(OMPClause *));
  1867. void *Mem = C.Allocate(
  1868. Size + sizeof(OMPClause *) * NumClauses +
  1869. sizeof(Stmt *) *
  1870. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
  1871. return new (Mem)
  1872. OMPTargetTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
  1873. }