Emitting PPC branches


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.