blob: b79a00643324ad1921202087233202b98b381b4a [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//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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//===----------------------------------------------------------------------===//
17// MMX Pattern Fragments
18//===----------------------------------------------------------------------===//
19
20def load_mmx : PatFrag<(ops node:$ptr), (v1i64 (load node:$ptr))>;
21
22def bc_v8i8 : PatFrag<(ops node:$in), (v8i8 (bitconvert node:$in))>;
23def bc_v4i16 : PatFrag<(ops node:$in), (v4i16 (bitconvert node:$in))>;
24def bc_v2i32 : PatFrag<(ops node:$in), (v2i32 (bitconvert node:$in))>;
25def bc_v1i64 : PatFrag<(ops node:$in), (v1i64 (bitconvert node:$in))>;
26
27//===----------------------------------------------------------------------===//
28// MMX Masks
29//===----------------------------------------------------------------------===//
30
31// MMX_SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to
32// PSHUFW imm.
Nate Begeman543d2142009-04-27 18:41:29 +000033def MMX_SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +000034 return getI8Imm(X86::getShuffleSHUFImmediate(N));
35}]>;
36
37// Patterns for: vector_shuffle v1, v2, <2, 6, 3, 7, ...>
Nate Begeman543d2142009-04-27 18:41:29 +000038def mmx_unpckh : PatFrag<(ops node:$lhs, node:$rhs),
39 (vector_shuffle node:$lhs, node:$rhs), [{
40 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041}]>;
42
43// Patterns for: vector_shuffle v1, v2, <0, 4, 2, 5, ...>
Nate Begeman543d2142009-04-27 18:41:29 +000044def mmx_unpckl : PatFrag<(ops node:$lhs, node:$rhs),
45 (vector_shuffle node:$lhs, node:$rhs), [{
46 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +000047}]>;
48
49// Patterns for: vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Nate Begeman543d2142009-04-27 18:41:29 +000050def mmx_unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
51 (vector_shuffle node:$lhs, node:$rhs), [{
52 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +000053}]>;
54
55// Patterns for: vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Nate Begeman543d2142009-04-27 18:41:29 +000056def mmx_unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
57 (vector_shuffle node:$lhs, node:$rhs), [{
58 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +000059}]>;
60
Nate Begeman543d2142009-04-27 18:41:29 +000061def mmx_pshufw : PatFrag<(ops node:$lhs, node:$rhs),
62 (vector_shuffle node:$lhs, node:$rhs), [{
63 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064}], MMX_SHUFFLE_get_shuf_imm>;
65
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066//===----------------------------------------------------------------------===//
67// MMX Multiclasses
68//===----------------------------------------------------------------------===//
69
70let isTwoAddress = 1 in {
71 // MMXI_binop_rm - Simple MMX binary operator.
72 multiclass MMXI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
73 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +000074 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000075 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076 [(set VR64:$dst, (OpVT (OpNode VR64:$src1, VR64:$src2)))]> {
77 let isCommutable = Commutable;
78 }
Evan Chengb783fa32007-07-19 01:14:50 +000079 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000080 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000081 [(set VR64:$dst, (OpVT (OpNode VR64:$src1,
82 (bitconvert
83 (load_mmx addr:$src2)))))]>;
84 }
85
86 multiclass MMXI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
87 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +000088 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000089 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000090 [(set VR64:$dst, (IntId VR64:$src1, VR64:$src2))]> {
91 let isCommutable = Commutable;
92 }
Evan Chengb783fa32007-07-19 01:14:50 +000093 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000094 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000095 [(set VR64:$dst, (IntId VR64:$src1,
96 (bitconvert (load_mmx addr:$src2))))]>;
97 }
98
99 // MMXI_binop_rm_v1i64 - Simple MMX binary operator whose type is v1i64.
100 //
101 // FIXME: we could eliminate this and use MMXI_binop_rm instead if tblgen knew
102 // to collapse (bitconvert VT to VT) into its operand.
103 //
104 multiclass MMXI_binop_rm_v1i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
105 bit Commutable = 0> {
Evan Cheng7fcccab2008-03-21 00:40:09 +0000106 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst),
107 (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000108 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000109 [(set VR64:$dst, (v1i64 (OpNode VR64:$src1, VR64:$src2)))]> {
110 let isCommutable = Commutable;
111 }
Evan Cheng7fcccab2008-03-21 00:40:09 +0000112 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst),
113 (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000114 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000115 [(set VR64:$dst,
116 (OpNode VR64:$src1,(load_mmx addr:$src2)))]>;
117 }
118
119 multiclass MMXI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
Evan Chengf90f8f82008-05-03 00:52:09 +0000120 string OpcodeStr, Intrinsic IntId,
121 Intrinsic IntId2> {
Evan Cheng7fcccab2008-03-21 00:40:09 +0000122 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst),
123 (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000124 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000125 [(set VR64:$dst, (IntId VR64:$src1, VR64:$src2))]>;
Evan Cheng7fcccab2008-03-21 00:40:09 +0000126 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst),
127 (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000128 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000129 [(set VR64:$dst, (IntId VR64:$src1,
130 (bitconvert (load_mmx addr:$src2))))]>;
Evan Cheng7fcccab2008-03-21 00:40:09 +0000131 def ri : MMXIi8<opc2, ImmForm, (outs VR64:$dst),
132 (ins VR64:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000133 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Chengf90f8f82008-05-03 00:52:09 +0000134 [(set VR64:$dst, (IntId2 VR64:$src1, (i32 imm:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135 }
136}
137
138//===----------------------------------------------------------------------===//
139// MMX EMMS & FEMMS Instructions
140//===----------------------------------------------------------------------===//
141
Evan Chengb783fa32007-07-19 01:14:50 +0000142def MMX_EMMS : MMXI<0x77, RawFrm, (outs), (ins), "emms", [(int_x86_mmx_emms)]>;
143def MMX_FEMMS : MMXI<0x0E, RawFrm, (outs), (ins), "femms", [(int_x86_mmx_femms)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000144
145//===----------------------------------------------------------------------===//
146// MMX Scalar Instructions
147//===----------------------------------------------------------------------===//
148
149// Data Transfer Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000150def MMX_MOVD64rr : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR32:$src),
Evan Chengd1045a62008-02-18 23:04:32 +0000151 "movd\t{$src, $dst|$dst, $src}",
152 [(set VR64:$dst, (v2i32 (scalar_to_vector GR32:$src)))]>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000153let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000154def MMX_MOVD64rm : MMXI<0x6E, MRMSrcMem, (outs VR64:$dst), (ins i32mem:$src),
Evan Chengd1045a62008-02-18 23:04:32 +0000155 "movd\t{$src, $dst|$dst, $src}",
156 [(set VR64:$dst, (v2i32 (scalar_to_vector (loadi32 addr:$src))))]>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000157let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000158def MMX_MOVD64mr : MMXI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000159 "movd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000160
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000161let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000162def MMX_MOVD64to64rr : MMXRI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR64:$src),
Evan Chengef356282009-02-23 09:03:22 +0000163 "movd\t{$src, $dst|$dst, $src}",
164 []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000165
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000166let neverHasSideEffects = 1 in
Evan Chengef356282009-02-23 09:03:22 +0000167def MMX_MOVD64from64rr : MMXRI<0x7E, MRMSrcReg,
168 (outs GR64:$dst), (ins VR64:$src),
Dan Gohman4535ae32008-04-15 23:55:07 +0000169 "movd\t{$src, $dst|$dst, $src}", []>;
170
171let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000172def MMX_MOVQ64rr : MMXI<0x6F, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000173 "movq\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000174let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000175def MMX_MOVQ64rm : MMXI<0x6F, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000176 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177 [(set VR64:$dst, (load_mmx addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000178def MMX_MOVQ64mr : MMXI<0x7F, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000179 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000180 [(store (v1i64 VR64:$src), addr:$dst)]>;
181
Bill Wendling64fe3dd2008-08-27 21:32:04 +0000182def MMX_MOVDQ2Qrr : SDIi8<0xD6, MRMDestMem, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000183 "movdq2q\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000184 [(set VR64:$dst,
Evan Cheng1428f582008-04-25 20:12:46 +0000185 (v1i64 (bitconvert
186 (i64 (vector_extract (v2i64 VR128:$src),
187 (iPTR 0))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000188
Bill Wendling64fe3dd2008-08-27 21:32:04 +0000189def MMX_MOVQ2DQrr : SSDIi8<0xD6, MRMDestMem, (outs VR128:$dst), (ins VR64:$src),
190 "movq2dq\t{$src, $dst|$dst, $src}",
Evan Cheng5e4d1e72008-04-25 18:19:54 +0000191 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000192 (movl immAllZerosV,
193 (v2i64 (scalar_to_vector (i64 (bitconvert VR64:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000194
Evan Chengef356282009-02-23 09:03:22 +0000195let neverHasSideEffects = 1 in
196def MMX_MOVQ2FR64rr: SSDIi8<0xD6, MRMDestMem, (outs FR64:$dst), (ins VR64:$src),
197 "movq2dq\t{$src, $dst|$dst, $src}", []>;
198
Evan Chengb783fa32007-07-19 01:14:50 +0000199def MMX_MOVNTQmr : MMXI<0xE7, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000200 "movntq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201 [(int_x86_mmx_movnt_dq addr:$dst, VR64:$src)]>;
202
203let AddedComplexity = 15 in
204// movd to MMX register zero-extends
Anders Carlssona31d51a2008-02-29 01:35:12 +0000205def MMX_MOVZDI2PDIrr : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000206 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng40ee6e52008-05-08 00:57:18 +0000207 [(set VR64:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +0000208 (v2i32 (X86vzmovl (v2i32 (scalar_to_vector GR32:$src)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209let AddedComplexity = 20 in
Anders Carlssona31d51a2008-02-29 01:35:12 +0000210def MMX_MOVZDI2PDIrm : MMXI<0x6E, MRMSrcMem, (outs VR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000211 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng40ee6e52008-05-08 00:57:18 +0000212 [(set VR64:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +0000213 (v2i32 (X86vzmovl (v2i32
Evan Cheng40ee6e52008-05-08 00:57:18 +0000214 (scalar_to_vector (loadi32 addr:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215
216// Arithmetic Instructions
217
218// -- Addition
219defm MMX_PADDB : MMXI_binop_rm<0xFC, "paddb", add, v8i8, 1>;
220defm MMX_PADDW : MMXI_binop_rm<0xFD, "paddw", add, v4i16, 1>;
221defm MMX_PADDD : MMXI_binop_rm<0xFE, "paddd", add, v2i32, 1>;
222defm MMX_PADDQ : MMXI_binop_rm<0xD4, "paddq", add, v1i64, 1>;
223
224defm MMX_PADDSB : MMXI_binop_rm_int<0xEC, "paddsb" , int_x86_mmx_padds_b, 1>;
225defm MMX_PADDSW : MMXI_binop_rm_int<0xED, "paddsw" , int_x86_mmx_padds_w, 1>;
226
227defm MMX_PADDUSB : MMXI_binop_rm_int<0xDC, "paddusb", int_x86_mmx_paddus_b, 1>;
228defm MMX_PADDUSW : MMXI_binop_rm_int<0xDD, "paddusw", int_x86_mmx_paddus_w, 1>;
229
230// -- Subtraction
231defm MMX_PSUBB : MMXI_binop_rm<0xF8, "psubb", sub, v8i8>;
232defm MMX_PSUBW : MMXI_binop_rm<0xF9, "psubw", sub, v4i16>;
233defm MMX_PSUBD : MMXI_binop_rm<0xFA, "psubd", sub, v2i32>;
234defm MMX_PSUBQ : MMXI_binop_rm<0xFB, "psubq", sub, v1i64>;
235
236defm MMX_PSUBSB : MMXI_binop_rm_int<0xE8, "psubsb" , int_x86_mmx_psubs_b>;
237defm MMX_PSUBSW : MMXI_binop_rm_int<0xE9, "psubsw" , int_x86_mmx_psubs_w>;
238
239defm MMX_PSUBUSB : MMXI_binop_rm_int<0xD8, "psubusb", int_x86_mmx_psubus_b>;
240defm MMX_PSUBUSW : MMXI_binop_rm_int<0xD9, "psubusw", int_x86_mmx_psubus_w>;
241
242// -- Multiplication
243defm MMX_PMULLW : MMXI_binop_rm<0xD5, "pmullw", mul, v4i16, 1>;
244
245defm MMX_PMULHW : MMXI_binop_rm_int<0xE5, "pmulhw", int_x86_mmx_pmulh_w, 1>;
246defm MMX_PMULHUW : MMXI_binop_rm_int<0xE4, "pmulhuw", int_x86_mmx_pmulhu_w, 1>;
247defm MMX_PMULUDQ : MMXI_binop_rm_int<0xF4, "pmuludq", int_x86_mmx_pmulu_dq, 1>;
248
249// -- Miscellanea
250defm MMX_PMADDWD : MMXI_binop_rm_int<0xF5, "pmaddwd", int_x86_mmx_pmadd_wd, 1>;
251
252defm MMX_PAVGB : MMXI_binop_rm_int<0xE0, "pavgb", int_x86_mmx_pavg_b, 1>;
253defm MMX_PAVGW : MMXI_binop_rm_int<0xE3, "pavgw", int_x86_mmx_pavg_w, 1>;
254
255defm MMX_PMINUB : MMXI_binop_rm_int<0xDA, "pminub", int_x86_mmx_pminu_b, 1>;
256defm MMX_PMINSW : MMXI_binop_rm_int<0xEA, "pminsw", int_x86_mmx_pmins_w, 1>;
257
258defm MMX_PMAXUB : MMXI_binop_rm_int<0xDE, "pmaxub", int_x86_mmx_pmaxu_b, 1>;
259defm MMX_PMAXSW : MMXI_binop_rm_int<0xEE, "pmaxsw", int_x86_mmx_pmaxs_w, 1>;
260
Bill Wendling953ad2e2009-05-28 02:04:00 +0000261defm MMX_PSADBW : MMXI_binop_rm_int<0xF6, "psadbw", int_x86_mmx_psad_bw, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262
263// Logical Instructions
264defm MMX_PAND : MMXI_binop_rm_v1i64<0xDB, "pand", and, 1>;
265defm MMX_POR : MMXI_binop_rm_v1i64<0xEB, "por" , or, 1>;
266defm MMX_PXOR : MMXI_binop_rm_v1i64<0xEF, "pxor", xor, 1>;
267
268let isTwoAddress = 1 in {
269 def MMX_PANDNrr : MMXI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000270 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000271 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272 [(set VR64:$dst, (v1i64 (and (vnot VR64:$src1),
273 VR64:$src2)))]>;
274 def MMX_PANDNrm : MMXI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000275 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000276 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000277 [(set VR64:$dst, (v1i64 (and (vnot VR64:$src1),
278 (load addr:$src2))))]>;
279}
280
281// Shift Instructions
282defm MMX_PSRLW : MMXI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
Evan Chengf90f8f82008-05-03 00:52:09 +0000283 int_x86_mmx_psrl_w, int_x86_mmx_psrli_w>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284defm MMX_PSRLD : MMXI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
Evan Chengf90f8f82008-05-03 00:52:09 +0000285 int_x86_mmx_psrl_d, int_x86_mmx_psrli_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000286defm MMX_PSRLQ : MMXI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Chengf90f8f82008-05-03 00:52:09 +0000287 int_x86_mmx_psrl_q, int_x86_mmx_psrli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000288
289defm MMX_PSLLW : MMXI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
Evan Chengf90f8f82008-05-03 00:52:09 +0000290 int_x86_mmx_psll_w, int_x86_mmx_pslli_w>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291defm MMX_PSLLD : MMXI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
Evan Chengf90f8f82008-05-03 00:52:09 +0000292 int_x86_mmx_psll_d, int_x86_mmx_pslli_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000293defm MMX_PSLLQ : MMXI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
Evan Chengf90f8f82008-05-03 00:52:09 +0000294 int_x86_mmx_psll_q, int_x86_mmx_pslli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295
296defm MMX_PSRAW : MMXI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
Evan Chengf90f8f82008-05-03 00:52:09 +0000297 int_x86_mmx_psra_w, int_x86_mmx_psrai_w>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298defm MMX_PSRAD : MMXI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Chengf90f8f82008-05-03 00:52:09 +0000299 int_x86_mmx_psra_d, int_x86_mmx_psrai_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300
Evan Chengdea99362008-05-29 08:22:04 +0000301// Shift up / down and insert zero's.
302def : Pat<(v1i64 (X86vshl VR64:$src, (i8 imm:$amt))),
303 (v1i64 (MMX_PSLLQri VR64:$src, imm:$amt))>;
304def : Pat<(v1i64 (X86vshr VR64:$src, (i8 imm:$amt))),
305 (v1i64 (MMX_PSRLQri VR64:$src, imm:$amt))>;
306
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307// Comparison Instructions
308defm MMX_PCMPEQB : MMXI_binop_rm_int<0x74, "pcmpeqb", int_x86_mmx_pcmpeq_b>;
309defm MMX_PCMPEQW : MMXI_binop_rm_int<0x75, "pcmpeqw", int_x86_mmx_pcmpeq_w>;
310defm MMX_PCMPEQD : MMXI_binop_rm_int<0x76, "pcmpeqd", int_x86_mmx_pcmpeq_d>;
311
312defm MMX_PCMPGTB : MMXI_binop_rm_int<0x64, "pcmpgtb", int_x86_mmx_pcmpgt_b>;
313defm MMX_PCMPGTW : MMXI_binop_rm_int<0x65, "pcmpgtw", int_x86_mmx_pcmpgt_w>;
314defm MMX_PCMPGTD : MMXI_binop_rm_int<0x66, "pcmpgtd", int_x86_mmx_pcmpgt_d>;
315
316// Conversion Instructions
317
318// -- Unpack Instructions
319let isTwoAddress = 1 in {
320 // Unpack High Packed Data Instructions
321 def MMX_PUNPCKHBWrr : MMXI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000322 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000323 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000324 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000325 (v8i8 (mmx_unpckh VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000326 def MMX_PUNPCKHBWrm : MMXI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000327 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000328 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000330 (v8i8 (mmx_unpckh VR64:$src1,
331 (bc_v8i8 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000332
333 def MMX_PUNPCKHWDrr : MMXI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000334 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000335 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000336 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000337 (v4i16 (mmx_unpckh VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000338 def MMX_PUNPCKHWDrm : MMXI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000339 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000340 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000342 (v4i16 (mmx_unpckh VR64:$src1,
343 (bc_v4i16 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344
345 def MMX_PUNPCKHDQrr : MMXI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000346 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000347 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000348 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000349 (v2i32 (mmx_unpckh VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000350 def MMX_PUNPCKHDQrm : MMXI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000351 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000352 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000353 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000354 (v2i32 (mmx_unpckh VR64:$src1,
355 (bc_v2i32 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356
357 // Unpack Low Packed Data Instructions
358 def MMX_PUNPCKLBWrr : MMXI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000359 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000360 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000362 (v8i8 (mmx_unpckl VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000363 def MMX_PUNPCKLBWrm : MMXI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000364 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000365 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000366 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000367 (v8i8 (mmx_unpckl VR64:$src1,
368 (bc_v8i8 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369
370 def MMX_PUNPCKLWDrr : MMXI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000371 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000372 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000373 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000374 (v4i16 (mmx_unpckl VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000375 def MMX_PUNPCKLWDrm : MMXI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000376 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000377 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000378 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000379 (v4i16 (mmx_unpckl VR64:$src1,
380 (bc_v4i16 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000381
382 def MMX_PUNPCKLDQrr : MMXI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000383 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000384 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000386 (v2i32 (mmx_unpckl VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000387 def MMX_PUNPCKLDQrm : MMXI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000388 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000389 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000391 (v2i32 (mmx_unpckl VR64:$src1,
392 (bc_v2i32 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393}
394
395// -- Pack Instructions
396defm MMX_PACKSSWB : MMXI_binop_rm_int<0x63, "packsswb", int_x86_mmx_packsswb>;
397defm MMX_PACKSSDW : MMXI_binop_rm_int<0x6B, "packssdw", int_x86_mmx_packssdw>;
398defm MMX_PACKUSWB : MMXI_binop_rm_int<0x67, "packuswb", int_x86_mmx_packuswb>;
399
400// -- Shuffle Instructions
401def MMX_PSHUFWri : MMXIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000402 (outs VR64:$dst), (ins VR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000403 "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000404 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000405 (v4i16 (mmx_pshufw:$src2 VR64:$src1, (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406def MMX_PSHUFWmi : MMXIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000407 (outs VR64:$dst), (ins i64mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000408 "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000410 (mmx_pshufw:$src2 (bc_v4i16 (load_mmx addr:$src1)),
411 (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412
413// -- Conversion Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000414let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000415def MMX_CVTPD2PIrr : MMX2I<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000416 "cvtpd2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000417let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000418def MMX_CVTPD2PIrm : MMX2I<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000419 "cvtpd2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420
Evan Chengb783fa32007-07-19 01:14:50 +0000421def MMX_CVTPI2PDrr : MMX2I<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000422 "cvtpi2pd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000423let mayLoad = 1 in
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}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000429let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000430def MMX_CVTPI2PSrm : MMXI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000431 "cvtpi2ps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000432
Evan Chengb783fa32007-07-19 01:14:50 +0000433def MMX_CVTPS2PIrr : MMXI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000434 "cvtps2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000435let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000436def MMX_CVTPS2PIrm : MMXI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000437 "cvtps2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000438
Evan Chengb783fa32007-07-19 01:14:50 +0000439def MMX_CVTTPD2PIrr : MMX2I<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000440 "cvttpd2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000441let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000442def MMX_CVTTPD2PIrm : MMX2I<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000443 "cvttpd2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444
Evan Chengb783fa32007-07-19 01:14:50 +0000445def MMX_CVTTPS2PIrr : MMXI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000446 "cvttps2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000447let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000448def MMX_CVTTPS2PIrm : MMXI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000449 "cvttps2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000450} // end neverHasSideEffects
451
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452
453// Extract / Insert
454def MMX_X86pextrw : SDNode<"X86ISD::PEXTRW", SDTypeProfile<1, 2, []>, []>;
455def MMX_X86pinsrw : SDNode<"X86ISD::PINSRW", SDTypeProfile<1, 3, []>, []>;
456
457def MMX_PEXTRWri : MMXIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000458 (outs GR32:$dst), (ins VR64:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000459 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460 [(set GR32:$dst, (MMX_X86pextrw (v4i16 VR64:$src1),
461 (iPTR imm:$src2)))]>;
462let isTwoAddress = 1 in {
463 def MMX_PINSRWrri : MMXIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000464 (outs VR64:$dst), (ins VR64:$src1, GR32:$src2, i16i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000465 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000466 [(set VR64:$dst, (v4i16 (MMX_X86pinsrw (v4i16 VR64:$src1),
467 GR32:$src2, (iPTR imm:$src3))))]>;
468 def MMX_PINSRWrmi : MMXIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000469 (outs VR64:$dst), (ins VR64:$src1, i16mem:$src2, i16i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000470 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471 [(set VR64:$dst,
472 (v4i16 (MMX_X86pinsrw (v4i16 VR64:$src1),
473 (i32 (anyext (loadi16 addr:$src2))),
474 (iPTR imm:$src3))))]>;
475}
476
477// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000478def MMX_PMOVMSKBrr : MMXI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000479 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000480 [(set GR32:$dst, (int_x86_mmx_pmovmskb VR64:$src))]>;
481
482// Misc.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000483let Uses = [EDI] in
Bill Wendling8fb68282009-06-23 19:52:59 +0000484def MMX_MASKMOVQ : MMXI<0xF7, MRMSrcReg, (outs), (ins VR64:$src, VR64:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +0000485 "maskmovq\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000486 [(int_x86_mmx_maskmovq VR64:$src, VR64:$mask, EDI)]>;
Anton Korobeynikov0e70d102008-08-23 15:53:19 +0000487let Uses = [RDI] in
Bill Wendling8fb68282009-06-23 19:52:59 +0000488def MMX_MASKMOVQ64: MMXI64<0xF7, MRMSrcReg, (outs), (ins VR64:$src, VR64:$mask),
Anton Korobeynikov0e70d102008-08-23 15:53:19 +0000489 "maskmovq\t{$mask, $src|$src, $mask}",
490 [(int_x86_mmx_maskmovq VR64:$src, VR64:$mask, RDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491
492//===----------------------------------------------------------------------===//
493// Alias Instructions
494//===----------------------------------------------------------------------===//
495
496// Alias instructions that map zero vector to pxor.
Chris Lattner17dab4a2008-01-10 05:45:39 +0000497let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000498 def MMX_V_SET0 : MMXI<0xEF, MRMInitReg, (outs VR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000499 "pxor\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000500 [(set VR64:$dst, (v2i32 immAllZerosV))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000501 def MMX_V_SETALLONES : MMXI<0x76, MRMInitReg, (outs VR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000502 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000503 [(set VR64:$dst, (v2i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504}
505
Evan Chenga15896e2008-03-12 07:02:50 +0000506let Predicates = [HasMMX] in {
507 def : Pat<(v1i64 immAllZerosV), (MMX_V_SET0)>;
508 def : Pat<(v4i16 immAllZerosV), (MMX_V_SET0)>;
509 def : Pat<(v8i8 immAllZerosV), (MMX_V_SET0)>;
510}
511
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512//===----------------------------------------------------------------------===//
513// Non-Instruction Patterns
514//===----------------------------------------------------------------------===//
515
516// Store 64-bit integer vector values.
517def : Pat<(store (v8i8 VR64:$src), addr:$dst),
518 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
519def : Pat<(store (v4i16 VR64:$src), addr:$dst),
520 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
521def : Pat<(store (v2i32 VR64:$src), addr:$dst),
522 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000523def : Pat<(store (v2f32 VR64:$src), addr:$dst),
524 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525def : Pat<(store (v1i64 VR64:$src), addr:$dst),
526 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
527
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528// Bit convert.
529def : Pat<(v8i8 (bitconvert (v1i64 VR64:$src))), (v8i8 VR64:$src)>;
530def : Pat<(v8i8 (bitconvert (v2i32 VR64:$src))), (v8i8 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000531def : Pat<(v8i8 (bitconvert (v2f32 VR64:$src))), (v8i8 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532def : Pat<(v8i8 (bitconvert (v4i16 VR64:$src))), (v8i8 VR64:$src)>;
533def : Pat<(v4i16 (bitconvert (v1i64 VR64:$src))), (v4i16 VR64:$src)>;
534def : Pat<(v4i16 (bitconvert (v2i32 VR64:$src))), (v4i16 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000535def : Pat<(v4i16 (bitconvert (v2f32 VR64:$src))), (v4i16 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536def : Pat<(v4i16 (bitconvert (v8i8 VR64:$src))), (v4i16 VR64:$src)>;
537def : Pat<(v2i32 (bitconvert (v1i64 VR64:$src))), (v2i32 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000538def : Pat<(v2i32 (bitconvert (v2f32 VR64:$src))), (v2i32 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539def : Pat<(v2i32 (bitconvert (v4i16 VR64:$src))), (v2i32 VR64:$src)>;
540def : Pat<(v2i32 (bitconvert (v8i8 VR64:$src))), (v2i32 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000541def : Pat<(v2f32 (bitconvert (v1i64 VR64:$src))), (v2f32 VR64:$src)>;
542def : Pat<(v2f32 (bitconvert (v2i32 VR64:$src))), (v2f32 VR64:$src)>;
543def : Pat<(v2f32 (bitconvert (v4i16 VR64:$src))), (v2f32 VR64:$src)>;
544def : Pat<(v2f32 (bitconvert (v8i8 VR64:$src))), (v2f32 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545def : Pat<(v1i64 (bitconvert (v2i32 VR64:$src))), (v1i64 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000546def : Pat<(v1i64 (bitconvert (v2f32 VR64:$src))), (v1i64 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547def : Pat<(v1i64 (bitconvert (v4i16 VR64:$src))), (v1i64 VR64:$src)>;
548def : Pat<(v1i64 (bitconvert (v8i8 VR64:$src))), (v1i64 VR64:$src)>;
549
550// 64-bit bit convert.
551def : Pat<(v1i64 (bitconvert (i64 GR64:$src))),
552 (MMX_MOVD64to64rr GR64:$src)>;
553def : Pat<(v2i32 (bitconvert (i64 GR64:$src))),
554 (MMX_MOVD64to64rr GR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000555def : Pat<(v2f32 (bitconvert (i64 GR64:$src))),
556 (MMX_MOVD64to64rr GR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557def : Pat<(v4i16 (bitconvert (i64 GR64:$src))),
558 (MMX_MOVD64to64rr GR64:$src)>;
559def : Pat<(v8i8 (bitconvert (i64 GR64:$src))),
560 (MMX_MOVD64to64rr GR64:$src)>;
Dan Gohman4535ae32008-04-15 23:55:07 +0000561def : Pat<(i64 (bitconvert (v1i64 VR64:$src))),
562 (MMX_MOVD64from64rr VR64:$src)>;
563def : Pat<(i64 (bitconvert (v2i32 VR64:$src))),
564 (MMX_MOVD64from64rr VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000565def : Pat<(i64 (bitconvert (v2f32 VR64:$src))),
566 (MMX_MOVD64from64rr VR64:$src)>;
Dan Gohman4535ae32008-04-15 23:55:07 +0000567def : Pat<(i64 (bitconvert (v4i16 VR64:$src))),
568 (MMX_MOVD64from64rr VR64:$src)>;
569def : Pat<(i64 (bitconvert (v8i8 VR64:$src))),
570 (MMX_MOVD64from64rr VR64:$src)>;
Evan Chengef356282009-02-23 09:03:22 +0000571def : Pat<(f64 (bitconvert (v1i64 VR64:$src))),
572 (MMX_MOVQ2FR64rr VR64:$src)>;
573def : Pat<(f64 (bitconvert (v2i32 VR64:$src))),
574 (MMX_MOVQ2FR64rr VR64:$src)>;
575def : Pat<(f64 (bitconvert (v4i16 VR64:$src))),
576 (MMX_MOVQ2FR64rr VR64:$src)>;
577def : Pat<(f64 (bitconvert (v8i8 VR64:$src))),
578 (MMX_MOVQ2FR64rr VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000579
Evan Cheng778641e2008-11-05 06:04:51 +0000580let AddedComplexity = 20 in {
Evan Cheng778641e2008-11-05 06:04:51 +0000581 def : Pat<(v2i32 (X86vzmovl (bc_v2i32 (load_mmx addr:$src)))),
Evan Chengb76ecc82008-12-03 19:38:05 +0000582 (MMX_MOVZDI2PDIrm addr:$src)>;
583}
584
585// Clear top half.
586let AddedComplexity = 15 in {
Evan Chengb76ecc82008-12-03 19:38:05 +0000587 def : Pat<(v2i32 (X86vzmovl VR64:$src)),
588 (MMX_PUNPCKLDQrr VR64:$src, (MMX_V_SET0))>;
Evan Cheng778641e2008-11-05 06:04:51 +0000589}
590
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591// Patterns to perform canonical versions of vector shuffling.
592let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000593 def : Pat<(v8i8 (mmx_unpckl_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594 (MMX_PUNPCKLBWrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000595 def : Pat<(v4i16 (mmx_unpckl_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596 (MMX_PUNPCKLWDrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000597 def : Pat<(v2i32 (mmx_unpckl_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598 (MMX_PUNPCKLDQrr VR64:$src, VR64:$src)>;
599}
600
601let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000602 def : Pat<(v8i8 (mmx_unpckh_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603 (MMX_PUNPCKHBWrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000604 def : Pat<(v4i16 (mmx_unpckh_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605 (MMX_PUNPCKHWDrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000606 def : Pat<(v2i32 (mmx_unpckh_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607 (MMX_PUNPCKHDQrr VR64:$src, VR64:$src)>;
608}
609
610// Patterns to perform vector shuffling with a zeroed out vector.
611let AddedComplexity = 20 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000612 def : Pat<(bc_v2i32 (mmx_unpckl immAllZerosV,
613 (v2i32 (scalar_to_vector (load_mmx addr:$src))))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614 (MMX_PUNPCKLDQrm VR64:$src, VR64:$src)>;
615}
616
617// Some special case PANDN patterns.
618// FIXME: Get rid of these.
619def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v2i32 immAllOnesV))),
620 VR64:$src2)),
621 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
Chris Lattnere6aa3862007-11-25 00:24:49 +0000622def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v4i16 immAllOnesV_bc))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623 VR64:$src2)),
624 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
Chris Lattnere6aa3862007-11-25 00:24:49 +0000625def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v8i8 immAllOnesV_bc))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000626 VR64:$src2)),
627 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
628
629def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v2i32 immAllOnesV))),
630 (load addr:$src2))),
631 (MMX_PANDNrm VR64:$src1, addr:$src2)>;
Chris Lattnere6aa3862007-11-25 00:24:49 +0000632def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v4i16 immAllOnesV_bc))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000633 (load addr:$src2))),
634 (MMX_PANDNrm VR64:$src1, addr:$src2)>;
Chris Lattnere6aa3862007-11-25 00:24:49 +0000635def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v8i8 immAllOnesV_bc))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000636 (load addr:$src2))),
637 (MMX_PANDNrm VR64:$src1, addr:$src2)>;
Evan Cheng2aea0b42008-04-25 19:11:04 +0000638
639// Move MMX to lower 64-bit of XMM
Evan Chengef356282009-02-23 09:03:22 +0000640def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v8i8 VR64:$src))))),
641 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
642def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v4i16 VR64:$src))))),
643 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
644def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v2i32 VR64:$src))))),
645 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
646def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v1i64 VR64:$src))))),
Evan Cheng2aea0b42008-04-25 19:11:04 +0000647 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
Evan Cheng1428f582008-04-25 20:12:46 +0000648
649// Move lower 64-bit of XMM to MMX.
650def : Pat<(v2i32 (bitconvert (i64 (vector_extract (v2i64 VR128:$src),
651 (iPTR 0))))),
652 (v2i32 (MMX_MOVDQ2Qrr VR128:$src))>;
653def : Pat<(v4i16 (bitconvert (i64 (vector_extract (v2i64 VR128:$src),
654 (iPTR 0))))),
655 (v4i16 (MMX_MOVDQ2Qrr VR128:$src))>;
656def : Pat<(v8i8 (bitconvert (i64 (vector_extract (v2i64 VR128:$src),
657 (iPTR 0))))),
658 (v8i8 (MMX_MOVDQ2Qrr VR128:$src))>;
659
Mon P Wang83edba52008-12-12 01:25:51 +0000660// CMOV* - Used to implement the SELECT DAG operation. Expanded by the
661// scheduler into a branch sequence.
662// These are expanded by the scheduler.
663let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
664 def CMOV_V1I64 : I<0, Pseudo,
665 (outs VR64:$dst), (ins VR64:$t, VR64:$f, i8imm:$cond),
666 "#CMOV_V1I64 PSEUDO!",
667 [(set VR64:$dst,
668 (v1i64 (X86cmov VR64:$t, VR64:$f, imm:$cond,
669 EFLAGS)))]>;
670}