[LLVMdev] selecting select_cc

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Aug 21 13:09:10 PDT 2006


I am trying to add support for select_cc. In ARM it can be implemented with:

mov $dst, $falseVal
cmp $a, $b
moveq $dst, $trueVal

My current strategy is to expand select_cc in two ARM nodes:
ARM::SELECT and ARM::CMP.  The two nodes would be connected by a flag
edge.

ARM::CMP would then expand to "cmp $a, $b". This instruction has no
results. It only alters the CPSR (current program status register).

ARM::SELECT would expand to a conditional move (moveq for example).
Something similar is done by the Alpha backend:

---------------------------------------------------------------------------------------------
def CMOVEQ   : OForm4<  0x11, 0x24, "cmoveq $RCOND,$RTRUE,$RDEST",
                [(set GPRC:$RDEST, (select (seteq GPRC:$RCOND, 0),
GPRC:$RTRUE, GPRC:$RFALSE))], s_cmov>;
----------------------------------------------------------------------------------------------

One thing that I don't understand is how the $RFALSE value is used.
$RDEST must equal $RFALSE before the cmov is executed. How does the
Alpha backend enforces this?

Thanks,
Rafael



More information about the llvm-dev mailing list