[cfarm-users] PowerPC 32 bit abi on gcc110.fsffrance.org

Paulo César Pereira de Andrade paulo.cesar.pereira.de.andrade at gmail.com
Mon Sep 9 21:39:56 CEST 2019


Em sáb, 7 de set de 2019 às 21:39, Bruno Haible <bruno at clisp.org> escreveu:

  Hi  Bruno and thanks to all that replied.

> >   Just testing for hopefully soon new release of GNU Lightning, I noticed
> > now when building with -m32 it appears to have a different abi that I
> > could not find any description searching on google; probably I did not
> > search enough..
>
> Generally you find this info in the GCC sources, more precisely in
> gcc/config/rs6000/rs6000.[hc]. But it's easy to misunderstand these
> macro definitions. To get a reliable understanding, I compile specific
> C functions [1] with "gcc -S -O2" and look at the generated code.
>
> On 32-bit PowerPC, there are essentially two ABIs: "AIX" and "SysV.4".
>
> Argument passing conventions are as follows:
>
>   All arguments, except the first 8 words, are passed on the stack with
>   word alignment. Doubles take two words. The first 13 doubles and floats
>   are also passed in floating-point-registers.
>   To return a structure, the called function copies the value to space
>   pointed to by its first argument, and all other arguments are shifted
>   down by one.
>
>   Differences between AIX and SysV.4 argument passing conventions:
>   - AIX: the first 13 doubles and floats are passed in FP registers,
>          and when they do, there is still room allocated for them in the
>          argument sequence (integer regs or stack).
>     SysV.4: the first 8 doubles and floats are passed in FP registers,
>          and no room is allocated for them in the argument sequence.
>   - AIX: Structures are passed in the argument sequence, possibly partially
>          in registers and partially on the stack. But stack room is
>          reserved for the parts that are passed in registers, so that it's
>          not too expensive to take the address of such a struct in C.
>     SysV.4: Structures are passed by reference: only a pointer appears in
>          the argument sequence.
>   - AIX: Long longs are only word aligned.
>     SysV.4: Long longs are two-word aligned, both when passed in registers
>          (pairs: 3/4, 5/6, 7/8, 9/10) and when passed on the stack. (Recall
>          that the stack is always 8-byte aligned).
>
> Linux uses the SysV.4 ABI. (Does anyone know of a non-Linux platform that
> also uses the SysV.4 ABI?)
>
> AIX and Mac OS X use the AIX ABI, with a difference in a detail:
> Small structures (less than a word large) are passed left-adjusted by AIX xlc,
> but right-adjusted by GCC on AIX and on Mac OS X.
>
> All this does not take into account varargs calls. Note that for varargs calls,
> different compilers have a different notion of what a "varargs call" is. On
> HP-PA (I know it doesn't help you directly - just to highlight the potential
> issue) for the HP compiler, a "varargs call" is a call done through a function
> pointer or directly to a function declared with a varargs prototype; whereas
> for GCC, a "varargs call" is when the function's type is a varargs function.
> When in doubt, you can put the floating-point values into the general registers
> and the floating-point registers (in the AIX ABI).

  Long story short. I believe previously I had tested powerpc 32 bit abi
only on AIX, when snakebite.org was available. It was really a long time
since I last touched the powerpc 32 bit abi logic...

  When testing on gcc110.fsffrance.org I got confused as there were no
function descriptors, and the float abi to call varargs functions did
not match.

  Now I understand what is wrong, and why I got confused :)

> Bruno
>
> [1] https://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=blob;f=testcases.c

Thanks,
Paulo


More information about the cfarm-users mailing list