This is an archive of the discontinued LLVM Phabricator instance.

[flang] Initial support of lowering derived type passed by value
AbandonedPublic

Authored by peixin on Aug 8 2022, 5:47 AM.

Details

Reviewers
sscalpone
Summary

This initially supports the lowering of derived type passed by value,
which is for the derived type with value attribute and interoperable
with C. The argument passing must be consistent with the ABI in clang,
which is defined in clang/lib/CodeGen/TargetInfo.cpp.

The initial support only contains the AArch64::AAPCS on non-windows OS.
The function result type is not covered in this patch. This patch adds
functions to compute the size and alignment of the derived type on
AArch64, which should be replaced by one general target-diagnostic way.

Diff Detail

Event Timeline

peixin created this revision.Aug 8 2022, 5:47 AM
peixin requested review of this revision.Aug 8 2022, 5:47 AM
peixin updated this revision to Diff 450782.Aug 8 2022, 6:18 AM

Add --target=aarch64-unknown-linux-gnu and ! REQUIRES: shell.

As Jean mentioned during our last call, this is done too early. It is better to perform this in the code gen.

peixin planned changes to this revision.Aug 10 2022, 2:25 AM

As Jean mentioned during our last call, this is done too early. It is better to perform this in the code gen.

Right. After converting to LLVM type for the derived type during code gen, there are some helper functions which can be used such as llvm::IRBuilderBase builder.GetInsertBlock()->getModule()->getDataLayout().getTypeStoreSize(type). I haven't found the function to handle the the alignment, but there should be.

BTW, I found out that the test case when building HDF5 is type(C_PTR), which is different from the usual derived type since the component is the C address, and the ABI for it is different from that for the usual derived type. So, currently I don't need to implement the whole feature. Instead, I plan to support the scenario in HDF5 first and am working on it.

peixin abandoned this revision.Jul 6 2023, 6:16 PM