[flang-commits] [openmp] [flang] [mlir] [Flang][OpenMP] Initial mapping of Fortran pointers and allocatables for target devices (PR #71766)

via flang-commits flang-commits at lists.llvm.org
Fri Nov 10 10:30:46 PST 2023


================
@@ -1718,11 +1737,38 @@ llvm::Value *getSizeInBytes(DataLayout &dl, const mlir::Type &type,
       return builder.CreateMul(elementCount,
                                builder.getInt64(underlyingTypeSzInBits / 8));
     }
+
+    // The case for allocatables that are not arrays, could perhaps treat these
+    // as just pointer size
+    if (memberClause.getBounds().empty() &&
+        memberClause.getIsFortranAllocatable()) {
+      return builder.CreateLoad(
+          builder.getInt64Ty(),
+          builder.CreateGEP(baseType, basePointer,
+                            std::vector<llvm::Value *>{builder.getInt64(0),
+                                                       builder.getInt32(1)},
+                            "element_size"));
+    }
   }
 
   return builder.getInt64(underlyingTypeSzInBits / 8);
 }
 
+// Get the underlying LLVM type, this will bypass the pointer and
+// access the underlying type. Which bypasses llvm's opaque pointers
+// to get the underlying type via MLIR.
+llvm::Type *getLLVMIRType(mlir::Type inputType,
+                          LLVM::ModuleTranslation &moduleTranslation) {
+  llvm::Type *type = moduleTranslation.convertType(inputType);
+  if (auto pointerType =
+          llvm::dyn_cast<mlir::omp::PointerLikeType>(inputType)) {
+    if (auto eleType = pointerType.getElementType()) {
----------------
agozillon wrote:

Yes, sorry, this was a bit of an oversight when I created the PR from the downstream branch, I'll remove it. 

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


More information about the flang-commits mailing list