================ @@ -2701,7 +2701,42 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable, semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval, const parser::OpenMPDeclareMapperConstruct &declareMapperConstruct) { - TODO(converter.getCurrentLocation(), "OpenMPDeclareMapperConstruct"); + fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder(); + lower::StatementContext stmtCtx; + const auto &spec = + std::get<parser::OmpDeclareMapperSpecifier>(declareMapperConstruct.t); + const auto &mapperName{std::get<std::optional<parser::Name>>(spec.t)}; + const auto &varType{std::get<parser::TypeSpec>(spec.t)}; + const auto &varName{std::get<parser::Name>(spec.t)}; + assert(varType.declTypeSpec->category() == + semantics::DeclTypeSpec::Category::TypeDerived && + "Expected derived type"); + + std::string mapperNameStr; + if (mapperName.has_value()) + mapperNameStr = mapperName->ToString(); + else + mapperNameStr = + "default_" + varType.declTypeSpec->derivedTypeSpec().name().ToString(); + + mlir::OpBuilder::InsertPoint insPt = firOpBuilder.saveInsertionPoint(); + firOpBuilder.setInsertionPointToStart(converter.getModuleOp().getBody()); + auto mlirType = converter.genType(varType.declTypeSpec->derivedTypeSpec()); + auto varVal = firOpBuilder.createTemporaryAlloc( + converter.getCurrentLocation(), mlirType, varName.ToString()); ---------------- kiranchandramohan wrote:
Looks like @skatrak is also thinking similarly, see his comment in https://github.com/llvm/llvm-project/pull/117045#discussion_r1858907868 > A new mapper function is emitted, and a pointer to this function is passed on > to the runtime kernel call for target. The OMPRTL takes offload_mappers as > the last argument, which is an array of pointers to the user defined mapper > funcs. If this is the way it is implemented in Clang, I think you can do it this way by creating the mapper function from the MLIR region-based declare mapper specification operation. https://github.com/llvm/llvm-project/pull/117046 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits