25 return mlir::omp::ClauseMapFlags::to;
27 return mlir::omp::ClauseMapFlags::from;
29 return mlir::omp::ClauseMapFlags::to | mlir::omp::ClauseMapFlags::from;
31 case OMPC_MAP_release:
32 return mlir::omp::ClauseMapFlags::storage;
34 return mlir::omp::ClauseMapFlags::del;
36 return mlir::omp::ClauseMapFlags::none;
41 mlir::OpBuilder &builder,
42 mlir::Location loc,
const VarDecl *vd,
43 mlir::omp::ClauseMapFlags mapFlags) {
46 auto varPtrType = mlir::cast<cir::PointerType>(varPtr.getType());
47 mlir::Type elementType = varPtrType.getPointee();
50 if (varPtrType.getAddrSpace()) {
52 cir::PointerType::get(builder.getContext(), elementType);
53 varPtr = cir::CastOp::create(builder, loc, genericPtrType,
54 cir::CastKind::address_space, varPtr);
55 varPtrType = genericPtrType;
58 return mlir::omp::MapInfoOp::create(
62 mlir::TypeAttr::get(elementType),
63 builder.getAttr<mlir::omp::ClauseMapFlagsAttr>(mapFlags),
65 builder.getAttr<mlir::omp::VariableCaptureKindAttr>(
66 mlir::omp::VariableCaptureKind::ByRef),
72 mlir::FlatSymbolRefAttr{},
73 builder.getStringAttr(vd->
getName()),
74 builder.getBoolAttr(
false));
78 mlir::omp::ProcBindClauseOps &result)
const {
80 const auto *pbc = dyn_cast<OMPProcBindClause>(clause);
84 llvm::omp::ProcBindKind
kind = pbc->getProcBindKind();
85 assert(
kind != llvm::omp::ProcBindKind::OMP_PROC_BIND_unknown &&
86 "unknown proc-bind kind");
88 if (
kind != llvm::omp::ProcBindKind::OMP_PROC_BIND_default)
89 result.procBindKind = mlir::omp::ClauseProcBindKindAttr::get(
90 builder.getContext(), mlir::omp::convertProcBindKind(
kind));
97 mlir::omp::MapClauseOps &result,
100 for (
const OMPClause *clause : clauses) {
101 const auto *mc = dyn_cast<OMPMapClause>(clause);
109 cgm.errorNYI(mc->getBeginLoc(),
110 std::string(
"OpenMP map modifier '") +
112 llvm::omp::Clause::OMPC_map, mod) +
116 if (mc->isImplicit()) {
117 cgm.errorNYI(mc->getBeginLoc(),
"OpenMP implicit map clause");
123 for (
const Expr *varExpr : mc->varlist()) {
124 const auto *refExpr = dyn_cast<DeclRefExpr>(varExpr->IgnoreImplicit());
126 cgm.errorNYI(varExpr->getExprLoc(),
127 "OpenMP map clause with non-DeclRefExpr variable");
131 const auto *vd = dyn_cast<VarDecl>(refExpr->getDecl());
133 cgm.errorNYI(varExpr->getExprLoc(),
134 "OpenMP map clause with non-VarDecl variable");
138 result.mapVars.push_back(
141 mapSyms->push_back(vd);
static mlir::Value emitMapInfoForVar(CIRGenFunction &cgf, mlir::OpBuilder &builder, mlir::Location loc, const VarDecl *vd, mlir::omp::ClauseMapFlags mapFlags)