[PATCH] D32683: [X86] Adding FoldGenRegForm helper field (for memory folding tables tableGen backend) to X86Inst class and set its value for the relevant instructions.

Ayman Musa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 30 07:30:48 PDT 2017


aymanmus created this revision.

Some register-register instructions can be encoded in 2 different ways, this happens when 2 register operands can be folded (separately). 
For example if we look at the MOV8rr and MOV8rr_REV, both instructions perform exactly the same operation, but are encoded differently. Here is the relevant information about these instructions from Intel's 64-ia-32-architectures-software-developer-manual:

| Opcode | Instruction | Op/En | 64-Bit Mode | Compat/Leg Mode | Description      |
| 8A /r  | MOV r8,r/m8 | RM    | Valid       | Valid           | Move r/m8 to r8. |
| 88 /r  | MOV r/m8,r8 | MR    | Valid       | Valid           | Move r8 to r/m8. |

Here we can see that in order to enable the folding of the output and input registers, we had to define 2 "encodings", and as a result we got 2 move 8-bit register-register instructions.

In the X86 backend, we define both of these instructions, usually one has a regular name (MOV8rr) while the other has "_REV" suffix (MOV8rr_REV), must be marked with isCodeGenOnly flag and is not emitted from CodeGen.

Automatically generating the memory folding tables relies on matching encodings of instructions, but in these cases where we want to map both memory forms of the mov 8-bit (MOV8rm & MOV8mr) to MOV8rr (not to MOV8rr_REV) we have to somehow point from the MOV8rr_REV to the "regular" appropriate instruction which in this case is MOV8rr.

This field enable this "pointing" mechanism - which is used in the TableGen backend for generating memory folding tables.


https://reviews.llvm.org/D32683

Files:
  lib/Target/X86/X86InstrAVX512.td
  lib/Target/X86/X86InstrArithmetic.td
  lib/Target/X86/X86InstrFMA.td
  lib/Target/X86/X86InstrFormats.td
  lib/Target/X86/X86InstrInfo.td
  lib/Target/X86/X86InstrMMX.td
  lib/Target/X86/X86InstrSSE.td
  lib/Target/X86/X86InstrXOP.td

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32683.97231.patch
Type: text/x-patch
Size: 31310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170430/79e86878/attachment.bin>


More information about the llvm-commits mailing list