[PATCH] D26018: Function-relative jump-table encoding

Joerg Sonnenberger via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 17:08:46 PDT 2016


joerg created this revision.
joerg added subscribers: llvm-commits, artagnon.
joerg set the repository for this revision to rL LLVM.

This patch is a work-in-progress base for solving D23250 <https://reviews.llvm.org/D23250> and the jump-table handling on PPC64. It contains two parts:

1. A FUNCBASE ISD node that the target should turn into an appropriate address expression. The x86 implementation is provided.
2. 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 at GOTOFF(%eax,%ecx,4), %edx
  addl    %eax, %edx

Afterward it is:

  movl    .LJTI0_0 at 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.


Repository:
  rL LLVM

https://reviews.llvm.org/D26018

Files:
  include/llvm/CodeGen/ISDOpcodes.h
  include/llvm/CodeGen/MIRYamlMapping.h
  include/llvm/CodeGen/MachineFunction.h
  include/llvm/CodeGen/MachineJumpTableInfo.h
  include/llvm/CodeGen/SelectionDAG.h
  lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  lib/CodeGen/MachineFunction.cpp
  lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  lib/CodeGen/SelectionDAG/TargetLowering.cpp
  lib/Target/X86/X86ISelLowering.cpp
  lib/Target/X86/X86ISelLowering.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26018.75969.patch
Type: text/x-patch
Size: 13783 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161027/77cb508e/attachment.bin>


More information about the llvm-commits mailing list