diff --git a/lib/Target/X86/X86InstrExtension.td b/lib/Target/X86/X86InstrExtension.td index 421792c5599..c24d6d5b8df 100644 --- a/lib/Target/X86/X86InstrExtension.td +++ b/lib/Target/X86/X86InstrExtension.td @@ -163,6 +163,26 @@ def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src), [(set GR64:$dst, (sextloadi64i32 addr:$src))]>, Sched<[WriteALULd]>, Requires<[In64BitMode]>; +// These instructions exist as a consequence of operand size prefix having +// control of the destination size, but not the input size. Only support them +// for the disassembler. +let isCodeGenOnly = 1, ForceDisassemble = 1, hasSideEffects = 0 in { +def MOVSX16rr32: I<0x63, MRMSrcReg, (outs GR16:$dst), (ins GR32:$src), + "movs{lq|xd}\t{$src, $dst|$dst, $src}", []>, + Sched<[WriteALU]>, OpSize16, Requires<[In64BitMode]>; +def MOVSX32rr32: I<0x63, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src), + "movs{lq|xd}\t{$src, $dst|$dst, $src}", []>, + Sched<[WriteALU]>, OpSize32, Requires<[In64BitMode]>; +let mayLoad = 1 in { +def MOVSX16rm32: I<0x63, MRMSrcMem, (outs GR16:$dst), (ins i32mem:$src), + "movs{lq|xd}\t{$src, $dst|$dst, $src}", []>, + Sched<[WriteALULd]>, OpSize16, Requires<[In64BitMode]>; +def MOVSX32rm32: I<0x63, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src), + "movs{lq|xd}\t{$src, $dst|$dst, $src}", []>, + Sched<[WriteALULd]>, OpSize32, Requires<[In64BitMode]>; +} // mayLoad = 1 +} // isCodeGenOnly = 1, ForceDisassemble = 1, hasSideEffects = 0 + // movzbq and movzwq encodings for the disassembler let hasSideEffects = 0 in { def MOVZX64rr8 : RI<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8:$src), diff --git a/test/MC/Disassembler/X86/x86-64.txt b/test/MC/Disassembler/X86/x86-64.txt index ae0e95a5095..dcf9e7b923b 100644 --- a/test/MC/Disassembler/X86/x86-64.txt +++ b/test/MC/Disassembler/X86/x86-64.txt @@ -622,3 +622,12 @@ # 0x67 prefix prints %eip instead of %rip #CHECK: addb %al, (%eip) 0x67,0x00,0x05,0x00,0x00,0x00,0x00 + +# CHECK: movslq %eax, %eax +0x63 0xc0 +# CHECK: movslq %eax, %ax +0x66 0x63 0xc0 +# CHECK: movslq (%rax), %ecx +0x63 0x08 +# CHECK: movslq (%rax), %cx +0x66 0x63 0x08