StmtOpenMP.cpp 106 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530
  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::MutableArrayRef(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, std::nullopt, 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, std::nullopt, 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. OMPParallelMaskedDirective *OMPParallelMaskedDirective::Create(
  627. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  628. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef) {
  629. auto *Dir = createDirective<OMPParallelMaskedDirective>(
  630. C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
  631. Dir->setTaskReductionRefExpr(TaskRedRef);
  632. return Dir;
  633. }
  634. OMPParallelMaskedDirective *
  635. OMPParallelMaskedDirective::CreateEmpty(const ASTContext &C,
  636. unsigned NumClauses, EmptyShell) {
  637. return createEmptyDirective<OMPParallelMaskedDirective>(
  638. C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
  639. }
  640. OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(
  641. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  642. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
  643. bool HasCancel) {
  644. auto *Dir = createDirective<OMPParallelSectionsDirective>(
  645. C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
  646. Dir->setTaskReductionRefExpr(TaskRedRef);
  647. Dir->setHasCancel(HasCancel);
  648. return Dir;
  649. }
  650. OMPParallelSectionsDirective *
  651. OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,
  652. unsigned NumClauses, EmptyShell) {
  653. return createEmptyDirective<OMPParallelSectionsDirective>(
  654. C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
  655. }
  656. OMPTaskDirective *
  657. OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  658. SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
  659. Stmt *AssociatedStmt, bool HasCancel) {
  660. auto *Dir = createDirective<OMPTaskDirective>(
  661. C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
  662. Dir->setHasCancel(HasCancel);
  663. return Dir;
  664. }
  665. OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C,
  666. unsigned NumClauses,
  667. EmptyShell) {
  668. return createEmptyDirective<OMPTaskDirective>(C, NumClauses,
  669. /*HasAssociatedStmt=*/true);
  670. }
  671. OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C,
  672. SourceLocation StartLoc,
  673. SourceLocation EndLoc) {
  674. return new (C) OMPTaskyieldDirective(StartLoc, EndLoc);
  675. }
  676. OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C,
  677. EmptyShell) {
  678. return new (C) OMPTaskyieldDirective();
  679. }
  680. OMPErrorDirective *OMPErrorDirective::Create(const ASTContext &C,
  681. SourceLocation StartLoc,
  682. SourceLocation EndLoc,
  683. ArrayRef<OMPClause *> Clauses) {
  684. return createDirective<OMPErrorDirective>(
  685. C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
  686. EndLoc);
  687. }
  688. OMPErrorDirective *OMPErrorDirective::CreateEmpty(const ASTContext &C,
  689. unsigned NumClauses,
  690. EmptyShell) {
  691. return createEmptyDirective<OMPErrorDirective>(C, NumClauses);
  692. }
  693. OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,
  694. SourceLocation StartLoc,
  695. SourceLocation EndLoc) {
  696. return new (C) OMPBarrierDirective(StartLoc, EndLoc);
  697. }
  698. OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,
  699. EmptyShell) {
  700. return new (C) OMPBarrierDirective();
  701. }
  702. OMPTaskwaitDirective *
  703. OMPTaskwaitDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  704. SourceLocation EndLoc,
  705. ArrayRef<OMPClause *> Clauses) {
  706. return createDirective<OMPTaskwaitDirective>(
  707. C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
  708. EndLoc);
  709. }
  710. OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,
  711. unsigned NumClauses,
  712. EmptyShell) {
  713. return createEmptyDirective<OMPTaskwaitDirective>(C, NumClauses);
  714. }
  715. OMPTaskgroupDirective *OMPTaskgroupDirective::Create(
  716. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  717. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) {
  718. auto *Dir = createDirective<OMPTaskgroupDirective>(
  719. C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
  720. Dir->setReductionRef(ReductionRef);
  721. return Dir;
  722. }
  723. OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C,
  724. unsigned NumClauses,
  725. EmptyShell) {
  726. return createEmptyDirective<OMPTaskgroupDirective>(
  727. C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
  728. }
  729. OMPCancellationPointDirective *OMPCancellationPointDirective::Create(
  730. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  731. OpenMPDirectiveKind CancelRegion) {
  732. auto *Dir = new (C) OMPCancellationPointDirective(StartLoc, EndLoc);
  733. Dir->setCancelRegion(CancelRegion);
  734. return Dir;
  735. }
  736. OMPCancellationPointDirective *
  737. OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) {
  738. return new (C) OMPCancellationPointDirective();
  739. }
  740. OMPCancelDirective *
  741. OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  742. SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
  743. OpenMPDirectiveKind CancelRegion) {
  744. auto *Dir = createDirective<OMPCancelDirective>(
  745. C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
  746. EndLoc);
  747. Dir->setCancelRegion(CancelRegion);
  748. return Dir;
  749. }
  750. OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C,
  751. unsigned NumClauses,
  752. EmptyShell) {
  753. return createEmptyDirective<OMPCancelDirective>(C, NumClauses);
  754. }
  755. OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C,
  756. SourceLocation StartLoc,
  757. SourceLocation EndLoc,
  758. ArrayRef<OMPClause *> Clauses) {
  759. return createDirective<OMPFlushDirective>(
  760. C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
  761. EndLoc);
  762. }
  763. OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C,
  764. unsigned NumClauses,
  765. EmptyShell) {
  766. return createEmptyDirective<OMPFlushDirective>(C, NumClauses);
  767. }
  768. OMPDepobjDirective *OMPDepobjDirective::Create(const ASTContext &C,
  769. SourceLocation StartLoc,
  770. SourceLocation EndLoc,
  771. ArrayRef<OMPClause *> Clauses) {
  772. return createDirective<OMPDepobjDirective>(
  773. C, Clauses, /*AssociatedStmt=*/nullptr,
  774. /*NumChildren=*/0, StartLoc, EndLoc);
  775. }
  776. OMPDepobjDirective *OMPDepobjDirective::CreateEmpty(const ASTContext &C,
  777. unsigned NumClauses,
  778. EmptyShell) {
  779. return createEmptyDirective<OMPDepobjDirective>(C, NumClauses);
  780. }
  781. OMPScanDirective *OMPScanDirective::Create(const ASTContext &C,
  782. SourceLocation StartLoc,
  783. SourceLocation EndLoc,
  784. ArrayRef<OMPClause *> Clauses) {
  785. return createDirective<OMPScanDirective>(C, Clauses,
  786. /*AssociatedStmt=*/nullptr,
  787. /*NumChildren=*/0, StartLoc, EndLoc);
  788. }
  789. OMPScanDirective *OMPScanDirective::CreateEmpty(const ASTContext &C,
  790. unsigned NumClauses,
  791. EmptyShell) {
  792. return createEmptyDirective<OMPScanDirective>(C, NumClauses);
  793. }
  794. OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C,
  795. SourceLocation StartLoc,
  796. SourceLocation EndLoc,
  797. ArrayRef<OMPClause *> Clauses,
  798. Stmt *AssociatedStmt) {
  799. return createDirective<OMPOrderedDirective>(
  800. C, Clauses, cast_or_null<CapturedStmt>(AssociatedStmt),
  801. /*NumChildren=*/0, StartLoc, EndLoc);
  802. }
  803. OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C,
  804. unsigned NumClauses,
  805. bool IsStandalone,
  806. EmptyShell) {
  807. return createEmptyDirective<OMPOrderedDirective>(C, NumClauses,
  808. !IsStandalone);
  809. }
  810. OMPAtomicDirective *
  811. OMPAtomicDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  812. SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
  813. Stmt *AssociatedStmt, Expressions Exprs) {
  814. auto *Dir = createDirective<OMPAtomicDirective>(
  815. C, Clauses, AssociatedStmt, /*NumChildren=*/7, StartLoc, EndLoc);
  816. Dir->setX(Exprs.X);
  817. Dir->setV(Exprs.V);
  818. Dir->setR(Exprs.R);
  819. Dir->setExpr(Exprs.E);
  820. Dir->setUpdateExpr(Exprs.UE);
  821. Dir->setD(Exprs.D);
  822. Dir->setCond(Exprs.Cond);
  823. Dir->Flags.IsXLHSInRHSPart = Exprs.IsXLHSInRHSPart ? 1 : 0;
  824. Dir->Flags.IsPostfixUpdate = Exprs.IsPostfixUpdate ? 1 : 0;
  825. Dir->Flags.IsFailOnly = Exprs.IsFailOnly ? 1 : 0;
  826. return Dir;
  827. }
  828. OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,
  829. unsigned NumClauses,
  830. EmptyShell) {
  831. return createEmptyDirective<OMPAtomicDirective>(
  832. C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/7);
  833. }
  834. OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,
  835. SourceLocation StartLoc,
  836. SourceLocation EndLoc,
  837. ArrayRef<OMPClause *> Clauses,
  838. Stmt *AssociatedStmt) {
  839. return createDirective<OMPTargetDirective>(
  840. C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
  841. }
  842. OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,
  843. unsigned NumClauses,
  844. EmptyShell) {
  845. return createEmptyDirective<OMPTargetDirective>(C, NumClauses,
  846. /*HasAssociatedStmt=*/true);
  847. }
  848. OMPTargetParallelDirective *OMPTargetParallelDirective::Create(
  849. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  850. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
  851. bool HasCancel) {
  852. auto *Dir = createDirective<OMPTargetParallelDirective>(
  853. C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
  854. Dir->setTaskReductionRefExpr(TaskRedRef);
  855. Dir->setHasCancel(HasCancel);
  856. return Dir;
  857. }
  858. OMPTargetParallelDirective *
  859. OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,
  860. unsigned NumClauses, EmptyShell) {
  861. return createEmptyDirective<OMPTargetParallelDirective>(
  862. C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
  863. }
  864. OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(
  865. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  866. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  867. const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
  868. auto *Dir = createDirective<OMPTargetParallelForDirective>(
  869. C, Clauses, AssociatedStmt,
  870. numLoopChildren(CollapsedNum, OMPD_target_parallel_for) + 1, StartLoc,
  871. EndLoc, CollapsedNum);
  872. Dir->setIterationVariable(Exprs.IterationVarRef);
  873. Dir->setLastIteration(Exprs.LastIteration);
  874. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  875. Dir->setPreCond(Exprs.PreCond);
  876. Dir->setCond(Exprs.Cond);
  877. Dir->setInit(Exprs.Init);
  878. Dir->setInc(Exprs.Inc);
  879. Dir->setIsLastIterVariable(Exprs.IL);
  880. Dir->setLowerBoundVariable(Exprs.LB);
  881. Dir->setUpperBoundVariable(Exprs.UB);
  882. Dir->setStrideVariable(Exprs.ST);
  883. Dir->setEnsureUpperBound(Exprs.EUB);
  884. Dir->setNextLowerBound(Exprs.NLB);
  885. Dir->setNextUpperBound(Exprs.NUB);
  886. Dir->setNumIterations(Exprs.NumIterations);
  887. Dir->setCounters(Exprs.Counters);
  888. Dir->setPrivateCounters(Exprs.PrivateCounters);
  889. Dir->setInits(Exprs.Inits);
  890. Dir->setUpdates(Exprs.Updates);
  891. Dir->setFinals(Exprs.Finals);
  892. Dir->setDependentCounters(Exprs.DependentCounters);
  893. Dir->setDependentInits(Exprs.DependentInits);
  894. Dir->setFinalsConditions(Exprs.FinalsConditions);
  895. Dir->setPreInits(Exprs.PreInits);
  896. Dir->setTaskReductionRefExpr(TaskRedRef);
  897. Dir->setHasCancel(HasCancel);
  898. return Dir;
  899. }
  900. OMPTargetParallelForDirective *
  901. OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,
  902. unsigned NumClauses,
  903. unsigned CollapsedNum, EmptyShell) {
  904. return createEmptyDirective<OMPTargetParallelForDirective>(
  905. C, NumClauses, /*HasAssociatedStmt=*/true,
  906. numLoopChildren(CollapsedNum, OMPD_target_parallel_for) + 1,
  907. CollapsedNum);
  908. }
  909. OMPTargetDataDirective *OMPTargetDataDirective::Create(
  910. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  911. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  912. return createDirective<OMPTargetDataDirective>(
  913. C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
  914. }
  915. OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,
  916. unsigned N,
  917. EmptyShell) {
  918. return createEmptyDirective<OMPTargetDataDirective>(
  919. C, N, /*HasAssociatedStmt=*/true);
  920. }
  921. OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(
  922. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  923. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  924. return createDirective<OMPTargetEnterDataDirective>(
  925. C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
  926. }
  927. OMPTargetEnterDataDirective *
  928. OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
  929. EmptyShell) {
  930. return createEmptyDirective<OMPTargetEnterDataDirective>(
  931. C, N, /*HasAssociatedStmt=*/true);
  932. }
  933. OMPTargetExitDataDirective *OMPTargetExitDataDirective::Create(
  934. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  935. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  936. return createDirective<OMPTargetExitDataDirective>(
  937. C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
  938. }
  939. OMPTargetExitDataDirective *
  940. OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
  941. EmptyShell) {
  942. return createEmptyDirective<OMPTargetExitDataDirective>(
  943. C, N, /*HasAssociatedStmt=*/true);
  944. }
  945. OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
  946. SourceLocation StartLoc,
  947. SourceLocation EndLoc,
  948. ArrayRef<OMPClause *> Clauses,
  949. Stmt *AssociatedStmt) {
  950. return createDirective<OMPTeamsDirective>(
  951. C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
  952. }
  953. OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
  954. unsigned NumClauses,
  955. EmptyShell) {
  956. return createEmptyDirective<OMPTeamsDirective>(C, NumClauses,
  957. /*HasAssociatedStmt=*/true);
  958. }
  959. OMPTaskLoopDirective *OMPTaskLoopDirective::Create(
  960. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  961. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  962. const HelperExprs &Exprs, bool HasCancel) {
  963. auto *Dir = createDirective<OMPTaskLoopDirective>(
  964. C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_taskloop),
  965. StartLoc, EndLoc, CollapsedNum);
  966. Dir->setIterationVariable(Exprs.IterationVarRef);
  967. Dir->setLastIteration(Exprs.LastIteration);
  968. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  969. Dir->setPreCond(Exprs.PreCond);
  970. Dir->setCond(Exprs.Cond);
  971. Dir->setInit(Exprs.Init);
  972. Dir->setInc(Exprs.Inc);
  973. Dir->setIsLastIterVariable(Exprs.IL);
  974. Dir->setLowerBoundVariable(Exprs.LB);
  975. Dir->setUpperBoundVariable(Exprs.UB);
  976. Dir->setStrideVariable(Exprs.ST);
  977. Dir->setEnsureUpperBound(Exprs.EUB);
  978. Dir->setNextLowerBound(Exprs.NLB);
  979. Dir->setNextUpperBound(Exprs.NUB);
  980. Dir->setNumIterations(Exprs.NumIterations);
  981. Dir->setCounters(Exprs.Counters);
  982. Dir->setPrivateCounters(Exprs.PrivateCounters);
  983. Dir->setInits(Exprs.Inits);
  984. Dir->setUpdates(Exprs.Updates);
  985. Dir->setFinals(Exprs.Finals);
  986. Dir->setDependentCounters(Exprs.DependentCounters);
  987. Dir->setDependentInits(Exprs.DependentInits);
  988. Dir->setFinalsConditions(Exprs.FinalsConditions);
  989. Dir->setPreInits(Exprs.PreInits);
  990. Dir->setHasCancel(HasCancel);
  991. return Dir;
  992. }
  993. OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,
  994. unsigned NumClauses,
  995. unsigned CollapsedNum,
  996. EmptyShell) {
  997. return createEmptyDirective<OMPTaskLoopDirective>(
  998. C, NumClauses, /*HasAssociatedStmt=*/true,
  999. numLoopChildren(CollapsedNum, OMPD_taskloop), CollapsedNum);
  1000. }
  1001. OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(
  1002. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1003. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1004. const HelperExprs &Exprs) {
  1005. auto *Dir = createDirective<OMPTaskLoopSimdDirective>(
  1006. C, Clauses, AssociatedStmt,
  1007. numLoopChildren(CollapsedNum, OMPD_taskloop_simd), StartLoc, EndLoc,
  1008. CollapsedNum);
  1009. Dir->setIterationVariable(Exprs.IterationVarRef);
  1010. Dir->setLastIteration(Exprs.LastIteration);
  1011. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1012. Dir->setPreCond(Exprs.PreCond);
  1013. Dir->setCond(Exprs.Cond);
  1014. Dir->setInit(Exprs.Init);
  1015. Dir->setInc(Exprs.Inc);
  1016. Dir->setIsLastIterVariable(Exprs.IL);
  1017. Dir->setLowerBoundVariable(Exprs.LB);
  1018. Dir->setUpperBoundVariable(Exprs.UB);
  1019. Dir->setStrideVariable(Exprs.ST);
  1020. Dir->setEnsureUpperBound(Exprs.EUB);
  1021. Dir->setNextLowerBound(Exprs.NLB);
  1022. Dir->setNextUpperBound(Exprs.NUB);
  1023. Dir->setNumIterations(Exprs.NumIterations);
  1024. Dir->setCounters(Exprs.Counters);
  1025. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1026. Dir->setInits(Exprs.Inits);
  1027. Dir->setUpdates(Exprs.Updates);
  1028. Dir->setFinals(Exprs.Finals);
  1029. Dir->setDependentCounters(Exprs.DependentCounters);
  1030. Dir->setDependentInits(Exprs.DependentInits);
  1031. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1032. Dir->setPreInits(Exprs.PreInits);
  1033. return Dir;
  1034. }
  1035. OMPTaskLoopSimdDirective *
  1036. OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1037. unsigned CollapsedNum, EmptyShell) {
  1038. return createEmptyDirective<OMPTaskLoopSimdDirective>(
  1039. C, NumClauses, /*HasAssociatedStmt=*/true,
  1040. numLoopChildren(CollapsedNum, OMPD_taskloop_simd), CollapsedNum);
  1041. }
  1042. OMPMasterTaskLoopDirective *OMPMasterTaskLoopDirective::Create(
  1043. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1044. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1045. const HelperExprs &Exprs, bool HasCancel) {
  1046. auto *Dir = createDirective<OMPMasterTaskLoopDirective>(
  1047. C, Clauses, AssociatedStmt,
  1048. numLoopChildren(CollapsedNum, OMPD_master_taskloop), StartLoc, EndLoc,
  1049. CollapsedNum);
  1050. Dir->setIterationVariable(Exprs.IterationVarRef);
  1051. Dir->setLastIteration(Exprs.LastIteration);
  1052. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1053. Dir->setPreCond(Exprs.PreCond);
  1054. Dir->setCond(Exprs.Cond);
  1055. Dir->setInit(Exprs.Init);
  1056. Dir->setInc(Exprs.Inc);
  1057. Dir->setIsLastIterVariable(Exprs.IL);
  1058. Dir->setLowerBoundVariable(Exprs.LB);
  1059. Dir->setUpperBoundVariable(Exprs.UB);
  1060. Dir->setStrideVariable(Exprs.ST);
  1061. Dir->setEnsureUpperBound(Exprs.EUB);
  1062. Dir->setNextLowerBound(Exprs.NLB);
  1063. Dir->setNextUpperBound(Exprs.NUB);
  1064. Dir->setNumIterations(Exprs.NumIterations);
  1065. Dir->setCounters(Exprs.Counters);
  1066. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1067. Dir->setInits(Exprs.Inits);
  1068. Dir->setUpdates(Exprs.Updates);
  1069. Dir->setFinals(Exprs.Finals);
  1070. Dir->setDependentCounters(Exprs.DependentCounters);
  1071. Dir->setDependentInits(Exprs.DependentInits);
  1072. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1073. Dir->setPreInits(Exprs.PreInits);
  1074. Dir->setHasCancel(HasCancel);
  1075. return Dir;
  1076. }
  1077. OMPMasterTaskLoopDirective *
  1078. OMPMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
  1079. unsigned NumClauses,
  1080. unsigned CollapsedNum, EmptyShell) {
  1081. return createEmptyDirective<OMPMasterTaskLoopDirective>(
  1082. C, NumClauses, /*HasAssociatedStmt=*/true,
  1083. numLoopChildren(CollapsedNum, OMPD_master_taskloop), CollapsedNum);
  1084. }
  1085. OMPMaskedTaskLoopDirective *OMPMaskedTaskLoopDirective::Create(
  1086. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1087. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1088. const HelperExprs &Exprs, bool HasCancel) {
  1089. auto *Dir = createDirective<OMPMaskedTaskLoopDirective>(
  1090. C, Clauses, AssociatedStmt,
  1091. numLoopChildren(CollapsedNum, OMPD_masked_taskloop), StartLoc, EndLoc,
  1092. CollapsedNum);
  1093. Dir->setIterationVariable(Exprs.IterationVarRef);
  1094. Dir->setLastIteration(Exprs.LastIteration);
  1095. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1096. Dir->setPreCond(Exprs.PreCond);
  1097. Dir->setCond(Exprs.Cond);
  1098. Dir->setInit(Exprs.Init);
  1099. Dir->setInc(Exprs.Inc);
  1100. Dir->setIsLastIterVariable(Exprs.IL);
  1101. Dir->setLowerBoundVariable(Exprs.LB);
  1102. Dir->setUpperBoundVariable(Exprs.UB);
  1103. Dir->setStrideVariable(Exprs.ST);
  1104. Dir->setEnsureUpperBound(Exprs.EUB);
  1105. Dir->setNextLowerBound(Exprs.NLB);
  1106. Dir->setNextUpperBound(Exprs.NUB);
  1107. Dir->setNumIterations(Exprs.NumIterations);
  1108. Dir->setCounters(Exprs.Counters);
  1109. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1110. Dir->setInits(Exprs.Inits);
  1111. Dir->setUpdates(Exprs.Updates);
  1112. Dir->setFinals(Exprs.Finals);
  1113. Dir->setDependentCounters(Exprs.DependentCounters);
  1114. Dir->setDependentInits(Exprs.DependentInits);
  1115. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1116. Dir->setPreInits(Exprs.PreInits);
  1117. Dir->setHasCancel(HasCancel);
  1118. return Dir;
  1119. }
  1120. OMPMaskedTaskLoopDirective *
  1121. OMPMaskedTaskLoopDirective::CreateEmpty(const ASTContext &C,
  1122. unsigned NumClauses,
  1123. unsigned CollapsedNum, EmptyShell) {
  1124. return createEmptyDirective<OMPMaskedTaskLoopDirective>(
  1125. C, NumClauses, /*HasAssociatedStmt=*/true,
  1126. numLoopChildren(CollapsedNum, OMPD_masked_taskloop), CollapsedNum);
  1127. }
  1128. OMPMasterTaskLoopSimdDirective *OMPMasterTaskLoopSimdDirective::Create(
  1129. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1130. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1131. const HelperExprs &Exprs) {
  1132. auto *Dir = createDirective<OMPMasterTaskLoopSimdDirective>(
  1133. C, Clauses, AssociatedStmt,
  1134. numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd), StartLoc,
  1135. EndLoc, CollapsedNum);
  1136. Dir->setIterationVariable(Exprs.IterationVarRef);
  1137. Dir->setLastIteration(Exprs.LastIteration);
  1138. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1139. Dir->setPreCond(Exprs.PreCond);
  1140. Dir->setCond(Exprs.Cond);
  1141. Dir->setInit(Exprs.Init);
  1142. Dir->setInc(Exprs.Inc);
  1143. Dir->setIsLastIterVariable(Exprs.IL);
  1144. Dir->setLowerBoundVariable(Exprs.LB);
  1145. Dir->setUpperBoundVariable(Exprs.UB);
  1146. Dir->setStrideVariable(Exprs.ST);
  1147. Dir->setEnsureUpperBound(Exprs.EUB);
  1148. Dir->setNextLowerBound(Exprs.NLB);
  1149. Dir->setNextUpperBound(Exprs.NUB);
  1150. Dir->setNumIterations(Exprs.NumIterations);
  1151. Dir->setCounters(Exprs.Counters);
  1152. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1153. Dir->setInits(Exprs.Inits);
  1154. Dir->setUpdates(Exprs.Updates);
  1155. Dir->setFinals(Exprs.Finals);
  1156. Dir->setDependentCounters(Exprs.DependentCounters);
  1157. Dir->setDependentInits(Exprs.DependentInits);
  1158. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1159. Dir->setPreInits(Exprs.PreInits);
  1160. return Dir;
  1161. }
  1162. OMPMasterTaskLoopSimdDirective *
  1163. OMPMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
  1164. unsigned NumClauses,
  1165. unsigned CollapsedNum, EmptyShell) {
  1166. return createEmptyDirective<OMPMasterTaskLoopSimdDirective>(
  1167. C, NumClauses, /*HasAssociatedStmt=*/true,
  1168. numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd), CollapsedNum);
  1169. }
  1170. OMPMaskedTaskLoopSimdDirective *OMPMaskedTaskLoopSimdDirective::Create(
  1171. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1172. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1173. const HelperExprs &Exprs) {
  1174. auto *Dir = createDirective<OMPMaskedTaskLoopSimdDirective>(
  1175. C, Clauses, AssociatedStmt,
  1176. numLoopChildren(CollapsedNum, OMPD_masked_taskloop_simd), StartLoc,
  1177. EndLoc, CollapsedNum);
  1178. Dir->setIterationVariable(Exprs.IterationVarRef);
  1179. Dir->setLastIteration(Exprs.LastIteration);
  1180. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1181. Dir->setPreCond(Exprs.PreCond);
  1182. Dir->setCond(Exprs.Cond);
  1183. Dir->setInit(Exprs.Init);
  1184. Dir->setInc(Exprs.Inc);
  1185. Dir->setIsLastIterVariable(Exprs.IL);
  1186. Dir->setLowerBoundVariable(Exprs.LB);
  1187. Dir->setUpperBoundVariable(Exprs.UB);
  1188. Dir->setStrideVariable(Exprs.ST);
  1189. Dir->setEnsureUpperBound(Exprs.EUB);
  1190. Dir->setNextLowerBound(Exprs.NLB);
  1191. Dir->setNextUpperBound(Exprs.NUB);
  1192. Dir->setNumIterations(Exprs.NumIterations);
  1193. Dir->setCounters(Exprs.Counters);
  1194. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1195. Dir->setInits(Exprs.Inits);
  1196. Dir->setUpdates(Exprs.Updates);
  1197. Dir->setFinals(Exprs.Finals);
  1198. Dir->setDependentCounters(Exprs.DependentCounters);
  1199. Dir->setDependentInits(Exprs.DependentInits);
  1200. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1201. Dir->setPreInits(Exprs.PreInits);
  1202. return Dir;
  1203. }
  1204. OMPMaskedTaskLoopSimdDirective *
  1205. OMPMaskedTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
  1206. unsigned NumClauses,
  1207. unsigned CollapsedNum, EmptyShell) {
  1208. return createEmptyDirective<OMPMaskedTaskLoopSimdDirective>(
  1209. C, NumClauses, /*HasAssociatedStmt=*/true,
  1210. numLoopChildren(CollapsedNum, OMPD_masked_taskloop_simd), CollapsedNum);
  1211. }
  1212. OMPParallelMasterTaskLoopDirective *OMPParallelMasterTaskLoopDirective::Create(
  1213. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1214. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1215. const HelperExprs &Exprs, bool HasCancel) {
  1216. auto *Dir = createDirective<OMPParallelMasterTaskLoopDirective>(
  1217. C, Clauses, AssociatedStmt,
  1218. numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop), StartLoc,
  1219. EndLoc, CollapsedNum);
  1220. Dir->setIterationVariable(Exprs.IterationVarRef);
  1221. Dir->setLastIteration(Exprs.LastIteration);
  1222. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1223. Dir->setPreCond(Exprs.PreCond);
  1224. Dir->setCond(Exprs.Cond);
  1225. Dir->setInit(Exprs.Init);
  1226. Dir->setInc(Exprs.Inc);
  1227. Dir->setIsLastIterVariable(Exprs.IL);
  1228. Dir->setLowerBoundVariable(Exprs.LB);
  1229. Dir->setUpperBoundVariable(Exprs.UB);
  1230. Dir->setStrideVariable(Exprs.ST);
  1231. Dir->setEnsureUpperBound(Exprs.EUB);
  1232. Dir->setNextLowerBound(Exprs.NLB);
  1233. Dir->setNextUpperBound(Exprs.NUB);
  1234. Dir->setNumIterations(Exprs.NumIterations);
  1235. Dir->setCounters(Exprs.Counters);
  1236. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1237. Dir->setInits(Exprs.Inits);
  1238. Dir->setUpdates(Exprs.Updates);
  1239. Dir->setFinals(Exprs.Finals);
  1240. Dir->setDependentCounters(Exprs.DependentCounters);
  1241. Dir->setDependentInits(Exprs.DependentInits);
  1242. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1243. Dir->setPreInits(Exprs.PreInits);
  1244. Dir->setHasCancel(HasCancel);
  1245. return Dir;
  1246. }
  1247. OMPParallelMasterTaskLoopDirective *
  1248. OMPParallelMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
  1249. unsigned NumClauses,
  1250. unsigned CollapsedNum,
  1251. EmptyShell) {
  1252. return createEmptyDirective<OMPParallelMasterTaskLoopDirective>(
  1253. C, NumClauses, /*HasAssociatedStmt=*/true,
  1254. numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop),
  1255. CollapsedNum);
  1256. }
  1257. OMPParallelMaskedTaskLoopDirective *OMPParallelMaskedTaskLoopDirective::Create(
  1258. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1259. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1260. const HelperExprs &Exprs, bool HasCancel) {
  1261. auto *Dir = createDirective<OMPParallelMaskedTaskLoopDirective>(
  1262. C, Clauses, AssociatedStmt,
  1263. numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop), StartLoc,
  1264. EndLoc, CollapsedNum);
  1265. Dir->setIterationVariable(Exprs.IterationVarRef);
  1266. Dir->setLastIteration(Exprs.LastIteration);
  1267. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1268. Dir->setPreCond(Exprs.PreCond);
  1269. Dir->setCond(Exprs.Cond);
  1270. Dir->setInit(Exprs.Init);
  1271. Dir->setInc(Exprs.Inc);
  1272. Dir->setIsLastIterVariable(Exprs.IL);
  1273. Dir->setLowerBoundVariable(Exprs.LB);
  1274. Dir->setUpperBoundVariable(Exprs.UB);
  1275. Dir->setStrideVariable(Exprs.ST);
  1276. Dir->setEnsureUpperBound(Exprs.EUB);
  1277. Dir->setNextLowerBound(Exprs.NLB);
  1278. Dir->setNextUpperBound(Exprs.NUB);
  1279. Dir->setNumIterations(Exprs.NumIterations);
  1280. Dir->setCounters(Exprs.Counters);
  1281. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1282. Dir->setInits(Exprs.Inits);
  1283. Dir->setUpdates(Exprs.Updates);
  1284. Dir->setFinals(Exprs.Finals);
  1285. Dir->setDependentCounters(Exprs.DependentCounters);
  1286. Dir->setDependentInits(Exprs.DependentInits);
  1287. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1288. Dir->setPreInits(Exprs.PreInits);
  1289. Dir->setHasCancel(HasCancel);
  1290. return Dir;
  1291. }
  1292. OMPParallelMaskedTaskLoopDirective *
  1293. OMPParallelMaskedTaskLoopDirective::CreateEmpty(const ASTContext &C,
  1294. unsigned NumClauses,
  1295. unsigned CollapsedNum,
  1296. EmptyShell) {
  1297. return createEmptyDirective<OMPParallelMaskedTaskLoopDirective>(
  1298. C, NumClauses, /*HasAssociatedStmt=*/true,
  1299. numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop),
  1300. CollapsedNum);
  1301. }
  1302. OMPParallelMasterTaskLoopSimdDirective *
  1303. OMPParallelMasterTaskLoopSimdDirective::Create(
  1304. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1305. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1306. const HelperExprs &Exprs) {
  1307. auto *Dir = createDirective<OMPParallelMasterTaskLoopSimdDirective>(
  1308. C, Clauses, AssociatedStmt,
  1309. numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd),
  1310. StartLoc, EndLoc, CollapsedNum);
  1311. Dir->setIterationVariable(Exprs.IterationVarRef);
  1312. Dir->setLastIteration(Exprs.LastIteration);
  1313. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1314. Dir->setPreCond(Exprs.PreCond);
  1315. Dir->setCond(Exprs.Cond);
  1316. Dir->setInit(Exprs.Init);
  1317. Dir->setInc(Exprs.Inc);
  1318. Dir->setIsLastIterVariable(Exprs.IL);
  1319. Dir->setLowerBoundVariable(Exprs.LB);
  1320. Dir->setUpperBoundVariable(Exprs.UB);
  1321. Dir->setStrideVariable(Exprs.ST);
  1322. Dir->setEnsureUpperBound(Exprs.EUB);
  1323. Dir->setNextLowerBound(Exprs.NLB);
  1324. Dir->setNextUpperBound(Exprs.NUB);
  1325. Dir->setNumIterations(Exprs.NumIterations);
  1326. Dir->setCounters(Exprs.Counters);
  1327. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1328. Dir->setInits(Exprs.Inits);
  1329. Dir->setUpdates(Exprs.Updates);
  1330. Dir->setFinals(Exprs.Finals);
  1331. Dir->setDependentCounters(Exprs.DependentCounters);
  1332. Dir->setDependentInits(Exprs.DependentInits);
  1333. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1334. Dir->setPreInits(Exprs.PreInits);
  1335. return Dir;
  1336. }
  1337. OMPParallelMasterTaskLoopSimdDirective *
  1338. OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
  1339. unsigned NumClauses,
  1340. unsigned CollapsedNum,
  1341. EmptyShell) {
  1342. return createEmptyDirective<OMPParallelMasterTaskLoopSimdDirective>(
  1343. C, NumClauses, /*HasAssociatedStmt=*/true,
  1344. numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd),
  1345. CollapsedNum);
  1346. }
  1347. OMPParallelMaskedTaskLoopSimdDirective *
  1348. OMPParallelMaskedTaskLoopSimdDirective::Create(
  1349. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1350. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1351. const HelperExprs &Exprs) {
  1352. auto *Dir = createDirective<OMPParallelMaskedTaskLoopSimdDirective>(
  1353. C, Clauses, AssociatedStmt,
  1354. numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop_simd),
  1355. StartLoc, EndLoc, CollapsedNum);
  1356. Dir->setIterationVariable(Exprs.IterationVarRef);
  1357. Dir->setLastIteration(Exprs.LastIteration);
  1358. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1359. Dir->setPreCond(Exprs.PreCond);
  1360. Dir->setCond(Exprs.Cond);
  1361. Dir->setInit(Exprs.Init);
  1362. Dir->setInc(Exprs.Inc);
  1363. Dir->setIsLastIterVariable(Exprs.IL);
  1364. Dir->setLowerBoundVariable(Exprs.LB);
  1365. Dir->setUpperBoundVariable(Exprs.UB);
  1366. Dir->setStrideVariable(Exprs.ST);
  1367. Dir->setEnsureUpperBound(Exprs.EUB);
  1368. Dir->setNextLowerBound(Exprs.NLB);
  1369. Dir->setNextUpperBound(Exprs.NUB);
  1370. Dir->setNumIterations(Exprs.NumIterations);
  1371. Dir->setCounters(Exprs.Counters);
  1372. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1373. Dir->setInits(Exprs.Inits);
  1374. Dir->setUpdates(Exprs.Updates);
  1375. Dir->setFinals(Exprs.Finals);
  1376. Dir->setDependentCounters(Exprs.DependentCounters);
  1377. Dir->setDependentInits(Exprs.DependentInits);
  1378. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1379. Dir->setPreInits(Exprs.PreInits);
  1380. return Dir;
  1381. }
  1382. OMPParallelMaskedTaskLoopSimdDirective *
  1383. OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
  1384. unsigned NumClauses,
  1385. unsigned CollapsedNum,
  1386. EmptyShell) {
  1387. return createEmptyDirective<OMPParallelMaskedTaskLoopSimdDirective>(
  1388. C, NumClauses, /*HasAssociatedStmt=*/true,
  1389. numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop_simd),
  1390. CollapsedNum);
  1391. }
  1392. OMPDistributeDirective *OMPDistributeDirective::Create(
  1393. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1394. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1395. const HelperExprs &Exprs) {
  1396. auto *Dir = createDirective<OMPDistributeDirective>(
  1397. C, Clauses, AssociatedStmt,
  1398. numLoopChildren(CollapsedNum, OMPD_distribute), StartLoc, EndLoc,
  1399. CollapsedNum);
  1400. Dir->setIterationVariable(Exprs.IterationVarRef);
  1401. Dir->setLastIteration(Exprs.LastIteration);
  1402. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1403. Dir->setPreCond(Exprs.PreCond);
  1404. Dir->setCond(Exprs.Cond);
  1405. Dir->setInit(Exprs.Init);
  1406. Dir->setInc(Exprs.Inc);
  1407. Dir->setIsLastIterVariable(Exprs.IL);
  1408. Dir->setLowerBoundVariable(Exprs.LB);
  1409. Dir->setUpperBoundVariable(Exprs.UB);
  1410. Dir->setStrideVariable(Exprs.ST);
  1411. Dir->setEnsureUpperBound(Exprs.EUB);
  1412. Dir->setNextLowerBound(Exprs.NLB);
  1413. Dir->setNextUpperBound(Exprs.NUB);
  1414. Dir->setNumIterations(Exprs.NumIterations);
  1415. Dir->setCounters(Exprs.Counters);
  1416. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1417. Dir->setInits(Exprs.Inits);
  1418. Dir->setUpdates(Exprs.Updates);
  1419. Dir->setFinals(Exprs.Finals);
  1420. Dir->setDependentCounters(Exprs.DependentCounters);
  1421. Dir->setDependentInits(Exprs.DependentInits);
  1422. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1423. Dir->setPreInits(Exprs.PreInits);
  1424. return Dir;
  1425. }
  1426. OMPDistributeDirective *
  1427. OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1428. unsigned CollapsedNum, EmptyShell) {
  1429. return createEmptyDirective<OMPDistributeDirective>(
  1430. C, NumClauses, /*HasAssociatedStmt=*/true,
  1431. numLoopChildren(CollapsedNum, OMPD_distribute), CollapsedNum);
  1432. }
  1433. OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(
  1434. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1435. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  1436. return createDirective<OMPTargetUpdateDirective>(C, Clauses, AssociatedStmt,
  1437. /*NumChildren=*/0, StartLoc,
  1438. EndLoc);
  1439. }
  1440. OMPTargetUpdateDirective *
  1441. OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1442. EmptyShell) {
  1443. return createEmptyDirective<OMPTargetUpdateDirective>(
  1444. C, NumClauses, /*HasAssociatedStmt=*/true);
  1445. }
  1446. OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
  1447. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1448. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1449. const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
  1450. auto *Dir = createDirective<OMPDistributeParallelForDirective>(
  1451. C, Clauses, AssociatedStmt,
  1452. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for) + 1, StartLoc,
  1453. EndLoc, CollapsedNum);
  1454. Dir->setIterationVariable(Exprs.IterationVarRef);
  1455. Dir->setLastIteration(Exprs.LastIteration);
  1456. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1457. Dir->setPreCond(Exprs.PreCond);
  1458. Dir->setCond(Exprs.Cond);
  1459. Dir->setInit(Exprs.Init);
  1460. Dir->setInc(Exprs.Inc);
  1461. Dir->setIsLastIterVariable(Exprs.IL);
  1462. Dir->setLowerBoundVariable(Exprs.LB);
  1463. Dir->setUpperBoundVariable(Exprs.UB);
  1464. Dir->setStrideVariable(Exprs.ST);
  1465. Dir->setEnsureUpperBound(Exprs.EUB);
  1466. Dir->setNextLowerBound(Exprs.NLB);
  1467. Dir->setNextUpperBound(Exprs.NUB);
  1468. Dir->setNumIterations(Exprs.NumIterations);
  1469. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1470. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1471. Dir->setDistInc(Exprs.DistInc);
  1472. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1473. Dir->setCounters(Exprs.Counters);
  1474. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1475. Dir->setInits(Exprs.Inits);
  1476. Dir->setUpdates(Exprs.Updates);
  1477. Dir->setFinals(Exprs.Finals);
  1478. Dir->setDependentCounters(Exprs.DependentCounters);
  1479. Dir->setDependentInits(Exprs.DependentInits);
  1480. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1481. Dir->setPreInits(Exprs.PreInits);
  1482. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1483. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1484. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1485. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1486. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1487. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1488. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1489. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1490. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1491. Dir->setTaskReductionRefExpr(TaskRedRef);
  1492. Dir->HasCancel = HasCancel;
  1493. return Dir;
  1494. }
  1495. OMPDistributeParallelForDirective *
  1496. OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
  1497. unsigned NumClauses,
  1498. unsigned CollapsedNum,
  1499. EmptyShell) {
  1500. return createEmptyDirective<OMPDistributeParallelForDirective>(
  1501. C, NumClauses, /*HasAssociatedStmt=*/true,
  1502. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for) + 1,
  1503. CollapsedNum);
  1504. }
  1505. OMPDistributeParallelForSimdDirective *
  1506. OMPDistributeParallelForSimdDirective::Create(
  1507. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1508. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1509. const HelperExprs &Exprs) {
  1510. auto *Dir = createDirective<OMPDistributeParallelForSimdDirective>(
  1511. C, Clauses, AssociatedStmt,
  1512. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd),
  1513. StartLoc, EndLoc, CollapsedNum);
  1514. Dir->setIterationVariable(Exprs.IterationVarRef);
  1515. Dir->setLastIteration(Exprs.LastIteration);
  1516. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1517. Dir->setPreCond(Exprs.PreCond);
  1518. Dir->setCond(Exprs.Cond);
  1519. Dir->setInit(Exprs.Init);
  1520. Dir->setInc(Exprs.Inc);
  1521. Dir->setIsLastIterVariable(Exprs.IL);
  1522. Dir->setLowerBoundVariable(Exprs.LB);
  1523. Dir->setUpperBoundVariable(Exprs.UB);
  1524. Dir->setStrideVariable(Exprs.ST);
  1525. Dir->setEnsureUpperBound(Exprs.EUB);
  1526. Dir->setNextLowerBound(Exprs.NLB);
  1527. Dir->setNextUpperBound(Exprs.NUB);
  1528. Dir->setNumIterations(Exprs.NumIterations);
  1529. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1530. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1531. Dir->setDistInc(Exprs.DistInc);
  1532. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1533. Dir->setCounters(Exprs.Counters);
  1534. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1535. Dir->setInits(Exprs.Inits);
  1536. Dir->setUpdates(Exprs.Updates);
  1537. Dir->setFinals(Exprs.Finals);
  1538. Dir->setDependentCounters(Exprs.DependentCounters);
  1539. Dir->setDependentInits(Exprs.DependentInits);
  1540. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1541. Dir->setPreInits(Exprs.PreInits);
  1542. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1543. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1544. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1545. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1546. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1547. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1548. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1549. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1550. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1551. return Dir;
  1552. }
  1553. OMPDistributeParallelForSimdDirective *
  1554. OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
  1555. unsigned NumClauses,
  1556. unsigned CollapsedNum,
  1557. EmptyShell) {
  1558. return createEmptyDirective<OMPDistributeParallelForSimdDirective>(
  1559. C, NumClauses, /*HasAssociatedStmt=*/true,
  1560. numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd),
  1561. CollapsedNum);
  1562. }
  1563. OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
  1564. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1565. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1566. const HelperExprs &Exprs) {
  1567. auto *Dir = createDirective<OMPDistributeSimdDirective>(
  1568. C, Clauses, AssociatedStmt,
  1569. numLoopChildren(CollapsedNum, OMPD_distribute_simd), StartLoc, EndLoc,
  1570. CollapsedNum);
  1571. Dir->setIterationVariable(Exprs.IterationVarRef);
  1572. Dir->setLastIteration(Exprs.LastIteration);
  1573. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1574. Dir->setPreCond(Exprs.PreCond);
  1575. Dir->setCond(Exprs.Cond);
  1576. Dir->setInit(Exprs.Init);
  1577. Dir->setInc(Exprs.Inc);
  1578. Dir->setIsLastIterVariable(Exprs.IL);
  1579. Dir->setLowerBoundVariable(Exprs.LB);
  1580. Dir->setUpperBoundVariable(Exprs.UB);
  1581. Dir->setStrideVariable(Exprs.ST);
  1582. Dir->setEnsureUpperBound(Exprs.EUB);
  1583. Dir->setNextLowerBound(Exprs.NLB);
  1584. Dir->setNextUpperBound(Exprs.NUB);
  1585. Dir->setNumIterations(Exprs.NumIterations);
  1586. Dir->setCounters(Exprs.Counters);
  1587. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1588. Dir->setInits(Exprs.Inits);
  1589. Dir->setUpdates(Exprs.Updates);
  1590. Dir->setFinals(Exprs.Finals);
  1591. Dir->setDependentCounters(Exprs.DependentCounters);
  1592. Dir->setDependentInits(Exprs.DependentInits);
  1593. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1594. Dir->setPreInits(Exprs.PreInits);
  1595. return Dir;
  1596. }
  1597. OMPDistributeSimdDirective *
  1598. OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
  1599. unsigned NumClauses,
  1600. unsigned CollapsedNum, EmptyShell) {
  1601. return createEmptyDirective<OMPDistributeSimdDirective>(
  1602. C, NumClauses, /*HasAssociatedStmt=*/true,
  1603. numLoopChildren(CollapsedNum, OMPD_distribute_simd), CollapsedNum);
  1604. }
  1605. OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
  1606. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1607. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1608. const HelperExprs &Exprs) {
  1609. auto *Dir = createDirective<OMPTargetParallelForSimdDirective>(
  1610. C, Clauses, AssociatedStmt,
  1611. numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd), StartLoc,
  1612. EndLoc, CollapsedNum);
  1613. Dir->setIterationVariable(Exprs.IterationVarRef);
  1614. Dir->setLastIteration(Exprs.LastIteration);
  1615. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1616. Dir->setPreCond(Exprs.PreCond);
  1617. Dir->setCond(Exprs.Cond);
  1618. Dir->setInit(Exprs.Init);
  1619. Dir->setInc(Exprs.Inc);
  1620. Dir->setIsLastIterVariable(Exprs.IL);
  1621. Dir->setLowerBoundVariable(Exprs.LB);
  1622. Dir->setUpperBoundVariable(Exprs.UB);
  1623. Dir->setStrideVariable(Exprs.ST);
  1624. Dir->setEnsureUpperBound(Exprs.EUB);
  1625. Dir->setNextLowerBound(Exprs.NLB);
  1626. Dir->setNextUpperBound(Exprs.NUB);
  1627. Dir->setNumIterations(Exprs.NumIterations);
  1628. Dir->setCounters(Exprs.Counters);
  1629. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1630. Dir->setInits(Exprs.Inits);
  1631. Dir->setUpdates(Exprs.Updates);
  1632. Dir->setFinals(Exprs.Finals);
  1633. Dir->setDependentCounters(Exprs.DependentCounters);
  1634. Dir->setDependentInits(Exprs.DependentInits);
  1635. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1636. Dir->setPreInits(Exprs.PreInits);
  1637. return Dir;
  1638. }
  1639. OMPTargetParallelForSimdDirective *
  1640. OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
  1641. unsigned NumClauses,
  1642. unsigned CollapsedNum,
  1643. EmptyShell) {
  1644. return createEmptyDirective<OMPTargetParallelForSimdDirective>(
  1645. C, NumClauses, /*HasAssociatedStmt=*/true,
  1646. numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd),
  1647. CollapsedNum);
  1648. }
  1649. OMPTargetSimdDirective *
  1650. OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  1651. SourceLocation EndLoc, unsigned CollapsedNum,
  1652. ArrayRef<OMPClause *> Clauses,
  1653. Stmt *AssociatedStmt, const HelperExprs &Exprs) {
  1654. auto *Dir = createDirective<OMPTargetSimdDirective>(
  1655. C, Clauses, AssociatedStmt,
  1656. numLoopChildren(CollapsedNum, OMPD_target_simd), StartLoc, EndLoc,
  1657. CollapsedNum);
  1658. Dir->setIterationVariable(Exprs.IterationVarRef);
  1659. Dir->setLastIteration(Exprs.LastIteration);
  1660. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1661. Dir->setPreCond(Exprs.PreCond);
  1662. Dir->setCond(Exprs.Cond);
  1663. Dir->setInit(Exprs.Init);
  1664. Dir->setInc(Exprs.Inc);
  1665. Dir->setCounters(Exprs.Counters);
  1666. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1667. Dir->setInits(Exprs.Inits);
  1668. Dir->setUpdates(Exprs.Updates);
  1669. Dir->setFinals(Exprs.Finals);
  1670. Dir->setDependentCounters(Exprs.DependentCounters);
  1671. Dir->setDependentInits(Exprs.DependentInits);
  1672. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1673. Dir->setPreInits(Exprs.PreInits);
  1674. return Dir;
  1675. }
  1676. OMPTargetSimdDirective *
  1677. OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1678. unsigned CollapsedNum, EmptyShell) {
  1679. return createEmptyDirective<OMPTargetSimdDirective>(
  1680. C, NumClauses, /*HasAssociatedStmt=*/true,
  1681. numLoopChildren(CollapsedNum, OMPD_target_simd), CollapsedNum);
  1682. }
  1683. OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
  1684. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1685. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1686. const HelperExprs &Exprs) {
  1687. auto *Dir = createDirective<OMPTeamsDistributeDirective>(
  1688. C, Clauses, AssociatedStmt,
  1689. numLoopChildren(CollapsedNum, OMPD_teams_distribute), StartLoc, EndLoc,
  1690. CollapsedNum);
  1691. Dir->setIterationVariable(Exprs.IterationVarRef);
  1692. Dir->setLastIteration(Exprs.LastIteration);
  1693. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1694. Dir->setPreCond(Exprs.PreCond);
  1695. Dir->setCond(Exprs.Cond);
  1696. Dir->setInit(Exprs.Init);
  1697. Dir->setInc(Exprs.Inc);
  1698. Dir->setIsLastIterVariable(Exprs.IL);
  1699. Dir->setLowerBoundVariable(Exprs.LB);
  1700. Dir->setUpperBoundVariable(Exprs.UB);
  1701. Dir->setStrideVariable(Exprs.ST);
  1702. Dir->setEnsureUpperBound(Exprs.EUB);
  1703. Dir->setNextLowerBound(Exprs.NLB);
  1704. Dir->setNextUpperBound(Exprs.NUB);
  1705. Dir->setNumIterations(Exprs.NumIterations);
  1706. Dir->setCounters(Exprs.Counters);
  1707. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1708. Dir->setInits(Exprs.Inits);
  1709. Dir->setUpdates(Exprs.Updates);
  1710. Dir->setFinals(Exprs.Finals);
  1711. Dir->setDependentCounters(Exprs.DependentCounters);
  1712. Dir->setDependentInits(Exprs.DependentInits);
  1713. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1714. Dir->setPreInits(Exprs.PreInits);
  1715. return Dir;
  1716. }
  1717. OMPTeamsDistributeDirective *
  1718. OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
  1719. unsigned NumClauses,
  1720. unsigned CollapsedNum, EmptyShell) {
  1721. return createEmptyDirective<OMPTeamsDistributeDirective>(
  1722. C, NumClauses, /*HasAssociatedStmt=*/true,
  1723. numLoopChildren(CollapsedNum, OMPD_teams_distribute), CollapsedNum);
  1724. }
  1725. OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
  1726. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1727. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1728. const HelperExprs &Exprs) {
  1729. auto *Dir = createDirective<OMPTeamsDistributeSimdDirective>(
  1730. C, Clauses, AssociatedStmt,
  1731. numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd), StartLoc,
  1732. EndLoc, CollapsedNum);
  1733. Dir->setIterationVariable(Exprs.IterationVarRef);
  1734. Dir->setLastIteration(Exprs.LastIteration);
  1735. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1736. Dir->setPreCond(Exprs.PreCond);
  1737. Dir->setCond(Exprs.Cond);
  1738. Dir->setInit(Exprs.Init);
  1739. Dir->setInc(Exprs.Inc);
  1740. Dir->setIsLastIterVariable(Exprs.IL);
  1741. Dir->setLowerBoundVariable(Exprs.LB);
  1742. Dir->setUpperBoundVariable(Exprs.UB);
  1743. Dir->setStrideVariable(Exprs.ST);
  1744. Dir->setEnsureUpperBound(Exprs.EUB);
  1745. Dir->setNextLowerBound(Exprs.NLB);
  1746. Dir->setNextUpperBound(Exprs.NUB);
  1747. Dir->setNumIterations(Exprs.NumIterations);
  1748. Dir->setCounters(Exprs.Counters);
  1749. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1750. Dir->setInits(Exprs.Inits);
  1751. Dir->setUpdates(Exprs.Updates);
  1752. Dir->setFinals(Exprs.Finals);
  1753. Dir->setDependentCounters(Exprs.DependentCounters);
  1754. Dir->setDependentInits(Exprs.DependentInits);
  1755. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1756. Dir->setPreInits(Exprs.PreInits);
  1757. return Dir;
  1758. }
  1759. OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
  1760. const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
  1761. EmptyShell) {
  1762. return createEmptyDirective<OMPTeamsDistributeSimdDirective>(
  1763. C, NumClauses, /*HasAssociatedStmt=*/true,
  1764. numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd), CollapsedNum);
  1765. }
  1766. OMPTeamsDistributeParallelForSimdDirective *
  1767. OMPTeamsDistributeParallelForSimdDirective::Create(
  1768. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1769. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1770. const HelperExprs &Exprs) {
  1771. auto *Dir = createDirective<OMPTeamsDistributeParallelForSimdDirective>(
  1772. C, Clauses, AssociatedStmt,
  1773. numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for_simd),
  1774. StartLoc, EndLoc, CollapsedNum);
  1775. Dir->setIterationVariable(Exprs.IterationVarRef);
  1776. Dir->setLastIteration(Exprs.LastIteration);
  1777. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1778. Dir->setPreCond(Exprs.PreCond);
  1779. Dir->setCond(Exprs.Cond);
  1780. Dir->setInit(Exprs.Init);
  1781. Dir->setInc(Exprs.Inc);
  1782. Dir->setIsLastIterVariable(Exprs.IL);
  1783. Dir->setLowerBoundVariable(Exprs.LB);
  1784. Dir->setUpperBoundVariable(Exprs.UB);
  1785. Dir->setStrideVariable(Exprs.ST);
  1786. Dir->setEnsureUpperBound(Exprs.EUB);
  1787. Dir->setNextLowerBound(Exprs.NLB);
  1788. Dir->setNextUpperBound(Exprs.NUB);
  1789. Dir->setNumIterations(Exprs.NumIterations);
  1790. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1791. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1792. Dir->setDistInc(Exprs.DistInc);
  1793. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1794. Dir->setCounters(Exprs.Counters);
  1795. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1796. Dir->setInits(Exprs.Inits);
  1797. Dir->setUpdates(Exprs.Updates);
  1798. Dir->setFinals(Exprs.Finals);
  1799. Dir->setDependentCounters(Exprs.DependentCounters);
  1800. Dir->setDependentInits(Exprs.DependentInits);
  1801. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1802. Dir->setPreInits(Exprs.PreInits);
  1803. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1804. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1805. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1806. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1807. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1808. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1809. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1810. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1811. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1812. return Dir;
  1813. }
  1814. OMPTeamsDistributeParallelForSimdDirective *
  1815. OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
  1816. unsigned NumClauses,
  1817. unsigned CollapsedNum,
  1818. EmptyShell) {
  1819. return createEmptyDirective<OMPTeamsDistributeParallelForSimdDirective>(
  1820. C, NumClauses, /*HasAssociatedStmt=*/true,
  1821. numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for_simd),
  1822. CollapsedNum);
  1823. }
  1824. OMPTeamsDistributeParallelForDirective *
  1825. OMPTeamsDistributeParallelForDirective::Create(
  1826. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1827. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1828. const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
  1829. auto *Dir = createDirective<OMPTeamsDistributeParallelForDirective>(
  1830. C, Clauses, AssociatedStmt,
  1831. numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for) + 1,
  1832. StartLoc, EndLoc, CollapsedNum);
  1833. Dir->setIterationVariable(Exprs.IterationVarRef);
  1834. Dir->setLastIteration(Exprs.LastIteration);
  1835. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1836. Dir->setPreCond(Exprs.PreCond);
  1837. Dir->setCond(Exprs.Cond);
  1838. Dir->setInit(Exprs.Init);
  1839. Dir->setInc(Exprs.Inc);
  1840. Dir->setIsLastIterVariable(Exprs.IL);
  1841. Dir->setLowerBoundVariable(Exprs.LB);
  1842. Dir->setUpperBoundVariable(Exprs.UB);
  1843. Dir->setStrideVariable(Exprs.ST);
  1844. Dir->setEnsureUpperBound(Exprs.EUB);
  1845. Dir->setNextLowerBound(Exprs.NLB);
  1846. Dir->setNextUpperBound(Exprs.NUB);
  1847. Dir->setNumIterations(Exprs.NumIterations);
  1848. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1849. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1850. Dir->setDistInc(Exprs.DistInc);
  1851. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1852. Dir->setCounters(Exprs.Counters);
  1853. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1854. Dir->setInits(Exprs.Inits);
  1855. Dir->setUpdates(Exprs.Updates);
  1856. Dir->setFinals(Exprs.Finals);
  1857. Dir->setDependentCounters(Exprs.DependentCounters);
  1858. Dir->setDependentInits(Exprs.DependentInits);
  1859. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1860. Dir->setPreInits(Exprs.PreInits);
  1861. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1862. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1863. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1864. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1865. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1866. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1867. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1868. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1869. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1870. Dir->setTaskReductionRefExpr(TaskRedRef);
  1871. Dir->HasCancel = HasCancel;
  1872. return Dir;
  1873. }
  1874. OMPTeamsDistributeParallelForDirective *
  1875. OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
  1876. unsigned NumClauses,
  1877. unsigned CollapsedNum,
  1878. EmptyShell) {
  1879. return createEmptyDirective<OMPTeamsDistributeParallelForDirective>(
  1880. C, NumClauses, /*HasAssociatedStmt=*/true,
  1881. numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for) + 1,
  1882. CollapsedNum);
  1883. }
  1884. OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
  1885. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1886. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
  1887. return createDirective<OMPTargetTeamsDirective>(C, Clauses, AssociatedStmt,
  1888. /*NumChildren=*/0, StartLoc,
  1889. EndLoc);
  1890. }
  1891. OMPTargetTeamsDirective *
  1892. OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  1893. EmptyShell) {
  1894. return createEmptyDirective<OMPTargetTeamsDirective>(
  1895. C, NumClauses, /*HasAssociatedStmt=*/true);
  1896. }
  1897. OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
  1898. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1899. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1900. const HelperExprs &Exprs) {
  1901. auto *Dir = createDirective<OMPTargetTeamsDistributeDirective>(
  1902. C, Clauses, AssociatedStmt,
  1903. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute), StartLoc,
  1904. EndLoc, CollapsedNum);
  1905. Dir->setIterationVariable(Exprs.IterationVarRef);
  1906. Dir->setLastIteration(Exprs.LastIteration);
  1907. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1908. Dir->setPreCond(Exprs.PreCond);
  1909. Dir->setCond(Exprs.Cond);
  1910. Dir->setInit(Exprs.Init);
  1911. Dir->setInc(Exprs.Inc);
  1912. Dir->setIsLastIterVariable(Exprs.IL);
  1913. Dir->setLowerBoundVariable(Exprs.LB);
  1914. Dir->setUpperBoundVariable(Exprs.UB);
  1915. Dir->setStrideVariable(Exprs.ST);
  1916. Dir->setEnsureUpperBound(Exprs.EUB);
  1917. Dir->setNextLowerBound(Exprs.NLB);
  1918. Dir->setNextUpperBound(Exprs.NUB);
  1919. Dir->setNumIterations(Exprs.NumIterations);
  1920. Dir->setCounters(Exprs.Counters);
  1921. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1922. Dir->setInits(Exprs.Inits);
  1923. Dir->setUpdates(Exprs.Updates);
  1924. Dir->setFinals(Exprs.Finals);
  1925. Dir->setDependentCounters(Exprs.DependentCounters);
  1926. Dir->setDependentInits(Exprs.DependentInits);
  1927. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1928. Dir->setPreInits(Exprs.PreInits);
  1929. return Dir;
  1930. }
  1931. OMPTargetTeamsDistributeDirective *
  1932. OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
  1933. unsigned NumClauses,
  1934. unsigned CollapsedNum,
  1935. EmptyShell) {
  1936. return createEmptyDirective<OMPTargetTeamsDistributeDirective>(
  1937. C, NumClauses, /*HasAssociatedStmt=*/true,
  1938. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute),
  1939. CollapsedNum);
  1940. }
  1941. OMPTargetTeamsDistributeParallelForDirective *
  1942. OMPTargetTeamsDistributeParallelForDirective::Create(
  1943. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  1944. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  1945. const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
  1946. auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForDirective>(
  1947. C, Clauses, AssociatedStmt,
  1948. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_parallel_for) +
  1949. 1,
  1950. StartLoc, EndLoc, CollapsedNum);
  1951. Dir->setIterationVariable(Exprs.IterationVarRef);
  1952. Dir->setLastIteration(Exprs.LastIteration);
  1953. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  1954. Dir->setPreCond(Exprs.PreCond);
  1955. Dir->setCond(Exprs.Cond);
  1956. Dir->setInit(Exprs.Init);
  1957. Dir->setInc(Exprs.Inc);
  1958. Dir->setIsLastIterVariable(Exprs.IL);
  1959. Dir->setLowerBoundVariable(Exprs.LB);
  1960. Dir->setUpperBoundVariable(Exprs.UB);
  1961. Dir->setStrideVariable(Exprs.ST);
  1962. Dir->setEnsureUpperBound(Exprs.EUB);
  1963. Dir->setNextLowerBound(Exprs.NLB);
  1964. Dir->setNextUpperBound(Exprs.NUB);
  1965. Dir->setNumIterations(Exprs.NumIterations);
  1966. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  1967. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  1968. Dir->setDistInc(Exprs.DistInc);
  1969. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  1970. Dir->setCounters(Exprs.Counters);
  1971. Dir->setPrivateCounters(Exprs.PrivateCounters);
  1972. Dir->setInits(Exprs.Inits);
  1973. Dir->setUpdates(Exprs.Updates);
  1974. Dir->setFinals(Exprs.Finals);
  1975. Dir->setDependentCounters(Exprs.DependentCounters);
  1976. Dir->setDependentInits(Exprs.DependentInits);
  1977. Dir->setFinalsConditions(Exprs.FinalsConditions);
  1978. Dir->setPreInits(Exprs.PreInits);
  1979. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  1980. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  1981. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  1982. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  1983. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  1984. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  1985. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  1986. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  1987. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  1988. Dir->setTaskReductionRefExpr(TaskRedRef);
  1989. Dir->HasCancel = HasCancel;
  1990. return Dir;
  1991. }
  1992. OMPTargetTeamsDistributeParallelForDirective *
  1993. OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
  1994. unsigned NumClauses,
  1995. unsigned CollapsedNum,
  1996. EmptyShell) {
  1997. return createEmptyDirective<OMPTargetTeamsDistributeParallelForDirective>(
  1998. C, NumClauses, /*HasAssociatedStmt=*/true,
  1999. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_parallel_for) +
  2000. 1,
  2001. CollapsedNum);
  2002. }
  2003. OMPTargetTeamsDistributeParallelForSimdDirective *
  2004. OMPTargetTeamsDistributeParallelForSimdDirective::Create(
  2005. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  2006. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  2007. const HelperExprs &Exprs) {
  2008. auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForSimdDirective>(
  2009. C, Clauses, AssociatedStmt,
  2010. numLoopChildren(CollapsedNum,
  2011. OMPD_target_teams_distribute_parallel_for_simd),
  2012. StartLoc, EndLoc, CollapsedNum);
  2013. Dir->setIterationVariable(Exprs.IterationVarRef);
  2014. Dir->setLastIteration(Exprs.LastIteration);
  2015. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  2016. Dir->setPreCond(Exprs.PreCond);
  2017. Dir->setCond(Exprs.Cond);
  2018. Dir->setInit(Exprs.Init);
  2019. Dir->setInc(Exprs.Inc);
  2020. Dir->setIsLastIterVariable(Exprs.IL);
  2021. Dir->setLowerBoundVariable(Exprs.LB);
  2022. Dir->setUpperBoundVariable(Exprs.UB);
  2023. Dir->setStrideVariable(Exprs.ST);
  2024. Dir->setEnsureUpperBound(Exprs.EUB);
  2025. Dir->setNextLowerBound(Exprs.NLB);
  2026. Dir->setNextUpperBound(Exprs.NUB);
  2027. Dir->setNumIterations(Exprs.NumIterations);
  2028. Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
  2029. Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
  2030. Dir->setDistInc(Exprs.DistInc);
  2031. Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
  2032. Dir->setCounters(Exprs.Counters);
  2033. Dir->setPrivateCounters(Exprs.PrivateCounters);
  2034. Dir->setInits(Exprs.Inits);
  2035. Dir->setUpdates(Exprs.Updates);
  2036. Dir->setFinals(Exprs.Finals);
  2037. Dir->setDependentCounters(Exprs.DependentCounters);
  2038. Dir->setDependentInits(Exprs.DependentInits);
  2039. Dir->setFinalsConditions(Exprs.FinalsConditions);
  2040. Dir->setPreInits(Exprs.PreInits);
  2041. Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
  2042. Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
  2043. Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
  2044. Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
  2045. Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
  2046. Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
  2047. Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
  2048. Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
  2049. Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
  2050. return Dir;
  2051. }
  2052. OMPTargetTeamsDistributeParallelForSimdDirective *
  2053. OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
  2054. const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
  2055. EmptyShell) {
  2056. return createEmptyDirective<OMPTargetTeamsDistributeParallelForSimdDirective>(
  2057. C, NumClauses, /*HasAssociatedStmt=*/true,
  2058. numLoopChildren(CollapsedNum,
  2059. OMPD_target_teams_distribute_parallel_for_simd),
  2060. CollapsedNum);
  2061. }
  2062. OMPTargetTeamsDistributeSimdDirective *
  2063. OMPTargetTeamsDistributeSimdDirective::Create(
  2064. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  2065. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  2066. const HelperExprs &Exprs) {
  2067. auto *Dir = createDirective<OMPTargetTeamsDistributeSimdDirective>(
  2068. C, Clauses, AssociatedStmt,
  2069. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd),
  2070. StartLoc, EndLoc, CollapsedNum);
  2071. Dir->setIterationVariable(Exprs.IterationVarRef);
  2072. Dir->setLastIteration(Exprs.LastIteration);
  2073. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  2074. Dir->setPreCond(Exprs.PreCond);
  2075. Dir->setCond(Exprs.Cond);
  2076. Dir->setInit(Exprs.Init);
  2077. Dir->setInc(Exprs.Inc);
  2078. Dir->setIsLastIterVariable(Exprs.IL);
  2079. Dir->setLowerBoundVariable(Exprs.LB);
  2080. Dir->setUpperBoundVariable(Exprs.UB);
  2081. Dir->setStrideVariable(Exprs.ST);
  2082. Dir->setEnsureUpperBound(Exprs.EUB);
  2083. Dir->setNextLowerBound(Exprs.NLB);
  2084. Dir->setNextUpperBound(Exprs.NUB);
  2085. Dir->setNumIterations(Exprs.NumIterations);
  2086. Dir->setCounters(Exprs.Counters);
  2087. Dir->setPrivateCounters(Exprs.PrivateCounters);
  2088. Dir->setInits(Exprs.Inits);
  2089. Dir->setUpdates(Exprs.Updates);
  2090. Dir->setFinals(Exprs.Finals);
  2091. Dir->setDependentCounters(Exprs.DependentCounters);
  2092. Dir->setDependentInits(Exprs.DependentInits);
  2093. Dir->setFinalsConditions(Exprs.FinalsConditions);
  2094. Dir->setPreInits(Exprs.PreInits);
  2095. return Dir;
  2096. }
  2097. OMPTargetTeamsDistributeSimdDirective *
  2098. OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
  2099. unsigned NumClauses,
  2100. unsigned CollapsedNum,
  2101. EmptyShell) {
  2102. return createEmptyDirective<OMPTargetTeamsDistributeSimdDirective>(
  2103. C, NumClauses, /*HasAssociatedStmt=*/true,
  2104. numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd),
  2105. CollapsedNum);
  2106. }
  2107. OMPInteropDirective *
  2108. OMPInteropDirective::Create(const ASTContext &C, SourceLocation StartLoc,
  2109. SourceLocation EndLoc,
  2110. ArrayRef<OMPClause *> Clauses) {
  2111. return createDirective<OMPInteropDirective>(
  2112. C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
  2113. EndLoc);
  2114. }
  2115. OMPInteropDirective *OMPInteropDirective::CreateEmpty(const ASTContext &C,
  2116. unsigned NumClauses,
  2117. EmptyShell) {
  2118. return createEmptyDirective<OMPInteropDirective>(C, NumClauses);
  2119. }
  2120. OMPDispatchDirective *OMPDispatchDirective::Create(
  2121. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  2122. ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  2123. SourceLocation TargetCallLoc) {
  2124. auto *Dir = createDirective<OMPDispatchDirective>(
  2125. C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
  2126. Dir->setTargetCallLoc(TargetCallLoc);
  2127. return Dir;
  2128. }
  2129. OMPDispatchDirective *OMPDispatchDirective::CreateEmpty(const ASTContext &C,
  2130. unsigned NumClauses,
  2131. EmptyShell) {
  2132. return createEmptyDirective<OMPDispatchDirective>(C, NumClauses,
  2133. /*HasAssociatedStmt=*/true,
  2134. /*NumChildren=*/0);
  2135. }
  2136. OMPMaskedDirective *OMPMaskedDirective::Create(const ASTContext &C,
  2137. SourceLocation StartLoc,
  2138. SourceLocation EndLoc,
  2139. ArrayRef<OMPClause *> Clauses,
  2140. Stmt *AssociatedStmt) {
  2141. return createDirective<OMPMaskedDirective>(C, Clauses, AssociatedStmt,
  2142. /*NumChildren=*/0, StartLoc,
  2143. EndLoc);
  2144. }
  2145. OMPMaskedDirective *OMPMaskedDirective::CreateEmpty(const ASTContext &C,
  2146. unsigned NumClauses,
  2147. EmptyShell) {
  2148. return createEmptyDirective<OMPMaskedDirective>(C, NumClauses,
  2149. /*HasAssociatedStmt=*/true);
  2150. }
  2151. OMPGenericLoopDirective *OMPGenericLoopDirective::Create(
  2152. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  2153. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  2154. const HelperExprs &Exprs) {
  2155. auto *Dir = createDirective<OMPGenericLoopDirective>(
  2156. C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_loop),
  2157. StartLoc, EndLoc, CollapsedNum);
  2158. Dir->setIterationVariable(Exprs.IterationVarRef);
  2159. Dir->setLastIteration(Exprs.LastIteration);
  2160. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  2161. Dir->setPreCond(Exprs.PreCond);
  2162. Dir->setCond(Exprs.Cond);
  2163. Dir->setInit(Exprs.Init);
  2164. Dir->setInc(Exprs.Inc);
  2165. Dir->setIsLastIterVariable(Exprs.IL);
  2166. Dir->setLowerBoundVariable(Exprs.LB);
  2167. Dir->setUpperBoundVariable(Exprs.UB);
  2168. Dir->setStrideVariable(Exprs.ST);
  2169. Dir->setEnsureUpperBound(Exprs.EUB);
  2170. Dir->setNextLowerBound(Exprs.NLB);
  2171. Dir->setNextUpperBound(Exprs.NUB);
  2172. Dir->setNumIterations(Exprs.NumIterations);
  2173. Dir->setCounters(Exprs.Counters);
  2174. Dir->setPrivateCounters(Exprs.PrivateCounters);
  2175. Dir->setInits(Exprs.Inits);
  2176. Dir->setUpdates(Exprs.Updates);
  2177. Dir->setFinals(Exprs.Finals);
  2178. Dir->setDependentCounters(Exprs.DependentCounters);
  2179. Dir->setDependentInits(Exprs.DependentInits);
  2180. Dir->setFinalsConditions(Exprs.FinalsConditions);
  2181. Dir->setPreInits(Exprs.PreInits);
  2182. return Dir;
  2183. }
  2184. OMPGenericLoopDirective *
  2185. OMPGenericLoopDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
  2186. unsigned CollapsedNum, EmptyShell) {
  2187. return createEmptyDirective<OMPGenericLoopDirective>(
  2188. C, NumClauses, /*HasAssociatedStmt=*/true,
  2189. numLoopChildren(CollapsedNum, OMPD_loop), CollapsedNum);
  2190. }
  2191. OMPTeamsGenericLoopDirective *OMPTeamsGenericLoopDirective::Create(
  2192. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  2193. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  2194. const HelperExprs &Exprs) {
  2195. auto *Dir = createDirective<OMPTeamsGenericLoopDirective>(
  2196. C, Clauses, AssociatedStmt,
  2197. numLoopChildren(CollapsedNum, OMPD_teams_loop), StartLoc, EndLoc,
  2198. CollapsedNum);
  2199. Dir->setIterationVariable(Exprs.IterationVarRef);
  2200. Dir->setLastIteration(Exprs.LastIteration);
  2201. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  2202. Dir->setPreCond(Exprs.PreCond);
  2203. Dir->setCond(Exprs.Cond);
  2204. Dir->setInit(Exprs.Init);
  2205. Dir->setInc(Exprs.Inc);
  2206. Dir->setIsLastIterVariable(Exprs.IL);
  2207. Dir->setLowerBoundVariable(Exprs.LB);
  2208. Dir->setUpperBoundVariable(Exprs.UB);
  2209. Dir->setStrideVariable(Exprs.ST);
  2210. Dir->setEnsureUpperBound(Exprs.EUB);
  2211. Dir->setNextLowerBound(Exprs.NLB);
  2212. Dir->setNextUpperBound(Exprs.NUB);
  2213. Dir->setNumIterations(Exprs.NumIterations);
  2214. Dir->setCounters(Exprs.Counters);
  2215. Dir->setPrivateCounters(Exprs.PrivateCounters);
  2216. Dir->setInits(Exprs.Inits);
  2217. Dir->setUpdates(Exprs.Updates);
  2218. Dir->setFinals(Exprs.Finals);
  2219. Dir->setDependentCounters(Exprs.DependentCounters);
  2220. Dir->setDependentInits(Exprs.DependentInits);
  2221. Dir->setFinalsConditions(Exprs.FinalsConditions);
  2222. Dir->setPreInits(Exprs.PreInits);
  2223. return Dir;
  2224. }
  2225. OMPTeamsGenericLoopDirective *
  2226. OMPTeamsGenericLoopDirective::CreateEmpty(const ASTContext &C,
  2227. unsigned NumClauses,
  2228. unsigned CollapsedNum, EmptyShell) {
  2229. return createEmptyDirective<OMPTeamsGenericLoopDirective>(
  2230. C, NumClauses, /*HasAssociatedStmt=*/true,
  2231. numLoopChildren(CollapsedNum, OMPD_teams_loop), CollapsedNum);
  2232. }
  2233. OMPTargetTeamsGenericLoopDirective *OMPTargetTeamsGenericLoopDirective::Create(
  2234. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  2235. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  2236. const HelperExprs &Exprs) {
  2237. auto *Dir = createDirective<OMPTargetTeamsGenericLoopDirective>(
  2238. C, Clauses, AssociatedStmt,
  2239. numLoopChildren(CollapsedNum, OMPD_target_teams_loop), StartLoc, EndLoc,
  2240. CollapsedNum);
  2241. Dir->setIterationVariable(Exprs.IterationVarRef);
  2242. Dir->setLastIteration(Exprs.LastIteration);
  2243. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  2244. Dir->setPreCond(Exprs.PreCond);
  2245. Dir->setCond(Exprs.Cond);
  2246. Dir->setInit(Exprs.Init);
  2247. Dir->setInc(Exprs.Inc);
  2248. Dir->setIsLastIterVariable(Exprs.IL);
  2249. Dir->setLowerBoundVariable(Exprs.LB);
  2250. Dir->setUpperBoundVariable(Exprs.UB);
  2251. Dir->setStrideVariable(Exprs.ST);
  2252. Dir->setEnsureUpperBound(Exprs.EUB);
  2253. Dir->setNextLowerBound(Exprs.NLB);
  2254. Dir->setNextUpperBound(Exprs.NUB);
  2255. Dir->setNumIterations(Exprs.NumIterations);
  2256. Dir->setCounters(Exprs.Counters);
  2257. Dir->setPrivateCounters(Exprs.PrivateCounters);
  2258. Dir->setInits(Exprs.Inits);
  2259. Dir->setUpdates(Exprs.Updates);
  2260. Dir->setFinals(Exprs.Finals);
  2261. Dir->setDependentCounters(Exprs.DependentCounters);
  2262. Dir->setDependentInits(Exprs.DependentInits);
  2263. Dir->setFinalsConditions(Exprs.FinalsConditions);
  2264. Dir->setPreInits(Exprs.PreInits);
  2265. return Dir;
  2266. }
  2267. OMPTargetTeamsGenericLoopDirective *
  2268. OMPTargetTeamsGenericLoopDirective::CreateEmpty(const ASTContext &C,
  2269. unsigned NumClauses,
  2270. unsigned CollapsedNum,
  2271. EmptyShell) {
  2272. return createEmptyDirective<OMPTargetTeamsGenericLoopDirective>(
  2273. C, NumClauses, /*HasAssociatedStmt=*/true,
  2274. numLoopChildren(CollapsedNum, OMPD_target_teams_loop), CollapsedNum);
  2275. }
  2276. OMPParallelGenericLoopDirective *OMPParallelGenericLoopDirective::Create(
  2277. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  2278. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  2279. const HelperExprs &Exprs) {
  2280. auto *Dir = createDirective<OMPParallelGenericLoopDirective>(
  2281. C, Clauses, AssociatedStmt,
  2282. numLoopChildren(CollapsedNum, OMPD_parallel_loop), StartLoc, EndLoc,
  2283. CollapsedNum);
  2284. Dir->setIterationVariable(Exprs.IterationVarRef);
  2285. Dir->setLastIteration(Exprs.LastIteration);
  2286. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  2287. Dir->setPreCond(Exprs.PreCond);
  2288. Dir->setCond(Exprs.Cond);
  2289. Dir->setInit(Exprs.Init);
  2290. Dir->setInc(Exprs.Inc);
  2291. Dir->setIsLastIterVariable(Exprs.IL);
  2292. Dir->setLowerBoundVariable(Exprs.LB);
  2293. Dir->setUpperBoundVariable(Exprs.UB);
  2294. Dir->setStrideVariable(Exprs.ST);
  2295. Dir->setEnsureUpperBound(Exprs.EUB);
  2296. Dir->setNextLowerBound(Exprs.NLB);
  2297. Dir->setNextUpperBound(Exprs.NUB);
  2298. Dir->setNumIterations(Exprs.NumIterations);
  2299. Dir->setCounters(Exprs.Counters);
  2300. Dir->setPrivateCounters(Exprs.PrivateCounters);
  2301. Dir->setInits(Exprs.Inits);
  2302. Dir->setUpdates(Exprs.Updates);
  2303. Dir->setFinals(Exprs.Finals);
  2304. Dir->setDependentCounters(Exprs.DependentCounters);
  2305. Dir->setDependentInits(Exprs.DependentInits);
  2306. Dir->setFinalsConditions(Exprs.FinalsConditions);
  2307. Dir->setPreInits(Exprs.PreInits);
  2308. return Dir;
  2309. }
  2310. OMPParallelGenericLoopDirective *OMPParallelGenericLoopDirective::CreateEmpty(
  2311. const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
  2312. EmptyShell) {
  2313. return createEmptyDirective<OMPParallelGenericLoopDirective>(
  2314. C, NumClauses, /*HasAssociatedStmt=*/true,
  2315. numLoopChildren(CollapsedNum, OMPD_parallel_loop), CollapsedNum);
  2316. }
  2317. OMPTargetParallelGenericLoopDirective *
  2318. OMPTargetParallelGenericLoopDirective::Create(
  2319. const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  2320. unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
  2321. const HelperExprs &Exprs) {
  2322. auto *Dir = createDirective<OMPTargetParallelGenericLoopDirective>(
  2323. C, Clauses, AssociatedStmt,
  2324. numLoopChildren(CollapsedNum, OMPD_target_parallel_loop), StartLoc,
  2325. EndLoc, CollapsedNum);
  2326. Dir->setIterationVariable(Exprs.IterationVarRef);
  2327. Dir->setLastIteration(Exprs.LastIteration);
  2328. Dir->setCalcLastIteration(Exprs.CalcLastIteration);
  2329. Dir->setPreCond(Exprs.PreCond);
  2330. Dir->setCond(Exprs.Cond);
  2331. Dir->setInit(Exprs.Init);
  2332. Dir->setInc(Exprs.Inc);
  2333. Dir->setIsLastIterVariable(Exprs.IL);
  2334. Dir->setLowerBoundVariable(Exprs.LB);
  2335. Dir->setUpperBoundVariable(Exprs.UB);
  2336. Dir->setStrideVariable(Exprs.ST);
  2337. Dir->setEnsureUpperBound(Exprs.EUB);
  2338. Dir->setNextLowerBound(Exprs.NLB);
  2339. Dir->setNextUpperBound(Exprs.NUB);
  2340. Dir->setNumIterations(Exprs.NumIterations);
  2341. Dir->setCounters(Exprs.Counters);
  2342. Dir->setPrivateCounters(Exprs.PrivateCounters);
  2343. Dir->setInits(Exprs.Inits);
  2344. Dir->setUpdates(Exprs.Updates);
  2345. Dir->setFinals(Exprs.Finals);
  2346. Dir->setDependentCounters(Exprs.DependentCounters);
  2347. Dir->setDependentInits(Exprs.DependentInits);
  2348. Dir->setFinalsConditions(Exprs.FinalsConditions);
  2349. Dir->setPreInits(Exprs.PreInits);
  2350. return Dir;
  2351. }
  2352. OMPTargetParallelGenericLoopDirective *
  2353. OMPTargetParallelGenericLoopDirective::CreateEmpty(const ASTContext &C,
  2354. unsigned NumClauses,
  2355. unsigned CollapsedNum,
  2356. EmptyShell) {
  2357. return createEmptyDirective<OMPTargetParallelGenericLoopDirective>(
  2358. C, NumClauses, /*HasAssociatedStmt=*/true,
  2359. numLoopChildren(CollapsedNum, OMPD_target_parallel_loop), CollapsedNum);
  2360. }