I am in the process of porting our target to GlobalISel and have encountered the following problem. In our target, the predicate for conditional branching is placed on the branch instruction instead of the compare instruction. To make this work in our SelectionISel-based implementation, we declare our own nodes, e.g.:
def XYZ_COMPARE_SIGNED : SDNode<“XYZISD::COMPARE_SIGNED”, SDT_PHXiCmp, [SDNPHasChain, SDNPOutGlue]>;
During legalization, we lower BR_CC nodes into:
These are then used for pattern matching, e.g.:
def : Pat<(XYZ_COMPARE_SIGNED i16:$src1, (i16 Imm_m32768_32767_i16:$SImm)), (cmp_nimm16_a16 $src1, imm:$SImm)>;
Now to my question: What is the best way to achieve the same thing in GlobalISel? Is it possible to introduce new node types in GlobalISel? If so, how? If not, what’s a suitable work-around that allows me to reuse the tablegen-declared patterns?