Hi Geraint,
Now that the PGI announcement is public, and I had an opportunity to talk to some other LLVM developers and/with some of the PGI developers...
There are two aspects of the ABI that I know about that are potentially-relevant here:
1. Structure layout
2. Function-call value representation coercion
Regarding (1), I had thought that we'd need to do extensive borrowing from Clang to get the target-ABI-specific aspects of structure layout correct (for structures with BIND(C) attached). I discussed this with Chandler and Bob Scollard (PGI), and their feeling is that this is a non-issue. MOst of the non-trivial layout logic in Clang relates to things like bit fields and other things that are not relevant to Fortran. Just using LLVM structure types should be generally sufficient, and messing around with Clang's logic is not worthwhile for any remaining corner cases.
The issues surrounding (2) might be more difficult. This is essentially the logic in Clang's lib/CodeGen/TargetInfo.cpp, and deals with how various types are marshaled through the IR across function-call boundaries. As my colleagues at IBM reminded me, this can be non-trivial, and touches on some very-lightly-documented contracts between the frontends and the backends in order to comply with ABI requirements (on PowerPC, for example, some types are coerced into arrays for correct argument stack layout and register assignment). A lot of this cannot be done strictly at the IR level because it deals with higher-level types (_Complex, for example, which the IR cannot see directly).
Thus, regarding the ABI task, I think the first task is to study the depth of the problem (the amount of code from lib/CodeGen/TargetInfo.cpp that would need to be duplicated) and decide whether it is worth just duplicating the necessary parts of it (with a Fortran/ISO_C_BINDING theme), or refactoring it so that both Flang and Clang can use it.
> Hi Hal - thanks for the detailed response (and apologies at my end
> for the late reply!). Our new developer starts on Monday, so I'll
> get him started and I'm sure he'll be back here for some more detail
> before long. I agree that work on the ABI design would be a good
> starting point, but from my reading of your note, any actual
> implementation would probably be gated on the successful refactoring
> of the key parts of clang so that flang wouldn't have to reinvent
> them, is that correct?
>
>
> Thanks,
> Geraint.
>
> On Sunday, October 25, 2015 at 3:19:09 PM UTC, hfinkel wrote:
>
> Hi Geraint,
>
> Obviously this is a bit delayed, and I apologize.
>
> For general context: First, we have a repository here (
>
https://github.com/llvm-flang/flang ) with the current source. It
> >
https://groups.google.com/d/msgid/flang-dev/10748581.748.1444074345205.JavaMail.javamailuser%40localhost
> > .
> > For more options, visit
https://groups.google.com/d/optout .
> >
>
> --
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "flang-dev" group.
> To unsubscribe from this group and stop receiving emails from it,
>
https://groups.google.com/d/msgid/flang-dev/20e3bbed-a5d1-4dbd-9d68-f9c67e194f66%40googlegroups.com