This is WIP on iseling icmp, select and branch patterns that involve pointers.
Pointers in GlobalISel have pointer type, unlike SDAG where they have integer type.
Thus GlobalISel selectImpl cannot select pointer instructions from SDAG td files since there are no patterns for pointers there.
It is already possible to write td file for GlobalIsel that will allow selection of pointer patterns.
For that reason I am adding a new td file with additional patterns for pointers, everything from SDAG td files is also included.
Introducing new ValueType, NullPtrValue. It allows to specify nullpointer integer value in td file that will be matched with:
%0:gprb(scalar) = G_CONSTANT intvalue %1:gprb(p_addrspace) = G_INTTOPTR %0(scalar)
since that is how globalisel translates llvm-ir null. For MIPS intvalue is 0.
Added a few pointer patterns example tests for MIPS in new td file.
Similar thing could be possible for x86, this pattern for example:
def : Pat<(X86cmp GR32:$src1, 0), (TEST32rr GR32:$src1, GR32:$src1)>;
also works for pointers in SDAG, but for globalisel it would require custom legalize that generates GINodeEquiv of X86cmp and new pattern with PtrValueType and NullPtrValue instead of 0.
TODO: If NullPtrValue idea works, split to smaller patches and add detailed tests for source patterns with two or more instructions.
The indentation in this file is all over the place