[LLVMdev] Selection Condition Codes

Eli Friedman eli.friedman at gmail.com
Thu Sep 11 20:11:36 PDT 2008


On Thu, Sep 11, 2008 at 6:14 PM, Villmow, Micah <Micah.Villmow at amd.com> wrote:
> I am attempting to lower the selectCC instruction to the instruction set of
> the backend I'm working on and I cannot seem to find a way to correctly
> implement this instruction. I know how this instruction should get
> implemented; I just have yet to find a way to do it. I want the select_cc
> instruction to be lowered into a comparison followed by a conditional move.

"setOperationAction(ISD::SELECT_CC        , MVT::Other, Expand);"
should do the trick; that will prevent SELECT_CC instructions from
being introduced.  This one is easy to miss.

> def CMOVLOG     : InstFormat<(outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS,
> GPR:$TVAL, GPR:$FVAL, CCOp:$cond),

The condition isn't properly an input... this seems likely to confuse
ISel.  I'm not sure, though; I'm not really an expert on patterns, and
they can mess up in non-obvious ways.

> Maybe I'm approaching this from the wrong way, but I don't think this
> transformation should be that difficult.

If you need to transform a construct into multiple instructions, there
are a few different ways; one is a custom lowering, one is a selection
pattern, and another is a custom inserter.  Stuffing multiple actual
instructions into a single target instruction is generally a bad
approach.

-Eli



More information about the llvm-dev mailing list