[flang-commits] [flang] [flang] AArch64 support for BIND(C) derived return types (PR #114051)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Wed Nov 13 03:01:27 PST 2024
================
@@ -826,19 +826,65 @@ struct TargetAArch64 : public GenericTarget<TargetAArch64> {
return marshal;
}
+ // Flatten a RecordType::TypeList containing more record types or array types
+ static std::optional<std::vector<mlir::Type>>
+ flattenTypeList(const RecordType::TypeList &types) {
+ std::vector<mlir::Type> flatTypes;
+ // The flat list will be at least the same size as the non-flat list.
+ flatTypes.reserve(types.size());
+ for (auto [c, type] : types) {
+ // Flatten record type
+ if (auto recTy = mlir::dyn_cast<RecordType>(type)) {
+ auto subTypeList = flattenTypeList(recTy.getTypeList());
+ if (!subTypeList)
+ return std::nullopt;
+ llvm::copy(*subTypeList, std::back_inserter(flatTypes));
+ continue;
+ }
+
+ // Flatten array type
+ if (auto seqTy = mlir::dyn_cast<SequenceType>(type)) {
+ if (seqTy.hasDynamicExtents())
+ return std::nullopt;
+ std::size_t n = seqTy.getConstantArraySize();
----------------
tblah wrote:
What about dynamic sized arrays?
https://github.com/llvm/llvm-project/pull/114051
More information about the flang-commits
mailing list