blob: 89f020cc72fc640764ca5b9274a46c62e18d2c9c [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//====- X86InstrMMX.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Eric Christopher74c525e2009-08-10 22:37:37 +00002//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003// 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.
Eric Christopher74c525e2009-08-10 22:37:37 +00007//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00008//===----------------------------------------------------------------------===//
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//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +000017// MMX Multiclasses
18//===----------------------------------------------------------------------===//
19
Eric Christopher74c525e2009-08-10 22:37:37 +000020let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000021 // MMXI_binop_rm - Simple MMX binary operator.
22 multiclass MMXI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
23 ValueType OpVT, bit Commutable = 0> {
Eric Christopher74c525e2009-08-10 22:37:37 +000024 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +000025 (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000026 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027 [(set VR64:$dst, (OpVT (OpNode VR64:$src1, VR64:$src2)))]> {
28 let isCommutable = Commutable;
29 }
Eric Christopher74c525e2009-08-10 22:37:37 +000030 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +000031 (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000032 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000033 [(set VR64:$dst, (OpVT (OpNode VR64:$src1,
34 (bitconvert
35 (load_mmx addr:$src2)))))]>;
36 }
37
38 multiclass MMXI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
39 bit Commutable = 0> {
Eric Christopher74c525e2009-08-10 22:37:37 +000040 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +000041 (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000042 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043 [(set VR64:$dst, (IntId VR64:$src1, VR64:$src2))]> {
44 let isCommutable = Commutable;
45 }
Eric Christopher74c525e2009-08-10 22:37:37 +000046 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +000047 (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000048 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000049 [(set VR64:$dst, (IntId VR64:$src1,
50 (bitconvert (load_mmx addr:$src2))))]>;
51 }
52
53 // MMXI_binop_rm_v1i64 - Simple MMX binary operator whose type is v1i64.
54 //
55 // FIXME: we could eliminate this and use MMXI_binop_rm instead if tblgen knew
56 // to collapse (bitconvert VT to VT) into its operand.
57 //
58 multiclass MMXI_binop_rm_v1i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
59 bit Commutable = 0> {
Evan Cheng7fcccab2008-03-21 00:40:09 +000060 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst),
61 (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000062 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000063 [(set VR64:$dst, (v1i64 (OpNode VR64:$src1, VR64:$src2)))]> {
64 let isCommutable = Commutable;
65 }
Evan Cheng7fcccab2008-03-21 00:40:09 +000066 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst),
67 (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000068 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069 [(set VR64:$dst,
70 (OpNode VR64:$src1,(load_mmx addr:$src2)))]>;
71 }
72
73 multiclass MMXI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
Evan Chengf90f8f82008-05-03 00:52:09 +000074 string OpcodeStr, Intrinsic IntId,
75 Intrinsic IntId2> {
Evan Cheng7fcccab2008-03-21 00:40:09 +000076 def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst),
77 (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000078 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079 [(set VR64:$dst, (IntId VR64:$src1, VR64:$src2))]>;
Evan Cheng7fcccab2008-03-21 00:40:09 +000080 def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst),
81 (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000082 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083 [(set VR64:$dst, (IntId VR64:$src1,
84 (bitconvert (load_mmx addr:$src2))))]>;
Evan Cheng7fcccab2008-03-21 00:40:09 +000085 def ri : MMXIi8<opc2, ImmForm, (outs VR64:$dst),
86 (ins VR64:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +000087 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Chengf90f8f82008-05-03 00:52:09 +000088 [(set VR64:$dst, (IntId2 VR64:$src1, (i32 imm:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000089 }
90}
91
92//===----------------------------------------------------------------------===//
93// MMX EMMS & FEMMS Instructions
94//===----------------------------------------------------------------------===//
95
Eric Christopher74c525e2009-08-10 22:37:37 +000096def MMX_EMMS : MMXI<0x77, RawFrm, (outs), (ins), "emms",
Sean Callanan2c48df22009-12-18 00:01:26 +000097 [(int_x86_mmx_emms)]>;
Eric Christopher74c525e2009-08-10 22:37:37 +000098def MMX_FEMMS : MMXI<0x0E, RawFrm, (outs), (ins), "femms",
Sean Callanan2c48df22009-12-18 00:01:26 +000099 [(int_x86_mmx_femms)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000100
101//===----------------------------------------------------------------------===//
102// MMX Scalar Instructions
103//===----------------------------------------------------------------------===//
104
105// Data Transfer Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000106def MMX_MOVD64rr : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR32:$src),
Evan Chengd1045a62008-02-18 23:04:32 +0000107 "movd\t{$src, $dst|$dst, $src}",
Sean Callanan2c48df22009-12-18 00:01:26 +0000108 [(set VR64:$dst,
109 (v2i32 (scalar_to_vector GR32:$src)))]>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000110let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000111def MMX_MOVD64rm : MMXI<0x6E, MRMSrcMem, (outs VR64:$dst), (ins i32mem:$src),
Evan Chengd1045a62008-02-18 23:04:32 +0000112 "movd\t{$src, $dst|$dst, $src}",
Eric Christopher74c525e2009-08-10 22:37:37 +0000113 [(set VR64:$dst,
Sean Callanan2c48df22009-12-18 00:01:26 +0000114 (v2i32 (scalar_to_vector (loadi32 addr:$src))))]>;
Eric Christopher74c525e2009-08-10 22:37:37 +0000115let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000116def MMX_MOVD64mr : MMXI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000117 "movd\t{$src, $dst|$dst, $src}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000118def MMX_MOVD64grr : MMXI<0x7E, MRMDestReg, (outs), (ins GR32:$dst, VR64:$src),
119 "movd\t{$src, $dst|$dst, $src}", []>;
120def MMX_MOVQ64gmr : MMXRI<0x7E, MRMDestMem, (outs),
121 (ins i64mem:$dst, VR64:$src),
122 "movq\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000124let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000125def MMX_MOVD64to64rr : MMXRI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR64:$src),
Evan Chengef356282009-02-23 09:03:22 +0000126 "movd\t{$src, $dst|$dst, $src}",
127 []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000128
Evan Chengcd6d09d2009-08-03 18:07:19 +0000129let neverHasSideEffects = 1 in
Rafael Espindola97b78282009-08-03 05:21:05 +0000130// These are 64 bit moves, but since the OS X assembler doesn't
131// recognize a register-register movq, we write them as
132// movd.
Rafael Espindolac1fcb8c2009-08-03 03:27:05 +0000133def MMX_MOVD64from64rr : MMXRI<0x7E, MRMDestReg,
Evan Chengef356282009-02-23 09:03:22 +0000134 (outs GR64:$dst), (ins VR64:$src),
Rafael Espindola97b78282009-08-03 05:21:05 +0000135 "movd\t{$src, $dst|$dst, $src}", []>;
Rafael Espindolac1fcb8c2009-08-03 03:27:05 +0000136def MMX_MOVD64rrv164 : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR64:$src),
Rafael Espindola97b78282009-08-03 05:21:05 +0000137 "movd\t{$src, $dst|$dst, $src}",
Eric Christopher74c525e2009-08-10 22:37:37 +0000138 [(set VR64:$dst,
Sean Callanan2c48df22009-12-18 00:01:26 +0000139 (v1i64 (scalar_to_vector GR64:$src)))]>;
Dan Gohman4535ae32008-04-15 23:55:07 +0000140
141let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000142def MMX_MOVQ64rr : MMXI<0x6F, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000143 "movq\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000144let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000145def MMX_MOVQ64rm : MMXI<0x6F, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000146 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000147 [(set VR64:$dst, (load_mmx addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000148def MMX_MOVQ64mr : MMXI<0x7F, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000149 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000150 [(store (v1i64 VR64:$src), addr:$dst)]>;
151
Eli Friedman6ff96fc2009-07-09 16:49:25 +0000152def MMX_MOVDQ2Qrr : SDIi8<0xD6, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000153 "movdq2q\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000154 [(set VR64:$dst,
Evan Cheng1428f582008-04-25 20:12:46 +0000155 (v1i64 (bitconvert
156 (i64 (vector_extract (v2i64 VR128:$src),
157 (iPTR 0))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000158
Eli Friedman6ff96fc2009-07-09 16:49:25 +0000159def MMX_MOVQ2DQrr : SSDIi8<0xD6, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
Bill Wendling64fe3dd2008-08-27 21:32:04 +0000160 "movq2dq\t{$src, $dst|$dst, $src}",
Evan Cheng5e4d1e72008-04-25 18:19:54 +0000161 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000162 (movl immAllZerosV,
163 (v2i64 (scalar_to_vector (i64 (bitconvert VR64:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000164
Evan Chengef356282009-02-23 09:03:22 +0000165let neverHasSideEffects = 1 in
Eli Friedman6ff96fc2009-07-09 16:49:25 +0000166def MMX_MOVQ2FR64rr: SSDIi8<0xD6, MRMSrcReg, (outs FR64:$dst), (ins VR64:$src),
Evan Chengef356282009-02-23 09:03:22 +0000167 "movq2dq\t{$src, $dst|$dst, $src}", []>;
168
Evan Chengb783fa32007-07-19 01:14:50 +0000169def MMX_MOVNTQmr : MMXI<0xE7, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000170 "movntq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171 [(int_x86_mmx_movnt_dq addr:$dst, VR64:$src)]>;
172
173let AddedComplexity = 15 in
174// movd to MMX register zero-extends
Anders Carlssona31d51a2008-02-29 01:35:12 +0000175def MMX_MOVZDI2PDIrr : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000176 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng40ee6e52008-05-08 00:57:18 +0000177 [(set VR64:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +0000178 (v2i32 (X86vzmovl (v2i32 (scalar_to_vector GR32:$src)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179let AddedComplexity = 20 in
Eric Christopher74c525e2009-08-10 22:37:37 +0000180def MMX_MOVZDI2PDIrm : MMXI<0x6E, MRMSrcMem, (outs VR64:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +0000181 (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000182 "movd\t{$src, $dst|$dst, $src}",
Evan Cheng40ee6e52008-05-08 00:57:18 +0000183 [(set VR64:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +0000184 (v2i32 (X86vzmovl (v2i32
Evan Cheng40ee6e52008-05-08 00:57:18 +0000185 (scalar_to_vector (loadi32 addr:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186
187// Arithmetic Instructions
188
189// -- Addition
190defm MMX_PADDB : MMXI_binop_rm<0xFC, "paddb", add, v8i8, 1>;
191defm MMX_PADDW : MMXI_binop_rm<0xFD, "paddw", add, v4i16, 1>;
192defm MMX_PADDD : MMXI_binop_rm<0xFE, "paddd", add, v2i32, 1>;
193defm MMX_PADDQ : MMXI_binop_rm<0xD4, "paddq", add, v1i64, 1>;
194
195defm MMX_PADDSB : MMXI_binop_rm_int<0xEC, "paddsb" , int_x86_mmx_padds_b, 1>;
196defm MMX_PADDSW : MMXI_binop_rm_int<0xED, "paddsw" , int_x86_mmx_padds_w, 1>;
197
198defm MMX_PADDUSB : MMXI_binop_rm_int<0xDC, "paddusb", int_x86_mmx_paddus_b, 1>;
199defm MMX_PADDUSW : MMXI_binop_rm_int<0xDD, "paddusw", int_x86_mmx_paddus_w, 1>;
200
201// -- Subtraction
202defm MMX_PSUBB : MMXI_binop_rm<0xF8, "psubb", sub, v8i8>;
203defm MMX_PSUBW : MMXI_binop_rm<0xF9, "psubw", sub, v4i16>;
204defm MMX_PSUBD : MMXI_binop_rm<0xFA, "psubd", sub, v2i32>;
205defm MMX_PSUBQ : MMXI_binop_rm<0xFB, "psubq", sub, v1i64>;
206
207defm MMX_PSUBSB : MMXI_binop_rm_int<0xE8, "psubsb" , int_x86_mmx_psubs_b>;
208defm MMX_PSUBSW : MMXI_binop_rm_int<0xE9, "psubsw" , int_x86_mmx_psubs_w>;
209
210defm MMX_PSUBUSB : MMXI_binop_rm_int<0xD8, "psubusb", int_x86_mmx_psubus_b>;
211defm MMX_PSUBUSW : MMXI_binop_rm_int<0xD9, "psubusw", int_x86_mmx_psubus_w>;
212
213// -- Multiplication
214defm MMX_PMULLW : MMXI_binop_rm<0xD5, "pmullw", mul, v4i16, 1>;
215
216defm MMX_PMULHW : MMXI_binop_rm_int<0xE5, "pmulhw", int_x86_mmx_pmulh_w, 1>;
217defm MMX_PMULHUW : MMXI_binop_rm_int<0xE4, "pmulhuw", int_x86_mmx_pmulhu_w, 1>;
218defm MMX_PMULUDQ : MMXI_binop_rm_int<0xF4, "pmuludq", int_x86_mmx_pmulu_dq, 1>;
219
220// -- Miscellanea
221defm MMX_PMADDWD : MMXI_binop_rm_int<0xF5, "pmaddwd", int_x86_mmx_pmadd_wd, 1>;
222
223defm MMX_PAVGB : MMXI_binop_rm_int<0xE0, "pavgb", int_x86_mmx_pavg_b, 1>;
224defm MMX_PAVGW : MMXI_binop_rm_int<0xE3, "pavgw", int_x86_mmx_pavg_w, 1>;
225
226defm MMX_PMINUB : MMXI_binop_rm_int<0xDA, "pminub", int_x86_mmx_pminu_b, 1>;
227defm MMX_PMINSW : MMXI_binop_rm_int<0xEA, "pminsw", int_x86_mmx_pmins_w, 1>;
228
229defm MMX_PMAXUB : MMXI_binop_rm_int<0xDE, "pmaxub", int_x86_mmx_pmaxu_b, 1>;
230defm MMX_PMAXSW : MMXI_binop_rm_int<0xEE, "pmaxsw", int_x86_mmx_pmaxs_w, 1>;
231
Bill Wendling953ad2e2009-05-28 02:04:00 +0000232defm MMX_PSADBW : MMXI_binop_rm_int<0xF6, "psadbw", int_x86_mmx_psad_bw, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233
234// Logical Instructions
235defm MMX_PAND : MMXI_binop_rm_v1i64<0xDB, "pand", and, 1>;
236defm MMX_POR : MMXI_binop_rm_v1i64<0xEB, "por" , or, 1>;
237defm MMX_PXOR : MMXI_binop_rm_v1i64<0xEF, "pxor", xor, 1>;
238
Eric Christopher74c525e2009-08-10 22:37:37 +0000239let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000240 def MMX_PANDNrr : MMXI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000241 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000242 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243 [(set VR64:$dst, (v1i64 (and (vnot VR64:$src1),
244 VR64:$src2)))]>;
245 def MMX_PANDNrm : MMXI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000246 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000247 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000248 [(set VR64:$dst, (v1i64 (and (vnot VR64:$src1),
249 (load addr:$src2))))]>;
250}
251
252// Shift Instructions
253defm MMX_PSRLW : MMXI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
Evan Chengf90f8f82008-05-03 00:52:09 +0000254 int_x86_mmx_psrl_w, int_x86_mmx_psrli_w>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255defm MMX_PSRLD : MMXI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
Evan Chengf90f8f82008-05-03 00:52:09 +0000256 int_x86_mmx_psrl_d, int_x86_mmx_psrli_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000257defm MMX_PSRLQ : MMXI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Chengf90f8f82008-05-03 00:52:09 +0000258 int_x86_mmx_psrl_q, int_x86_mmx_psrli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000259
260defm MMX_PSLLW : MMXI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
Evan Chengf90f8f82008-05-03 00:52:09 +0000261 int_x86_mmx_psll_w, int_x86_mmx_pslli_w>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262defm MMX_PSLLD : MMXI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
Evan Chengf90f8f82008-05-03 00:52:09 +0000263 int_x86_mmx_psll_d, int_x86_mmx_pslli_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264defm MMX_PSLLQ : MMXI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
Evan Chengf90f8f82008-05-03 00:52:09 +0000265 int_x86_mmx_psll_q, int_x86_mmx_pslli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266
267defm MMX_PSRAW : MMXI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
Evan Chengf90f8f82008-05-03 00:52:09 +0000268 int_x86_mmx_psra_w, int_x86_mmx_psrai_w>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269defm MMX_PSRAD : MMXI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Chengf90f8f82008-05-03 00:52:09 +0000270 int_x86_mmx_psra_d, int_x86_mmx_psrai_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271
Evan Chengdea99362008-05-29 08:22:04 +0000272// Shift up / down and insert zero's.
273def : Pat<(v1i64 (X86vshl VR64:$src, (i8 imm:$amt))),
274 (v1i64 (MMX_PSLLQri VR64:$src, imm:$amt))>;
275def : Pat<(v1i64 (X86vshr VR64:$src, (i8 imm:$amt))),
276 (v1i64 (MMX_PSRLQri VR64:$src, imm:$amt))>;
277
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278// Comparison Instructions
279defm MMX_PCMPEQB : MMXI_binop_rm_int<0x74, "pcmpeqb", int_x86_mmx_pcmpeq_b>;
280defm MMX_PCMPEQW : MMXI_binop_rm_int<0x75, "pcmpeqw", int_x86_mmx_pcmpeq_w>;
281defm MMX_PCMPEQD : MMXI_binop_rm_int<0x76, "pcmpeqd", int_x86_mmx_pcmpeq_d>;
282
283defm MMX_PCMPGTB : MMXI_binop_rm_int<0x64, "pcmpgtb", int_x86_mmx_pcmpgt_b>;
284defm MMX_PCMPGTW : MMXI_binop_rm_int<0x65, "pcmpgtw", int_x86_mmx_pcmpgt_w>;
285defm MMX_PCMPGTD : MMXI_binop_rm_int<0x66, "pcmpgtd", int_x86_mmx_pcmpgt_d>;
286
287// Conversion Instructions
288
289// -- Unpack Instructions
Eric Christopher74c525e2009-08-10 22:37:37 +0000290let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291 // Unpack High Packed Data Instructions
Eric Christopher74c525e2009-08-10 22:37:37 +0000292 def MMX_PUNPCKHBWrr : MMXI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000293 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000294 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000296 (v8i8 (mmx_unpckh VR64:$src1, VR64:$src2)))]>;
Eric Christopher74c525e2009-08-10 22:37:37 +0000297 def MMX_PUNPCKHBWrm : MMXI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000298 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000299 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000301 (v8i8 (mmx_unpckh VR64:$src1,
302 (bc_v8i8 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000303
Eric Christopher74c525e2009-08-10 22:37:37 +0000304 def MMX_PUNPCKHWDrr : MMXI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000305 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000306 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000308 (v4i16 (mmx_unpckh VR64:$src1, VR64:$src2)))]>;
Eric Christopher74c525e2009-08-10 22:37:37 +0000309 def MMX_PUNPCKHWDrm : MMXI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000310 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000311 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000313 (v4i16 (mmx_unpckh VR64:$src1,
314 (bc_v4i16 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315
Eric Christopher74c525e2009-08-10 22:37:37 +0000316 def MMX_PUNPCKHDQrr : MMXI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000317 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000318 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000320 (v2i32 (mmx_unpckh VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000321 def MMX_PUNPCKHDQrm : MMXI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000322 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000323 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000324 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000325 (v2i32 (mmx_unpckh VR64:$src1,
326 (bc_v2i32 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327
328 // Unpack Low Packed Data Instructions
329 def MMX_PUNPCKLBWrr : MMXI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000330 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000331 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000332 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000333 (v8i8 (mmx_unpckl VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334 def MMX_PUNPCKLBWrm : MMXI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000335 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000336 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000338 (v8i8 (mmx_unpckl VR64:$src1,
339 (bc_v8i8 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340
341 def MMX_PUNPCKLWDrr : MMXI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000342 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000343 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000345 (v4i16 (mmx_unpckl VR64:$src1, VR64:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346 def MMX_PUNPCKLWDrm : MMXI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000347 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000348 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000350 (v4i16 (mmx_unpckl VR64:$src1,
351 (bc_v4i16 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000352
Eric Christopher74c525e2009-08-10 22:37:37 +0000353 def MMX_PUNPCKLDQrr : MMXI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000354 (outs VR64:$dst), (ins VR64:$src1, VR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000355 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000357 (v2i32 (mmx_unpckl VR64:$src1, VR64:$src2)))]>;
Eric Christopher74c525e2009-08-10 22:37:37 +0000358 def MMX_PUNPCKLDQrm : MMXI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000359 (outs VR64:$dst), (ins VR64:$src1, i64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000360 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000362 (v2i32 (mmx_unpckl VR64:$src1,
363 (bc_v2i32 (load_mmx addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364}
365
366// -- Pack Instructions
367defm MMX_PACKSSWB : MMXI_binop_rm_int<0x63, "packsswb", int_x86_mmx_packsswb>;
368defm MMX_PACKSSDW : MMXI_binop_rm_int<0x6B, "packssdw", int_x86_mmx_packssdw>;
369defm MMX_PACKUSWB : MMXI_binop_rm_int<0x67, "packuswb", int_x86_mmx_packuswb>;
370
371// -- Shuffle Instructions
372def MMX_PSHUFWri : MMXIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000373 (outs VR64:$dst), (ins VR64:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000374 "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000375 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000376 (v4i16 (mmx_pshufw:$src2 VR64:$src1, (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000377def MMX_PSHUFWmi : MMXIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000378 (outs VR64:$dst), (ins i64mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000379 "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380 [(set VR64:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000381 (mmx_pshufw:$src2 (bc_v4i16 (load_mmx addr:$src1)),
382 (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383
384// -- Conversion Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000385let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000386def MMX_CVTPD2PIrr : MMX2I<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000387 "cvtpd2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000388let mayLoad = 1 in
Eric Christopher74c525e2009-08-10 22:37:37 +0000389def MMX_CVTPD2PIrm : MMX2I<0x2D, MRMSrcMem, (outs VR64:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +0000390 (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000391 "cvtpd2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000392
Evan Chengb783fa32007-07-19 01:14:50 +0000393def MMX_CVTPI2PDrr : MMX2I<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000394 "cvtpi2pd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000395let mayLoad = 1 in
Eric Christopher74c525e2009-08-10 22:37:37 +0000396def MMX_CVTPI2PDrm : MMX2I<0x2A, MRMSrcMem, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +0000397 (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000398 "cvtpi2pd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399
Evan Chengb783fa32007-07-19 01:14:50 +0000400def MMX_CVTPI2PSrr : MMXI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000401 "cvtpi2ps\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000402let mayLoad = 1 in
Eric Christopher74c525e2009-08-10 22:37:37 +0000403def MMX_CVTPI2PSrm : MMXI<0x2A, MRMSrcMem, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +0000404 (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000405 "cvtpi2ps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406
Evan Chengb783fa32007-07-19 01:14:50 +0000407def MMX_CVTPS2PIrr : MMXI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000408 "cvtps2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000409let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000410def MMX_CVTPS2PIrm : MMXI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000411 "cvtps2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412
Evan Chengb783fa32007-07-19 01:14:50 +0000413def MMX_CVTTPD2PIrr : MMX2I<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000414 "cvttpd2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000415let mayLoad = 1 in
Eric Christopher74c525e2009-08-10 22:37:37 +0000416def MMX_CVTTPD2PIrm : MMX2I<0x2C, MRMSrcMem, (outs VR64:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +0000417 (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000418 "cvttpd2pi\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419
Evan Chengb783fa32007-07-19 01:14:50 +0000420def MMX_CVTTPS2PIrr : MMXI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000421 "cvttps2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000422let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000423def MMX_CVTTPS2PIrm : MMXI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000424 "cvttps2pi\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000425} // end neverHasSideEffects
426
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000427
428// Extract / Insert
429def MMX_X86pextrw : SDNode<"X86ISD::PEXTRW", SDTypeProfile<1, 2, []>, []>;
430def MMX_X86pinsrw : SDNode<"X86ISD::PINSRW", SDTypeProfile<1, 3, []>, []>;
431
432def MMX_PEXTRWri : MMXIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000433 (outs GR32:$dst), (ins VR64:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000434 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435 [(set GR32:$dst, (MMX_X86pextrw (v4i16 VR64:$src1),
436 (iPTR imm:$src2)))]>;
Eric Christopher74c525e2009-08-10 22:37:37 +0000437let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000438 def MMX_PINSRWrri : MMXIi8<0xC4, MRMSrcReg,
Sean Callanan2c48df22009-12-18 00:01:26 +0000439 (outs VR64:$dst),
440 (ins VR64:$src1, GR32:$src2,i16i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000441 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442 [(set VR64:$dst, (v4i16 (MMX_X86pinsrw (v4i16 VR64:$src1),
Eric Christopher74c525e2009-08-10 22:37:37 +0000443 GR32:$src2,(iPTR imm:$src3))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444 def MMX_PINSRWrmi : MMXIi8<0xC4, MRMSrcMem,
Sean Callanan2c48df22009-12-18 00:01:26 +0000445 (outs VR64:$dst),
446 (ins VR64:$src1, i16mem:$src2, i16i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000447 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000448 [(set VR64:$dst,
449 (v4i16 (MMX_X86pinsrw (v4i16 VR64:$src1),
450 (i32 (anyext (loadi16 addr:$src2))),
451 (iPTR imm:$src3))))]>;
452}
453
Mon P Wanga8ff0dd2010-01-24 00:05:03 +0000454// MMX to XMM for vector types
455def MMX_X86movq2dq : SDNode<"X86ISD::MOVQ2DQ", SDTypeProfile<1, 1,
456 [SDTCisVT<0, v2i64>, SDTCisVT<1, v1i64>]>>;
457
458def : Pat<(v2i64 (MMX_X86movq2dq VR64:$src)),
459 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
460
461def : Pat<(v2i64 (MMX_X86movq2dq (load_mmx addr:$src))),
462 (v2i64 (MOVQI2PQIrm addr:$src))>;
463
464def : Pat<(v2i64 (MMX_X86movq2dq (v1i64 (bitconvert
465 (v2i32 (scalar_to_vector (loadi32 addr:$src))))))),
466 (v2i64 (MOVDI2PDIrm addr:$src))>;
467
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000469def MMX_PMOVMSKBrr : MMXI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000470 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471 [(set GR32:$dst, (int_x86_mmx_pmovmskb VR64:$src))]>;
472
473// Misc.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000474let Uses = [EDI] in
Bill Wendling8fb68282009-06-23 19:52:59 +0000475def MMX_MASKMOVQ : MMXI<0xF7, MRMSrcReg, (outs), (ins VR64:$src, VR64:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +0000476 "maskmovq\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000477 [(int_x86_mmx_maskmovq VR64:$src, VR64:$mask, EDI)]>;
Anton Korobeynikov0e70d102008-08-23 15:53:19 +0000478let Uses = [RDI] in
Bill Wendling8fb68282009-06-23 19:52:59 +0000479def MMX_MASKMOVQ64: MMXI64<0xF7, MRMSrcReg, (outs), (ins VR64:$src, VR64:$mask),
Anton Korobeynikov0e70d102008-08-23 15:53:19 +0000480 "maskmovq\t{$mask, $src|$src, $mask}",
481 [(int_x86_mmx_maskmovq VR64:$src, VR64:$mask, RDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000482
483//===----------------------------------------------------------------------===//
484// Alias Instructions
485//===----------------------------------------------------------------------===//
486
487// Alias instructions that map zero vector to pxor.
Daniel Dunbara0e62002009-08-11 22:17:52 +0000488let isReMaterializable = 1, isCodeGenOnly = 1 in {
Chris Lattnercb521fb2010-02-05 21:30:49 +0000489 // FIXME: Change encoding to pseudo.
490 def MMX_V_SET0 : MMXI<0xEF, MRMInitReg, (outs VR64:$dst), (ins), "",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000491 [(set VR64:$dst, (v2i32 immAllZerosV))]>;
Chris Lattnercb521fb2010-02-05 21:30:49 +0000492 def MMX_V_SETALLONES : MMXI<0x76, MRMInitReg, (outs VR64:$dst), (ins), "",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000493 [(set VR64:$dst, (v2i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494}
495
Evan Chenga15896e2008-03-12 07:02:50 +0000496let Predicates = [HasMMX] in {
497 def : Pat<(v1i64 immAllZerosV), (MMX_V_SET0)>;
498 def : Pat<(v4i16 immAllZerosV), (MMX_V_SET0)>;
499 def : Pat<(v8i8 immAllZerosV), (MMX_V_SET0)>;
500}
501
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502//===----------------------------------------------------------------------===//
503// Non-Instruction Patterns
504//===----------------------------------------------------------------------===//
505
506// Store 64-bit integer vector values.
507def : Pat<(store (v8i8 VR64:$src), addr:$dst),
508 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
509def : Pat<(store (v4i16 VR64:$src), addr:$dst),
510 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
511def : Pat<(store (v2i32 VR64:$src), addr:$dst),
512 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000513def : Pat<(store (v2f32 VR64:$src), addr:$dst),
514 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515def : Pat<(store (v1i64 VR64:$src), addr:$dst),
516 (MMX_MOVQ64mr addr:$dst, VR64:$src)>;
517
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000518// Bit convert.
519def : Pat<(v8i8 (bitconvert (v1i64 VR64:$src))), (v8i8 VR64:$src)>;
520def : Pat<(v8i8 (bitconvert (v2i32 VR64:$src))), (v8i8 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000521def : Pat<(v8i8 (bitconvert (v2f32 VR64:$src))), (v8i8 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522def : Pat<(v8i8 (bitconvert (v4i16 VR64:$src))), (v8i8 VR64:$src)>;
523def : Pat<(v4i16 (bitconvert (v1i64 VR64:$src))), (v4i16 VR64:$src)>;
524def : Pat<(v4i16 (bitconvert (v2i32 VR64:$src))), (v4i16 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000525def : Pat<(v4i16 (bitconvert (v2f32 VR64:$src))), (v4i16 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526def : Pat<(v4i16 (bitconvert (v8i8 VR64:$src))), (v4i16 VR64:$src)>;
527def : Pat<(v2i32 (bitconvert (v1i64 VR64:$src))), (v2i32 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000528def : Pat<(v2i32 (bitconvert (v2f32 VR64:$src))), (v2i32 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529def : Pat<(v2i32 (bitconvert (v4i16 VR64:$src))), (v2i32 VR64:$src)>;
530def : Pat<(v2i32 (bitconvert (v8i8 VR64:$src))), (v2i32 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000531def : Pat<(v2f32 (bitconvert (v1i64 VR64:$src))), (v2f32 VR64:$src)>;
532def : Pat<(v2f32 (bitconvert (v2i32 VR64:$src))), (v2f32 VR64:$src)>;
533def : Pat<(v2f32 (bitconvert (v4i16 VR64:$src))), (v2f32 VR64:$src)>;
534def : Pat<(v2f32 (bitconvert (v8i8 VR64:$src))), (v2f32 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535def : Pat<(v1i64 (bitconvert (v2i32 VR64:$src))), (v1i64 VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000536def : Pat<(v1i64 (bitconvert (v2f32 VR64:$src))), (v1i64 VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537def : Pat<(v1i64 (bitconvert (v4i16 VR64:$src))), (v1i64 VR64:$src)>;
538def : Pat<(v1i64 (bitconvert (v8i8 VR64:$src))), (v1i64 VR64:$src)>;
539
540// 64-bit bit convert.
541def : Pat<(v1i64 (bitconvert (i64 GR64:$src))),
542 (MMX_MOVD64to64rr GR64:$src)>;
543def : Pat<(v2i32 (bitconvert (i64 GR64:$src))),
544 (MMX_MOVD64to64rr GR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000545def : Pat<(v2f32 (bitconvert (i64 GR64:$src))),
546 (MMX_MOVD64to64rr GR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547def : Pat<(v4i16 (bitconvert (i64 GR64:$src))),
548 (MMX_MOVD64to64rr GR64:$src)>;
549def : Pat<(v8i8 (bitconvert (i64 GR64:$src))),
550 (MMX_MOVD64to64rr GR64:$src)>;
Dan Gohman4535ae32008-04-15 23:55:07 +0000551def : Pat<(i64 (bitconvert (v1i64 VR64:$src))),
552 (MMX_MOVD64from64rr VR64:$src)>;
553def : Pat<(i64 (bitconvert (v2i32 VR64:$src))),
554 (MMX_MOVD64from64rr VR64:$src)>;
Dale Johannesena585daf2008-06-24 22:01:44 +0000555def : Pat<(i64 (bitconvert (v2f32 VR64:$src))),
556 (MMX_MOVD64from64rr VR64:$src)>;
Dan Gohman4535ae32008-04-15 23:55:07 +0000557def : Pat<(i64 (bitconvert (v4i16 VR64:$src))),
558 (MMX_MOVD64from64rr VR64:$src)>;
559def : Pat<(i64 (bitconvert (v8i8 VR64:$src))),
560 (MMX_MOVD64from64rr VR64:$src)>;
Evan Chengef356282009-02-23 09:03:22 +0000561def : Pat<(f64 (bitconvert (v1i64 VR64:$src))),
562 (MMX_MOVQ2FR64rr VR64:$src)>;
563def : Pat<(f64 (bitconvert (v2i32 VR64:$src))),
564 (MMX_MOVQ2FR64rr VR64:$src)>;
565def : Pat<(f64 (bitconvert (v4i16 VR64:$src))),
566 (MMX_MOVQ2FR64rr VR64:$src)>;
567def : Pat<(f64 (bitconvert (v8i8 VR64:$src))),
568 (MMX_MOVQ2FR64rr VR64:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569
Evan Cheng778641e2008-11-05 06:04:51 +0000570let AddedComplexity = 20 in {
Evan Cheng778641e2008-11-05 06:04:51 +0000571 def : Pat<(v2i32 (X86vzmovl (bc_v2i32 (load_mmx addr:$src)))),
Eric Christopher74c525e2009-08-10 22:37:37 +0000572 (MMX_MOVZDI2PDIrm addr:$src)>;
Evan Chengb76ecc82008-12-03 19:38:05 +0000573}
574
575// Clear top half.
576let AddedComplexity = 15 in {
Evan Chengb76ecc82008-12-03 19:38:05 +0000577 def : Pat<(v2i32 (X86vzmovl VR64:$src)),
578 (MMX_PUNPCKLDQrr VR64:$src, (MMX_V_SET0))>;
Evan Cheng778641e2008-11-05 06:04:51 +0000579}
580
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000581// Patterns to perform canonical versions of vector shuffling.
582let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000583 def : Pat<(v8i8 (mmx_unpckl_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 (MMX_PUNPCKLBWrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000585 def : Pat<(v4i16 (mmx_unpckl_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586 (MMX_PUNPCKLWDrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000587 def : Pat<(v2i32 (mmx_unpckl_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588 (MMX_PUNPCKLDQrr VR64:$src, VR64:$src)>;
589}
590
591let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000592 def : Pat<(v8i8 (mmx_unpckh_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000593 (MMX_PUNPCKHBWrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000594 def : Pat<(v4i16 (mmx_unpckh_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595 (MMX_PUNPCKHWDrr VR64:$src, VR64:$src)>;
Nate Begeman543d2142009-04-27 18:41:29 +0000596 def : Pat<(v2i32 (mmx_unpckh_undef VR64:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597 (MMX_PUNPCKHDQrr VR64:$src, VR64:$src)>;
598}
599
600// Patterns to perform vector shuffling with a zeroed out vector.
601let AddedComplexity = 20 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000602 def : Pat<(bc_v2i32 (mmx_unpckl immAllZerosV,
603 (v2i32 (scalar_to_vector (load_mmx addr:$src))))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000604 (MMX_PUNPCKLDQrm VR64:$src, VR64:$src)>;
605}
606
607// Some special case PANDN patterns.
608// FIXME: Get rid of these.
609def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v2i32 immAllOnesV))),
610 VR64:$src2)),
611 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
Chris Lattnere6aa3862007-11-25 00:24:49 +0000612def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v4i16 immAllOnesV_bc))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613 VR64:$src2)),
614 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
Chris Lattnere6aa3862007-11-25 00:24:49 +0000615def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v8i8 immAllOnesV_bc))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000616 VR64:$src2)),
617 (MMX_PANDNrr VR64:$src1, VR64:$src2)>;
618
619def : Pat<(v1i64 (and (xor VR64:$src1, (bc_v1i64 (v2i32 immAllOnesV))),
620 (load addr:$src2))),
621 (MMX_PANDNrm VR64:$src1, addr:$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 (load addr:$src2))),
624 (MMX_PANDNrm VR64:$src1, addr:$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 (load addr:$src2))),
627 (MMX_PANDNrm VR64:$src1, addr:$src2)>;
Evan Cheng2aea0b42008-04-25 19:11:04 +0000628
629// Move MMX to lower 64-bit of XMM
Evan Chengef356282009-02-23 09:03:22 +0000630def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v8i8 VR64:$src))))),
631 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
632def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v4i16 VR64:$src))))),
633 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
634def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v2i32 VR64:$src))))),
635 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
636def : Pat<(v2i64 (scalar_to_vector (i64 (bitconvert (v1i64 VR64:$src))))),
Evan Cheng2aea0b42008-04-25 19:11:04 +0000637 (v2i64 (MMX_MOVQ2DQrr VR64:$src))>;
Evan Cheng1428f582008-04-25 20:12:46 +0000638
639// Move lower 64-bit of XMM to MMX.
640def : Pat<(v2i32 (bitconvert (i64 (vector_extract (v2i64 VR128:$src),
641 (iPTR 0))))),
642 (v2i32 (MMX_MOVDQ2Qrr VR128:$src))>;
643def : Pat<(v4i16 (bitconvert (i64 (vector_extract (v2i64 VR128:$src),
644 (iPTR 0))))),
645 (v4i16 (MMX_MOVDQ2Qrr VR128:$src))>;
646def : Pat<(v8i8 (bitconvert (i64 (vector_extract (v2i64 VR128:$src),
647 (iPTR 0))))),
648 (v8i8 (MMX_MOVDQ2Qrr VR128:$src))>;
649
Eli Friedman7dab4932009-07-22 01:06:52 +0000650// Patterns for vector comparisons
651def : Pat<(v8i8 (X86pcmpeqb VR64:$src1, VR64:$src2)),
652 (MMX_PCMPEQBrr VR64:$src1, VR64:$src2)>;
653def : Pat<(v8i8 (X86pcmpeqb VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
654 (MMX_PCMPEQBrm VR64:$src1, addr:$src2)>;
655def : Pat<(v4i16 (X86pcmpeqw VR64:$src1, VR64:$src2)),
656 (MMX_PCMPEQWrr VR64:$src1, VR64:$src2)>;
657def : Pat<(v4i16 (X86pcmpeqw VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
658 (MMX_PCMPEQWrm VR64:$src1, addr:$src2)>;
659def : Pat<(v2i32 (X86pcmpeqd VR64:$src1, VR64:$src2)),
660 (MMX_PCMPEQDrr VR64:$src1, VR64:$src2)>;
661def : Pat<(v2i32 (X86pcmpeqd VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
662 (MMX_PCMPEQDrm VR64:$src1, addr:$src2)>;
663
664def : Pat<(v8i8 (X86pcmpgtb VR64:$src1, VR64:$src2)),
665 (MMX_PCMPGTBrr VR64:$src1, VR64:$src2)>;
666def : Pat<(v8i8 (X86pcmpgtb VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
667 (MMX_PCMPGTBrm VR64:$src1, addr:$src2)>;
668def : Pat<(v4i16 (X86pcmpgtw VR64:$src1, VR64:$src2)),
669 (MMX_PCMPGTWrr VR64:$src1, VR64:$src2)>;
670def : Pat<(v4i16 (X86pcmpgtw VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
671 (MMX_PCMPGTWrm VR64:$src1, addr:$src2)>;
672def : Pat<(v2i32 (X86pcmpgtd VR64:$src1, VR64:$src2)),
673 (MMX_PCMPGTDrr VR64:$src1, VR64:$src2)>;
674def : Pat<(v2i32 (X86pcmpgtd VR64:$src1, (bitconvert (load_mmx addr:$src2)))),
675 (MMX_PCMPGTDrm VR64:$src1, addr:$src2)>;
676
Dan Gohman30afe012009-10-29 18:10:34 +0000677// CMOV* - Used to implement the SELECT DAG operation. Expanded after
678// instruction selection into a branch sequence.
679let Uses = [EFLAGS], usesCustomInserter = 1 in {
Mon P Wang83edba52008-12-12 01:25:51 +0000680 def CMOV_V1I64 : I<0, Pseudo,
681 (outs VR64:$dst), (ins VR64:$t, VR64:$f, i8imm:$cond),
682 "#CMOV_V1I64 PSEUDO!",
683 [(set VR64:$dst,
684 (v1i64 (X86cmov VR64:$t, VR64:$f, imm:$cond,
685 EFLAGS)))]>;
686}