[LLVMdev] Emitting PPC branches

Misha Brukman brukman at uiuc.edu
Thu Feb 10 14:05:10 PST 2005


On Thu, Feb 10, 2005 at 03:21:53PM -0600, Brent Monroe wrote:
> I want to take an intrinsic function, and get the PowerPC back
> end to emit:
> 
> loop:  lwarx  ...
>        add    ...
>        stwcx. ...
>        bne- loop
> 
> I can successfully emit:
> 
> lwarx  ...
> add    ...
> stwcx. ...
> 
> How do I emit a label and a branch instruction?

You cannot emit a "label", but you can create a MachineBasicBlock, which
will become a "label" in assembly code, and then you can create a branch
to that MachineBasicBlock.

For an example, see PPC32ISelSimple.cpp, in particular, this function:

  void PPC32ISel::visitSetCondInst(SetCondInst &I) { ... }

towards the end of that function you'll see some asm code in comments
and the LLVM code to create such code.

-- 
Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu




More information about the llvm-dev mailing list