blob: bf34fbb01dada2e38e45c51bf1f95ad7008968ce [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//====- X86InstrMMX.td - Describe the X86 Instruction Set --*- tablegen -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Evan Cheng and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 MMX instruction set, defining the instructions,
11// and properties of the instructions which are needed for code generation,
12// machine code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
Dan Gohmanf17a25c2007-07-18 16:29:46 +000016// Some 'special' instructions
Evan Chengb783fa32007-07-19 01:14:50 +000017def IMPLICIT_DEF_VR64 : I<0, Pseudo, (outs VR64:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018 "#IMPLICIT_DEF $dst",
19 [(set VR64:$dst, (v8i8 (undef)))]>,
20 Requires<[HasMMX]>;
21
22// 64-bit vector undef's.
23def : Pat<(v8i8 (undef)), (IMPLICIT_DEF_VR64)>;
24def : Pat<(v4i16 (undef)), (IMPLICIT_DEF_VR64)>;
25def : Pat<(v2i32 (undef)), (IMPLICIT_DEF_VR64)>;
26def : Pat<(v1i64 (undef)), (IMPLICIT_DEF_VR64)>;
27
28//===----------------------------------------------------------------------===//
29// MMX Pattern Fragments
30//===----------------------------------------------------------------------===//
31
32def load_mmx : PatFrag<(ops node:$ptr), (v1i64 (load node:$ptr))>;
33
34def bc_v8i8 : PatFrag<(ops node:$in), (v8i8 (bitconvert node:$in))>;
35def bc_v4i16 : PatFrag<(ops node:$in), (v4i16 (bitconvert node:$in))>;
36def bc_v2i32 : PatFrag<(ops node:$in), (v2i32 (bitconvert node:$in))>;
37def bc_v1i64 : PatFrag<(ops node:$in), (v1i64 (bitconvert node:$in))>;
38
39//===----------------------------------------------------------------------===//
40// MMX Masks
41//===----------------------------------------------------------------------===//
42
43// MMX_SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to
44// PSHUFW imm.
45def MMX_SHUFFLE_get_shuf_imm : SDNodeXForm<build_vector, [{
46 return getI8Imm(X86::getShuffleSHUFImmediate(N));
47}]>;
48
49// Patterns for: vector_shuffle v1, v2, <2, 6, 3, 7, ...>
50def MMX_UNPCKH_shuffle_mask : PatLeaf<(build_vector), [{
51 return X86::isUNPCKHMask(N);
52}]>;
53
54// Patterns for: vector_shuffle v1, v2, <0, 4, 2, 5, ...>
55def MMX_UNPCKL_shuffle_mask : PatLeaf<(build_vector), [{
56 return X86::isUNPCKLMask(N);
57}]>;
58
59// Patterns for: vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
60def MMX_UNPCKH_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
61 return X86::isUNPCKH_v_undef_Mask(N);
62}]>;
63
64// Patterns for: vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
65def MMX_UNPCKL_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
66 return X86::isUNPCKL_v_undef_Mask(N);
67}]>;
68
69// Patterns for shuffling.
70def MMX_PSHUFW_shuffle_mask : PatLeaf<(build_vector), [{
71 return X86::isPSHUFDMask(N);
72}], MMX_SHUFFLE_get_shuf_imm>;
73
74// Patterns for: vector_shuffle v1, v2, <4, 5, 2, 3>; etc.
75def MMX_MOVL_shuffle_mask : PatLeaf<(build_vector), [{
76 return X86::isMOVLMask(N);
77}]>;
78
79//===----------------------------------------------------------------------===//
80// MMX Multiclasses
81//===----------------------------------------------------------------------===//
82
83let isTwoAddress = 1 in {
84 // MMXI_binop_rm - Simple MMX binary operator.
85 multiclass MMXI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
86 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +000087 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000088 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000089 [(set VR64:$dst, (OpVT (OpNode VR64:$src1, VR64:$src2)))]> {
90 let isCommutable = Commutable;
91 }
Evan Chengb783fa32007-07-19 01:14:50 +000092 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000093 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000094 [(set VR64:$dst, (OpVT (OpNode VR64:$src1,
95 (bitconvert
96 (load_mmx addr:$src2)))))]>;
97 }
98
99 multiclass MMXI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
100 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +0000101 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000102 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000103 [(set VR64:$dst, (IntId VR64:$src1, VR64:$src2))]> {
104 let isCommutable = Commutable;
105 }
Evan Chengb783fa32007-07-19 01:14:50 +0000106 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000107 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000108 [(set VR64:$dst, (IntId VR64:$src1,
109 (bitconvert (load_mmx addr:$src2))))]>;
110 }
111
112 // MMXI_binop_rm_v1i64 - Simple MMX binary operator whose type is v1i64.
113 //
114 // FIXME: we could eliminate this and use MMXI_binop_rm instead if tblgen knew
115 // to collapse (bitconvert VT to VT) into its operand.
116 //
117 multiclass MMXI_binop_rm_v1i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
118 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +0000119 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000120 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000121 [(set VR64:$dst, (v1i64 (OpNode VR64:$src1, VR64:$src2)))]> {
122 let isCommutable = Commutable;
123 }
Evan Chengb783fa32007-07-19 01:14:50 +0000124 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000125 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126 [(set VR64:$dst,
127 (OpNode VR64:$src1,(load_mmx addr:$src2)))]>;
128 }
129
130 multiclass MMXI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
131 string OpcodeStr, Intrinsic IntId> {
Evan Chengb783fa32007-07-19 01:14:50 +0000132 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000133 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134 [(set VR64:$dst, (IntId VR64:$src1, VR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000135 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000136 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000137 [(set VR64:$dst, (IntId VR64:$src1,
138 (bitconvert (load_mmx addr:$src2))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000139 def ri : MMXIi8<opc2, ImmForm, (outs VR64:$dst), (ins VR64:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000140 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000141 [(set VR64:$dst, (IntId VR64:$src1,
142 (scalar_to_vector (i32 imm:$src2))))]>;
143 }
144}
145
146//===----------------------------------------------------------------------===//
147// MMX EMMS & FEMMS Instructions
148//===----------------------------------------------------------------------===//
149
Evan Chengb783fa32007-07-19 01:14:50 +0000150def MMX_EMMS : MMXI<0x77, RawFrm, (outs), (ins), "emms", [(int_x86_mmx_emms)]>;
151def MMX_FEMMS : MMXI<0x0E, RawFrm, (outs), (ins), "femms", [(int_x86_mmx_femms)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152
153//===----------------------------------------------------------------------===//
154// MMX Scalar Instructions
155//===----------------------------------------------------------------------===//
156
157// Data Transfer Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000158def MMX_MOVD64rr : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000159 "movd\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000160def MMX_MOVD64rm : MMXI<0x6E, MRMSrcMem, (outs VR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000161 "movd\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000162def MMX_MOVD64mr : MMXI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000163 "movd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000164
Evan Chengb783fa32007-07-19 01:14:50 +0000165def MMX_MOVD64to64rr : MMXRI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000166 "movd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167
Evan Chengb783fa32007-07-19 01:14:50 +0000168def MMX_MOVQ64rr : MMXI<0x6F, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000169 "movq\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000170def MMX_MOVQ64rm : MMXI<0x6F, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000171 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172 [(set VR64:$dst, (load_mmx addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000173def MMX_MOVQ64mr : MMXI<0x7F, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000174 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175 [(store (v1i64 VR64:$src), addr:$dst)]>;
176
Evan Chengb783fa32007-07-19 01:14:50 +0000177def MMX_MOVDQ2Qrr : MMXID<0xD6, MRMDestMem, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000178 "movdq2q\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179 [(set VR64:$dst,
180 (v1i64 (vector_extract (v2i64 VR128:$src),
181 (iPTR 0))))]>;
182
Evan Chengb783fa32007-07-19 01:14:50 +0000183def MMX_MOVQ2DQrr : MMXIS<0xD6, MRMDestMem, (outs VR128:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000184 "movq2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 [(set VR128:$dst,
186 (bitconvert (v1i64 VR64:$src)))]>;
187
Evan Chengb783fa32007-07-19 01:14:50 +0000188def MMX_MOVNTQmr : MMXI<0xE7, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000189 "movntq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190 [(int_x86_mmx_movnt_dq addr:$dst, VR64:$src)]>;
191
192let AddedComplexity = 15 in
193// movd to MMX register zero-extends
Evan Chengb783fa32007-07-19 01:14:50 +0000194def MMX_MOVZDI2PDIrr : MMX2I<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000195 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196 [(set VR64:$dst,
197 (v2i32 (vector_shuffle immAllZerosV,
198 (v2i32 (scalar_to_vector GR32:$src)),
199 MMX_MOVL_shuffle_mask)))]>;
200let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +0000201def MMX_MOVZDI2PDIrm : MMX2I<0x6E, MRMSrcMem, (outs VR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000202 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203 [(set VR64:$dst,
204 (v2i32 (vector_shuffle immAllZerosV,
205 (v2i32 (scalar_to_vector
206 (loadi32 addr:$src))),
207 MMX_MOVL_shuffle_mask)))]>;
208
209// Arithmetic Instructions
210
211// -- Addition
212defm MMX_PADDB : MMXI_binop_rm<0xFC, "paddb", add, v8i8, 1>;
213defm MMX_PADDW : MMXI_binop_rm<0xFD, "paddw", add, v4i16, 1>;
214defm MMX_PADDD : MMXI_binop_rm<0xFE, "paddd", add, v2i32, 1>;
215defm MMX_PADDQ : MMXI_binop_rm<0xD4, "paddq", add, v1i64, 1>;
216
217defm MMX_PADDSB : MMXI_binop_rm_int<0xEC, "paddsb" , int_x86_mmx_padds_b, 1>;
218defm MMX_PADDSW : MMXI_binop_rm_int<0xED, "paddsw" , int_x86_mmx_padds_w, 1>;
219
220defm MMX_PADDUSB : MMXI_binop_rm_int<0xDC, "paddusb", int_x86_mmx_paddus_b, 1>;
221defm MMX_PADDUSW : MMXI_binop_rm_int<0xDD, "paddusw", int_x86_mmx_paddus_w, 1>;
222
223// -- Subtraction
224defm MMX_PSUBB : MMXI_binop_rm<0xF8, "psubb", sub, v8i8>;
225defm MMX_PSUBW : MMXI_binop_rm<0xF9, "psubw", sub, v4i16>;
226defm MMX_PSUBD : MMXI_binop_rm<0xFA, "psubd", sub, v2i32>;
227defm MMX_PSUBQ : MMXI_binop_rm<0xFB, "psubq", sub, v1i64>;
228
229defm MMX_PSUBSB : MMXI_binop_rm_int<0xE8, "psubsb" , int_x86_mmx_psubs_b>;
230defm MMX_PSUBSW : MMXI_binop_rm_int<0xE9, "psubsw" , int_x86_mmx_psubs_w>;
231
232defm MMX_PSUBUSB : MMXI_binop_rm_int<0xD8, "psubusb", int_x86_mmx_psubus_b>;
233defm MMX_PSUBUSW : MMXI_binop_rm_int<0xD9, "psubusw", int_x86_mmx_psubus_w>;
234
235// -- Multiplication
236defm MMX_PMULLW : MMXI_binop_rm<0xD5, "pmullw", mul, v4i16, 1>;
237
238defm MMX_PMULHW : MMXI_binop_rm_int<0xE5, "pmulhw", int_x86_mmx_pmulh_w, 1>;
239defm MMX_PMULHUW : MMXI_binop_rm_int<0xE4, "pmulhuw", int_x86_mmx_pmulhu_w, 1>;
240defm MMX_PMULUDQ : MMXI_binop_rm_int<0xF4, "pmuludq", int_x86_mmx_pmulu_dq, 1>;
241
242// -- Miscellanea
243defm MMX_PMADDWD : MMXI_binop_rm_int<0xF5, "pmaddwd", int_x86_mmx_pmadd_wd, 1>;
244
245defm MMX_PAVGB : MMXI_binop_rm_int<0xE0, "pavgb", int_x86_mmx_pavg_b, 1>;
246defm MMX_PAVGW : MMXI_binop_rm_int<0xE3, "pavgw", int_x86_mmx_pavg_w, 1>;
247
248defm MMX_PMINUB : MMXI_binop_rm_int<0xDA, "pminub", int_x86_mmx_pminu_b, 1>;
249defm MMX_PMINSW : MMXI_binop_rm_int<0xEA, "pminsw", int_x86_mmx_pmins_w, 1>;
250
251defm MMX_PMAXUB : MMXI_binop_rm_int<0xDE, "pmaxub", int_x86_mmx_pmaxu_b, 1>;
252defm MMX_PMAXSW : MMXI_binop_rm_int<0xEE, "pmaxsw", int_x86_mmx_pmaxs_w, 1>;
253
254defm MMX_PSADBW : MMXI_binop_rm_int<0xE0, "psadbw", int_x86_mmx_psad_bw, 1>;
255
256// Logical Instructions
257defm MMX_PAND : MMXI_binop_rm_v1i64<0xDB, "pand", and, 1>;
258defm MMX_POR : MMXI_binop_rm_v1i64<0xEB, "por" , or, 1>;
259defm MMX_PXOR : MMXI_binop_rm_v1i64<0xEF, "pxor", xor, 1>;
260
261let isTwoAddress = 1 in {
262 def MMX_PANDNrr : MMXI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000263 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000264 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000265 [(set VR64:$dst, (v1i64 (and (vnot VR64:$src1),
266 VR64:$src2)))]>;
267 def MMX_PANDNrm : MMXI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000268 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000269 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000270 [(set VR64:$dst, (v1i64 (and (vnot VR64:$src1),
271 (load addr:$src2))))]>;
272}
273
274// Shift Instructions
275defm MMX_PSRLW : MMXI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
276 int_x86_mmx_psrl_w>;
277defm MMX_PSRLD : MMXI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
278 int_x86_mmx_psrl_d>;
279defm MMX_PSRLQ : MMXI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
280 int_x86_mmx_psrl_q>;
281
282defm MMX_PSLLW : MMXI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
283 int_x86_mmx_psll_w>;
284defm MMX_PSLLD : MMXI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
285 int_x86_mmx_psll_d>;
286defm MMX_PSLLQ : MMXI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
287 int_x86_mmx_psll_q>;
288
289defm MMX_PSRAW : MMXI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
290 int_x86_mmx_psra_w>;
291defm MMX_PSRAD : MMXI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
292 int_x86_mmx_psra_d>;
293
294// Comparison Instructions
295defm MMX_PCMPEQB : MMXI_binop_rm_int<0x74, "pcmpeqb", int_x86_mmx_pcmpeq_b>;
296defm MMX_PCMPEQW : MMXI_binop_rm_int<0x75, "pcmpeqw", int_x86_mmx_pcmpeq_w>;
297defm MMX_PCMPEQD : MMXI_binop_rm_int<0x76, "pcmpeqd", int_x86_mmx_pcmpeq_d>;
298
299defm MMX_PCMPGTB : MMXI_binop_rm_int<0x64, "pcmpgtb", int_x86_mmx_pcmpgt_b>;
300defm MMX_PCMPGTW : MMXI_binop_rm_int<0x65, "pcmpgtw", int_x86_mmx_pcmpgt_w>;
301defm MMX_PCMPGTD : MMXI_binop_rm_int<0x66, "pcmpgtd", int_x86_mmx_pcmpgt_d>;
302
303// Conversion Instructions
304
305// -- Unpack Instructions
306let isTwoAddress = 1 in {
307 // Unpack High Packed Data Instructions
308 def MMX_PUNPCKHBWrr : MMXI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000309 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000310 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311 [(set VR64:$dst,
312 (v8i8 (vector_shuffle VR64:$src1, VR64:$src2,
313 MMX_UNPCKH_shuffle_mask)))]>;
314 def MMX_PUNPCKHBWrm : MMXI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000315 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000316 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317 [(set VR64:$dst,
318 (v8i8 (vector_shuffle VR64:$src1,
319 (bc_v8i8 (load_mmx addr:$src2)),
320 MMX_UNPCKH_shuffle_mask)))]>;
321
322 def MMX_PUNPCKHWDrr : MMXI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000323 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000324 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325 [(set VR64:$dst,
326 (v4i16 (vector_shuffle VR64:$src1, VR64:$src2,
327 MMX_UNPCKH_shuffle_mask)))]>;
328 def MMX_PUNPCKHWDrm : MMXI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000329 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000330 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 [(set VR64:$dst,
332 (v4i16 (vector_shuffle VR64:$src1,
333 (bc_v4i16 (load_mmx addr:$src2)),
334 MMX_UNPCKH_shuffle_mask)))]>;
335
336 def MMX_PUNPCKHDQrr : MMXI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000337 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000338 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000339 [(set VR64:$dst,
340 (v2i32 (vector_shuffle VR64:$src1, VR64:$src2,
341 MMX_UNPCKH_shuffle_mask)))]>;
342 def MMX_PUNPCKHDQrm : MMXI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000343 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000344 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345 [(set VR64:$dst,
346 (v2i32 (vector_shuffle VR64:$src1,
347 (bc_v2i32 (load_mmx addr:$src2)),
348 MMX_UNPCKH_shuffle_mask)))]>;
349
350 // Unpack Low Packed Data Instructions
351 def MMX_PUNPCKLBWrr : MMXI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000352 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000353 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 [(set VR64:$dst,
355 (v8i8 (vector_shuffle VR64:$src1, VR64:$src2,
356 MMX_UNPCKL_shuffle_mask)))]>;
357 def MMX_PUNPCKLBWrm : MMXI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000358 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000359 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000360 [(set VR64:$dst,
361 (v8i8 (vector_shuffle VR64:$src1,
362 (bc_v8i8 (load_mmx addr:$src2)),
363 MMX_UNPCKL_shuffle_mask)))]>;
364
365 def MMX_PUNPCKLWDrr : MMXI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000366 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000367 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000368 [(set VR64:$dst,
369 (v4i16 (vector_shuffle VR64:$src1, VR64:$src2,
370 MMX_UNPCKL_shuffle_mask)))]>;
371 def MMX_PUNPCKLWDrm : MMXI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000372 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000373 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000374 [(set VR64:$dst,
375 (v4i16 (vector_shuffle VR64:$src1,
376 (bc_v4i16 (load_mmx addr:$src2)),
377 MMX_UNPCKL_shuffle_mask)))]>;
378
379 def MMX_PUNPCKLDQrr : MMXI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000380 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 [(set VR64:$dst,
383 (v2i32 (vector_shuffle VR64:$src1, VR64:$src2,
384 MMX_UNPCKL_shuffle_mask)))]>;
385 def MMX_PUNPCKLDQrm : MMXI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000386 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000387 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388 [(set VR64:$dst,
389 (v2i32 (vector_shuffle VR64:$src1,
390 (bc_v2i32 (load_mmx addr:$src2)),
391 MMX_UNPCKL_shuffle_mask)))]>;
392}
393
394// -- Pack Instructions
395defm MMX_PACKSSWB : MMXI_binop_rm_int<0x63, "packsswb", int_x86_mmx_packsswb>;
396defm MMX_PACKSSDW : MMXI_binop_rm_int<0x6B, "packssdw", int_x86_mmx_packssdw>;
397defm MMX_PACKUSWB : MMXI_binop_rm_int<0x67, "packuswb", int_x86_mmx_packuswb>;
398
399// -- Shuffle Instructions
400def MMX_PSHUFWri : MMXIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000401 (outs VR64:$dst), (ins VR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000402 "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000403 [(set VR64:$dst,
404 (v4i16 (vector_shuffle
405 VR64:$src1, (undef),
406 MMX_PSHUFW_shuffle_mask:$src2)))]>;
407def MMX_PSHUFWmi : MMXIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000408 (outs VR64:$dst), (ins i64mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000409 "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410 [(set VR64:$dst,
411 (v4i16 (vector_shuffle
412 (bc_v4i16 (load_mmx addr:$src1)),
413 (undef),
414 MMX_PSHUFW_shuffle_mask:$src2)))]>;
415
416// -- Conversion Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000417def MMX_CVTPD2PIrr : MMX2I<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000418 "cvtpd2pi\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000419def MMX_CVTPD2PIrm : MMX2I<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000420 "cvtpd2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000421
Evan Chengb783fa32007-07-19 01:14:50 +0000422def MMX_CVTPI2PDrr : MMX2I<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000423 "cvtpi2pd\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000424def MMX_CVTPI2PDrm : MMX2I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000425 "cvtpi2pd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426
Evan Chengb783fa32007-07-19 01:14:50 +0000427def MMX_CVTPI2PSrr : MMXI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000428 "cvtpi2ps\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000429def MMX_CVTPI2PSrm : MMXI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000430 "cvtpi2ps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431
Evan Chengb783fa32007-07-19 01:14:50 +0000432def MMX_CVTPS2PIrr : MMXI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000433 "cvtps2pi\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000434def MMX_CVTPS2PIrm : MMXI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000435 "cvtps2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436
Evan Chengb783fa32007-07-19 01:14:50 +0000437def MMX_CVTTPD2PIrr : MMX2I<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000438 "cvttpd2pi\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000439def MMX_CVTTPD2PIrm : MMX2I<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000440 "cvttpd2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441
Evan Chengb783fa32007-07-19 01:14:50 +0000442def MMX_CVTTPS2PIrr : MMXI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000443 "cvttps2pi\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000444def MMX_CVTTPS2PIrm : MMXI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000445 "cvttps2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446
447// Extract / Insert
448def MMX_X86pextrw : SDNode<"X86ISD::PEXTRW", SDTypeProfile<1, 2, []>, []>;
449def MMX_X86pinsrw : SDNode<"X86ISD::PINSRW", SDTypeProfile<1, 3, []>, []>;
450
451def MMX_PEXTRWri : MMXIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000452 (outs GR32:$dst), (ins VR64:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000453 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000454 [(set GR32:$dst, (MMX_X86pextrw (v4i16 VR64:$src1),
455 (iPTR imm:$src2)))]>;
456let isTwoAddress = 1 in {
457 def MMX_PINSRWrri : MMXIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000458 (outs VR64:$dst), (ins VR64:$src1, GR32:$src2, i16i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000459 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460 [(set VR64:$dst, (v4i16 (MMX_X86pinsrw (v4i16 VR64:$src1),
461 GR32:$src2, (iPTR imm:$src3))))]>;
462 def MMX_PINSRWrmi : MMXIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000463 (outs VR64:$dst), (ins VR64:$src1, i16mem:$src2, i16i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000464 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000465 [(set VR64:$dst,
466 (v4i16 (MMX_X86pinsrw (v4i16 VR64:$src1),
467 (i32 (anyext (loadi16 addr:$src2))),
468 (iPTR imm:$src3))))]>;
469}
470
471// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000472def MMX_PMOVMSKBrr : MMXI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000473 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000474 [(set GR32:$dst, (int_x86_mmx_pmovmskb VR64:$src))]>;
475
476// Misc.
Evan Chengb783fa32007-07-19 01:14:50 +0000477def MMX_MASKMOVQ : MMXI<0xF7, MRMDestMem, (outs), (ins VR64:$src, VR64:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +0000478 "maskmovq\t{$mask, $src|$src, $mask}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000479 [(int_x86_mmx_maskmovq VR64:$src, VR64:$mask, EDI)]>,
480 Imp<[EDI],[]>;
481
482//===----------------------------------------------------------------------===//
483// Alias Instructions
484//===----------------------------------------------------------------------===//
485
486// Alias instructions that map zero vector to pxor.
487// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
488let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000489 def MMX_V_SET0 : MMXI<0xEF, MRMInitReg, (outs VR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000490 "pxor\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491 [(set VR64:$dst, (v1i64 immAllZerosV))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000492 def MMX_V_SETALLONES : MMXI<0x76, MRMInitReg, (outs VR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000493 "pcmpeqd\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494 [(set VR64:$dst, (v1i64 immAllOnesV))]>;
495}
496
497//===----------------------------------------------------------------------===//
498// Non-Instruction Patterns
499//===----------------------------------------------------------------------===//
500
501// Store 64-bit integer vector values.
502def : Pat<(store (v8i8 VR64:$src), addr:$dst),
503 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
504def : Pat<(store (v4i16 VR64:$src), addr:$dst),
505 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
506def : Pat<(store (v2i32 VR64:$src), addr:$dst),
507 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
508def : Pat<(store (v1i64 VR64:$src), addr:$dst),
509 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
510
511// 64-bit vector all zero's.
512def : Pat<(v8i8 immAllZerosV), (MMX_V_SET0)>;
513def : Pat<(v4i16 immAllZerosV), (MMX_V_SET0)>;
514def : Pat<(v2i32 immAllZerosV), (MMX_V_SET0)>;
515def : Pat<(v1i64 immAllZerosV), (MMX_V_SET0)>;
516
517// 64-bit vector all one's.
518def : Pat<(v8i8 immAllOnesV), (MMX_V_SETALLONES)>;
519def : Pat<(v4i16 immAllOnesV), (MMX_V_SETALLONES)>;
520def : Pat<(v2i32 immAllOnesV), (MMX_V_SETALLONES)>;
521def : Pat<(v1i64 immAllOnesV), (MMX_V_SETALLONES)>;
522
523// Bit convert.
524def : Pat<(v8i8 (bitconvert (v1i64 VR64:$src))), (v8i8 VR64:$src)>;
525def : Pat<(v8i8 (bitconvert (v2i32 VR64:$src))), (v8i8 VR64:$src)>;
526def : Pat<(v8i8 (bitconvert (v4i16 VR64:$src))), (v8i8 VR64:$src)>;
527def : Pat<(v4i16 (bitconvert (v1i64 VR64:$src))), (v4i16 VR64:$src)>;
528def : Pat<(v4i16 (bitconvert (v2i32 VR64:$src))), (v4i16 VR64:$src)>;
529def : Pat<(v4i16 (bitconvert (v8i8 VR64:$src))), (v4i16 VR64:$src)>;
530def : Pat<(v2i32 (bitconvert (v1i64 VR64:$src))), (v2i32 VR64:$src)>;
531def : Pat<(v2i32 (bitconvert (v4i16 VR64:$src))), (v2i32 VR64:$src)>;
532def : Pat<(v2i32 (bitconvert (v8i8 VR64:$src))), (v2i32 VR64:$src)>;
533def : Pat<(v1i64 (bitconvert (v2i32 VR64:$src))), (v1i64 VR64:$src)>;
534def : Pat<(v1i64 (bitconvert (v4i16 VR64:$src))), (v1i64 VR64:$src)>;
535def : Pat<(v1i64 (bitconvert (v8i8 VR64:$src))), (v1i64 VR64:$src)>;
536
537// 64-bit bit convert.
538def : Pat<(v1i64 (bitconvert (i64 GR64:$src))),
539 (MMX_MOVD64to64rr GR64:$src)>;
540def : Pat<(v2i32 (bitconvert (i64 GR64:$src))),
541 (MMX_MOVD64to64rr GR64:$src)>;
542def : Pat<(v4i16 (bitconvert (i64 GR64:$src))),
543 (MMX_MOVD64to64rr GR64:$src)>;
544def : Pat<(v8i8 (bitconvert (i64 GR64:$src))),
545 (MMX_MOVD64to64rr GR64:$src)>;
546
547def MMX_X86s2vec : SDNode<"X86ISD::S2VEC", SDTypeProfile<1, 1, []>, []>;
548
549// Move scalar to XMM zero-extended
550// movd to XMM register zero-extends
551let AddedComplexity = 15 in {
552 def : Pat<(v8i8 (vector_shuffle immAllZerosV,
553 (v8i8 (MMX_X86s2vec GR32:$src)), MMX_MOVL_shuffle_mask)),
554 (MMX_MOVZDI2PDIrr GR32:$src)>;
555 def : Pat<(v4i16 (vector_shuffle immAllZerosV,
556 (v4i16 (MMX_X86s2vec GR32:$src)), MMX_MOVL_shuffle_mask)),
557 (MMX_MOVZDI2PDIrr GR32:$src)>;
558 def : Pat<(v2i32 (vector_shuffle immAllZerosV,
559 (v2i32 (MMX_X86s2vec GR32:$src)), MMX_MOVL_shuffle_mask)),
560 (MMX_MOVZDI2PDIrr GR32:$src)>;
561}
562
563// Scalar to v2i32 / v4i16 / v8i8. The source may be a GR32, but only the lower
564// 8 or 16-bits matter.
565def : Pat<(v8i8 (MMX_X86s2vec GR32:$src)), (MMX_MOVD64rr GR32:$src)>;
566def : Pat<(v4i16 (MMX_X86s2vec GR32:$src)), (MMX_MOVD64rr GR32:$src)>;
567def : Pat<(v2i32 (MMX_X86s2vec GR32:$src)), (MMX_MOVD64rr GR32:$src)>;
568
569// Patterns to perform canonical versions of vector shuffling.
570let AddedComplexity = 10 in {
571 def : Pat<(v8i8 (vector_shuffle VR64:$src, (undef),
572 MMX_UNPCKL_v_undef_shuffle_mask)),
573 (MMX_PUNPCKLBWrr VR64:$src, VR64:$src)>;
574 def : Pat<(v4i16 (vector_shuffle VR64:$src, (undef),
575 MMX_UNPCKL_v_undef_shuffle_mask)),
576 (MMX_PUNPCKLWDrr VR64:$src, VR64:$src)>;
577 def : Pat<(v2i32 (vector_shuffle VR64:$src, (undef),
578 MMX_UNPCKL_v_undef_shuffle_mask)),
579 (MMX_PUNPCKLDQrr VR64:$src, VR64:$src)>;
580}
581
582let AddedComplexity = 10 in {
583 def : Pat<(v8i8 (vector_shuffle VR64:$src, (undef),
584 MMX_UNPCKH_v_undef_shuffle_mask)),
585 (MMX_PUNPCKHBWrr VR64:$src, VR64:$src)>;
586 def : Pat<(v4i16 (vector_shuffle VR64:$src, (undef),
587 MMX_UNPCKH_v_undef_shuffle_mask)),
588 (MMX_PUNPCKHWDrr VR64:$src, VR64:$src)>;
589 def : Pat<(v2i32 (vector_shuffle VR64:$src, (undef),
590 MMX_UNPCKH_v_undef_shuffle_mask)),
591 (MMX_PUNPCKHDQrr VR64:$src, VR64:$src)>;
592}
593
594// Patterns to perform vector shuffling with a zeroed out vector.
595let AddedComplexity = 20 in {
596 def : Pat<(bc_v2i32 (vector_shuffle immAllZerosV,
597 (v2i32 (scalar_to_vector (load_mmx addr:$src))),
598 MMX_UNPCKL_shuffle_mask)),
599 (MMX_PUNPCKLDQrm VR64:$src, VR64:$src)>;
600}
601
602// Some special case PANDN patterns.
603// FIXME: Get rid of these.
604def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v2i32 immAllOnesV))),
605 VR64:$src2)),
606 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
607def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v4i16 immAllOnesV))),
608 VR64:$src2)),
609 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
610def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v8i8 immAllOnesV))),
611 VR64:$src2)),
612 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
613
614def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v2i32 immAllOnesV))),
615 (load addr:$src2))),
616 (MMX_PANDNrm VR64:$src1, addr:$src2)>;
617def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v4i16 immAllOnesV))),
618 (load addr:$src2))),
619 (MMX_PANDNrm VR64:$src1, addr:$src2)>;
620def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v8i8 immAllOnesV))),
621 (load addr:$src2))),
622 (MMX_PANDNrm VR64:$src1, addr:$src2)>;