StmtOpenMP.cpp 90 KB

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