@@ -969,8 +969,10 @@ void ClauseProcessor::processMapObjects(
969
969
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
970
970
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
971
971
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 {
973
974
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
975
+ mlir::FlatSymbolRefAttr mapperId;
974
976
975
977
for (const omp::Object &object : objects) {
976
978
llvm::SmallVector<mlir::Value> bounds;
@@ -1003,6 +1005,20 @@ void ClauseProcessor::processMapObjects(
1003
1005
}
1004
1006
}
1005
1007
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
+ }
1006
1022
// Explicit map captures are captured ByRef by default,
1007
1023
// optimisation passes may alter this to ByCopy or other capture
1008
1024
// types to optimise
@@ -1016,7 +1032,8 @@ void ClauseProcessor::processMapObjects(
1016
1032
static_cast <
1017
1033
std::underlying_type_t <llvm::omp::OpenMPOffloadMappingFlags>>(
1018
1034
mapTypeBits),
1019
- mlir::omp::VariableCaptureKind::ByRef, baseOp.getType ());
1035
+ mlir::omp::VariableCaptureKind::ByRef, baseOp.getType (), false ,
1036
+ mapperId);
1020
1037
1021
1038
if (parentObj.has_value ()) {
1022
1039
parentMemberIndices[parentObj.value ()].addChildIndexAndMapToParent (
@@ -1047,6 +1064,7 @@ bool ClauseProcessor::processMap(
1047
1064
const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t ;
1048
1065
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
1049
1066
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
1067
+ std::string mapperIdName;
1050
1068
// If the map type is specified, then process it else Tofrom is the
1051
1069
// default.
1052
1070
Map::MapType type = mapType.value_or (Map::MapType::Tofrom);
@@ -1090,13 +1108,17 @@ bool ClauseProcessor::processMap(
1090
1108
" Support for iterator modifiers is not implemented yet" );
1091
1109
}
1092
1110
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 ());
1095
1116
}
1096
1117
1097
1118
processMapObjects (stmtCtx, clauseLocation,
1098
1119
std::get<omp::ObjectList>(clause.t ), mapTypeBits,
1099
- parentMemberIndices, result.mapVars , *ptrMapSyms);
1120
+ parentMemberIndices, result.mapVars , *ptrMapSyms,
1121
+ mapperIdName);
1100
1122
};
1101
1123
1102
1124
bool clauseFound = findRepeatableClause<omp::clause::Map>(process);
0 commit comments