@@ -936,8 +936,10 @@ void ClauseProcessor::processMapObjects(
936936 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
937937 std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
938938 llvm::SmallVectorImpl<mlir::Value> &mapVars,
939- llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms) const {
939+ llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
940+ std::string mapperIdName) const {
940941 fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
942+ mlir::FlatSymbolRefAttr mapperId;
941943
942944 for (const omp::Object &object : objects) {
943945 llvm::SmallVector<mlir::Value> bounds;
@@ -970,6 +972,20 @@ void ClauseProcessor::processMapObjects(
970972 }
971973 }
972974
975+ if (!mapperIdName.empty ()) {
976+ if (mapperIdName == " default" ) {
977+ auto &typeSpec = object.sym ()->owner ().IsDerivedType ()
978+ ? *object.sym ()->owner ().derivedTypeSpec ()
979+ : object.sym ()->GetType ()->derivedTypeSpec ();
980+ mapperIdName = typeSpec.name ().ToString () + " .default" ;
981+ mapperIdName = converter.mangleName (mapperIdName, *typeSpec.GetScope ());
982+ }
983+ assert (converter.getMLIRSymbolTable ()->lookup (mapperIdName) &&
984+ " mapper not found" );
985+ mapperId = mlir::FlatSymbolRefAttr::get (&converter.getMLIRContext (),
986+ mapperIdName);
987+ mapperIdName.clear ();
988+ }
973989 // Explicit map captures are captured ByRef by default,
974990 // optimisation passes may alter this to ByCopy or other capture
975991 // types to optimise
@@ -983,7 +999,8 @@ void ClauseProcessor::processMapObjects(
983999 static_cast <
9841000 std::underlying_type_t <llvm::omp::OpenMPOffloadMappingFlags>>(
9851001 mapTypeBits),
986- mlir::omp::VariableCaptureKind::ByRef, baseOp.getType ());
1002+ mlir::omp::VariableCaptureKind::ByRef, baseOp.getType (), false ,
1003+ mapperId);
9871004
9881005 if (parentObj.has_value ()) {
9891006 parentMemberIndices[parentObj.value ()].addChildIndexAndMapToParent (
@@ -1014,6 +1031,7 @@ bool ClauseProcessor::processMap(
10141031 const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t ;
10151032 llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
10161033 llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
1034+ std::string mapperIdName;
10171035 // If the map type is specified, then process it else Tofrom is the
10181036 // default.
10191037 Map::MapType type = mapType.value_or (Map::MapType::Tofrom);
@@ -1057,13 +1075,17 @@ bool ClauseProcessor::processMap(
10571075 " Support for iterator modifiers is not implemented yet" );
10581076 }
10591077 if (mappers) {
1060- TODO (currentLocation,
1061- " Support for mapper modifiers is not implemented yet" );
1078+ assert (mappers->size () == 1 && " more than one mapper" );
1079+ mapperIdName = mappers->front ().v .id ().symbol ->name ().ToString ();
1080+ if (mapperIdName != " default" )
1081+ mapperIdName = converter.mangleName (
1082+ mapperIdName, mappers->front ().v .id ().symbol ->owner ());
10621083 }
10631084
10641085 processMapObjects (stmtCtx, clauseLocation,
10651086 std::get<omp::ObjectList>(clause.t ), mapTypeBits,
1066- parentMemberIndices, result.mapVars , *ptrMapSyms);
1087+ parentMemberIndices, result.mapVars , *ptrMapSyms,
1088+ mapperIdName);
10671089 };
10681090
10691091 bool clauseFound = findRepeatableClause<omp::clause::Map>(process);
0 commit comments