[llvm-branch-commits] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #111192)

Sergio Afonso via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Oct 22 07:43:23 PDT 2024


================
@@ -58,21 +67,62 @@ class MapInfoFinalizationPass
            /*corresponding local alloca=*/fir::AllocaOp>
       localBoxAllocas;
 
-  void genDescriptorMemberMaps(mlir::omp::MapInfoOp op,
-                               fir::FirOpBuilder &builder,
-                               mlir::Operation *target) {
-    mlir::Location loc = op.getLoc();
-    mlir::Value descriptor = op.getVarPtr();
+  /// 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 (auto [i, mapMember] : llvm::enumerate(map.getMembers()))
+          if (mapMember.getDefiningOp() == op)
+            mapMemberUsers.push_back({map, i});
+  }
+
+  llvm::SmallVector<int64_t>
+  getAsIntegers(llvm::ArrayRef<mlir::Attribute> values) {
+    llvm::SmallVector<int64_t> ints;
+    ints.reserve(values.size());
+    llvm::transform(values, std::back_inserter(ints),
+                    [](mlir::Attribute value) {
+                      return mlir::cast<mlir::IntegerAttr>(value).getInt();
+                    });
+    return ints;
+  }
+
+  /// 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<int64_t>> &indices) {
----------------
skatrak wrote:

```suggestion
      llvm::SmallVectorImpl<llvm::SmallVector<int64_t>> &indices) {
```

https://github.com/llvm/llvm-project/pull/111192


More information about the llvm-branch-commits mailing list