Using branches in lowered operations

Hello,

My expansion for an operation uses if and loops. How do I introduce
branches in the target lowering stage? Do I have to create basic blocks,
add the instructions to them and and add them to the machine function's
basic block list?

Thanks,
Javier

See X86InstrInfo.td
let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
def CMOV_GR8 : I<0, Pseudo,

This creates a CMOV_GR8 pseudo instruction at isel time which can be expanded during scheduling time.

Evan

Hi Evan,

Thanks for the useful pointer. When trying to implement the example to my
situation I ran into a strange issue that I don't know how to resolve.

My target doesn't support 64-bit operations and so far all operations have
been expanded using LLVM except for division and remainder. For division,
LLVM only gives you the option of either calling an external library or
custom lowering the division. If the operation is custom lowered, because
the return type (i64) is not legal, LLVM ends up calling into
ReplaceNodeResults(). ReplaceNodeResults() has the restriction that the
result has to have the same number of values and types. This forces the
lowering function to return a target defined custom i64 node. At the next
legalization cycle ExpandIntegerResults() is called to expand this node
causing an assert because getOperationAction doesn't operate on custom
nodes.

Am I doing something wrong? My goal is to provide an expansion for 64-bit
division that unfortunately uses branches for a target that doesn't support
64-bit integers.

Thanks,
Javier

You should return a BUILD_PAIR of a custom node returning a split result.

-Eli