Hi all, I'm trying to understand which ABIs are supported in the PowerPC backend and I'm getting a bit confused. Here's what I've gathered so far alongside with some questions. - In PPCSubtarget.h there's DarwinABI, SVR4ABI and ELFv2ABI. - The CodeGenerator documentation claims that the AIX PowerPC ABI is followed (with some deviations). Is this refering to the DarwinABI? - In a recent commit a TargetABI value and enumeration was added to PPCSubtarget which contains PPC_ABI_UNKNOWN, PPC_ABI_ELFv1 and PPC_ABI_ELFv2. For 64-bit non-Darwin the TargetABI value is set to either ELF-variant in resetSubtargetFeatures(...) based on endianess (unless explicitly set previously). As I understand it ELFv2 is a new ABI but which ABI does ELFv1 map to? - Since isSVR4ABI() is defined as !isDarwin() it currently is possible for SVR4 and ELFv2 to be true at the same time which doesn't seem correct to me. - My understanding of SVR4ABI have been that it is the 32-bit PPC processor supplement from Sun. Is this correct? If so, which ABI is used for 64-bit non-Darwin? I'm trying to implement the PPC EABI (which is based on the SVR4ABI) for an out-of-tree subtarget which means I need to understand the current status a bit better. Best regards David
Hi David,> I'm trying to understand which ABIs are supported in the PowerPC > backend and I'm getting a bit confused. Here's what I've gathered so > far alongside with some questions.Sorry for the confusion, this all should probably be cleaned up a bit. In general, LLVM today supports the following ABIs: - The Darwin ABI (32-bit and 64-bit flavors) - The 32-bit SVR4 ABI - Two variants of the 64-bit SVR4 ABI: ELFv1 and ELFv2 The ELFv1 ABI is used on 64-bit big-endian Linux and AIX. The ELFv2 ABI is used on 64-bit little-endian Linux. Unfortunately, the term "SVR4" is quite overloaded, and applies both to the 32-bit and the 64-bit ABIs, even though they are quite different. "ELF ABI" is used interchangably with "SVR4 ABI". ELFv1 is a recently introduced term to refer to what was previously just called the ELF ABI (or equivalently SVR4 ABI); it is now used to refer to the *old* variant of the ELF ABI as opposed to the new one (ELFv2).> - In PPCSubtarget.h there's DarwinABI, SVR4ABI and ELFv2ABI. > - The CodeGenerator documentation claims that the AIX PowerPC ABI is > followed (with some deviations). Is this refering to the DarwinABI?No, that's the ELFv1 ABI.> - In a recent commit a TargetABI value and enumeration was added to > PPCSubtarget which contains PPC_ABI_UNKNOWN, PPC_ABI_ELFv1 and > PPC_ABI_ELFv2. For 64-bit non-Darwin the TargetABI value is set to > either ELF-variant in resetSubtargetFeatures(...) based on endianess > (unless explicitly set previously). As I understand it ELFv2 is a new > ABI but which ABI does ELFv1 map to?I hope the above makes it clearer.> - Since isSVR4ABI() is defined as !isDarwin() it currently is possible > for SVR4 and ELFv2 to be true at the same time which doesn't seem > correct to me.isSVR4ABI is true for either ELFv1 or ELFv2, and also for the 32-bit SVR4 ABI. This should probably be cleaned up by having three separate predicates ...> - My understanding of SVR4ABI have been that it is the 32-bit PPC > processor supplement from Sun. Is this correct? If so, which ABI is > used for 64-bit non-Darwin?SVR4 has always been used for either the 32-bit or 64-bit ELF ABIs (*both* are processor supplement documents based on the original Sun ELF/SVR4 ABI).> I'm trying to implement the PPC EABI (which is based on the SVR4ABI) > for an out-of-tree subtarget which means I need to understand the > current status a bit better.It's up to Hal, but I'd suggest to split up the isSVR4ABI predicate into three separate options, e.g. isSVR4ABI (or maybe isSVR4_32ABI), isELFv1ABI, and isELFv2ABI; and then add another one for your new ABI. Bye, Ulrich
Hello Ulrich, Thank you for a good explanation of the different variants. 2014-07-30 21:29 GMT+02:00 Ulrich Weigand <Ulrich.Weigand at de.ibm.com>:> Hi David, > >> I'm trying to understand which ABIs are supported in the PowerPC >> backend and I'm getting a bit confused. Here's what I've gathered so >> far alongside with some questions. > > Sorry for the confusion, this all should probably be cleaned up a bit. > In general, LLVM today supports the following ABIs: > - The Darwin ABI (32-bit and 64-bit flavors) > - The 32-bit SVR4 ABI > - Two variants of the 64-bit SVR4 ABI: ELFv1 and ELFv2 > > The ELFv1 ABI is used on 64-bit big-endian Linux and AIX. > The ELFv2 ABI is used on 64-bit little-endian Linux. > > Unfortunately, the term "SVR4" is quite overloaded, and applies > both to the 32-bit and the 64-bit ABIs, even though they are > quite different. "ELF ABI" is used interchangably with "SVR4 ABI". > > ELFv1 is a recently introduced term to refer to what was previously > just called the ELF ABI (or equivalently SVR4 ABI); it is now used > to refer to the *old* variant of the ELF ABI as opposed to the new > one (ELFv2). > >> - In PPCSubtarget.h there's DarwinABI, SVR4ABI and ELFv2ABI. >> - The CodeGenerator documentation claims that the AIX PowerPC ABI is >> followed (with some deviations). Is this refering to the DarwinABI? > > No, that's the ELFv1 ABI. >But it describes both 64-bit and 32-bit linkage areas. Doesn't that imply that it isn't ELFv1? Just to be clear the document I'm talking about is: http://llvm.org/docs/CodeGenerator.html#llvm-powerpc-abi - David>> - In a recent commit a TargetABI value and enumeration was added to >> PPCSubtarget which contains PPC_ABI_UNKNOWN, PPC_ABI_ELFv1 and >> PPC_ABI_ELFv2. For 64-bit non-Darwin the TargetABI value is set to >> either ELF-variant in resetSubtargetFeatures(...) based on endianess >> (unless explicitly set previously). As I understand it ELFv2 is a new >> ABI but which ABI does ELFv1 map to? > > I hope the above makes it clearer. > >> - Since isSVR4ABI() is defined as !isDarwin() it currently is possible >> for SVR4 and ELFv2 to be true at the same time which doesn't seem >> correct to me. > > isSVR4ABI is true for either ELFv1 or ELFv2, and also for the 32-bit > SVR4 ABI. This should probably be cleaned up by having three separate > predicates ... > >> - My understanding of SVR4ABI have been that it is the 32-bit PPC >> processor supplement from Sun. Is this correct? If so, which ABI is >> used for 64-bit non-Darwin? > > SVR4 has always been used for either the 32-bit or 64-bit ELF ABIs > (*both* are processor supplement documents based on the original > Sun ELF/SVR4 ABI). > >> I'm trying to implement the PPC EABI (which is based on the SVR4ABI) >> for an out-of-tree subtarget which means I need to understand the >> current status a bit better. > > It's up to Hal, but I'd suggest to split up the isSVR4ABI predicate > into three separate options, e.g. isSVR4ABI (or maybe isSVR4_32ABI), > isELFv1ABI, and isELFv2ABI; and then add another one for your new > ABI. > > Bye, > Ulrich > >
----- Original Message -----> From: "Ulrich Weigand" <Ulrich.Weigand at de.ibm.com> > To: "David Wiberg" <dwiberg at gmail.com> > Cc: llvmdev at cs.uiuc.edu > Sent: Wednesday, July 30, 2014 2:29:22 PM > Subject: Re: [LLVMdev] [PowerPC] ABI questions > > Hi David, > > > I'm trying to understand which ABIs are supported in the PowerPC > > backend and I'm getting a bit confused. Here's what I've gathered > > so > > far alongside with some questions. > > Sorry for the confusion, this all should probably be cleaned up a > bit. > In general, LLVM today supports the following ABIs: > - The Darwin ABI (32-bit and 64-bit flavors) > - The 32-bit SVR4 ABI > - Two variants of the 64-bit SVR4 ABI: ELFv1 and ELFv2 > > The ELFv1 ABI is used on 64-bit big-endian Linux and AIX. > The ELFv2 ABI is used on 64-bit little-endian Linux. > > Unfortunately, the term "SVR4" is quite overloaded, and applies > both to the 32-bit and the 64-bit ABIs, even though they are > quite different. "ELF ABI" is used interchangably with "SVR4 ABI". > > ELFv1 is a recently introduced term to refer to what was previously > just called the ELF ABI (or equivalently SVR4 ABI); it is now used > to refer to the *old* variant of the ELF ABI as opposed to the new > one (ELFv2). > > > - In PPCSubtarget.h there's DarwinABI, SVR4ABI and ELFv2ABI. > > - The CodeGenerator documentation claims that the AIX PowerPC ABI > > is > > followed (with some deviations). Is this refering to the DarwinABI? > > No, that's the ELFv1 ABI. > > > - In a recent commit a TargetABI value and enumeration was added to > > PPCSubtarget which contains PPC_ABI_UNKNOWN, PPC_ABI_ELFv1 and > > PPC_ABI_ELFv2. For 64-bit non-Darwin the TargetABI value is set to > > either ELF-variant in resetSubtargetFeatures(...) based on > > endianess > > (unless explicitly set previously). As I understand it ELFv2 is a > > new > > ABI but which ABI does ELFv1 map to? > > I hope the above makes it clearer. > > > - Since isSVR4ABI() is defined as !isDarwin() it currently is > > possible > > for SVR4 and ELFv2 to be true at the same time which doesn't seem > > correct to me. > > isSVR4ABI is true for either ELFv1 or ELFv2, and also for the 32-bit > SVR4 ABI. This should probably be cleaned up by having three > separate > predicates ... > > > - My understanding of SVR4ABI have been that it is the 32-bit PPC > > processor supplement from Sun. Is this correct? If so, which ABI is > > used for 64-bit non-Darwin? > > SVR4 has always been used for either the 32-bit or 64-bit ELF ABIs > (*both* are processor supplement documents based on the original > Sun ELF/SVR4 ABI). > > > I'm trying to implement the PPC EABI (which is based on the > > SVR4ABI) > > for an out-of-tree subtarget which means I need to understand the > > current status a bit better. > > It's up to Hal, but I'd suggest to split up the isSVR4ABI predicate > into three separate options, e.g. isSVR4ABI (or maybe isSVR4_32ABI), > isELFv1ABI, and isELFv2ABI; and then add another one for your new > ABI.I'd certainly welcome this. The current state of affairs seems to be the result of evolution more than design, and cleaning this up seems like a good idea. Thanks again, Hal> > Bye, > Ulrich > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory
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>