clang 24.0.0git
CIRGenStmtOpenMP.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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// Emit OpenMP Stmt nodes as CIR code.
10//
11//===----------------------------------------------------------------------===//
12
13#include "CIRGenBuilder.h"
14#include "CIRGenFunction.h"
15#include "CIRGenOpenMPClause.h"
17#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
20#include "llvm/ADT/STLFunctionalExtras.h"
21#include "llvm/Frontend/OpenMP/OMP.h"
22#include "llvm/Frontend/OpenMP/OMPConstants.h"
23using namespace clang;
24using namespace clang::CIRGen;
25
26mlir::LogicalResult
28 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPScopeDirective");
29 return mlir::failure();
30}
31mlir::LogicalResult
33 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPErrorDirective");
34 return mlir::failure();
35}
36
37/// Report \p item's synthesized clauses as not-yet-implemented: having no AST
38/// node, they cannot go through the clause emitters.
39static mlir::LogicalResult
41 omp::ConstructQueue::const_iterator item) {
42 mlir::LogicalResult res = mlir::success();
43 for (llvm::omp::Clause synth : item->synthesized) {
44 cgf.getCIRGenModule().errorNYI(s.getSourceRange(),
45 (llvm::Twine("OpenMP synthesized '") +
46 llvm::omp::getOpenMPClauseName(synth) +
47 "' clause from construct decomposition")
48 .str());
49 res = mlir::failure();
50 }
51 return res;
52}
53
54static mlir::LogicalResult
56 CIRGenBuilderTy &builder, mlir::Location loc,
58 mlir::omp::ParallelOperands &clauseOps) {
59 OpenMPClauseEmitter ce(cgf, cgm, builder, loc, clauses);
60 ce.emitIf(clauseOps, llvm::omp::Directive::OMPD_parallel);
61 ce.emitNumThreads(clauseOps);
62 ce.emitProcBind(clauseOps);
63 return ce.emitNYI</*supported=*/OMPIfClause, OMPNumThreadsClause,
64 OMPProcBindClause>(
66 OMPDefaultClause, OMPFirstprivateClause,
67 OMPPrivateClause, OMPReductionClause,
68 OMPSharedClause>{},
69 llvm::omp::Directive::OMPD_parallel);
70}
71
72template <typename DirectiveTy>
73static mlir::LogicalResult
74emitParallelOp(CIRGenFunction &cgf, const DirectiveTy &s,
75 const omp::ConstructQueue &queue,
76 omp::ConstructQueue::const_iterator item, mlir::Location begin,
77 mlir::Location end, const mlir::omp::ParallelOperands &clauseOps,
78 llvm::function_ref<mlir::LogicalResult()> emitBody) {
79 CIRGenBuilderTy &builder = cgf.getBuilder();
80 CIRGenModule &cgm = cgf.getCIRGenModule();
81
82 auto parallelOp = mlir::omp::ParallelOp::create(builder, begin, clauseOps);
83 if (!omp::isLastItemInQueue(item, queue))
84 parallelOp.setCombined(true);
85
86 mlir::Block &block = parallelOp.getRegion().emplaceBlock();
87 mlir::OpBuilder::InsertionGuard guard(builder);
88 builder.setInsertionPointToEnd(&block);
89
90 CIRGenFunction::LexicalScope ls{cgf, begin, builder.getInsertionBlock()};
91
92 // hasCancel() reports a nested cancel/cancellation point directive in the
93 // body, not a clause on `parallel`, so it can't be an emitParallelClauses()
94 // NYI check.
95 if (s.hasCancel()) {
96 cgm.errorNYI(s.getBeginLoc(), "OpenMP Parallel with Cancel");
97 return mlir::failure();
98 }
99 // Only set for reduction(task: ...), already rejected as NYI above.
100 assert(!s.getTaskReductionRefExpr() &&
101 "reduction(task: ...) should already be rejected as NYI");
102
103 mlir::LogicalResult res = emitBody();
104 mlir::omp::TerminatorOp::create(builder, end);
105 return res;
106}
107
108mlir::LogicalResult
109CIRGenFunction::emitOMPParallelDirective(const OMPParallelDirective &s) {
110 mlir::Location begin = getLoc(s.getBeginLoc());
111 mlir::Location end = getLoc(s.getEndLoc());
112
113 omp::ConstructQueue queue =
115 omp::ConstructQueue::const_iterator item = queue.begin();
116
117 if (mlir::failed(checkSynthesizedClauses(*this, s, item)))
118 return mlir::failure();
119
120 mlir::omp::ParallelOperands clauseOps;
121 if (mlir::failed(emitParallelClauses(*this, getCIRGenModule(), builder, begin,
122 item->clauses, clauseOps)))
123 return mlir::failure();
124
125 return emitParallelOp(
126 *this, s, queue, item, begin, end, clauseOps,
127 [&]() -> mlir::LogicalResult {
128 // emitStmt() rejects CapturedStmt directly; the parent construct
129 // must unwrap it, so emit the inner statement instead.
130 const CapturedStmt *cs = s.getCapturedStmt(llvm::omp::OMPD_parallel);
131 return emitStmt(cs->getCapturedStmt(), /*useCurrentScope=*/true);
132 });
133}
134
135mlir::LogicalResult
137 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPTaskwaitDirective");
138 return mlir::failure();
139}
140mlir::LogicalResult
142 getCIRGenModule().errorNYI(s.getSourceRange(),
143 "OpenMP OMPTaskyieldDirective");
144 return mlir::failure();
145}
146mlir::LogicalResult
148 mlir::omp::BarrierOp::create(builder, getLoc(s.getBeginLoc()));
149 assert(s.clauses().empty() && "omp barrier doesn't support clauses");
150 return mlir::success();
151}
152mlir::LogicalResult
154 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPMetaDirective");
155 return mlir::failure();
156}
157mlir::LogicalResult
158CIRGenFunction::emitOMPCanonicalLoop(const OMPCanonicalLoop &s) {
159 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPCanonicalLoop");
160 return mlir::failure();
161}
162mlir::LogicalResult
164 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPSimdDirective");
165 return mlir::failure();
166}
167mlir::LogicalResult
169 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPTileDirective");
170 return mlir::failure();
171}
172mlir::LogicalResult
174 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPUnrollDirective");
175 return mlir::failure();
176}
177mlir::LogicalResult
179 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPFuseDirective");
180 return mlir::failure();
181}
182mlir::LogicalResult
184 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPForDirective");
185 return mlir::failure();
186}
187mlir::LogicalResult
189 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPForSimdDirective");
190 return mlir::failure();
191}
192mlir::LogicalResult
194 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPSectionsDirective");
195 return mlir::failure();
196}
197mlir::LogicalResult
199 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPSectionDirective");
200 return mlir::failure();
201}
202mlir::LogicalResult
204 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPSingleDirective");
205 return mlir::failure();
206}
207mlir::LogicalResult
209 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPMasterDirective");
210 return mlir::failure();
211}
212mlir::LogicalResult
214 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPCriticalDirective");
215 return mlir::failure();
216}
217mlir::LogicalResult
219 getCIRGenModule().errorNYI(s.getSourceRange(),
220 "OpenMP OMPParallelForDirective");
221 return mlir::failure();
222}
225 getCIRGenModule().errorNYI(s.getSourceRange(),
226 "OpenMP OMPParallelForSimdDirective");
227 return mlir::failure();
228}
231 getCIRGenModule().errorNYI(s.getSourceRange(),
232 "OpenMP OMPParallelMasterDirective");
233 return mlir::failure();
234}
237 getCIRGenModule().errorNYI(s.getSourceRange(),
238 "OpenMP OMPParallelSectionsDirective");
239 return mlir::failure();
240}
241mlir::LogicalResult
243 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPTaskDirective");
244 return mlir::failure();
245}
246mlir::LogicalResult
248 getCIRGenModule().errorNYI(s.getSourceRange(),
249 "OpenMP OMPTaskgroupDirective");
250 return mlir::failure();
251}
252mlir::LogicalResult
254 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPFlushDirective");
255 return mlir::failure();
256}
257mlir::LogicalResult
259 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPDepobjDirective");
260 return mlir::failure();
261}
262mlir::LogicalResult
264 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPScanDirective");
265 return mlir::failure();
266}
269 getCIRGenModule().errorNYI(s.getSourceRange(),
270 "OpenMP OMPOrderedStandaloneDirective");
271 return mlir::failure();
272}
275 getCIRGenModule().errorNYI(s.getSourceRange(),
276 "OpenMP OMPOrderedBlockAssocDirective");
277 return mlir::failure();
278}
279mlir::LogicalResult
281 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPAtomicDirective");
282 return mlir::failure();
283}
284
285/// Check for unsupported implicit captures in a target region.
286static mlir::LogicalResult
288 const OMPExecutableDirective &s,
290 const CapturedStmt *cs = s.getCapturedStmt(llvm::omp::OMPD_target);
291 mlir::LogicalResult res = mlir::success();
292 for (const auto &capture : cs->captures()) {
293 if (capture.capturesThis()) {
294 cgf.getCIRGenModule().errorNYI(s.getBeginLoc(),
295 "OpenMP target capture of 'this' pointer");
296 res = mlir::failure();
297 continue;
298 }
299 if (capture.capturesVariableByCopy()) {
300 cgf.getCIRGenModule().errorNYI(s.getBeginLoc(),
301 "OpenMP target capture by copy");
302 res = mlir::failure();
303 continue;
304 }
305 if (capture.capturesVariableArrayType()) {
307 s.getBeginLoc(),
308 "OpenMP target capture of variable-length array type");
309 res = mlir::failure();
310 continue;
311 }
312 if (capture.capturesVariable()) {
313 const VarDecl *vd = capture.getCapturedVar();
314 if (llvm::is_contained(mapSyms, vd))
315 continue;
316
317 cgf.getCIRGenModule().errorNYI(s.getBeginLoc(),
318 "OpenMP target implicit by-ref capture");
319 res = mlir::failure();
320 }
321 }
322 return res;
323}
324
325static mlir::LogicalResult
327 CIRGenBuilderTy &builder, mlir::Location loc,
329 mlir::omp::TargetExtOperands &clauseOps,
331 OpenMPClauseEmitter ce(cgf, cgm, builder, loc, clauses);
332 ce.emitMap(clauseOps, &mapSyms);
333 return ce.emitNYI</*supported=*/OMPMapClause>(
334 /*nyi=*/OpenMPNYIClauseList<
336 OMPDependClause, OMPDeviceClause, OMPFirstprivateClause,
337 OMPHasDeviceAddrClause, OMPIfClause, OMPInReductionClause,
338 OMPIsDevicePtrClause, OMPNowaitClause, OMPPrivateClause,
340 llvm::omp::Directive::OMPD_target);
341}
342
343template <typename DirectiveTy>
344static mlir::LogicalResult
345emitTargetOp(CIRGenFunction &cgf, const DirectiveTy &s,
346 const omp::ConstructQueue &queue,
347 omp::ConstructQueue::const_iterator item, mlir::Location begin,
348 mlir::Location end, mlir::omp::TargetExtOperands &clauseOps,
350 llvm::function_ref<mlir::LogicalResult()> emitBody) {
351 CIRGenBuilderTy &builder = cgf.getBuilder();
352
353 if (mlir::failed(emitOMPTargetImplicitCaptures(cgf, s, mapSyms)))
354 return mlir::failure();
355
356 // Use generic for now.
357 clauseOps.kernelType = mlir::omp::TargetExecModeAttr::get(
358 &cgf.getMLIRContext(), mlir::omp::TargetExecMode::generic);
359
360 auto targetOp = mlir::omp::TargetOp::create(builder, begin, clauseOps);
361 if (!omp::isLastItemInQueue(item, queue))
362 targetOp.setCombined(true);
363
364 mlir::Block &block = targetOp.getRegion().emplaceBlock();
365 for (mlir::Value mapVar : clauseOps.mapVars)
366 block.addArgument(mapVar.getType(), begin);
367
368 mlir::OpBuilder::InsertionGuard guard(builder);
369 builder.setInsertionPointToEnd(&block);
370
371 CIRGenFunction::LexicalScope ls{cgf, begin, builder.getInsertionBlock()};
372
374 for (auto [idx, vd] : llvm::enumerate(mapSyms)) {
375 Address origAddr = cgf.getAddrOfLocalVar(vd);
376 savedAddrs.push_back({vd, origAddr});
377 mlir::Value blockArg = block.getArgument(idx);
378 cgf.replaceAddrOfLocalVar(vd, Address(blockArg, origAddr.getAlignment()));
379 }
380
381 mlir::LogicalResult res = emitBody();
382 mlir::omp::TerminatorOp::create(builder, end);
383
384 for (auto &[vd, addr] : savedAddrs)
385 cgf.replaceAddrOfLocalVar(vd, addr);
386
387 return res;
388}
389
390mlir::LogicalResult
392 mlir::Location begin = getLoc(s.getBeginLoc());
393 mlir::Location end = getLoc(s.getEndLoc());
394
395 omp::ConstructQueue queue =
397 omp::ConstructQueue::const_iterator item = queue.begin();
398
399 if (mlir::failed(checkSynthesizedClauses(*this, s, item)))
400 return mlir::failure();
401
402 mlir::omp::TargetExtOperands clauseOps;
404 if (mlir::failed(emitTargetClauses(*this, getCIRGenModule(), builder, begin,
405 item->clauses, clauseOps, mapSyms)))
406 return mlir::failure();
407
408 return emitTargetOp(*this, s, queue, item, begin, end, clauseOps, mapSyms,
409 [&]() -> mlir::LogicalResult {
410 const CapturedStmt *cs =
411 s.getCapturedStmt(llvm::omp::OMPD_target);
412 return emitStmt(cs->getCapturedStmt(),
413 /*useCurrentScope=*/true);
414 });
415}
416mlir::LogicalResult
418 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPTeamsDirective");
419 return mlir::failure();
420}
423 getCIRGenModule().errorNYI(s.getSourceRange(),
424 "OpenMP OMPCancellationPointDirective");
425 return mlir::failure();
426}
427mlir::LogicalResult
429 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPCancelDirective");
430 return mlir::failure();
431}
432mlir::LogicalResult
434 getCIRGenModule().errorNYI(s.getSourceRange(),
435 "OpenMP OMPTargetDataDirective");
436 return mlir::failure();
437}
440 getCIRGenModule().errorNYI(s.getSourceRange(),
441 "OpenMP OMPTargetEnterDataDirective");
442 return mlir::failure();
443}
446 getCIRGenModule().errorNYI(s.getSourceRange(),
447 "OpenMP OMPTargetExitDataDirective");
448 return mlir::failure();
449}
452 mlir::Location begin = getLoc(s.getBeginLoc());
453 mlir::Location end = getLoc(s.getEndLoc());
454
455 omp::ConstructQueue queue =
457 omp::ConstructQueue::const_iterator targetItem = queue.begin();
458 assert(targetItem->id == llvm::omp::OMPD_target &&
459 "expected 'target' to be the outermost leaf");
460
461 if (mlir::failed(checkSynthesizedClauses(*this, s, targetItem)))
462 return mlir::failure();
463
464 mlir::omp::TargetExtOperands targetOps;
466 if (mlir::failed(emitTargetClauses(*this, getCIRGenModule(), builder, begin,
467 targetItem->clauses, targetOps, mapSyms)))
468 return mlir::failure();
469
470 return emitTargetOp(
471 *this, s, queue, targetItem, begin, end, targetOps, mapSyms,
472 [&]() -> mlir::LogicalResult {
473 omp::ConstructQueue::const_iterator parallelItem =
474 std::next(targetItem);
475 assert(parallelItem != queue.end() &&
476 parallelItem->id == llvm::omp::OMPD_parallel &&
477 "expected a 'parallel' leaf nested in 'target'");
478
479 if (mlir::failed(checkSynthesizedClauses(*this, s, parallelItem)))
480 return mlir::failure();
481
482 mlir::omp::ParallelOperands parallelOps;
483 if (mlir::failed(emitParallelClauses(*this, getCIRGenModule(), builder,
484 begin, parallelItem->clauses,
485 parallelOps)))
486 return mlir::failure();
487
488 return emitParallelOp(*this, s, queue, parallelItem, begin, end,
489 parallelOps, [&]() -> mlir::LogicalResult {
490 const CapturedStmt *cs =
491 s.getCapturedStmt(llvm::omp::OMPD_parallel);
492 return emitStmt(cs->getCapturedStmt(),
493 /*useCurrentScope=*/true);
494 });
495 });
496}
499 getCIRGenModule().errorNYI(s.getSourceRange(),
500 "OpenMP OMPTargetParallelForDirective");
501 return mlir::failure();
502}
503mlir::LogicalResult
505 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPTaskLoopDirective");
506 return mlir::failure();
507}
509 const OMPTaskLoopSimdDirective &s) {
510 getCIRGenModule().errorNYI(s.getSourceRange(),
511 "OpenMP OMPTaskLoopSimdDirective");
512 return mlir::failure();
513}
516 getCIRGenModule().errorNYI(s.getSourceRange(),
517 "OpenMP OMPMaskedTaskLoopDirective");
518 return mlir::failure();
519}
522 getCIRGenModule().errorNYI(s.getSourceRange(),
523 "OpenMP OMPMaskedTaskLoopSimdDirective");
524 return mlir::failure();
525}
528 getCIRGenModule().errorNYI(s.getSourceRange(),
529 "OpenMP OMPMasterTaskLoopDirective");
530 return mlir::failure();
531}
534 getCIRGenModule().errorNYI(s.getSourceRange(),
535 "OpenMP OMPMasterTaskLoopSimdDirective");
536 return mlir::failure();
537}
540 getCIRGenModule().errorNYI(s.getSourceRange(),
541 "OpenMP OMPParallelGenericLoopDirective");
542 return mlir::failure();
543}
546 getCIRGenModule().errorNYI(s.getSourceRange(),
547 "OpenMP OMPParallelMaskedDirective");
548 return mlir::failure();
549}
552 getCIRGenModule().errorNYI(s.getSourceRange(),
553 "OpenMP OMPParallelMaskedTaskLoopDirective");
554 return mlir::failure();
555}
558 getCIRGenModule().errorNYI(s.getSourceRange(),
559 "OpenMP OMPParallelMaskedTaskLoopSimdDirective");
560 return mlir::failure();
561}
564 getCIRGenModule().errorNYI(s.getSourceRange(),
565 "OpenMP OMPParallelMasterTaskLoopDirective");
566 return mlir::failure();
567}
570 getCIRGenModule().errorNYI(s.getSourceRange(),
571 "OpenMP OMPParallelMasterTaskLoopSimdDirective");
572 return mlir::failure();
573}
574mlir::LogicalResult
576 getCIRGenModule().errorNYI(s.getSourceRange(),
577 "OpenMP OMPDistributeDirective");
578 return mlir::failure();
579}
582 getCIRGenModule().errorNYI(s.getSourceRange(),
583 "OpenMP OMPDistributeParallelForDirective");
584 return mlir::failure();
585}
588 getCIRGenModule().errorNYI(s.getSourceRange(),
589 "OpenMP OMPDistributeParallelForSimdDirective");
590 return mlir::failure();
591}
594 getCIRGenModule().errorNYI(s.getSourceRange(),
595 "OpenMP OMPDistributeSimdDirective");
596 return mlir::failure();
597}
600 getCIRGenModule().errorNYI(s.getSourceRange(),
601 "OpenMP OMPTargetParallelGenericLoopDirective");
602 return mlir::failure();
603}
606 getCIRGenModule().errorNYI(s.getSourceRange(),
607 "OpenMP OMPTargetParallelForSimdDirective");
608 return mlir::failure();
609}
610mlir::LogicalResult
612 getCIRGenModule().errorNYI(s.getSourceRange(),
613 "OpenMP OMPTargetSimdDirective");
614 return mlir::failure();
615}
618 getCIRGenModule().errorNYI(s.getSourceRange(),
619 "OpenMP OMPTargetTeamsGenericLoopDirective");
620 return mlir::failure();
621}
623 const OMPTargetUpdateDirective &s) {
624 getCIRGenModule().errorNYI(s.getSourceRange(),
625 "OpenMP OMPTargetUpdateDirective");
626 return mlir::failure();
627}
630 getCIRGenModule().errorNYI(s.getSourceRange(),
631 "OpenMP OMPTeamsDistributeDirective");
632 return mlir::failure();
633}
636 getCIRGenModule().errorNYI(s.getSourceRange(),
637 "OpenMP OMPTeamsDistributeSimdDirective");
638 return mlir::failure();
639}
640mlir::LogicalResult
644 s.getSourceRange(), "OpenMP OMPTeamsDistributeParallelForSimdDirective");
645 return mlir::failure();
646}
649 getCIRGenModule().errorNYI(s.getSourceRange(),
650 "OpenMP OMPTeamsDistributeParallelForDirective");
651 return mlir::failure();
652}
655 getCIRGenModule().errorNYI(s.getSourceRange(),
656 "OpenMP OMPTeamsGenericLoopDirective");
657 return mlir::failure();
658}
659mlir::LogicalResult
661 getCIRGenModule().errorNYI(s.getSourceRange(),
662 "OpenMP OMPTargetTeamsDirective");
663 return mlir::failure();
664}
667 getCIRGenModule().errorNYI(s.getSourceRange(),
668 "OpenMP OMPTargetTeamsDistributeDirective");
669 return mlir::failure();
670}
671mlir::LogicalResult
675 s.getSourceRange(),
676 "OpenMP OMPTargetTeamsDistributeParallelForDirective");
677 return mlir::failure();
678}
679mlir::LogicalResult
683 s.getSourceRange(),
684 "OpenMP OMPTargetTeamsDistributeParallelForSimdDirective");
685 return mlir::failure();
686}
689 getCIRGenModule().errorNYI(s.getSourceRange(),
690 "OpenMP OMPTargetTeamsDistributeSimdDirective");
691 return mlir::failure();
692}
693mlir::LogicalResult
695 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPInteropDirective");
696 return mlir::failure();
697}
698mlir::LogicalResult
700 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPDispatchDirective");
701 return mlir::failure();
702}
703mlir::LogicalResult
705 getCIRGenModule().errorNYI(s.getSourceRange(),
706 "OpenMP OMPGenericLoopDirective");
707 return mlir::failure();
708}
709mlir::LogicalResult
711 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPReverseDirective");
712 return mlir::failure();
713}
714mlir::LogicalResult
716 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPSplitDirective");
717 return mlir::failure();
718}
719mlir::LogicalResult
721 getCIRGenModule().errorNYI(s.getSourceRange(),
722 "OpenMP OMPInterchangeDirective");
723 return mlir::failure();
724}
725mlir::LogicalResult
727 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPFlattenDirective");
728 return mlir::failure();
729}
730mlir::LogicalResult
732 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPAssumeDirective");
733 return mlir::failure();
734}
735mlir::LogicalResult
737 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPMaskedDirective");
738 return mlir::failure();
739}
740mlir::LogicalResult
742 getCIRGenModule().errorNYI(s.getSourceRange(), "OpenMP OMPStripeDirective");
743 return mlir::failure();
744}
static void emitBody(CodeGenFunction &CGF, const Stmt *S, const Stmt *NextLoop, int MaxLevel, int Level=0)
static mlir::LogicalResult emitOMPTargetImplicitCaptures(CIRGenFunction &cgf, const OMPExecutableDirective &s, llvm::ArrayRef< const VarDecl * > mapSyms)
Check for unsupported implicit captures in a target region.
static mlir::LogicalResult checkSynthesizedClauses(CIRGenFunction &cgf, const OMPExecutableDirective &s, omp::ConstructQueue::const_iterator item)
Report item's synthesized clauses as not-yet-implemented: having no AST node, they cannot go through ...
static mlir::LogicalResult emitTargetOp(CIRGenFunction &cgf, const DirectiveTy &s, const omp::ConstructQueue &queue, omp::ConstructQueue::const_iterator item, mlir::Location begin, mlir::Location end, mlir::omp::TargetExtOperands &clauseOps, llvm::ArrayRef< const VarDecl * > mapSyms, llvm::function_ref< mlir::LogicalResult()> emitBody)
static mlir::LogicalResult emitParallelOp(CIRGenFunction &cgf, const DirectiveTy &s, const omp::ConstructQueue &queue, omp::ConstructQueue::const_iterator item, mlir::Location begin, mlir::Location end, const mlir::omp::ParallelOperands &clauseOps, llvm::function_ref< mlir::LogicalResult()> emitBody)
static mlir::LogicalResult emitParallelClauses(CIRGenFunction &cgf, CIRGenModule &cgm, CIRGenBuilderTy &builder, mlir::Location loc, llvm::ArrayRef< const OMPClause * > clauses, mlir::omp::ParallelOperands &clauseOps)
static mlir::LogicalResult emitTargetClauses(CIRGenFunction &cgf, CIRGenModule &cgm, CIRGenBuilderTy &builder, mlir::Location loc, llvm::ArrayRef< const OMPClause * > clauses, mlir::omp::TargetExtOperands &clauseOps, llvm::SmallVectorImpl< const VarDecl * > &mapSyms)
This file defines OpenMP AST classes for clauses.
This file defines OpenMP AST classes for executable directives and clauses.
This represents 'pragma omp atomic' directive.
This represents 'pragma omp barrier' directive.
This represents 'pragma omp cancel' directive.
This represents 'pragma omp cancellation point' directive.
This represents clause 'copyin' in the 'pragma omp ...' directives.
This represents 'pragma omp critical' directive.
This represents 'defaultmap' clause in the 'pragma omp ...' directive.
This represents implicit clause 'depend' for the 'pragma omp task' directive.
This represents 'pragma omp depobj' directive.
This represents 'device' clause in the 'pragma omp ...' directive.
This represents 'pragma omp dispatch' directive.
This represents 'pragma omp distribute' directive.
This represents 'pragma omp distribute parallel for' composite directive.
This represents 'pragma omp distribute parallel for simd' composite directive.
This represents 'pragma omp distribute simd' composite directive.
This represents 'pragma omp error' directive.
Represents the 'pragma omp flatten' loop transformation directive.
This represents 'pragma omp flush' directive.
This represents 'pragma omp for' directive.
This represents 'pragma omp for simd' directive.
Represents the 'pragma omp fuse' loop transformation directive.
This represents 'pragma omp loop' directive.
This represents clause 'has_device_ptr' in the 'pragma omp ...' directives.
Represents the 'pragma omp interchange' loop transformation directive.
This represents 'pragma omp interop' directive.
This represents clause 'is_device_ptr' in the 'pragma omp ...' directives.
This represents clause 'map' in the 'pragma omp ...' directives.
This represents 'pragma omp masked' directive.
This represents 'pragma omp masked taskloop' directive.
This represents 'pragma omp masked taskloop simd' directive.
This represents 'pragma omp master' directive.
This represents 'pragma omp master taskloop' directive.
This represents 'pragma omp master taskloop simd' directive.
This represents 'pragma omp metadirective' directive.
This represents block-associated 'pragma omp ordered' directive.
This represents standalone 'pragma omp ordered' directive.
This represents 'pragma omp parallel for' directive.
This represents 'pragma omp parallel for simd' directive.
This represents 'pragma omp parallel loop' directive.
This represents 'pragma omp parallel masked' directive.
This represents 'pragma omp parallel masked taskloop' directive.
This represents 'pragma omp parallel masked taskloop simd' directive.
This represents 'pragma omp parallel master' directive.
This represents 'pragma omp parallel master taskloop' directive.
This represents 'pragma omp parallel master taskloop simd' directive.
This represents 'pragma omp parallel sections' directive.
Represents the 'pragma omp reverse' loop transformation directive.
This represents 'pragma omp scan' directive.
This represents 'pragma omp scope' directive.
This represents 'pragma omp section' directive.
This represents 'pragma omp sections' directive.
This represents 'pragma omp simd' directive.
This represents 'pragma omp single' directive.
Represents the 'pragma omp split' loop transformation directive.
This represents the 'pragma omp stripe' loop transformation directive.
This represents 'pragma omp target data' directive.
This represents 'pragma omp target' directive.
This represents 'pragma omp target enter data' directive.
This represents 'pragma omp target exit data' directive.
This represents 'pragma omp target parallel' directive.
This represents 'pragma omp target parallel for' directive.
This represents 'pragma omp target parallel for simd' directive.
This represents 'pragma omp target parallel loop' directive.
This represents 'pragma omp target simd' directive.
This represents 'pragma omp target teams' directive.
This represents 'pragma omp target teams distribute' combined directive.
This represents 'pragma omp target teams distribute parallel for' combined directive.
This represents 'pragma omp target teams distribute parallel for simd' combined directive.
This represents 'pragma omp target teams distribute simd' combined directive.
This represents 'pragma omp target teams loop' directive.
This represents 'pragma omp target update' directive.
This represents 'pragma omp task' directive.
This represents 'pragma omp taskloop' directive.
This represents 'pragma omp taskloop simd' directive.
This represents 'pragma omp taskgroup' directive.
This represents 'pragma omp taskwait' directive.
This represents 'pragma omp taskyield' directive.
This represents 'pragma omp teams' directive.
This represents 'pragma omp teams distribute' directive.
This represents 'pragma omp teams distribute parallel for' composite directive.
This represents 'pragma omp teams distribute parallel for simd' composite directive.
This represents 'pragma omp teams distribute simd' combined directive.
This represents 'pragma omp teams loop' directive.
This represents 'thread_limit' clause in the 'pragma omp ...' directive.
This represents the 'pragma omp tile' loop transformation directive.
This represents the 'pragma omp unroll' loop transformation directive.
This represents clause 'uses_allocators' in the 'pragma omp target'-based directives.
This represents 'ompx_bare' clause in the 'pragma omp target teams ...' directive.
clang::CharUnits getAlignment() const
Definition Address.h:138
mlir::LogicalResult emitOMPTargetParallelForDirective(const OMPTargetParallelForDirective &s)
mlir::LogicalResult emitOMPParallelMasterTaskLoopSimdDirective(const OMPParallelMasterTaskLoopSimdDirective &s)
mlir::LogicalResult emitOMPSimdDirective(const OMPSimdDirective &s)
mlir::LogicalResult emitOMPCriticalDirective(const OMPCriticalDirective &s)
mlir::LogicalResult emitOMPParallelMasterDirective(const OMPParallelMasterDirective &s)
mlir::LogicalResult emitOMPCancellationPointDirective(const OMPCancellationPointDirective &s)
mlir::LogicalResult emitOMPParallelMaskedTaskLoopDirective(const OMPParallelMaskedTaskLoopDirective &s)
mlir::LogicalResult emitOMPReverseDirective(const OMPReverseDirective &s)
const clang::LangOptions & getLangOpts() const
mlir::LogicalResult emitOMPTileDirective(const OMPTileDirective &s)
mlir::LogicalResult emitOMPTargetTeamsDirective(const OMPTargetTeamsDirective &s)
mlir::LogicalResult emitOMPTeamsDistributeParallelForDirective(const OMPTeamsDistributeParallelForDirective &s)
mlir::LogicalResult emitOMPBarrierDirective(const OMPBarrierDirective &s)
mlir::LogicalResult emitOMPTargetParallelDirective(const OMPTargetParallelDirective &s)
void replaceAddrOfLocalVar(const clang::VarDecl *vd, Address addr)
mlir::LogicalResult emitOMPTargetDirective(const OMPTargetDirective &s)
Address getAddrOfLocalVar(const clang::VarDecl *vd)
Return the address of a local variable.
mlir::LogicalResult emitOMPScopeDirective(const OMPScopeDirective &s)
mlir::Location getLoc(clang::SourceLocation srcLoc)
Helpers to convert Clang's SourceLocation to a MLIR Location.
mlir::LogicalResult emitOMPDepobjDirective(const OMPDepobjDirective &s)
mlir::LogicalResult emitOMPDistributeParallelForSimdDirective(const OMPDistributeParallelForSimdDirective &s)
mlir::LogicalResult emitOMPUnrollDirective(const OMPUnrollDirective &s)
mlir::LogicalResult emitOMPTaskDirective(const OMPTaskDirective &s)
mlir::LogicalResult emitOMPTeamsGenericLoopDirective(const OMPTeamsGenericLoopDirective &s)
mlir::LogicalResult emitOMPCanonicalLoop(const OMPCanonicalLoop &s)
mlir::LogicalResult emitOMPTeamsDirective(const OMPTeamsDirective &s)
mlir::LogicalResult emitOMPMaskedTaskLoopDirective(const OMPMaskedTaskLoopDirective &s)
mlir::LogicalResult emitOMPFuseDirective(const OMPFuseDirective &s)
mlir::LogicalResult emitOMPSectionDirective(const OMPSectionDirective &s)
mlir::LogicalResult emitOMPFlattenDirective(const OMPFlattenDirective &s)
mlir::LogicalResult emitOMPParallelForSimdDirective(const OMPParallelForSimdDirective &s)
mlir::LogicalResult emitOMPDistributeParallelForDirective(const OMPDistributeParallelForDirective &s)
mlir::LogicalResult emitOMPOrderedStandaloneDirective(const OMPOrderedStandaloneDirective &s)
mlir::LogicalResult emitOMPMasterTaskLoopSimdDirective(const OMPMasterTaskLoopSimdDirective &s)
mlir::LogicalResult emitOMPTaskwaitDirective(const OMPTaskwaitDirective &s)
mlir::LogicalResult emitOMPFlushDirective(const OMPFlushDirective &s)
mlir::LogicalResult emitOMPGenericLoopDirective(const OMPGenericLoopDirective &s)
mlir::LogicalResult emitOMPTargetUpdateDirective(const OMPTargetUpdateDirective &s)
mlir::LogicalResult emitOMPTargetParallelForSimdDirective(const OMPTargetParallelForSimdDirective &s)
mlir::LogicalResult emitOMPInterchangeDirective(const OMPInterchangeDirective &s)
mlir::LogicalResult emitOMPDispatchDirective(const OMPDispatchDirective &s)
mlir::LogicalResult emitOMPParallelDirective(const OMPParallelDirective &s)
mlir::LogicalResult emitOMPForSimdDirective(const OMPForSimdDirective &s)
mlir::LogicalResult emitOMPTaskLoopDirective(const OMPTaskLoopDirective &s)
mlir::LogicalResult emitOMPTargetDataDirective(const OMPTargetDataDirective &s)
mlir::LogicalResult emitOMPTargetParallelGenericLoopDirective(const OMPTargetParallelGenericLoopDirective &s)
mlir::LogicalResult emitOMPParallelMaskedDirective(const OMPParallelMaskedDirective &s)
mlir::LogicalResult emitOMPMaskedTaskLoopSimdDirective(const OMPMaskedTaskLoopSimdDirective &s)
mlir::LogicalResult emitOMPAtomicDirective(const OMPAtomicDirective &s)
mlir::LogicalResult emitOMPTeamsDistributeParallelForSimdDirective(const OMPTeamsDistributeParallelForSimdDirective &s)
mlir::LogicalResult emitOMPTaskgroupDirective(const OMPTaskgroupDirective &s)
mlir::LogicalResult emitOMPParallelMaskedTaskLoopSimdDirective(const OMPParallelMaskedTaskLoopSimdDirective &s)
mlir::LogicalResult emitOMPTeamsDistributeDirective(const OMPTeamsDistributeDirective &s)
mlir::LogicalResult emitOMPInteropDirective(const OMPInteropDirective &s)
mlir::LogicalResult emitOMPErrorDirective(const OMPErrorDirective &s)
mlir::LogicalResult emitOMPSingleDirective(const OMPSingleDirective &s)
mlir::LogicalResult emitOMPTaskyieldDirective(const OMPTaskyieldDirective &s)
mlir::LogicalResult emitOMPTargetTeamsDistributeSimdDirective(const OMPTargetTeamsDistributeSimdDirective &s)
mlir::LogicalResult emitOMPScanDirective(const OMPScanDirective &s)
mlir::LogicalResult emitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective &s)
mlir::LogicalResult emitOMPMasterTaskLoopDirective(const OMPMasterTaskLoopDirective &s)
mlir::LogicalResult emitOMPForDirective(const OMPForDirective &s)
mlir::LogicalResult emitOMPMasterDirective(const OMPMasterDirective &s)
mlir::LogicalResult emitOMPMetaDirective(const OMPMetaDirective &s)
mlir::LogicalResult emitOMPDistributeSimdDirective(const OMPDistributeSimdDirective &s)
CIRGenBuilderTy & getBuilder()
mlir::LogicalResult emitOMPParallelGenericLoopDirective(const OMPParallelGenericLoopDirective &s)
mlir::LogicalResult emitOMPMaskedDirective(const OMPMaskedDirective &s)
mlir::LogicalResult emitOMPSplitDirective(const OMPSplitDirective &s)
mlir::MLIRContext & getMLIRContext()
mlir::LogicalResult emitOMPTargetExitDataDirective(const OMPTargetExitDataDirective &s)
mlir::LogicalResult emitOMPOrderedBlockAssocDirective(const OMPOrderedBlockAssocDirective &s)
mlir::LogicalResult emitOMPTargetTeamsDistributeParallelForDirective(const OMPTargetTeamsDistributeParallelForDirective &s)
mlir::LogicalResult emitOMPParallelForDirective(const OMPParallelForDirective &s)
mlir::LogicalResult emitOMPSectionsDirective(const OMPSectionsDirective &s)
mlir::LogicalResult emitOMPDistributeDirective(const OMPDistributeDirective &s)
mlir::LogicalResult emitOMPTargetTeamsDistributeParallelForSimdDirective(const OMPTargetTeamsDistributeParallelForSimdDirective &s)
mlir::LogicalResult emitOMPTargetTeamsGenericLoopDirective(const OMPTargetTeamsGenericLoopDirective &s)
mlir::LogicalResult emitOMPTeamsDistributeSimdDirective(const OMPTeamsDistributeSimdDirective &s)
mlir::LogicalResult emitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &s)
clang::ASTContext & getContext() const
mlir::LogicalResult emitOMPParallelMasterTaskLoopDirective(const OMPParallelMasterTaskLoopDirective &s)
mlir::LogicalResult emitStmt(const clang::Stmt *s, bool useCurrentScope, llvm::ArrayRef< const Attr * > attrs={})
mlir::LogicalResult emitOMPCancelDirective(const OMPCancelDirective &s)
mlir::LogicalResult emitOMPStripeDirective(const OMPStripeDirective &s)
mlir::LogicalResult emitOMPTargetTeamsDistributeDirective(const OMPTargetTeamsDistributeDirective &s)
mlir::LogicalResult emitOMPParallelSectionsDirective(const OMPParallelSectionsDirective &s)
mlir::LogicalResult emitOMPTargetSimdDirective(const OMPTargetSimdDirective &s)
mlir::LogicalResult emitOMPAssumeDirective(const OMPAssumeDirective &s)
This class organizes the cross-function state that is used while generating CIR code.
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
Emits OpenMP clauses for a directive, writing results into the auto-generated ClauseOps from the OMP ...
mlir::LogicalResult emitNYI(OpenMPNYIClauseList< NYIClauses... > nyi, llvm::omp::Directive directive) const
Verify the clauses of a directive to make sure all legal cases are either implemented or give a NYI e...
bool emitMap(mlir::omp::MapClauseOps &result, llvm::SmallVectorImpl< const VarDecl * > *mapSyms=nullptr) const
Emit map clauses.
bool emitIf(mlir::omp::IfClauseOps &result, llvm::omp::Directive directiveName) const
bool emitProcBind(mlir::omp::ProcBindClauseOps &result) const
bool emitNumThreads(mlir::omp::NumThreadsClauseOps &result) const
This captures a statement into a function.
Definition Stmt.h:3949
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition Stmt.h:4053
capture_range captures()
Definition Stmt.h:4087
This represents clause 'allocate' in the 'pragma omp ...' directives.
This represents 'default' clause in the 'pragma omp ...' directive.
This represents 'if' clause in the 'pragma omp ...' directive.
This represents 'num_threads' clause in the 'pragma omp ...' directive.
Represents a variable declaration or definition.
Definition Decl.h:933
bool isLastItemInQueue(ConstructQueue::const_iterator item, const ConstructQueue &queue)
llvm::SmallVector< LeafWithClauses > ConstructQueue
ConstructQueue buildConstructQueue(unsigned openmpVersion, const OMPExecutableDirective &s)
Given a potentially compound directive with a list of clauses that apply to it, break it up into indi...
Top level wrappers for InstallAPI frontend operations.
Represents a scope, including function bodies, compound statements, and the substatements of if/while...
A type-only list of OpenMP clause AST node types.