Skip to content

Commit 03ddad8

Browse files
committedDec 29, 2017
Fix incorrect operand sizes for some MMX instructions: punpcklwd, punpcklbw and punpckldq.
Differential Revision: https://reviews.llvm.org/D41595 llvm-svn: 321549
1 parent 02e7f02 commit 03ddad8

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed
 

‎llvm/lib/Target/X86/X86InstrMMX.td

+9-5
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ let Constraints = "$src1 = $dst" in {
9494
// MMXI_binop_rm_int - Simple MMX binary operator based on intrinsic.
9595
// When this is cleaned up, remove the FIXME from X86RecognizableInstr.cpp.
9696
multiclass MMXI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
97-
OpndItins itins, bit Commutable = 0> {
97+
OpndItins itins, bit Commutable = 0,
98+
X86MemOperand OType = i64mem> {
9899
def irr : MMXI<opc, MRMSrcReg, (outs VR64:$dst),
99100
(ins VR64:$src1, VR64:$src2),
100101
!strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
@@ -103,7 +104,7 @@ let Constraints = "$src1 = $dst" in {
103104
let isCommutable = Commutable;
104105
}
105106
def irm : MMXI<opc, MRMSrcMem, (outs VR64:$dst),
106-
(ins VR64:$src1, i64mem:$src2),
107+
(ins VR64:$src1, OType:$src2),
107108
!strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
108109
[(set VR64:$dst, (IntId VR64:$src1,
109110
(bitconvert (load_mmx addr:$src2))))],
@@ -524,13 +525,16 @@ defm MMX_PUNPCKHDQ : MMXI_binop_rm_int<0x6A, "punpckhdq",
524525
MMX_UNPCK_H_ITINS>;
525526
defm MMX_PUNPCKLBW : MMXI_binop_rm_int<0x60, "punpcklbw",
526527
int_x86_mmx_punpcklbw,
527-
MMX_UNPCK_L_ITINS>;
528+
MMX_UNPCK_L_ITINS,
529+
0, i32mem>;
528530
defm MMX_PUNPCKLWD : MMXI_binop_rm_int<0x61, "punpcklwd",
529531
int_x86_mmx_punpcklwd,
530-
MMX_UNPCK_L_ITINS>;
532+
MMX_UNPCK_L_ITINS,
533+
0, i32mem>;
531534
defm MMX_PUNPCKLDQ : MMXI_binop_rm_int<0x62, "punpckldq",
532535
int_x86_mmx_punpckldq,
533-
MMX_UNPCK_L_ITINS>;
536+
MMX_UNPCK_L_ITINS,
537+
0, i32mem>;
534538

535539
// -- Pack Instructions
536540
defm MMX_PACKSSWB : MMXI_binop_rm_int<0x63, "packsswb", int_x86_mmx_packsswb,

‎llvm/test/MC/X86/intel-syntax-error.s

+10
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,13 @@ lea RDX, [4 * RAX + 27 * RBX + _pat]
3434
lea RDX, [[arr]
3535
//CHECK: error: unexpected bracket encountered
3636
lea RDX, [arr[]
37+
38+
.intel_syntax
39+
40+
// CHECK: error: invalid operand for instruction
41+
punpcklbw mm0, qword ptr [rsp]
42+
// CHECK: error: invalid operand for instruction
43+
punpcklwd mm0, word ptr [rsp]
44+
// CHECK: error: invalid operand for instruction
45+
punpckldq mm0, qword ptr [rsp]
46+

‎llvm/test/MC/X86/intel-syntax.s

+8
Original file line numberDiff line numberDiff line change
@@ -867,3 +867,11 @@ movsd qword ptr [rax], xmm0
867867
xlat byte ptr [eax]
868868
// CHECK: xlatb
869869
// CHECK-STDERR: memory operand is only for determining the size, (R|E)BX will be used for the location
870+
871+
// CHECK: punpcklbw
872+
punpcklbw mm0, dword ptr [rsp]
873+
// CHECK: punpcklwd
874+
punpcklwd mm0, dword ptr [rsp]
875+
// CHECK: punpckldq
876+
punpckldq mm0, dword ptr [rsp]
877+

‎llvm/test/MC/X86/x86_64-asm-match.s

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
// CHECK: Matching formal operand class MCK_VR64 against actual operand at index 2 (): Opcode result: multiple operand mismatches, ignoring this opcode
4040
// CHECK:Trying to match opcode MMX_PUNPCKLBWirm
4141
// CHECK: Matching formal operand class MCK_VR64 against actual operand at index 1 (): match success using generic matcher
42-
// CHECK: Matching formal operand class MCK_Mem64 against actual operand at index 2 (): match success using generic matcher
42+
// CHECK: Matching formal operand class MCK_Mem32 against actual operand at index 2 (): match success using generic matcher
4343
// CHECK: Matching formal operand class InvalidMatchClass against actual operand at index 3: actual operand index out of range Opcode result: complete match, selecting this opcode
4444

4545

@@ -49,4 +49,4 @@ pinsrw $3, %ecx, %xmm5
4949
crc32l %gs:0xdeadbeef(%rbx,%rcx,8),%ecx
5050

5151
.intel_syntax
52-
punpcklbw mm0, qword ptr [rsp]
52+
punpcklbw mm0, dword ptr [rsp]

0 commit comments

Comments
 (0)
Please sign in to comment.