================
@@ -496,6 +733,57 @@ class MapInfoFinalizationPass
return false;
}
+ // This function generates an attach map, which is an type of OpenMP map that
+ // binds a pointer to its data, in the case of Fortran, this binding is
+ // primarily for binding the pointer inside of descriptors to the underlying
+ // data pointed to by the descriptor. This is simply an extra map that we
must
+ // emit when generating any map of a descriptor type be it ref_ptr, ref_ptee
+ // or ref_ptr + ref_ptee (ref_ptr_ptee in OpenMP parlance), to bind the
+ // pointer inside of the descriptor to its respective data. The only case
this
+ // can be omitted is when a user has explicitly asked for different attach
+ // semantics e.g. specifying attach(none) as a map modifier, this is the case
+ // where the [[maybe_unused]] attribute is relevant.
+ [[maybe_unused]] mlir::Operation *genImplicitAttachMap(
+ mlir::omp::MapInfoOp descMapOp, mlir::Value descriptor,
+ llvm::SmallVectorImpl<ParentAndPlacement> &mapMemberUsers,
+ mlir::Operation *target, fir::FirOpBuilder &builder,
+ mlir::omp::ClauseMapFlags refFlagType, bool isAttachAlways = false,
+ mlir::Value reuseBaseAddr = mlir::Value{}) {
+ auto baseAddr =
+ reuseBaseAddr
+ ? reuseBaseAddr
+ : fir::BoxOffsetOp::create(builder, descMapOp->getLoc(),
descriptor,
+ fir::BoxFieldAttr::base_addr);
+ mlir::Type underlyingVarType = llvm::cast<mlir::omp::PointerLikeType>(
+ fir::unwrapRefType(baseAddr.getType()))
+ .getElementType();
+ if (auto seqType = llvm::dyn_cast<fir::SequenceType>(underlyingVarType))
+ if (seqType.hasDynamicExtents())
+ underlyingVarType = seqType.getEleTy();
+
+ auto implicitAttachMap = mlir::omp::MapInfoOp::create(
+ builder, descMapOp->getLoc(), descMapOp.getResult().getType(),
+ descriptor,
+ mlir::TypeAttr::get(fir::unwrapRefType(descriptor.getType())),
+ builder.getAttr<mlir::omp::ClauseMapFlagsAttr>(
+ mlir::omp::ClauseMapFlags::attach | refFlagType |
+ (isAttachAlways ? mlir::omp::ClauseMapFlags::always
+ : mlir::omp::ClauseMapFlags::none)),
+ descMapOp.getMapCaptureTypeAttr(), /*varPtrPtr=*/
+ baseAddr, mlir::TypeAttr::get(underlyingVarType),
+ /*members=*/mlir::SmallVector<mlir::Value>{},
+ /*membersIndex=*/mlir::ArrayAttr{},
+ /*bounds=*/descMapOp.getBounds(),
----------------
bhandarkar-pranav wrote:
Do we need to pass on the bounds to the attach map, whose job, semantically is
to simply bind the pointer field of the descriptor to already mapped data?
https://github.com/llvm/llvm-project/pull/177715
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits