[llvm-dev] ARM Backend: Emit conditional move

Robert Schilling via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 13 01:36:20 PST 2017


Hi,

I'm trying to emit a conditional move in the ARM backend for a custom 
intrinsic. Basically, I want to emit the following the following 
instruction sequence:

cmp r0, r1
moveq r2, #1

To implement this, I first emit a compare instruction and then I'm 
trying to emit the conditional move, which is failing.

BuildMI(&MBB, DL, TII->get(ARM::CMPrr))
         .addReg(MI.getOperand(1).getReg())
         .addReg(MI.getOperand(2).getReg())
         .addImm(ARMCC::EQ);

BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::MOVr),
               MI.getOperand(0).getReg())
           .addImm(ARMCC::EQ)
           .addImm(1)
           .addReg(0); // 's' bit

But with the last conditional move, I am a bit lost. The result of the 
condional move should be saved in operand 0. Can someone help on how to 
emit this instruction?

Cheers,
Robert


More information about the llvm-dev mailing list