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]. 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140801/a5f5913f/attachment.html>
Jonas Maebe <jonas.maebe at elis.ugent.be> wrote on 01.08.2014 15:19:29:> 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].Ah, right, that's still a special case on AIX.> 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).Well, LLVM follows the Linux variant. I don't think we really support AIX in LLVM anyway at this point ... Bye, Ulrich
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
On 01 Aug 2014, at 16:39, Iain Sandoe wrote:> On 1 Aug 2014, at 14:19, Jonas Maebe wrote: > >> 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).Well, its requirement to pass individual floating point and vector fields of structs as if they were passed as separate parameters while packing everything else still together into integer registers is another matter...> 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 know, I've implemented the parameter passing for ppc32 for Linux, Mac OS X and AIX in our own compiler :) (and I'm currently working on cleaning up the 64 bit ppc parameter passing while adding support for ELFv2). In general, I consider the Darwin/ppc32 ABI much easier than the Darwin/ppc64 ABI.> 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.Absolutely! I guess the main reason is that very few system APIs make use of call-by-value struct parameters. For "project-internal" code, it doesn't really matter what you use as long as it's the same everywhere. Jonas