[flang-commits] [flang] [flang][acc] Implement PointerLikeType API gen[Allocate/Free/Copy] (PR #163660)
Razvan Lupusoru via flang-commits
flang-commits at lists.llvm.org
Thu Oct 16 11:31:10 PDT 2025
================
@@ -751,4 +751,226 @@ template bool OpenACCMappableModel<fir::PointerType>::generatePrivateDestroy(
mlir::Type type, mlir::OpBuilder &builder, mlir::Location loc,
mlir::Value privatized) const;
+template <typename Ty>
+mlir::Value OpenACCPointerLikeModel<Ty>::genAllocate(
+ mlir::Type pointer, mlir::OpBuilder &builder, mlir::Location loc,
+ llvm::StringRef varName, mlir::Type varType, mlir::Value originalVar,
+ bool &needsFree) const {
+
+ // Get the element type from the pointer type
+ mlir::Type eleTy = mlir::cast<Ty>(pointer).getElementType();
+
+ // Unlimited polymorphic (class(*)) cannot be handled - size unknown
+ if (fir::isUnlimitedPolymorphicType(eleTy))
+ return {};
+
+ // Character types with dynamic length cannot be handled without a descriptor.
+ if (auto charTy = mlir::dyn_cast<fir::CharacterType>(eleTy))
+ if (charTy.hasDynamicLen())
+ return {};
+
+ // Return null for dynamic or unknown shape arrays because the size of the
+ // allocation cannot be determined simply from the type.
+ if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(eleTy))
+ if (seqTy.hasDynamicExtents() || seqTy.hasUnknownShape())
+ return {};
----------------
razvanlupusoru wrote:
Done
https://github.com/llvm/llvm-project/pull/163660
More information about the flang-commits
mailing list