[LLVMdev] ABI: how to let the backend know that an aggregate should be allocated on stack

Eli Friedman eli.friedman at gmail.com
Tue Oct 23 16:39:55 PDT 2012


On Tue, Oct 23, 2012 at 11:22 AM, manman ren <mren at apple.com> wrote:
>
> Hi All,
>
> I am trying to handle the Homogeneous Aggregate for ARM-VFP according to the
> spec:
>
> C.1.vfp If the argument is a VFP CPRC and there are sufficient consecutive
> VFP registers of the appropriate type unallocated then the argument is
> allocated to the lowest-numbered sequence of such registers.
>
> C.2.vfp If the argument is a VFP CPRC then any VFP registers that are
> unallocated are marked as unavailable. The NSAA is adjusted upwards until it
> is correctly aligned for the argument and the argument is copied to the
> stack at the adjusted NSAA. The NSAA is further incremented by the size of
> the argument. The argument has now been allocated.
>
> We currently expand the Homogeneous Aggregate in Clang, but that does not
> conform to the standard when we have a few VFP registers available but not
> enough.
>
> In that case, the beginning members of HA will be allocated to VFP, and the
> rest will go on stack.
>
> To fix the problem, it will be great if we can let the backend know the HA
> will be on stack and later VPF CPRCs will be on stack as well.
> There are some discussions on this, at least from the comments in
> TargetInfo.cpp:
> // This assumption is optimistic, as there could be free registers available
> // when we need to pass this argument in memory, and LLVM could try to pass
> // the argument in the free register. This does not seem to happen
> currently,
> // but this code would be much safer if we could mark the argument with
> // 'onstack'. See PR12193.
>
> I am just wondering whether it is necessary to add onstack flag and is there
> any issue related to that?
>
> Another option, suggested by Daniel, is to convert HA to a convenient
> similar type the backend won't pass in registers.
> I tried to pass a struct with vector types, but the backend will expand the
> struct
> See llvm::ComputeValueVTs
> // Given a struct type, recursively traverse the elements.
>
> I tried to use indirect in Clang, it does not work out as I wish.

See MipsABIInfo::getPaddingType; a similar sort of approach should
work here.  (Granted, onstack would be more convenient, but it doesn't
exist at the moment.)

-Eli



More information about the llvm-dev mailing list