================ @@ -51,21 +55,66 @@ class OMPMapInfoFinalizationPass : public fir::impl::OMPMapInfoFinalizationPassBase< OMPMapInfoFinalizationPass> { - void genDescriptorMemberMaps(mlir::omp::MapInfoOp op, - fir::FirOpBuilder &builder, - mlir::Operation *target) { - mlir::Location loc = op.getLoc(); - mlir::Value descriptor = op.getVarPtr(); + /// Small helper class tracking a members parent and its + /// placement in the parents member list + struct ParentAndPlacement { + mlir::omp::MapInfoOp parent; + size_t index; + }; - // If we enter this function, but the mapped type itself is not the - // descriptor, then it's likely the address of the descriptor so we - // must retrieve the descriptor SSA. - if (!fir::isTypeWithDescriptor(op.getVarType())) { - if (auto addrOp = mlir::dyn_cast_if_present<fir::BoxAddrOp>( - op.getVarPtr().getDefiningOp())) { - descriptor = addrOp.getVal(); + /// getMemberUserList gathers all users of a particular MapInfoOp that are + /// other MapInfoOp's and places them into the mapMemberUsers list, which + /// records the map that the current argument MapInfoOp "op" is part of + /// alongside the placement of "op" in the recorded users members list. The + /// intent of the generated list is to find all MapInfoOp's that may be + /// considered parents of the passed in "op" and in which it shows up in the + /// member list, alongside collecting the placement information of "op" in its + /// parents member list. + void + getMemberUserList(mlir::omp::MapInfoOp op, + llvm::SmallVectorImpl<ParentAndPlacement> &mapMemberUsers) { + for (auto *users : op->getUsers()) + if (auto map = mlir::dyn_cast_if_present<mlir::omp::MapInfoOp>(users)) + for (size_t i = 0; i < map.getMembers().size(); ++i) + if (map.getMembers()[i].getDefiningOp() == op) + mapMemberUsers.push_back({map, i}); + } + + /// This function will expand a MapInfoOp's member indices back into a vector + /// so that they can be trivially modified as unfortunately the attribute type + /// that's used does not have modifiable fields at the moment (generally + /// awkward to work with) + void getMemberIndicesAsVectors( + mlir::omp::MapInfoOp mapInfo, + llvm::SmallVector<llvm::SmallVector<int32_t>> &indices) { + size_t row = 0; + size_t shapeX = mapInfo.getMembersIndexAttr().getShapedType().getShape()[0]; + size_t shapeJ = mapInfo.getMembersIndexAttr().getShapedType().getShape()[1]; + ---------------- skatrak wrote:
Nit: `indices.reserve(indices.size() + shapeX);` https://github.com/llvm/llvm-project/pull/96266 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits