blob: 0033d837bbaf5b1572f9421ca452db44fbf84cb1 [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
Rafael Espindolafe2a3972009-08-03 02:45:34 +0000166let neverHasSideEffects = 1 in {
167def MMX_MOVD64from64rr : MMXRI<0x7F, MRMDestReg,
Evan Chengef356282009-02-23 09:03:22 +0000168 (outs GR64:$dst), (ins VR64:$src),
Rafael Espindolafe2a3972009-08-03 02:45:34 +0000169 "movq\t{$src, $dst|$dst, $src}", []>;
170def MMX_MOVD64rrv164 : MMXI<0x6F, MRMSrcReg, (outs VR64:$dst), (ins GR64:$src),
171 "movq\t{$src, $dst|$dst, $src}",
172 [(set VR64:$dst, (v1i64 (scalar_to_vector GR64:$src)))]>;
173}
Dan Gohman4535ae32008-04-15 23:55:07 +0000174
175let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000176def MMX_MOVQ64rr : MMXI<0x6F, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000177 "movq\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000178let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000179def MMX_MOVQ64rm : MMXI<0x6F, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000180 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181 [(set VR64:$dst, (load_mmx addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000182def MMX_MOVQ64mr : MMXI<0x7F, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000183 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000184 [(store (v1i64 VR64:$src), addr:$dst)]>;
185
Eli Friedman6ff96fc2009-07-09 16:49:25 +0000186def MMX_MOVDQ2Qrr : SDIi8<0xD6, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000187 "movdq2q\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000188 [(set VR64:$dst,
Evan Cheng1428f582008-04-25 20:12:46 +0000189 (v1i64 (bitconvert
190 (i64 (vector_extract (v2i64 VR128:$src),
191 (iPTR 0))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192
Eli Friedman6ff96fc2009-07-09 16:49:25 +0000193def MMX_MOVQ2DQrr : SSDIi8<0xD6, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
Bill Wendling64fe3dd2008-08-27 21:32:04 +0000194 "movq2dq\t{$src, $dst|$dst, $src}",
Evan Cheng5e4d1e72008-04-25 18:19:54 +0000195 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000196 (movl immAllZerosV,
197 (v2i64 (scalar_to_vector (i64 (bitconvert VR64:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198
Evan Chengef356282009-02-23 09:03:22 +0000199let neverHasSideEffects = 1 in
Eli Friedman6ff96fc2009-07-09 16:49:25 +0000200def MMX_MOVQ2FR64rr: SSDIi8<0xD6, MRMSrcReg, (outs FR64:$dst), (ins VR64:$src),
Evan Chengef356282009-02-23 09:03:22 +0000201 "movq2dq\t{$src, $dst|$dst, $src}", []>;
202
Evan Chengb783fa32007-07-19 01:14:50 +0000203def MMX_MOVNTQmr : MMXI<0xE7, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000204 "movntq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000205 [(int_x86_mmx_movnt_dq addr:$dst, VR64:$src)]>;
206
207let AddedComplexity = 15 in
208// movd to MMX register zero-extends
Anders Carlssona31d51a2008-02-29 01:35:12 +0000209def MMX_MOVZDI2PDIrr : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000210 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng40ee6e52008-05-08 00:57:18 +0000211 [(set VR64:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +0000212 (v2i32 (X86vzmovl (v2i32 (scalar_to_vector GR32:$src)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213let AddedComplexity = 20 in
Anders Carlssona31d51a2008-02-29 01:35:12 +0000214def MMX_MOVZDI2PDIrm : MMXI<0x6E, MRMSrcMem, (outs VR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000215 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng40ee6e52008-05-08 00:57:18 +0000216 [(set VR64:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +0000217 (v2i32 (X86vzmovl (v2i32
Evan Cheng40ee6e52008-05-08 00:57:18 +0000218 (scalar_to_vector (loadi32 addr:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000219
220// Arithmetic Instructions
221
222// -- Addition
223defm MMX_PADDB : MMXI_binop_rm<0xFC, "paddb", add, v8i8, 1>;
224defm MMX_PADDW : MMXI_binop_rm<0xFD, "paddw", add, v4i16, 1>;
225defm MMX_PADDD : MMXI_binop_rm<0xFE, "paddd", add, v2i32, 1>;
226defm MMX_PADDQ : MMXI_binop_rm<0xD4, "paddq", add, v1i64, 1>;
227
228defm MMX_PADDSB : MMXI_binop_rm_int<0xEC, "paddsb" , int_x86_mmx_padds_b, 1>;
229defm MMX_PADDSW : MMXI_binop_rm_int<0xED, "paddsw" , int_x86_mmx_padds_w, 1>;
230
231defm MMX_PADDUSB : MMXI_binop_rm_int<0xDC, "paddusb", int_x86_mmx_paddus_b, 1>;
232defm MMX_PADDUSW : MMXI_binop_rm_int<0xDD, "paddusw", int_x86_mmx_paddus_w, 1>;
233
234// -- Subtraction
235defm MMX_PSUBB : MMXI_binop_rm<0xF8, "psubb", sub, v8i8>;
236defm MMX_PSUBW : MMXI_binop_rm<0xF9, "psubw", sub, v4i16>;
237defm MMX_PSUBD : MMXI_binop_rm<0xFA, "psubd", sub, v2i32>;
238defm MMX_PSUBQ : MMXI_binop_rm<0xFB, "psubq", sub, v1i64>;
239
240defm MMX_PSUBSB : MMXI_binop_rm_int<0xE8, "psubsb" , int_x86_mmx_psubs_b>;
241defm MMX_PSUBSW : MMXI_binop_rm_int<0xE9, "psubsw" , int_x86_mmx_psubs_w>;
242
243defm MMX_PSUBUSB : MMXI_binop_rm_int<0xD8, "psubusb", int_x86_mmx_psubus_b>;
244defm MMX_PSUBUSW : MMXI_binop_rm_int<0xD9, "psubusw", int_x86_mmx_psubus_w>;
245
246// -- Multiplication
247defm MMX_PMULLW : MMXI_binop_rm<0xD5, "pmullw", mul, v4i16, 1>;
248
249defm MMX_PMULHW : MMXI_binop_rm_int<0xE5, "pmulhw", int_x86_mmx_pmulh_w, 1>;
250defm MMX_PMULHUW : MMXI_binop_rm_int<0xE4, "pmulhuw", int_x86_mmx_pmulhu_w, 1>;
251defm MMX_PMULUDQ : MMXI_binop_rm_int<0xF4, "pmuludq", int_x86_mmx_pmulu_dq, 1>;
252
253// -- Miscellanea
254defm MMX_PMADDWD : MMXI_binop_rm_int<0xF5, "pmaddwd", int_x86_mmx_pmadd_wd, 1>;
255
256defm MMX_PAVGB : MMXI_binop_rm_int<0xE0, "pavgb", int_x86_mmx_pavg_b, 1>;
257defm MMX_PAVGW : MMXI_binop_rm_int<0xE3, "pavgw", int_x86_mmx_pavg_w, 1>;
258
259defm MMX_PMINUB : MMXI_binop_rm_int<0xDA, "pminub", int_x86_mmx_pminu_b, 1>;
260defm MMX_PMINSW : MMXI_binop_rm_int<0xEA, "pminsw", int_x86_mmx_pmins_w, 1>;
261
262defm MMX_PMAXUB : MMXI_binop_rm_int<0xDE, "pmaxub", int_x86_mmx_pmaxu_b, 1>;
263defm MMX_PMAXSW : MMXI_binop_rm_int<0xEE, "pmaxsw", int_x86_mmx_pmaxs_w, 1>;
264
Bill Wendling953ad2e2009-05-28 02:04:00 +0000265defm MMX_PSADBW : MMXI_binop_rm_int<0xF6, "psadbw", int_x86_mmx_psad_bw, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266
267// Logical Instructions
268defm MMX_PAND : MMXI_binop_rm_v1i64<0xDB, "pand", and, 1>;
269defm MMX_POR : MMXI_binop_rm_v1i64<0xEB, "por" , or, 1>;
270defm MMX_PXOR : MMXI_binop_rm_v1i64<0xEF, "pxor", xor, 1>;
271
272let isTwoAddress = 1 in {
273 def MMX_PANDNrr : MMXI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000274 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000275 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276 [(set VR64:$dst, (v1i64 (and (vnot VR64:$src1),
277 VR64:$src2)))]>;
278 def MMX_PANDNrm : MMXI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000279 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000280 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000281 [(set VR64:$dst, (v1i64 (and (vnot VR64:$src1),
282 (load addr:$src2))))]>;
283}
284
285// Shift Instructions
286defm MMX_PSRLW : MMXI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
Evan Chengf90f8f82008-05-03 00:52:09 +0000287 int_x86_mmx_psrl_w, int_x86_mmx_psrli_w>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000288defm MMX_PSRLD : MMXI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
Evan Chengf90f8f82008-05-03 00:52:09 +0000289 int_x86_mmx_psrl_d, int_x86_mmx_psrli_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290defm MMX_PSRLQ : MMXI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Chengf90f8f82008-05-03 00:52:09 +0000291 int_x86_mmx_psrl_q, int_x86_mmx_psrli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000292
293defm MMX_PSLLW : MMXI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
Evan Chengf90f8f82008-05-03 00:52:09 +0000294 int_x86_mmx_psll_w, int_x86_mmx_pslli_w>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295defm MMX_PSLLD : MMXI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
Evan Chengf90f8f82008-05-03 00:52:09 +0000296 int_x86_mmx_psll_d, int_x86_mmx_pslli_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000297defm MMX_PSLLQ : MMXI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
Evan Chengf90f8f82008-05-03 00:52:09 +0000298 int_x86_mmx_psll_q, int_x86_mmx_pslli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000299
300defm MMX_PSRAW : MMXI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
Evan Chengf90f8f82008-05-03 00:52:09 +0000301 int_x86_mmx_psra_w, int_x86_mmx_psrai_w>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302defm MMX_PSRAD : MMXI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Chengf90f8f82008-05-03 00:52:09 +0000303 int_x86_mmx_psra_d, int_x86_mmx_psrai_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304
Evan Chengdea99362008-05-29 08:22:04 +0000305// Shift up / down and insert zero's.
306def : Pat<(v1i64 (X86vshl VR64:$src, (i8 imm:$amt))),
307 (v1i64 (MMX_PSLLQri VR64:$src, imm:$amt))>;
308def : Pat<(v1i64 (X86vshr VR64:$src, (i8 imm:$amt))),
309 (v1i64 (MMX_PSRLQri VR64:$src, imm:$amt))>;
310
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311// Comparison Instructions
312defm MMX_PCMPEQB : MMXI_binop_rm_int<0x74, "pcmpeqb", int_x86_mmx_pcmpeq_b>;
313defm MMX_PCMPEQW : MMXI_binop_rm_int<0x75, "pcmpeqw", int_x86_mmx_pcmpeq_w>;
314defm MMX_PCMPEQD : MMXI_binop_rm_int<0x76, "pcmpeqd", int_x86_mmx_pcmpeq_d>;
315
316defm MMX_PCMPGTB : MMXI_binop_rm_int<0x64, "pcmpgtb", int_x86_mmx_pcmpgt_b>;
317defm MMX_PCMPGTW : MMXI_binop_rm_int<0x65, "pcmpgtw", int_x86_mmx_pcmpgt_w>;
318defm MMX_PCMPGTD : MMXI_binop_rm_int<0x66, "pcmpgtd", int_x86_mmx_pcmpgt_d>;
319
320// Conversion Instructions
321
322// -- Unpack Instructions
323let isTwoAddress = 1 in {
324 // Unpack High Packed Data Instructions
325 def MMX_PUNPCKHBWrr : MMXI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000326 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000327 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000329 (v8i8 (mmx_unpckh VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000330 def MMX_PUNPCKHBWrm : MMXI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000331 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000332 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000334 (v8i8 (mmx_unpckh VR64:$src1,
335 (bc_v8i8 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000336
337 def MMX_PUNPCKHWDrr : MMXI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000338 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000339 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000341 (v4i16 (mmx_unpckh VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000342 def MMX_PUNPCKHWDrm : MMXI<0x69, 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 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000346 (v4i16 (mmx_unpckh VR64:$src1,
347 (bc_v4i16 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000348
349 def MMX_PUNPCKHDQrr : MMXI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000350 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000351 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000352 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000353 (v2i32 (mmx_unpckh VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 def MMX_PUNPCKHDQrm : MMXI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000355 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000356 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000358 (v2i32 (mmx_unpckh VR64:$src1,
359 (bc_v2i32 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000360
361 // Unpack Low Packed Data Instructions
362 def MMX_PUNPCKLBWrr : MMXI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000363 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000364 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000366 (v8i8 (mmx_unpckl VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000367 def MMX_PUNPCKLBWrm : MMXI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000368 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000369 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000370 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000371 (v8i8 (mmx_unpckl VR64:$src1,
372 (bc_v8i8 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000373
374 def MMX_PUNPCKLWDrr : MMXI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000375 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000376 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000377 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000378 (v4i16 (mmx_unpckl VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000379 def MMX_PUNPCKLWDrm : MMXI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000380 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000383 (v4i16 (mmx_unpckl VR64:$src1,
384 (bc_v4i16 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385
386 def MMX_PUNPCKLDQrr : MMXI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000387 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000388 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000389 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000390 (v2i32 (mmx_unpckl VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391 def MMX_PUNPCKLDQrm : MMXI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000392 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000393 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000395 (v2i32 (mmx_unpckl VR64:$src1,
396 (bc_v2i32 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000397}
398
399// -- Pack Instructions
400defm MMX_PACKSSWB : MMXI_binop_rm_int<0x63, "packsswb", int_x86_mmx_packsswb>;
401defm MMX_PACKSSDW : MMXI_binop_rm_int<0x6B, "packssdw", int_x86_mmx_packssdw>;
402defm MMX_PACKUSWB : MMXI_binop_rm_int<0x67, "packuswb", int_x86_mmx_packuswb>;
403
404// -- Shuffle Instructions
405def MMX_PSHUFWri : MMXIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000406 (outs VR64:$dst), (ins VR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000407 "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000408 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000409 (v4i16 (mmx_pshufw:$src2 VR64:$src1, (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410def MMX_PSHUFWmi : MMXIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000411 (outs VR64:$dst), (ins i64mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000412 "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000414 (mmx_pshufw:$src2 (bc_v4i16 (load_mmx addr:$src1)),
415 (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416
417// -- Conversion Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000418let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000419def MMX_CVTPD2PIrr : MMX2I<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000420 "cvtpd2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000421let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000422def MMX_CVTPD2PIrm : MMX2I<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000423 "cvtpd2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424
Evan Chengb783fa32007-07-19 01:14:50 +0000425def MMX_CVTPI2PDrr : MMX2I<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000426 "cvtpi2pd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000427let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000428def MMX_CVTPI2PDrm : MMX2I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000429 "cvtpi2pd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430
Evan Chengb783fa32007-07-19 01:14:50 +0000431def MMX_CVTPI2PSrr : MMXI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000432 "cvtpi2ps\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000433let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000434def MMX_CVTPI2PSrm : MMXI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000435 "cvtpi2ps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436
Evan Chengb783fa32007-07-19 01:14:50 +0000437def MMX_CVTPS2PIrr : MMXI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000438 "cvtps2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000439let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000440def MMX_CVTPS2PIrm : MMXI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000441 "cvtps2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442
Evan Chengb783fa32007-07-19 01:14:50 +0000443def MMX_CVTTPD2PIrr : MMX2I<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000444 "cvttpd2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000445let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000446def MMX_CVTTPD2PIrm : MMX2I<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000447 "cvttpd2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000448
Evan Chengb783fa32007-07-19 01:14:50 +0000449def MMX_CVTTPS2PIrr : MMXI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000450 "cvttps2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000451let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000452def MMX_CVTTPS2PIrm : MMXI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000453 "cvttps2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000454} // end neverHasSideEffects
455
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456
457// Extract / Insert
458def MMX_X86pextrw : SDNode<"X86ISD::PEXTRW", SDTypeProfile<1, 2, []>, []>;
459def MMX_X86pinsrw : SDNode<"X86ISD::PINSRW", SDTypeProfile<1, 3, []>, []>;
460
461def MMX_PEXTRWri : MMXIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000462 (outs GR32:$dst), (ins VR64:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000463 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464 [(set GR32:$dst, (MMX_X86pextrw (v4i16 VR64:$src1),
465 (iPTR imm:$src2)))]>;
466let isTwoAddress = 1 in {
467 def MMX_PINSRWrri : MMXIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000468 (outs VR64:$dst), (ins VR64:$src1, GR32:$src2, i16i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000469 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470 [(set VR64:$dst, (v4i16 (MMX_X86pinsrw (v4i16 VR64:$src1),
471 GR32:$src2, (iPTR imm:$src3))))]>;
472 def MMX_PINSRWrmi : MMXIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000473 (outs VR64:$dst), (ins VR64:$src1, i16mem:$src2, i16i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000474 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000475 [(set VR64:$dst,
476 (v4i16 (MMX_X86pinsrw (v4i16 VR64:$src1),
477 (i32 (anyext (loadi16 addr:$src2))),
478 (iPTR imm:$src3))))]>;
479}
480
481// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000482def MMX_PMOVMSKBrr : MMXI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000483 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000484 [(set GR32:$dst, (int_x86_mmx_pmovmskb VR64:$src))]>;
485
486// Misc.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000487let Uses = [EDI] in
Bill Wendling8fb68282009-06-23 19:52:59 +0000488def MMX_MASKMOVQ : MMXI<0xF7, MRMSrcReg, (outs), (ins VR64:$src, VR64:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +0000489 "maskmovq\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000490 [(int_x86_mmx_maskmovq VR64:$src, VR64:$mask, EDI)]>;
Anton Korobeynikov0e70d102008-08-23 15:53:19 +0000491let Uses = [RDI] in
Bill Wendling8fb68282009-06-23 19:52:59 +0000492def MMX_MASKMOVQ64: MMXI64<0xF7, MRMSrcReg, (outs), (ins VR64:$src, VR64:$mask),
Anton Korobeynikov0e70d102008-08-23 15:53:19 +0000493 "maskmovq\t{$mask, $src|$src, $mask}",
494 [(int_x86_mmx_maskmovq VR64:$src, VR64:$mask, RDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495
496//===----------------------------------------------------------------------===//
497// Alias Instructions
498//===----------------------------------------------------------------------===//
499
500// Alias instructions that map zero vector to pxor.
Chris Lattner17dab4a2008-01-10 05:45:39 +0000501let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000502 def MMX_V_SET0 : MMXI<0xEF, MRMInitReg, (outs VR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000503 "pxor\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000504 [(set VR64:$dst, (v2i32 immAllZerosV))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000505 def MMX_V_SETALLONES : MMXI<0x76, MRMInitReg, (outs VR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000506 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000507 [(set VR64:$dst, (v2i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508}
509
Evan Chenga15896e2008-03-12 07:02:50 +0000510let Predicates = [HasMMX] in {
511 def : Pat<(v1i64 immAllZerosV), (MMX_V_SET0)>;
512 def : Pat<(v4i16 immAllZerosV), (MMX_V_SET0)>;
513 def : Pat<(v8i8 immAllZerosV), (MMX_V_SET0)>;
514}
515
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516//===----------------------------------------------------------------------===//
517// Non-Instruction Patterns
518//===----------------------------------------------------------------------===//
519
520// Store 64-bit integer vector values.
521def : Pat<(store (v8i8 VR64:$src), addr:$dst),
522 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
523def : Pat<(store (v4i16 VR64:$src), addr:$dst),
524 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
525def : Pat<(store (v2i32 VR64:$src), addr:$dst),
526 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000527def : Pat<(store (v2f32 VR64:$src), addr:$dst),
528 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529def : Pat<(store (v1i64 VR64:$src), addr:$dst),
530 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
531
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532// Bit convert.
533def : Pat<(v8i8 (bitconvert (v1i64 VR64:$src))), (v8i8 VR64:$src)>;
534def : Pat<(v8i8 (bitconvert (v2i32 VR64:$src))), (v8i8 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000535def : Pat<(v8i8 (bitconvert (v2f32 VR64:$src))), (v8i8 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536def : Pat<(v8i8 (bitconvert (v4i16 VR64:$src))), (v8i8 VR64:$src)>;
537def : Pat<(v4i16 (bitconvert (v1i64 VR64:$src))), (v4i16 VR64:$src)>;
538def : Pat<(v4i16 (bitconvert (v2i32 VR64:$src))), (v4i16 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000539def : Pat<(v4i16 (bitconvert (v2f32 VR64:$src))), (v4i16 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540def : Pat<(v4i16 (bitconvert (v8i8 VR64:$src))), (v4i16 VR64:$src)>;
541def : Pat<(v2i32 (bitconvert (v1i64 VR64:$src))), (v2i32 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000542def : Pat<(v2i32 (bitconvert (v2f32 VR64:$src))), (v2i32 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543def : Pat<(v2i32 (bitconvert (v4i16 VR64:$src))), (v2i32 VR64:$src)>;
544def : Pat<(v2i32 (bitconvert (v8i8 VR64:$src))), (v2i32 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000545def : Pat<(v2f32 (bitconvert (v1i64 VR64:$src))), (v2f32 VR64:$src)>;
546def : Pat<(v2f32 (bitconvert (v2i32 VR64:$src))), (v2f32 VR64:$src)>;
547def : Pat<(v2f32 (bitconvert (v4i16 VR64:$src))), (v2f32 VR64:$src)>;
548def : Pat<(v2f32 (bitconvert (v8i8 VR64:$src))), (v2f32 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549def : Pat<(v1i64 (bitconvert (v2i32 VR64:$src))), (v1i64 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000550def : Pat<(v1i64 (bitconvert (v2f32 VR64:$src))), (v1i64 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551def : Pat<(v1i64 (bitconvert (v4i16 VR64:$src))), (v1i64 VR64:$src)>;
552def : Pat<(v1i64 (bitconvert (v8i8 VR64:$src))), (v1i64 VR64:$src)>;
553
554// 64-bit bit convert.
555def : Pat<(v1i64 (bitconvert (i64 GR64:$src))),
556 (MMX_MOVD64to64rr GR64:$src)>;
557def : Pat<(v2i32 (bitconvert (i64 GR64:$src))),
558 (MMX_MOVD64to64rr GR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000559def : Pat<(v2f32 (bitconvert (i64 GR64:$src))),
560 (MMX_MOVD64to64rr GR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561def : Pat<(v4i16 (bitconvert (i64 GR64:$src))),
562 (MMX_MOVD64to64rr GR64:$src)>;
563def : Pat<(v8i8 (bitconvert (i64 GR64:$src))),
564 (MMX_MOVD64to64rr GR64:$src)>;
Dan Gohman4535ae32008-04-15 23:55:07 +0000565def : Pat<(i64 (bitconvert (v1i64 VR64:$src))),
566 (MMX_MOVD64from64rr VR64:$src)>;
567def : Pat<(i64 (bitconvert (v2i32 VR64:$src))),
568 (MMX_MOVD64from64rr VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000569def : Pat<(i64 (bitconvert (v2f32 VR64:$src))),
570 (MMX_MOVD64from64rr VR64:$src)>;
Dan Gohman4535ae32008-04-15 23:55:07 +0000571def : Pat<(i64 (bitconvert (v4i16 VR64:$src))),
572 (MMX_MOVD64from64rr VR64:$src)>;
573def : Pat<(i64 (bitconvert (v8i8 VR64:$src))),
574 (MMX_MOVD64from64rr VR64:$src)>;
Evan Chengef356282009-02-23 09:03:22 +0000575def : Pat<(f64 (bitconvert (v1i64 VR64:$src))),
576 (MMX_MOVQ2FR64rr VR64:$src)>;
577def : Pat<(f64 (bitconvert (v2i32 VR64:$src))),
578 (MMX_MOVQ2FR64rr VR64:$src)>;
579def : Pat<(f64 (bitconvert (v4i16 VR64:$src))),
580 (MMX_MOVQ2FR64rr VR64:$src)>;
581def : Pat<(f64 (bitconvert (v8i8 VR64:$src))),
582 (MMX_MOVQ2FR64rr VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000583
Evan Cheng778641e2008-11-05 06:04:51 +0000584let AddedComplexity = 20 in {
Evan Cheng778641e2008-11-05 06:04:51 +0000585 def : Pat<(v2i32 (X86vzmovl (bc_v2i32 (load_mmx addr:$src)))),
Evan Chengb76ecc82008-12-03 19:38:05 +0000586 (MMX_MOVZDI2PDIrm addr:$src)>;
587}
588
589// Clear top half.
590let AddedComplexity = 15 in {
Evan Chengb76ecc82008-12-03 19:38:05 +0000591 def : Pat<(v2i32 (X86vzmovl VR64:$src)),
592 (MMX_PUNPCKLDQrr VR64:$src, (MMX_V_SET0))>;
Evan Cheng778641e2008-11-05 06:04:51 +0000593}
594
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595// Patterns to perform canonical versions of vector shuffling.
596let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000597 def : Pat<(v8i8 (mmx_unpckl_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598 (MMX_PUNPCKLBWrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000599 def : Pat<(v4i16 (mmx_unpckl_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600 (MMX_PUNPCKLWDrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000601 def : Pat<(v2i32 (mmx_unpckl_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000602 (MMX_PUNPCKLDQrr VR64:$src, VR64:$src)>;
603}
604
605let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000606 def : Pat<(v8i8 (mmx_unpckh_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607 (MMX_PUNPCKHBWrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000608 def : Pat<(v4i16 (mmx_unpckh_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609 (MMX_PUNPCKHWDrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000610 def : Pat<(v2i32 (mmx_unpckh_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611 (MMX_PUNPCKHDQrr VR64:$src, VR64:$src)>;
612}
613
614// Patterns to perform vector shuffling with a zeroed out vector.
615let AddedComplexity = 20 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000616 def : Pat<(bc_v2i32 (mmx_unpckl immAllZerosV,
617 (v2i32 (scalar_to_vector (load_mmx addr:$src))))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618 (MMX_PUNPCKLDQrm VR64:$src, VR64:$src)>;
619}
620
621// Some special case PANDN patterns.
622// FIXME: Get rid of these.
623def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v2i32 immAllOnesV))),
624 VR64:$src2)),
625 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
Chris Lattnere6aa3862007-11-25 00:24:49 +0000626def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v4i16 immAllOnesV_bc))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 VR64:$src2)),
628 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
Chris Lattnere6aa3862007-11-25 00:24:49 +0000629def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v8i8 immAllOnesV_bc))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630 VR64:$src2)),
631 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
632
633def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v2i32 immAllOnesV))),
634 (load addr:$src2))),
635 (MMX_PANDNrm VR64:$src1, addr:$src2)>;
Chris Lattnere6aa3862007-11-25 00:24:49 +0000636def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v4i16 immAllOnesV_bc))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000637 (load addr:$src2))),
638 (MMX_PANDNrm VR64:$src1, addr:$src2)>;
Chris Lattnere6aa3862007-11-25 00:24:49 +0000639def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v8i8 immAllOnesV_bc))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640 (load addr:$src2))),
641 (MMX_PANDNrm VR64:$src1, addr:$src2)>;
Evan Cheng2aea0b42008-04-25 19:11:04 +0000642
643// Move MMX to lower 64-bit of XMM
Evan Chengef356282009-02-23 09:03:22 +0000644def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v8i8 VR64:$src))))),
645 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
646def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v4i16 VR64:$src))))),
647 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
648def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v2i32 VR64:$src))))),
649 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
650def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v1i64 VR64:$src))))),
Evan Cheng2aea0b42008-04-25 19:11:04 +0000651 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
Evan Cheng1428f582008-04-25 20:12:46 +0000652
653// Move lower 64-bit of XMM to MMX.
654def : Pat<(v2i32 (bitconvert (i64 (vector_extract (v2i64 VR128:$src),
655 (iPTR 0))))),
656 (v2i32 (MMX_MOVDQ2Qrr VR128:$src))>;
657def : Pat<(v4i16 (bitconvert (i64 (vector_extract (v2i64 VR128:$src),
658 (iPTR 0))))),
659 (v4i16 (MMX_MOVDQ2Qrr VR128:$src))>;
660def : Pat<(v8i8 (bitconvert (i64 (vector_extract (v2i64 VR128:$src),
661 (iPTR 0))))),
662 (v8i8 (MMX_MOVDQ2Qrr VR128:$src))>;
663
Eli Friedman7dab4932009-07-22 01:06:52 +0000664// Patterns for vector comparisons
665def : Pat<(v8i8 (X86pcmpeqb VR64:$src1, VR64:$src2)),
666 (MMX_PCMPEQBrr VR64:$src1, VR64:$src2)>;
667def : Pat<(v8i8 (X86pcmpeqb VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
668 (MMX_PCMPEQBrm VR64:$src1, addr:$src2)>;
669def : Pat<(v4i16 (X86pcmpeqw VR64:$src1, VR64:$src2)),
670 (MMX_PCMPEQWrr VR64:$src1, VR64:$src2)>;
671def : Pat<(v4i16 (X86pcmpeqw VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
672 (MMX_PCMPEQWrm VR64:$src1, addr:$src2)>;
673def : Pat<(v2i32 (X86pcmpeqd VR64:$src1, VR64:$src2)),
674 (MMX_PCMPEQDrr VR64:$src1, VR64:$src2)>;
675def : Pat<(v2i32 (X86pcmpeqd VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
676 (MMX_PCMPEQDrm VR64:$src1, addr:$src2)>;
677
678def : Pat<(v8i8 (X86pcmpgtb VR64:$src1, VR64:$src2)),
679 (MMX_PCMPGTBrr VR64:$src1, VR64:$src2)>;
680def : Pat<(v8i8 (X86pcmpgtb VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
681 (MMX_PCMPGTBrm VR64:$src1, addr:$src2)>;
682def : Pat<(v4i16 (X86pcmpgtw VR64:$src1, VR64:$src2)),
683 (MMX_PCMPGTWrr VR64:$src1, VR64:$src2)>;
684def : Pat<(v4i16 (X86pcmpgtw VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
685 (MMX_PCMPGTWrm VR64:$src1, addr:$src2)>;
686def : Pat<(v2i32 (X86pcmpgtd VR64:$src1, VR64:$src2)),
687 (MMX_PCMPGTDrr VR64:$src1, VR64:$src2)>;
688def : Pat<(v2i32 (X86pcmpgtd VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
689 (MMX_PCMPGTDrm VR64:$src1, addr:$src2)>;
690
Mon P Wang83edba52008-12-12 01:25:51 +0000691// CMOV* - Used to implement the SELECT DAG operation. Expanded by the
692// scheduler into a branch sequence.
693// These are expanded by the scheduler.
694let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
695 def CMOV_V1I64 : I<0, Pseudo,
696 (outs VR64:$dst), (ins VR64:$t, VR64:$f, i8imm:$cond),
697 "#CMOV_V1I64 PSEUDO!",
698 [(set VR64:$dst,
699 (v1i64 (X86cmov VR64:$t, VR64:$f, imm:$cond,
700 EFLAGS)))]>;
701}