[LLVMdev] Linux/ppc backend

Chris Lattner sabre at nondot.org
Fri Feb 2 10:38:52 PST 2007

On Fri, 2 Feb 2007, Nicolas Geoffray wrote:
> I have almost completed the implementation of  a linux/ppc backend in llvm.


> There were a few things to modify in
> lib/Target/PowerPC with a lot of "if (!isDarwin)".

Some meta comments:

1. Please don't change PPC -> llvmPPC.  I assume that you did this because
    PPC is a #define in some system header.  Please just add a '#undef PPC'
    where appropriate to make this unneeded.

2. The X86 backend has the unfortunate habit of saying "if !darwin" "if
    !cygwin" etc.  Most of the changes you've made are actually ABI related
    changes, not OS-specific changes.  As such, I'd prefer it if you added
    two methods to PPCSubtarget: isMachoABI() and isELF_ABI() (or whatever
    is the right name of the ABI that linux uses) and use those instead.

3. Please split up the patch into independent chunks for easier review.
    This will make it much more likely that your pieces will be applied in
    a timely fashion :).  This will also let you get pieces in before the
    whole thing is "done".

> 1) In order to generate a creqv instruction before a vararg call, I created a 
> new instruction in PPCInstrInfo.td: SETCR which
> uses the new XForm_1_ext format. It does not use the XForm_1 format because I 
> wanted to give only one register as operand.
> I'm not sure if this is the correct way to do this, but it works.

Yep, that's the right way to go.

> 2) Line 369 of PPCInstrInfo.td, we declare the non-callee saved registers. 
> However, Linux and Darwin do not have the same set
> of non-callee saved registers. I don't know how to make the if(isDarwin) test 
> in here

Take a look at ARM/ARMRegisterInfo.td for an example of this.

> 3) R31, which replaces R1 as stack pointer when there is a dynamic allocation 
> in a method, must be seen as a callee-saved register and must not be saved 
> and restored like it is actually for Darwin. I don't know how to specify 
> that, when there is a dynamic allocation, R31 must be added to the set of 
> registers that are saved before entering the method and restored at the end.

Can you just mark it callee saved?  If so, and if there is an instruction 
in the function that clobbers R31, it should automatically be saved and 

Thanks a lot for doing this, linux/ppc support is a major new feature!



More information about the llvm-dev mailing list