[llvm-branch-commits] [flang] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #96266)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jul 15 06:58:06 PDT 2024
================
@@ -671,4 +672,51 @@ static inline bool isEqual(const Fortran::lower::SomeExpr *x,
}
} // end namespace Fortran::lower
+// OpenMP utility functions used in locations outside of the
+// OpenMP lowering.
+namespace Fortran::lower::omp {
+
+[[maybe_unused]] static void fillMemberIndices(
+ llvm::SmallVector<llvm::SmallVector<int>> &memberPlacementData) {
+ size_t largestIndicesSize =
+ std::max_element(memberPlacementData.begin(), memberPlacementData.end(),
+ [](auto a, auto b) { return a.size() < b.size(); })
+ ->size();
+
+ // DenseElementsAttr expects a rectangular shape for the data, so all
+ // index lists have to be of the same length, this emplaces -1 as filler.
----------------
agozillon wrote:
The DenseElementsAttr construct unfortunately needs to be the same size in all dimensions, so in cases where the index data is not the same length in all dimensions we need some filler, It's a random value that makes some sense to indicate the end of an indice or a non-index value as indices can only be positive. Unfortunately DenseElementsAttr was the only appropriate MLIR attribute I could find for this case and it's a little rough around the edges it seems.
https://github.com/llvm/llvm-project/pull/96266
More information about the llvm-branch-commits
mailing list