[llvm-dev] [X86] Adding a new instruction JUMPB

Dean Michael Berris via llvm-dev llvm-dev at lists.llvm.org
Thu Jul 14 04:06:11 PDT 2016


Hi llvm-dev,

In the review of the LLVM-side changes to support XRay (which is now
upstream as http://reviews.llvm.org/rL275367) we hit one particular case
where we had to hack around the fact that we have no way to force the
emission of a short relative jump. It's even come up that jump relaxation
can come in and (at least with clang -O0) relax jumps to use the longer
version of the jump instruction rather than the shorter version that XRay
requires.

One suggestion that came up was to introduce a new instruction which forces
the emission of a short relative jump with an 8-bit operand, which will
fail if at assembly time the offset is outside the bounds of the relative
jump.

I mentioned that I liked this idea in the review, but I'm opening it up to
the list before actually introducing a new instruction and potentially
change some parts of the lower levels of the assembler (MC lowering?) for
X86. Some questions before I get stuck in and make this happen:

- Is the documentation in "Extending LLVM", in particular the SelectionDAG
node addition (
http://llvm.org/docs/ExtendingLLVM.html#adding-a-new-selectiondag-node) the
right guide to follow?
- Is there an example of how to enforce some assertions when assembling on
say the computed operands for a given instruction? For example, if the
MachineInstr for the JUMPB instruction was computed as an offset between
the current instruction and a label, and the distance was out-of-bounds
indicating a bad MachineInstr was used, is there a way to error out? Is
this purely implemented in the legalisation of the instruction?
- I've recently heard about and listened to the talk on the ongoing
developments for global instruction selection -- is there something there
that I'd need to worry about?
- If I'd like to make the instruction be recognised in FastISel, will the
SelectionDAG changes suffice for the instruction or will I need to be
making changes there too? How about in other ISel passes for X86 (if any)?

Looking forward to your thoughts on this!

Cheers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160714/84de299c/attachment.html>


More information about the llvm-dev mailing list