StmtOpenMP.cpp 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092
  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. OMPMasterTaskLoopSimdDirective *OMPMasterTaskLoopSimdDirective::Create(
  998. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  999. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1000. const HelperExprs &Exprs) {
  1001. unsigned Size = llvm::alignTo(sizeof(OMPMasterTaskLoopSimdDirective),
  1002. alignof(OMPClause *));
  1003. void *Mem =
  1004. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  1005. sizeof(Stmt *) *
  1006. numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd));
  1007. auto *Dir = new (Mem) OMPMasterTaskLoopSimdDirective(
  1008. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1009. Dir->setClauses(Clauses);
  1010. Dir->setAssociatedStmt(AssociatedStmt);
  1011. Dir->setIterationVariable(Exprs.IterationVarRef);
  1012. Dir->setLastIteration(Exprs.LastIteration);
  1013. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1014. Dir->setPreCond(Exprs.PreCond);
  1015. Dir->setCond(Exprs.Cond);
  1016. Dir->setInit(Exprs.Init);
  1017. Dir->setInc(Exprs.Inc);
  1018. Dir->setIsLastIterVariable(Exprs.IL);
  1019. Dir->setLowerBoundVariable(Exprs.LB);
  1020. Dir->setUpperBoundVariable(Exprs.UB);
  1021. Dir->setStrideVariable(Exprs.ST);
  1022. Dir->setEnsureUpperBound(Exprs.EUB);
  1023. Dir->setNextLowerBound(Exprs.NLB);
  1024. Dir->setNextUpperBound(Exprs.NUB);
  1025. Dir->setNumIterations(Exprs.NumIterations);
  1026. Dir->setCounters(Exprs.Counters);
  1027. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1028. Dir->setInits(Exprs.Inits);
  1029. Dir->setUpdates(Exprs.Updates);
  1030. Dir->setFinals(Exprs.Finals);
  1031. Dir->setDependentCounters(Exprs.DependentCounters);
  1032. Dir->setDependentInits(Exprs.DependentInits);
  1033. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1034. Dir->setPreInits(Exprs.PreInits);
  1035. return Dir;
  1036. }
  1037. OMPMasterTaskLoopSimdDirective *
  1038. OMPMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
  1039. unsigned NumClauses,
  1040. unsigned CollapsedNum, EmptyShell) {
  1041. unsigned Size = llvm::alignTo(sizeof(OMPMasterTaskLoopSimdDirective),
  1042. alignof(OMPClause *));
  1043. void *Mem =
  1044. C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  1045. sizeof(Stmt *) *
  1046. numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd));
  1047. return new (Mem) OMPMasterTaskLoopSimdDirective(CollapsedNum, NumClauses);
  1048. }
  1049. OMPParallelMasterTaskLoopDirective *OMPParallelMasterTaskLoopDirective::Create(
  1050. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1051. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1052. const HelperExprs &Exprs) {
  1053. unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopDirective),
  1054. alignof(OMPClause *));
  1055. void *Mem = C.Allocate(
  1056. Size + sizeof(OMPClause *) * Clauses.size() +
  1057. sizeof(Stmt *) *
  1058. numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop));
  1059. auto *Dir = new (Mem) OMPParallelMasterTaskLoopDirective(
  1060. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1061. Dir->setClauses(Clauses);
  1062. Dir->setAssociatedStmt(AssociatedStmt);
  1063. Dir->setIterationVariable(Exprs.IterationVarRef);
  1064. Dir->setLastIteration(Exprs.LastIteration);
  1065. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1066. Dir->setPreCond(Exprs.PreCond);
  1067. Dir->setCond(Exprs.Cond);
  1068. Dir->setInit(Exprs.Init);
  1069. Dir->setInc(Exprs.Inc);
  1070. Dir->setIsLastIterVariable(Exprs.IL);
  1071. Dir->setLowerBoundVariable(Exprs.LB);
  1072. Dir->setUpperBoundVariable(Exprs.UB);
  1073. Dir->setStrideVariable(Exprs.ST);
  1074. Dir->setEnsureUpperBound(Exprs.EUB);
  1075. Dir->setNextLowerBound(Exprs.NLB);
  1076. Dir->setNextUpperBound(Exprs.NUB);
  1077. Dir->setNumIterations(Exprs.NumIterations);
  1078. Dir->setCounters(Exprs.Counters);
  1079. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1080. Dir->setInits(Exprs.Inits);
  1081. Dir->setUpdates(Exprs.Updates);
  1082. Dir->setFinals(Exprs.Finals);
  1083. Dir->setDependentCounters(Exprs.DependentCounters);
  1084. Dir->setDependentInits(Exprs.DependentInits);
  1085. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1086. Dir->setPreInits(Exprs.PreInits);
  1087. return Dir;
  1088. }
  1089. OMPParallelMasterTaskLoopDirective *
  1090. OMPParallelMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
  1091. unsigned NumClauses,
  1092. unsigned CollapsedNum,
  1093. EmptyShell) {
  1094. unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopDirective),
  1095. alignof(OMPClause *));
  1096. void *Mem = C.Allocate(
  1097. Size + sizeof(OMPClause *) * NumClauses +
  1098. sizeof(Stmt *) *
  1099. numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop));
  1100. return new (Mem) OMPParallelMasterTaskLoopDirective(CollapsedNum, NumClauses);
  1101. }
  1102. OMPDistributeDirective *OMPDistributeDirective::Create(
  1103. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1104. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1105. const HelperExprs &Exprs) {
  1106. unsigned Size =
  1107. llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
  1108. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  1109. sizeof(Stmt *) *
  1110. numLoopChildren(CollapsedNum, OMPD_distribute));
  1111. OMPDistributeDirective *Dir = new (Mem)
  1112. OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1113. Dir->setClauses(Clauses);
  1114. Dir->setAssociatedStmt(AssociatedStmt);
  1115. Dir->setIterationVariable(Exprs.IterationVarRef);
  1116. Dir->setLastIteration(Exprs.LastIteration);
  1117. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1118. Dir->setPreCond(Exprs.PreCond);
  1119. Dir->setCond(Exprs.Cond);
  1120. Dir->setInit(Exprs.Init);
  1121. Dir->setInc(Exprs.Inc);
  1122. Dir->setIsLastIterVariable(Exprs.IL);
  1123. Dir->setLowerBoundVariable(Exprs.LB);
  1124. Dir->setUpperBoundVariable(Exprs.UB);
  1125. Dir->setStrideVariable(Exprs.ST);
  1126. Dir->setEnsureUpperBound(Exprs.EUB);
  1127. Dir->setNextLowerBound(Exprs.NLB);
  1128. Dir->setNextUpperBound(Exprs.NUB);
  1129. Dir->setNumIterations(Exprs.NumIterations);
  1130. Dir->setCounters(Exprs.Counters);
  1131. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1132. Dir->setInits(Exprs.Inits);
  1133. Dir->setUpdates(Exprs.Updates);
  1134. Dir->setFinals(Exprs.Finals);
  1135. Dir->setDependentCounters(Exprs.DependentCounters);
  1136. Dir->setDependentInits(Exprs.DependentInits);
  1137. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1138. Dir->setPreInits(Exprs.PreInits);
  1139. return Dir;
  1140. }
  1141. OMPDistributeDirective *
  1142. OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1143. unsigned CollapsedNum, EmptyShell) {
  1144. unsigned Size =
  1145. llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
  1146. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  1147. sizeof(Stmt *) *
  1148. numLoopChildren(CollapsedNum, OMPD_distribute));
  1149. return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses);
  1150. }
  1151. OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(
  1152. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1153. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  1154. unsigned Size =
  1155. llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
  1156. void *Mem =
  1157. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  1158. OMPTargetUpdateDirective *Dir =
  1159. new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size());
  1160. Dir->setClauses(Clauses);
  1161. Dir->setAssociatedStmt(AssociatedStmt);
  1162. return Dir;
  1163. }
  1164. OMPTargetUpdateDirective *
  1165. OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1166. EmptyShell) {
  1167. unsigned Size =
  1168. llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
  1169. void *Mem =
  1170. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  1171. return new (Mem) OMPTargetUpdateDirective(NumClauses);
  1172. }
  1173. OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
  1174. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1175. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1176. const HelperExprs &Exprs, bool HasCancel) {
  1177. unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
  1178. alignof(OMPClause *));
  1179. void *Mem = C.Allocate(
  1180. Size + sizeof(OMPClause *) * Clauses.size() +
  1181. sizeof(Stmt *) *
  1182. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
  1183. OMPDistributeParallelForDirective *Dir =
  1184. new (Mem) OMPDistributeParallelForDirective(StartLoc, EndLoc,
  1185. CollapsedNum, Clauses.size());
  1186. Dir->setClauses(Clauses);
  1187. Dir->setAssociatedStmt(AssociatedStmt);
  1188. Dir->setIterationVariable(Exprs.IterationVarRef);
  1189. Dir->setLastIteration(Exprs.LastIteration);
  1190. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1191. Dir->setPreCond(Exprs.PreCond);
  1192. Dir->setCond(Exprs.Cond);
  1193. Dir->setInit(Exprs.Init);
  1194. Dir->setInc(Exprs.Inc);
  1195. Dir->setIsLastIterVariable(Exprs.IL);
  1196. Dir->setLowerBoundVariable(Exprs.LB);
  1197. Dir->setUpperBoundVariable(Exprs.UB);
  1198. Dir->setStrideVariable(Exprs.ST);
  1199. Dir->setEnsureUpperBound(Exprs.EUB);
  1200. Dir->setNextLowerBound(Exprs.NLB);
  1201. Dir->setNextUpperBound(Exprs.NUB);
  1202. Dir->setNumIterations(Exprs.NumIterations);
  1203. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1204. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1205. Dir->setDistInc(Exprs.DistInc);
  1206. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1207. Dir->setCounters(Exprs.Counters);
  1208. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1209. Dir->setInits(Exprs.Inits);
  1210. Dir->setUpdates(Exprs.Updates);
  1211. Dir->setFinals(Exprs.Finals);
  1212. Dir->setDependentCounters(Exprs.DependentCounters);
  1213. Dir->setDependentInits(Exprs.DependentInits);
  1214. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1215. Dir->setPreInits(Exprs.PreInits);
  1216. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1217. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1218. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1219. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1220. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1221. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1222. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1223. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1224. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1225. Dir->HasCancel = HasCancel;
  1226. return Dir;
  1227. }
  1228. OMPDistributeParallelForDirective *
  1229. OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
  1230. unsigned NumClauses,
  1231. unsigned CollapsedNum,
  1232. EmptyShell) {
  1233. unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
  1234. alignof(OMPClause *));
  1235. void *Mem = C.Allocate(
  1236. Size + sizeof(OMPClause *) * NumClauses +
  1237. sizeof(Stmt *) *
  1238. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
  1239. return new (Mem) OMPDistributeParallelForDirective(CollapsedNum, NumClauses);
  1240. }
  1241. OMPDistributeParallelForSimdDirective *
  1242. OMPDistributeParallelForSimdDirective::Create(
  1243. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1244. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1245. const HelperExprs &Exprs) {
  1246. unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
  1247. alignof(OMPClause *));
  1248. void *Mem = C.Allocate(
  1249. Size + sizeof(OMPClause *) * Clauses.size() +
  1250. sizeof(Stmt *) *
  1251. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
  1252. OMPDistributeParallelForSimdDirective *Dir = new (Mem)
  1253. OMPDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
  1254. Clauses.size());
  1255. Dir->setClauses(Clauses);
  1256. Dir->setAssociatedStmt(AssociatedStmt);
  1257. Dir->setIterationVariable(Exprs.IterationVarRef);
  1258. Dir->setLastIteration(Exprs.LastIteration);
  1259. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1260. Dir->setPreCond(Exprs.PreCond);
  1261. Dir->setCond(Exprs.Cond);
  1262. Dir->setInit(Exprs.Init);
  1263. Dir->setInc(Exprs.Inc);
  1264. Dir->setIsLastIterVariable(Exprs.IL);
  1265. Dir->setLowerBoundVariable(Exprs.LB);
  1266. Dir->setUpperBoundVariable(Exprs.UB);
  1267. Dir->setStrideVariable(Exprs.ST);
  1268. Dir->setEnsureUpperBound(Exprs.EUB);
  1269. Dir->setNextLowerBound(Exprs.NLB);
  1270. Dir->setNextUpperBound(Exprs.NUB);
  1271. Dir->setNumIterations(Exprs.NumIterations);
  1272. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1273. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1274. Dir->setDistInc(Exprs.DistInc);
  1275. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1276. Dir->setCounters(Exprs.Counters);
  1277. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1278. Dir->setInits(Exprs.Inits);
  1279. Dir->setUpdates(Exprs.Updates);
  1280. Dir->setFinals(Exprs.Finals);
  1281. Dir->setDependentCounters(Exprs.DependentCounters);
  1282. Dir->setDependentInits(Exprs.DependentInits);
  1283. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1284. Dir->setPreInits(Exprs.PreInits);
  1285. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1286. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1287. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1288. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1289. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1290. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1291. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1292. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1293. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1294. return Dir;
  1295. }
  1296. OMPDistributeParallelForSimdDirective *
  1297. OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
  1298. unsigned NumClauses,
  1299. unsigned CollapsedNum,
  1300. EmptyShell) {
  1301. unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
  1302. alignof(OMPClause *));
  1303. void *Mem = C.Allocate(
  1304. Size + sizeof(OMPClause *) * NumClauses +
  1305. sizeof(Stmt *) *
  1306. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
  1307. return new (Mem)
  1308. OMPDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
  1309. }
  1310. OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
  1311. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1312. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1313. const HelperExprs &Exprs) {
  1314. unsigned Size =
  1315. llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
  1316. void *Mem = C.Allocate(
  1317. Size + sizeof(OMPClause *) * Clauses.size() +
  1318. sizeof(Stmt *) *
  1319. numLoopChildren(CollapsedNum, OMPD_distribute_simd));
  1320. OMPDistributeSimdDirective *Dir = new (Mem) OMPDistributeSimdDirective(
  1321. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1322. Dir->setClauses(Clauses);
  1323. Dir->setAssociatedStmt(AssociatedStmt);
  1324. Dir->setIterationVariable(Exprs.IterationVarRef);
  1325. Dir->setLastIteration(Exprs.LastIteration);
  1326. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1327. Dir->setPreCond(Exprs.PreCond);
  1328. Dir->setCond(Exprs.Cond);
  1329. Dir->setInit(Exprs.Init);
  1330. Dir->setInc(Exprs.Inc);
  1331. Dir->setIsLastIterVariable(Exprs.IL);
  1332. Dir->setLowerBoundVariable(Exprs.LB);
  1333. Dir->setUpperBoundVariable(Exprs.UB);
  1334. Dir->setStrideVariable(Exprs.ST);
  1335. Dir->setEnsureUpperBound(Exprs.EUB);
  1336. Dir->setNextLowerBound(Exprs.NLB);
  1337. Dir->setNextUpperBound(Exprs.NUB);
  1338. Dir->setNumIterations(Exprs.NumIterations);
  1339. Dir->setCounters(Exprs.Counters);
  1340. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1341. Dir->setInits(Exprs.Inits);
  1342. Dir->setUpdates(Exprs.Updates);
  1343. Dir->setFinals(Exprs.Finals);
  1344. Dir->setDependentCounters(Exprs.DependentCounters);
  1345. Dir->setDependentInits(Exprs.DependentInits);
  1346. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1347. Dir->setPreInits(Exprs.PreInits);
  1348. return Dir;
  1349. }
  1350. OMPDistributeSimdDirective *
  1351. OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
  1352. unsigned NumClauses,
  1353. unsigned CollapsedNum, EmptyShell) {
  1354. unsigned Size =
  1355. llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
  1356. void *Mem = C.Allocate(
  1357. Size + sizeof(OMPClause *) * NumClauses +
  1358. sizeof(Stmt *) *
  1359. numLoopChildren(CollapsedNum, OMPD_distribute_simd));
  1360. return new (Mem) OMPDistributeSimdDirective(CollapsedNum, NumClauses);
  1361. }
  1362. OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
  1363. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1364. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1365. const HelperExprs &Exprs) {
  1366. unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
  1367. alignof(OMPClause *));
  1368. void *Mem = C.Allocate(
  1369. Size + sizeof(OMPClause *) * Clauses.size() +
  1370. sizeof(Stmt *) *
  1371. numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
  1372. OMPTargetParallelForSimdDirective *Dir =
  1373. new (Mem) OMPTargetParallelForSimdDirective(StartLoc, EndLoc,
  1374. CollapsedNum, Clauses.size());
  1375. Dir->setClauses(Clauses);
  1376. Dir->setAssociatedStmt(AssociatedStmt);
  1377. Dir->setIterationVariable(Exprs.IterationVarRef);
  1378. Dir->setLastIteration(Exprs.LastIteration);
  1379. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1380. Dir->setPreCond(Exprs.PreCond);
  1381. Dir->setCond(Exprs.Cond);
  1382. Dir->setInit(Exprs.Init);
  1383. Dir->setInc(Exprs.Inc);
  1384. Dir->setIsLastIterVariable(Exprs.IL);
  1385. Dir->setLowerBoundVariable(Exprs.LB);
  1386. Dir->setUpperBoundVariable(Exprs.UB);
  1387. Dir->setStrideVariable(Exprs.ST);
  1388. Dir->setEnsureUpperBound(Exprs.EUB);
  1389. Dir->setNextLowerBound(Exprs.NLB);
  1390. Dir->setNextUpperBound(Exprs.NUB);
  1391. Dir->setNumIterations(Exprs.NumIterations);
  1392. Dir->setCounters(Exprs.Counters);
  1393. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1394. Dir->setInits(Exprs.Inits);
  1395. Dir->setUpdates(Exprs.Updates);
  1396. Dir->setFinals(Exprs.Finals);
  1397. Dir->setDependentCounters(Exprs.DependentCounters);
  1398. Dir->setDependentInits(Exprs.DependentInits);
  1399. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1400. Dir->setPreInits(Exprs.PreInits);
  1401. return Dir;
  1402. }
  1403. OMPTargetParallelForSimdDirective *
  1404. OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
  1405. unsigned NumClauses,
  1406. unsigned CollapsedNum,
  1407. EmptyShell) {
  1408. unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
  1409. alignof(OMPClause *));
  1410. void *Mem = C.Allocate(
  1411. Size + sizeof(OMPClause *) * NumClauses +
  1412. sizeof(Stmt *) *
  1413. numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
  1414. return new (Mem) OMPTargetParallelForSimdDirective(CollapsedNum, NumClauses);
  1415. }
  1416. OMPTargetSimdDirective *
  1417. OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  1418. SourceLocation EndLoc, unsigned CollapsedNum,
  1419. ArrayRef<OMPClause *> Clauses,
  1420. Stmt *AssociatedStmt, const HelperExprs &Exprs) {
  1421. unsigned Size =
  1422. llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
  1423. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  1424. sizeof(Stmt *) *
  1425. numLoopChildren(CollapsedNum, OMPD_target_simd));
  1426. OMPTargetSimdDirective *Dir = new (Mem)
  1427. OMPTargetSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1428. Dir->setClauses(Clauses);
  1429. Dir->setAssociatedStmt(AssociatedStmt);
  1430. Dir->setIterationVariable(Exprs.IterationVarRef);
  1431. Dir->setLastIteration(Exprs.LastIteration);
  1432. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1433. Dir->setPreCond(Exprs.PreCond);
  1434. Dir->setCond(Exprs.Cond);
  1435. Dir->setInit(Exprs.Init);
  1436. Dir->setInc(Exprs.Inc);
  1437. Dir->setCounters(Exprs.Counters);
  1438. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1439. Dir->setInits(Exprs.Inits);
  1440. Dir->setUpdates(Exprs.Updates);
  1441. Dir->setFinals(Exprs.Finals);
  1442. Dir->setDependentCounters(Exprs.DependentCounters);
  1443. Dir->setDependentInits(Exprs.DependentInits);
  1444. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1445. Dir->setPreInits(Exprs.PreInits);
  1446. return Dir;
  1447. }
  1448. OMPTargetSimdDirective *
  1449. OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1450. unsigned CollapsedNum, EmptyShell) {
  1451. unsigned Size =
  1452. llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
  1453. void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  1454. sizeof(Stmt *) *
  1455. numLoopChildren(CollapsedNum, OMPD_target_simd));
  1456. return new (Mem) OMPTargetSimdDirective(CollapsedNum, NumClauses);
  1457. }
  1458. OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
  1459. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1460. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1461. const HelperExprs &Exprs) {
  1462. unsigned Size =
  1463. llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
  1464. void *Mem = C.Allocate(
  1465. Size + sizeof(OMPClause *) * Clauses.size() +
  1466. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
  1467. OMPTeamsDistributeDirective *Dir = new (Mem) OMPTeamsDistributeDirective(
  1468. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1469. Dir->setClauses(Clauses);
  1470. Dir->setAssociatedStmt(AssociatedStmt);
  1471. Dir->setIterationVariable(Exprs.IterationVarRef);
  1472. Dir->setLastIteration(Exprs.LastIteration);
  1473. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1474. Dir->setPreCond(Exprs.PreCond);
  1475. Dir->setCond(Exprs.Cond);
  1476. Dir->setInit(Exprs.Init);
  1477. Dir->setInc(Exprs.Inc);
  1478. Dir->setIsLastIterVariable(Exprs.IL);
  1479. Dir->setLowerBoundVariable(Exprs.LB);
  1480. Dir->setUpperBoundVariable(Exprs.UB);
  1481. Dir->setStrideVariable(Exprs.ST);
  1482. Dir->setEnsureUpperBound(Exprs.EUB);
  1483. Dir->setNextLowerBound(Exprs.NLB);
  1484. Dir->setNextUpperBound(Exprs.NUB);
  1485. Dir->setNumIterations(Exprs.NumIterations);
  1486. Dir->setCounters(Exprs.Counters);
  1487. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1488. Dir->setInits(Exprs.Inits);
  1489. Dir->setUpdates(Exprs.Updates);
  1490. Dir->setFinals(Exprs.Finals);
  1491. Dir->setDependentCounters(Exprs.DependentCounters);
  1492. Dir->setDependentInits(Exprs.DependentInits);
  1493. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1494. Dir->setPreInits(Exprs.PreInits);
  1495. return Dir;
  1496. }
  1497. OMPTeamsDistributeDirective *
  1498. OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
  1499. unsigned NumClauses,
  1500. unsigned CollapsedNum, EmptyShell) {
  1501. unsigned Size =
  1502. llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
  1503. void *Mem = C.Allocate(
  1504. Size + sizeof(OMPClause *) * NumClauses +
  1505. sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
  1506. return new (Mem) OMPTeamsDistributeDirective(CollapsedNum, NumClauses);
  1507. }
  1508. OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
  1509. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1510. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1511. const HelperExprs &Exprs) {
  1512. unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
  1513. alignof(OMPClause *));
  1514. void *Mem =
  1515. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  1516. sizeof(Stmt *) *
  1517. numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
  1518. OMPTeamsDistributeSimdDirective *Dir =
  1519. new (Mem) OMPTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
  1520. Clauses.size());
  1521. Dir->setClauses(Clauses);
  1522. Dir->setAssociatedStmt(AssociatedStmt);
  1523. Dir->setIterationVariable(Exprs.IterationVarRef);
  1524. Dir->setLastIteration(Exprs.LastIteration);
  1525. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1526. Dir->setPreCond(Exprs.PreCond);
  1527. Dir->setCond(Exprs.Cond);
  1528. Dir->setInit(Exprs.Init);
  1529. Dir->setInc(Exprs.Inc);
  1530. Dir->setIsLastIterVariable(Exprs.IL);
  1531. Dir->setLowerBoundVariable(Exprs.LB);
  1532. Dir->setUpperBoundVariable(Exprs.UB);
  1533. Dir->setStrideVariable(Exprs.ST);
  1534. Dir->setEnsureUpperBound(Exprs.EUB);
  1535. Dir->setNextLowerBound(Exprs.NLB);
  1536. Dir->setNextUpperBound(Exprs.NUB);
  1537. Dir->setNumIterations(Exprs.NumIterations);
  1538. Dir->setCounters(Exprs.Counters);
  1539. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1540. Dir->setInits(Exprs.Inits);
  1541. Dir->setUpdates(Exprs.Updates);
  1542. Dir->setFinals(Exprs.Finals);
  1543. Dir->setDependentCounters(Exprs.DependentCounters);
  1544. Dir->setDependentInits(Exprs.DependentInits);
  1545. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1546. Dir->setPreInits(Exprs.PreInits);
  1547. return Dir;
  1548. }
  1549. OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
  1550. const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
  1551. EmptyShell) {
  1552. unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
  1553. alignof(OMPClause *));
  1554. void *Mem =
  1555. C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  1556. sizeof(Stmt *) *
  1557. numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
  1558. return new (Mem) OMPTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
  1559. }
  1560. OMPTeamsDistributeParallelForSimdDirective *
  1561. OMPTeamsDistributeParallelForSimdDirective::Create(
  1562. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1563. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1564. const HelperExprs &Exprs) {
  1565. auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
  1566. alignof(OMPClause *));
  1567. void *Mem =
  1568. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
  1569. sizeof(Stmt *) *
  1570. numLoopChildren(CollapsedNum,
  1571. OMPD_teams_distribute_parallel_for_simd));
  1572. OMPTeamsDistributeParallelForSimdDirective *Dir = new (Mem)
  1573. OMPTeamsDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
  1574. Clauses.size());
  1575. Dir->setClauses(Clauses);
  1576. Dir->setAssociatedStmt(AssociatedStmt);
  1577. Dir->setIterationVariable(Exprs.IterationVarRef);
  1578. Dir->setLastIteration(Exprs.LastIteration);
  1579. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1580. Dir->setPreCond(Exprs.PreCond);
  1581. Dir->setCond(Exprs.Cond);
  1582. Dir->setInit(Exprs.Init);
  1583. Dir->setInc(Exprs.Inc);
  1584. Dir->setIsLastIterVariable(Exprs.IL);
  1585. Dir->setLowerBoundVariable(Exprs.LB);
  1586. Dir->setUpperBoundVariable(Exprs.UB);
  1587. Dir->setStrideVariable(Exprs.ST);
  1588. Dir->setEnsureUpperBound(Exprs.EUB);
  1589. Dir->setNextLowerBound(Exprs.NLB);
  1590. Dir->setNextUpperBound(Exprs.NUB);
  1591. Dir->setNumIterations(Exprs.NumIterations);
  1592. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1593. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1594. Dir->setDistInc(Exprs.DistInc);
  1595. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1596. Dir->setCounters(Exprs.Counters);
  1597. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1598. Dir->setInits(Exprs.Inits);
  1599. Dir->setUpdates(Exprs.Updates);
  1600. Dir->setFinals(Exprs.Finals);
  1601. Dir->setDependentCounters(Exprs.DependentCounters);
  1602. Dir->setDependentInits(Exprs.DependentInits);
  1603. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1604. Dir->setPreInits(Exprs.PreInits);
  1605. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1606. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1607. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1608. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1609. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1610. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1611. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1612. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1613. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1614. return Dir;
  1615. }
  1616. OMPTeamsDistributeParallelForSimdDirective *
  1617. OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
  1618. unsigned NumClauses,
  1619. unsigned CollapsedNum,
  1620. EmptyShell) {
  1621. auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
  1622. alignof(OMPClause *));
  1623. void *Mem =
  1624. C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
  1625. sizeof(Stmt *) *
  1626. numLoopChildren(CollapsedNum,
  1627. OMPD_teams_distribute_parallel_for_simd));
  1628. return new (Mem)
  1629. OMPTeamsDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
  1630. }
  1631. OMPTeamsDistributeParallelForDirective *
  1632. OMPTeamsDistributeParallelForDirective::Create(
  1633. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1634. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1635. const HelperExprs &Exprs, bool HasCancel) {
  1636. auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
  1637. alignof(OMPClause *));
  1638. void *Mem = C.Allocate(
  1639. Size + sizeof(OMPClause *) * Clauses.size() +
  1640. sizeof(Stmt *) *
  1641. numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
  1642. OMPTeamsDistributeParallelForDirective *Dir = new (Mem)
  1643. OMPTeamsDistributeParallelForDirective(StartLoc, EndLoc, CollapsedNum,
  1644. Clauses.size());
  1645. Dir->setClauses(Clauses);
  1646. Dir->setAssociatedStmt(AssociatedStmt);
  1647. Dir->setIterationVariable(Exprs.IterationVarRef);
  1648. Dir->setLastIteration(Exprs.LastIteration);
  1649. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1650. Dir->setPreCond(Exprs.PreCond);
  1651. Dir->setCond(Exprs.Cond);
  1652. Dir->setInit(Exprs.Init);
  1653. Dir->setInc(Exprs.Inc);
  1654. Dir->setIsLastIterVariable(Exprs.IL);
  1655. Dir->setLowerBoundVariable(Exprs.LB);
  1656. Dir->setUpperBoundVariable(Exprs.UB);
  1657. Dir->setStrideVariable(Exprs.ST);
  1658. Dir->setEnsureUpperBound(Exprs.EUB);
  1659. Dir->setNextLowerBound(Exprs.NLB);
  1660. Dir->setNextUpperBound(Exprs.NUB);
  1661. Dir->setNumIterations(Exprs.NumIterations);
  1662. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1663. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1664. Dir->setDistInc(Exprs.DistInc);
  1665. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1666. Dir->setCounters(Exprs.Counters);
  1667. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1668. Dir->setInits(Exprs.Inits);
  1669. Dir->setUpdates(Exprs.Updates);
  1670. Dir->setFinals(Exprs.Finals);
  1671. Dir->setDependentCounters(Exprs.DependentCounters);
  1672. Dir->setDependentInits(Exprs.DependentInits);
  1673. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1674. Dir->setPreInits(Exprs.PreInits);
  1675. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1676. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1677. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1678. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1679. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1680. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1681. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1682. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1683. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1684. Dir->HasCancel = HasCancel;
  1685. return Dir;
  1686. }
  1687. OMPTeamsDistributeParallelForDirective *
  1688. OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
  1689. unsigned NumClauses,
  1690. unsigned CollapsedNum,
  1691. EmptyShell) {
  1692. auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
  1693. alignof(OMPClause *));
  1694. void *Mem = C.Allocate(
  1695. Size + sizeof(OMPClause *) * NumClauses +
  1696. sizeof(Stmt *) *
  1697. numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
  1698. return new (Mem)
  1699. OMPTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
  1700. }
  1701. OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
  1702. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1703. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  1704. auto Size =
  1705. llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
  1706. void *Mem =
  1707. C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
  1708. OMPTargetTeamsDirective *Dir =
  1709. new (Mem) OMPTargetTeamsDirective(StartLoc, EndLoc, Clauses.size());
  1710. Dir->setClauses(Clauses);
  1711. Dir->setAssociatedStmt(AssociatedStmt);
  1712. return Dir;
  1713. }
  1714. OMPTargetTeamsDirective *
  1715. OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1716. EmptyShell) {
  1717. auto Size =
  1718. llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
  1719. void *Mem =
  1720. C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
  1721. return new (Mem) OMPTargetTeamsDirective(NumClauses);
  1722. }
  1723. OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
  1724. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1725. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1726. const HelperExprs &Exprs) {
  1727. auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
  1728. alignof(OMPClause *));
  1729. void *Mem = C.Allocate(
  1730. Size + sizeof(OMPClause *) * Clauses.size() +
  1731. sizeof(Stmt *) *
  1732. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
  1733. OMPTargetTeamsDistributeDirective *Dir =
  1734. new (Mem) OMPTargetTeamsDistributeDirective(StartLoc, EndLoc, CollapsedNum,
  1735. Clauses.size());
  1736. Dir->setClauses(Clauses);
  1737. Dir->setAssociatedStmt(AssociatedStmt);
  1738. Dir->setIterationVariable(Exprs.IterationVarRef);
  1739. Dir->setLastIteration(Exprs.LastIteration);
  1740. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1741. Dir->setPreCond(Exprs.PreCond);
  1742. Dir->setCond(Exprs.Cond);
  1743. Dir->setInit(Exprs.Init);
  1744. Dir->setInc(Exprs.Inc);
  1745. Dir->setIsLastIterVariable(Exprs.IL);
  1746. Dir->setLowerBoundVariable(Exprs.LB);
  1747. Dir->setUpperBoundVariable(Exprs.UB);
  1748. Dir->setStrideVariable(Exprs.ST);
  1749. Dir->setEnsureUpperBound(Exprs.EUB);
  1750. Dir->setNextLowerBound(Exprs.NLB);
  1751. Dir->setNextUpperBound(Exprs.NUB);
  1752. Dir->setNumIterations(Exprs.NumIterations);
  1753. Dir->setCounters(Exprs.Counters);
  1754. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1755. Dir->setInits(Exprs.Inits);
  1756. Dir->setUpdates(Exprs.Updates);
  1757. Dir->setFinals(Exprs.Finals);
  1758. Dir->setDependentCounters(Exprs.DependentCounters);
  1759. Dir->setDependentInits(Exprs.DependentInits);
  1760. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1761. Dir->setPreInits(Exprs.PreInits);
  1762. return Dir;
  1763. }
  1764. OMPTargetTeamsDistributeDirective *
  1765. OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
  1766. unsigned NumClauses,
  1767. unsigned CollapsedNum,
  1768. EmptyShell) {
  1769. auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
  1770. alignof(OMPClause *));
  1771. void *Mem = C.Allocate(
  1772. Size + sizeof(OMPClause *) * NumClauses +
  1773. sizeof(Stmt *) *
  1774. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
  1775. return new (Mem) OMPTargetTeamsDistributeDirective(CollapsedNum, NumClauses);
  1776. }
  1777. OMPTargetTeamsDistributeParallelForDirective *
  1778. OMPTargetTeamsDistributeParallelForDirective::Create(
  1779. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1780. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1781. const HelperExprs &Exprs, bool HasCancel) {
  1782. auto Size =
  1783. llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
  1784. alignof(OMPClause *));
  1785. void *Mem = C.Allocate(
  1786. Size + sizeof(OMPClause *) * Clauses.size() +
  1787. sizeof(Stmt *) *
  1788. numLoopChildren(CollapsedNum,
  1789. OMPD_target_teams_distribute_parallel_for));
  1790. OMPTargetTeamsDistributeParallelForDirective *Dir =
  1791. new (Mem) OMPTargetTeamsDistributeParallelForDirective(
  1792. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1793. Dir->setClauses(Clauses);
  1794. Dir->setAssociatedStmt(AssociatedStmt);
  1795. Dir->setIterationVariable(Exprs.IterationVarRef);
  1796. Dir->setLastIteration(Exprs.LastIteration);
  1797. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1798. Dir->setPreCond(Exprs.PreCond);
  1799. Dir->setCond(Exprs.Cond);
  1800. Dir->setInit(Exprs.Init);
  1801. Dir->setInc(Exprs.Inc);
  1802. Dir->setIsLastIterVariable(Exprs.IL);
  1803. Dir->setLowerBoundVariable(Exprs.LB);
  1804. Dir->setUpperBoundVariable(Exprs.UB);
  1805. Dir->setStrideVariable(Exprs.ST);
  1806. Dir->setEnsureUpperBound(Exprs.EUB);
  1807. Dir->setNextLowerBound(Exprs.NLB);
  1808. Dir->setNextUpperBound(Exprs.NUB);
  1809. Dir->setNumIterations(Exprs.NumIterations);
  1810. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1811. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1812. Dir->setDistInc(Exprs.DistInc);
  1813. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1814. Dir->setCounters(Exprs.Counters);
  1815. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1816. Dir->setInits(Exprs.Inits);
  1817. Dir->setUpdates(Exprs.Updates);
  1818. Dir->setFinals(Exprs.Finals);
  1819. Dir->setDependentCounters(Exprs.DependentCounters);
  1820. Dir->setDependentInits(Exprs.DependentInits);
  1821. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1822. Dir->setPreInits(Exprs.PreInits);
  1823. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1824. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1825. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1826. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1827. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1828. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1829. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1830. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1831. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1832. Dir->HasCancel = HasCancel;
  1833. return Dir;
  1834. }
  1835. OMPTargetTeamsDistributeParallelForDirective *
  1836. OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
  1837. unsigned NumClauses,
  1838. unsigned CollapsedNum,
  1839. EmptyShell) {
  1840. auto Size =
  1841. llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
  1842. alignof(OMPClause *));
  1843. void *Mem = C.Allocate(
  1844. Size + sizeof(OMPClause *) * NumClauses +
  1845. sizeof(Stmt *) *
  1846. numLoopChildren(CollapsedNum,
  1847. OMPD_target_teams_distribute_parallel_for));
  1848. return new (Mem)
  1849. OMPTargetTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
  1850. }
  1851. OMPTargetTeamsDistributeParallelForSimdDirective *
  1852. OMPTargetTeamsDistributeParallelForSimdDirective::Create(
  1853. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1854. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1855. const HelperExprs &Exprs) {
  1856. auto Size =
  1857. llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
  1858. alignof(OMPClause *));
  1859. void *Mem = C.Allocate(
  1860. Size + sizeof(OMPClause *) * Clauses.size() +
  1861. sizeof(Stmt *) *
  1862. numLoopChildren(CollapsedNum,
  1863. OMPD_target_teams_distribute_parallel_for_simd));
  1864. OMPTargetTeamsDistributeParallelForSimdDirective *Dir =
  1865. new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
  1866. StartLoc, EndLoc, CollapsedNum, Clauses.size());
  1867. Dir->setClauses(Clauses);
  1868. Dir->setAssociatedStmt(AssociatedStmt);
  1869. Dir->setIterationVariable(Exprs.IterationVarRef);
  1870. Dir->setLastIteration(Exprs.LastIteration);
  1871. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1872. Dir->setPreCond(Exprs.PreCond);
  1873. Dir->setCond(Exprs.Cond);
  1874. Dir->setInit(Exprs.Init);
  1875. Dir->setInc(Exprs.Inc);
  1876. Dir->setIsLastIterVariable(Exprs.IL);
  1877. Dir->setLowerBoundVariable(Exprs.LB);
  1878. Dir->setUpperBoundVariable(Exprs.UB);
  1879. Dir->setStrideVariable(Exprs.ST);
  1880. Dir->setEnsureUpperBound(Exprs.EUB);
  1881. Dir->setNextLowerBound(Exprs.NLB);
  1882. Dir->setNextUpperBound(Exprs.NUB);
  1883. Dir->setNumIterations(Exprs.NumIterations);
  1884. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1885. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1886. Dir->setDistInc(Exprs.DistInc);
  1887. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1888. Dir->setCounters(Exprs.Counters);
  1889. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1890. Dir->setInits(Exprs.Inits);
  1891. Dir->setUpdates(Exprs.Updates);
  1892. Dir->setFinals(Exprs.Finals);
  1893. Dir->setDependentCounters(Exprs.DependentCounters);
  1894. Dir->setDependentInits(Exprs.DependentInits);
  1895. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1896. Dir->setPreInits(Exprs.PreInits);
  1897. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1898. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1899. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1900. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1901. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1902. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1903. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1904. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1905. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1906. return Dir;
  1907. }
  1908. OMPTargetTeamsDistributeParallelForSimdDirective *
  1909. OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
  1910. const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
  1911. EmptyShell) {
  1912. auto Size =
  1913. llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
  1914. alignof(OMPClause *));
  1915. void *Mem = C.Allocate(
  1916. Size + sizeof(OMPClause *) * NumClauses +
  1917. sizeof(Stmt *) *
  1918. numLoopChildren(CollapsedNum,
  1919. OMPD_target_teams_distribute_parallel_for_simd));
  1920. return new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
  1921. CollapsedNum, NumClauses);
  1922. }
  1923. OMPTargetTeamsDistributeSimdDirective *
  1924. OMPTargetTeamsDistributeSimdDirective::Create(
  1925. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1926. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1927. const HelperExprs &Exprs) {
  1928. auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
  1929. alignof(OMPClause *));
  1930. void *Mem = C.Allocate(
  1931. Size + sizeof(OMPClause *) * Clauses.size() +
  1932. sizeof(Stmt *) *
  1933. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
  1934. OMPTargetTeamsDistributeSimdDirective *Dir = new (Mem)
  1935. OMPTargetTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
  1936. Clauses.size());
  1937. Dir->setClauses(Clauses);
  1938. Dir->setAssociatedStmt(AssociatedStmt);
  1939. Dir->setIterationVariable(Exprs.IterationVarRef);
  1940. Dir->setLastIteration(Exprs.LastIteration);
  1941. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1942. Dir->setPreCond(Exprs.PreCond);
  1943. Dir->setCond(Exprs.Cond);
  1944. Dir->setInit(Exprs.Init);
  1945. Dir->setInc(Exprs.Inc);
  1946. Dir->setIsLastIterVariable(Exprs.IL);
  1947. Dir->setLowerBoundVariable(Exprs.LB);
  1948. Dir->setUpperBoundVariable(Exprs.UB);
  1949. Dir->setStrideVariable(Exprs.ST);
  1950. Dir->setEnsureUpperBound(Exprs.EUB);
  1951. Dir->setNextLowerBound(Exprs.NLB);
  1952. Dir->setNextUpperBound(Exprs.NUB);
  1953. Dir->setNumIterations(Exprs.NumIterations);
  1954. Dir->setCounters(Exprs.Counters);
  1955. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1956. Dir->setInits(Exprs.Inits);
  1957. Dir->setUpdates(Exprs.Updates);
  1958. Dir->setFinals(Exprs.Finals);
  1959. Dir->setDependentCounters(Exprs.DependentCounters);
  1960. Dir->setDependentInits(Exprs.DependentInits);
  1961. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1962. Dir->setPreInits(Exprs.PreInits);
  1963. return Dir;
  1964. }
  1965. OMPTargetTeamsDistributeSimdDirective *
  1966. OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
  1967. unsigned NumClauses,
  1968. unsigned CollapsedNum,
  1969. EmptyShell) {
  1970. auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
  1971. alignof(OMPClause *));
  1972. void *Mem = C.Allocate(
  1973. Size + sizeof(OMPClause *) * NumClauses +
  1974. sizeof(Stmt *) *
  1975. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
  1976. return new (Mem)
  1977. OMPTargetTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
  1978. }