clang 22.0.0git
CIRGenOpenMPClause.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 clause nodes as CIR code.
10//
11//===----------------------------------------------------------------------===//
12
13#include "CIRGenFunction.h"
14#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
15
16using namespace clang;
17using namespace clang::CIRGen;
18
19namespace {
20template <typename OpTy>
21class OpenMPClauseCIREmitter final
22 : public ConstOMPClauseVisitor<OpenMPClauseCIREmitter<OpTy>> {
23 OpTy &operation;
24 CIRGen::CIRGenFunction &cgf;
25 CIRGen::CIRGenBuilderTy &builder;
26
27public:
28 OpenMPClauseCIREmitter(OpTy &operation, CIRGen::CIRGenFunction &cgf,
29 CIRGen::CIRGenBuilderTy &builder)
30 : operation(operation), cgf(cgf), builder(builder) {}
31
32 void VisitOMPClause(const OMPClause *clause) {
33 cgf.cgm.errorNYI(clause->getBeginLoc(), "OpenMPClause ",
34 clause->getClauseKind());
35 }
36
37 void emitClauses(ArrayRef<const OMPClause *> clauses) {
38 for (const auto *c : clauses)
39 this->Visit(c);
40 }
41};
42template <typename OpTy>
43auto makeClauseEmitter(OpTy &op, CIRGen::CIRGenFunction &cgf,
44 CIRGen::CIRGenBuilderTy &builder) {
45 return OpenMPClauseCIREmitter<OpTy>(op, cgf, builder);
46}
47} // namespace
48
49template <typename Op>
50void CIRGenFunction::emitOpenMPClauses(Op &op,
52 mlir::OpBuilder::InsertionGuard guardCase(builder);
53 builder.setInsertionPoint(op);
54 makeClauseEmitter(op, *this, builder).emitClauses(clauses);
55}
56
57// We're defining the template for this in a .cpp file, so we have to explicitly
58// specialize the templates.
59#define EXPL_SPEC(N) \
60 template void CIRGenFunction::emitOpenMPClauses<N>( \
61 N &, ArrayRef<const OMPClause *>);
62EXPL_SPEC(mlir::omp::ParallelOp)
63#undef EXPL_SPEC
#define EXPL_SPEC(N)
__device__ __2f16 float c
SourceLocation getBeginLoc() const
Returns the starting location of the clause.
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
The JSON file list parser is used to communicate input to InstallAPI.