[LLVMdev] [PowerPC] ABI questions

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Aug 1 06:19:29 PDT 2014


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>


More information about the llvm-dev mailing list