[LLVMdev] [PowerPC] ABI questions
Iain Sandoe
iain at codesourcery.com
Fri Aug 1 07:39:11 PDT 2014
Hi Jonas
On 1 Aug 2014, at 14:19, Jonas Maebe wrote:
> On 30 Jul 2014, at 21:29, Ulrich Weigand wrote:
>
>> The ELFv1 ABI is used on 64-bit big-endian Linux and AIX.
>
> There's one small difference between the two: with the 64 bit ELFv1/SVR4 ABI, tail padding for structs passed by value is only performed in case the struct is larger than 8 bytes, while for AIX 64 bit it's always done. As an aside, on Darwin/ppc64 it's done if the aggregate's size is not in [1,2,4].
JFTR,
1/ The darwin ppc64 case is, indeed, relatively sane (but darwin ppc64 is not yet implemented in clang or llvm).
2/ The Darwin ppc32 struct layout case is more complex (also inherited from AIX).
See "Mac OS X ABI Function Call Guide" (Feb 2009) [Apple]
- 32-bit PowerPC Calling Conventions
- Data Types and Alignments (Power case, which is the default).
I have almost completed an implementation of this ABI and hope to post patches in the next few weeks (test cases to make and polishing needed).
As of now, effectively, clang has "no detailed idea" of the Darwin PPC32 or PPC64 ABIs (except in so much as they are 32/64 bit RISCish) it is really quite amazing that any code works at all.
Iain
> For an example, look at the assembly code for the program below. I don't have the setup to compile for Linux/AIX PPC64 with clang, so I don't know what LLVM does right now (I performed the tests with gcc).
>
>
> Jonas
>
> ***
> struct str7 {
> char a[7];
> };
>
> int f7(struct str7 s)
> {
> return s.a[0]+s.a[6];
> }
>
> int main(int argc)
> {
> struct str7 s7;
> s7.a[0]=argc;
> s7.a[6]=argc;
> return f7(s7);
> }
> ***
>
> - Linux/ppc64 (gcc 4.7.2):
>
> main:
> [initialise s7 on stack]
> ld 9,112(31)
> srdi 3,9,8 ; shift struct into least significant bits = remove tail padding
> bl f7
>
>
> - AIX/ppc64 (gcc 4.8.1):
>
> [initialise s7, identical code as on Linux]
> ld 3,112(31) ; keep struct aligned in most signifcant bits (i.e., with tail padding)
> bl .f7
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list