[PATCH, PowerPC] ABI fixes / improvements for powerpc64-linux

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Wed Jul 9 13:06:27 PDT 2014

Ulrich Weigand/Germany/IBM wrote on 09.07.2014 21:54:20:

> Yes, the ABI doc is wrong here.  We'll fix this in the new version
> we're currently working on.  What was intended (and what is
> implemented in GCC today) is somewhat of a mixture of 2 and 3
> above: if the type's alignment requirement is >= 16 byte,  it
> will be passed in the save area at 16 byte alignment.
> The rationale is the this: alignment in the parameter save area
> matters for two reasons:
> - if you take the address of the parameter, it has to be properly
>  aligned, since code is allowed to assume that property;
> - when you access a member of the parameter in place in the save
>   area, the ISA may have alignment requirements; on PowerPC, the
>   only such requirement is 16 byte for VMX loads/stores.
> The reason why an argument in the save area is 16-byte aligned
> is that this will suffice for the second reason above, i.e. it
> is possible to access the argument using VMX instructions.
> If the argument type actually requires > 16 byte alignment,
> and code indeed takes the address of the argument, then the
> compiler will have to copy the incoming argument to another
> place, properly aligned, on the stack.

Oh, and I forgot another reason: the parameter area is at a fixed
place relative to the stack frame, and the stack frame itself is
only guaranteed to be 16 bytes aligned, so we *cannot* guarantee
more than 16 byte alignment for any component of the save area.

The only way to do that is by run-time pointer arithmetic within
a larger block allocated on the stack dynamically, which is how
larger alignments are guaranteed for local variables (and copies
of parameters if necessary).


More information about the cfe-commits mailing list