This patch is a work-in-progress base for solving D23250 and the jump-table handling on PPC64. It contains two parts:
- A FUNCBASE ISD node that the target should turn into an appropriate address expression. The x86 implementation is provided.
- A set of three different jump-table encodings, using different sizes for the delta. Since the value range is limited by the function size, the 32bit encoding works well for large code models as long as functions are still smaller than 4GB. A new peep hole pass could also choose the correct encoding on a per-function base.
I'd like some comments on the general direction of the patch. If someone with a bit familiarity of PPC wants to provide the ISD hook, it would be appreciated. I have no idea how to implement the peep hole pass right now. For 32bit x86, the PIC version results in a slightly more complex instruction, i.e. before it was:
movl .LJTI0_0@GOTOFF(%eax,%ecx,4), %edx addl %eax, %edx
Afterward it is:
movl .LJTI0_0@GOTOFF(%eax,%ecx,4), %edx leal .L0$fb(%edx,%eax), %edx
On 64bit x86, it adds a full instruction because the rip-relative addressing can't fold the offset addition into a single lea. The difference between the different encoding versions would be movl/movslq vs movsbl/movsbq vs movswl/movswq.