@@ -936,8 +936,10 @@ void ClauseProcessor::processMapObjects(
936
936
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
937
937
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
938
938
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 {
940
941
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
942
+ mlir::FlatSymbolRefAttr mapperId;
941
943
942
944
for (const omp::Object &object : objects) {
943
945
llvm::SmallVector<mlir::Value> bounds;
@@ -970,6 +972,20 @@ void ClauseProcessor::processMapObjects(
970
972
}
971
973
}
972
974
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
+ }
973
989
// Explicit map captures are captured ByRef by default,
974
990
// optimisation passes may alter this to ByCopy or other capture
975
991
// types to optimise
@@ -983,7 +999,8 @@ void ClauseProcessor::processMapObjects(
983
999
static_cast <
984
1000
std::underlying_type_t <llvm::omp::OpenMPOffloadMappingFlags>>(
985
1001
mapTypeBits),
986
- mlir::omp::VariableCaptureKind::ByRef, baseOp.getType ());
1002
+ mlir::omp::VariableCaptureKind::ByRef, baseOp.getType (), false ,
1003
+ mapperId);
987
1004
988
1005
if (parentObj.has_value ()) {
989
1006
parentMemberIndices[parentObj.value ()].addChildIndexAndMapToParent (
@@ -1014,6 +1031,7 @@ bool ClauseProcessor::processMap(
1014
1031
const auto &[mapType, typeMods, mappers, iterator, objects] = clause.t ;
1015
1032
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
1016
1033
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
1034
+ std::string mapperIdName;
1017
1035
// If the map type is specified, then process it else Tofrom is the
1018
1036
// default.
1019
1037
Map::MapType type = mapType.value_or (Map::MapType::Tofrom);
@@ -1057,13 +1075,17 @@ bool ClauseProcessor::processMap(
1057
1075
" Support for iterator modifiers is not implemented yet" );
1058
1076
}
1059
1077
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 ());
1062
1083
}
1063
1084
1064
1085
processMapObjects (stmtCtx, clauseLocation,
1065
1086
std::get<omp::ObjectList>(clause.t ), mapTypeBits,
1066
- parentMemberIndices, result.mapVars , *ptrMapSyms);
1087
+ parentMemberIndices, result.mapVars , *ptrMapSyms,
1088
+ mapperIdName);
1067
1089
};
1068
1090
1069
1091
bool clauseFound = findRepeatableClause<omp::clause::Map>(process);
0 commit comments