@@ -969,8 +969,10 @@ void ClauseProcessor::processMapObjects(
969969 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
970970 std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
971971 llvm::SmallVectorImpl<mlir::Value> &mapVars,
972- llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms) const {
972+ llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
973+ std::string mapperIdName) const {
973974 fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
975+ mlir::FlatSymbolRefAttr mapperId;
974976
975977 for (const omp::Object &object : objects) {
976978 llvm::SmallVector<mlir::Value> bounds;
@@ -1003,6 +1005,20 @@ void ClauseProcessor::processMapObjects(
10031005 }
10041006 }
10051007
1008+ if (!mapperIdName.empty ()) {
1009+ if (mapperIdName == " default" ) {
1010+ auto &typeSpec = object.sym ()->owner ().IsDerivedType ()
1011+ ? *object.sym ()->owner ().derivedTypeSpec ()
1012+ : object.sym ()->GetType ()->derivedTypeSpec ();
1013+ mapperIdName = typeSpec.name ().ToString () + " .default" ;
1014+ mapperIdName = converter.mangleName (mapperIdName, *typeSpec.GetScope ());
1015+ }
1016+ assert (converter.getMLIRSymbolTable ()->lookup (mapperIdName) &&
1017+ " mapper not found" );
1018+ mapperId = mlir::FlatSymbolRefAttr::get (&converter.getMLIRContext (),
1019+ mapperIdName);
1020+ mapperIdName.clear ();
1021+ }
10061022 // Explicit map captures are captured ByRef by default,
10071023 // optimisation passes may alter this to ByCopy or other capture
10081024 // types to optimise
@@ -1016,7 +1032,8 @@ void ClauseProcessor::processMapObjects(
10161032 static_cast <
10171033 std::underlying_type_t <llvm::omp::OpenMPOffloadMappingFlags>>(
10181034 mapTypeBits),
1019- mlir::omp::VariableCaptureKind::ByRef, baseOp.getType ());
1035+ mlir::omp::VariableCaptureKind::ByRef, baseOp.getType (), false ,
1036+ mapperId);
10201037
10211038 if (parentObj.has_value ()) {
10221039 parentMemberIndices[parentObj.value ()].addChildIndexAndMapToParent (
@@ -1047,6 +1064,7 @@ bool ClauseProcessor::processMap(
10471064 const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t ;
10481065 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
10491066 llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
1067+ std::string mapperIdName;
10501068 // If the map type is specified, then process it else Tofrom is the
10511069 // default.
10521070 Map::MapType type = mapType.value_or (Map::MapType::Tofrom);
@@ -1090,13 +1108,17 @@ bool ClauseProcessor::processMap(
10901108 " Support for iterator modifiers is not implemented yet" );
10911109 }
10921110 if (mappers) {
1093- TODO (currentLocation,
1094- " Support for mapper modifiers is not implemented yet" );
1111+ assert (mappers->size () == 1 && " more than one mapper" );
1112+ mapperIdName = mappers->front ().v .id ().symbol ->name ().ToString ();
1113+ if (mapperIdName != " default" )
1114+ mapperIdName = converter.mangleName (
1115+ mapperIdName, mappers->front ().v .id ().symbol ->owner ());
10951116 }
10961117
10971118 processMapObjects (stmtCtx, clauseLocation,
10981119 std::get<omp::ObjectList>(clause.t ), mapTypeBits,
1099- parentMemberIndices, result.mapVars , *ptrMapSyms);
1120+ parentMemberIndices, result.mapVars , *ptrMapSyms,
1121+ mapperIdName);
11001122 };
11011123
11021124 bool clauseFound = findRepeatableClause<omp::clause::Map>(process);
0 commit comments