blob: 694b91ea4298d51c779db15ee2404737a790d328 [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//====- X86InstrSSE.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Eric Christopher7f2d4f42009-07-31 20:07:27 +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 Christopher7f2d4f42009-07-31 20:07:27 +00007//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00008//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 SSE 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
16
17//===----------------------------------------------------------------------===//
18// SSE specific DAG Nodes.
19//===----------------------------------------------------------------------===//
20
21def SDTX86FPShiftOp : SDTypeProfile<1, 2, [ SDTCisSameAs<0, 1>,
22 SDTCisFP<0>, SDTCisInt<2> ]>;
Nate Begeman03605a02008-07-17 16:51:19 +000023def SDTX86VFCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>,
24 SDTCisFP<1>, SDTCisVT<3, i8>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000025
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026def X86fmin : SDNode<"X86ISD::FMIN", SDTFPBinOp>;
27def X86fmax : SDNode<"X86ISD::FMAX", SDTFPBinOp>;
28def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
29 [SDNPCommutative, SDNPAssociative]>;
30def X86for : SDNode<"X86ISD::FOR", SDTFPBinOp,
31 [SDNPCommutative, SDNPAssociative]>;
32def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
33 [SDNPCommutative, SDNPAssociative]>;
34def X86frsqrt : SDNode<"X86ISD::FRSQRT", SDTFPUnaryOp>;
35def X86frcp : SDNode<"X86ISD::FRCP", SDTFPUnaryOp>;
36def X86fsrl : SDNode<"X86ISD::FSRL", SDTX86FPShiftOp>;
Evan Chengf37bf452007-10-01 18:12:48 +000037def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest>;
Evan Cheng621216e2007-09-29 00:00:36 +000038def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +000039def X86pshufb : SDNode<"X86ISD::PSHUFB",
Nate Begeman2c87c422009-02-23 08:49:38 +000040 SDTypeProfile<1, 2, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
41 SDTCisSameAs<0,2>]>>;
Nate Begemand77e59e2008-02-11 04:19:36 +000042def X86pextrb : SDNode<"X86ISD::PEXTRB",
43 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
44def X86pextrw : SDNode<"X86ISD::PEXTRW",
45 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +000046def X86pinsrb : SDNode<"X86ISD::PINSRB",
Nate Begemand77e59e2008-02-11 04:19:36 +000047 SDTypeProfile<1, 3, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
48 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +000049def X86pinsrw : SDNode<"X86ISD::PINSRW",
Nate Begemand77e59e2008-02-11 04:19:36 +000050 SDTypeProfile<1, 3, [SDTCisVT<0, v8i16>, SDTCisSameAs<0,1>,
51 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +000052def X86insrtps : SDNode<"X86ISD::INSERTPS",
Nate Begemand77e59e2008-02-11 04:19:36 +000053 SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, SDTCisSameAs<0,1>,
Eric Christopherefb657e2009-07-24 00:33:09 +000054 SDTCisVT<2, v4f32>, SDTCisPtrTy<3>]>>;
Evan Chenge9b9c672008-05-09 21:53:03 +000055def X86vzmovl : SDNode<"X86ISD::VZEXT_MOVL",
56 SDTypeProfile<1, 1, [SDTCisSameAs<0,1>]>>;
57def X86vzload : SDNode<"X86ISD::VZEXT_LOAD", SDTLoad,
58 [SDNPHasChain, SDNPMayLoad]>;
Evan Chengdea99362008-05-29 08:22:04 +000059def X86vshl : SDNode<"X86ISD::VSHL", SDTIntShiftOp>;
60def X86vshr : SDNode<"X86ISD::VSRL", SDTIntShiftOp>;
Nate Begeman03605a02008-07-17 16:51:19 +000061def X86cmpps : SDNode<"X86ISD::CMPPS", SDTX86VFCMP>;
62def X86cmppd : SDNode<"X86ISD::CMPPD", SDTX86VFCMP>;
63def X86pcmpeqb : SDNode<"X86ISD::PCMPEQB", SDTIntBinOp, [SDNPCommutative]>;
64def X86pcmpeqw : SDNode<"X86ISD::PCMPEQW", SDTIntBinOp, [SDNPCommutative]>;
65def X86pcmpeqd : SDNode<"X86ISD::PCMPEQD", SDTIntBinOp, [SDNPCommutative]>;
66def X86pcmpeqq : SDNode<"X86ISD::PCMPEQQ", SDTIntBinOp, [SDNPCommutative]>;
67def X86pcmpgtb : SDNode<"X86ISD::PCMPGTB", SDTIntBinOp>;
68def X86pcmpgtw : SDNode<"X86ISD::PCMPGTW", SDTIntBinOp>;
69def X86pcmpgtd : SDNode<"X86ISD::PCMPGTD", SDTIntBinOp>;
70def X86pcmpgtq : SDNode<"X86ISD::PCMPGTQ", SDTIntBinOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000071
Eric Christopher85f187b2009-08-10 21:48:58 +000072def SDTX86CmpPTest : SDTypeProfile<0, 2, [SDTCisVT<0, v4f32>,
Sean Callanan2c48df22009-12-18 00:01:26 +000073 SDTCisVT<1, v4f32>]>;
Eric Christopher95d79262009-07-29 00:28:05 +000074def X86ptest : SDNode<"X86ISD::PTEST", SDTX86CmpPTest>;
75
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +000077// SSE Complex Patterns
78//===----------------------------------------------------------------------===//
79
80// These are 'extloads' from a scalar to the low element of a vector, zeroing
81// the top elements. These are used for the SSE 'ss' and 'sd' instruction
82// forms.
Rafael Espindolabca99f72009-04-08 21:14:34 +000083def sse_load_f32 : ComplexPattern<v4f32, 5, "SelectScalarSSELoad", [],
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000084 [SDNPHasChain, SDNPMayLoad]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +000085def sse_load_f64 : ComplexPattern<v2f64, 5, "SelectScalarSSELoad", [],
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000086 [SDNPHasChain, SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000087
88def ssmem : Operand<v4f32> {
89 let PrintMethod = "printf32mem";
Dan Gohmanfe606822009-07-30 01:56:29 +000090 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +000091 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000092}
93def sdmem : Operand<v2f64> {
94 let PrintMethod = "printf64mem";
Dan Gohmanfe606822009-07-30 01:56:29 +000095 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +000096 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097}
98
99//===----------------------------------------------------------------------===//
100// SSE pattern fragments
101//===----------------------------------------------------------------------===//
102
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000103def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
104def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
105def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
106def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
107
Dan Gohman11821702007-07-27 17:16:43 +0000108// Like 'store', but always requires vector alignment.
Dan Gohman4a4f1512007-07-18 20:23:34 +0000109def alignedstore : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman2a174122008-10-15 06:50:19 +0000110 (store node:$val, node:$ptr), [{
111 return cast<StoreSDNode>(N)->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000112}]>;
113
Dan Gohman11821702007-07-27 17:16:43 +0000114// Like 'load', but always requires vector alignment.
Dan Gohman2a174122008-10-15 06:50:19 +0000115def alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
116 return cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000117}]>;
118
Sean Callanan2c48df22009-12-18 00:01:26 +0000119def alignedloadfsf32 : PatFrag<(ops node:$ptr),
120 (f32 (alignedload node:$ptr))>;
121def alignedloadfsf64 : PatFrag<(ops node:$ptr),
122 (f64 (alignedload node:$ptr))>;
123def alignedloadv4f32 : PatFrag<(ops node:$ptr),
124 (v4f32 (alignedload node:$ptr))>;
125def alignedloadv2f64 : PatFrag<(ops node:$ptr),
126 (v2f64 (alignedload node:$ptr))>;
127def alignedloadv4i32 : PatFrag<(ops node:$ptr),
128 (v4i32 (alignedload node:$ptr))>;
129def alignedloadv2i64 : PatFrag<(ops node:$ptr),
130 (v2i64 (alignedload node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000131
132// Like 'load', but uses special alignment checks suitable for use in
133// memory operands in most SSE instructions, which are required to
134// be naturally aligned on some targets but not on others.
135// FIXME: Actually implement support for targets that don't require the
136// alignment. This probably wants a subtarget predicate.
Dan Gohman2a174122008-10-15 06:50:19 +0000137def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{
138 return cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000139}]>;
140
Dan Gohman11821702007-07-27 17:16:43 +0000141def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
142def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000143def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
144def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
145def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
146def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +0000147def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000148
Bill Wendling3b15d722007-08-11 09:52:53 +0000149// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
150// 16-byte boundary.
Nate Begeman9a58b8a2008-02-09 23:46:37 +0000151// FIXME: 8 byte alignment for mmx reads is not required
Dan Gohman61efc5a2008-10-16 00:03:00 +0000152def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Dan Gohman2a174122008-10-15 06:50:19 +0000153 return cast<LoadSDNode>(N)->getAlignment() >= 8;
Bill Wendling3b15d722007-08-11 09:52:53 +0000154}]>;
155
156def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
Bill Wendling3b15d722007-08-11 09:52:53 +0000157def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
158def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
159def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
160
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000161def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
162def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
163def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
164def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
165def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
166def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
167
Evan Cheng56ec77b2008-09-24 23:27:55 +0000168def vzmovl_v2i64 : PatFrag<(ops node:$src),
169 (bitconvert (v2i64 (X86vzmovl
170 (v2i64 (scalar_to_vector (loadi64 node:$src))))))>;
171def vzmovl_v4i32 : PatFrag<(ops node:$src),
172 (bitconvert (v4i32 (X86vzmovl
173 (v4i32 (scalar_to_vector (loadi32 node:$src))))))>;
174
175def vzload_v2i64 : PatFrag<(ops node:$src),
176 (bitconvert (v2i64 (X86vzload node:$src)))>;
177
178
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179def fp32imm0 : PatLeaf<(f32 fpimm), [{
180 return N->isExactlyValue(+0.0);
181}]>;
182
Evan Cheng06cd2072009-10-28 06:30:34 +0000183// BYTE_imm - Transform bit immediates into byte immediates.
184def BYTE_imm : SDNodeXForm<imm, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 // Transformation function: imm >> 3
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000186 return getI32Imm(N->getZExtValue() >> 3);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187}]>;
188
189// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
190// SHUFP* etc. imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000191def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 return getI8Imm(X86::getShuffleSHUFImmediate(N));
193}]>;
194
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000195// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196// PSHUFHW imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000197def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
199}]>;
200
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000201// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000202// PSHUFLW imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000203def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000204 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
205}]>;
206
Nate Begeman080f8e22009-10-19 02:17:23 +0000207// SHUFFLE_get_palign_imm xform function: convert vector_shuffle mask to
208// a PALIGNR imm.
209def SHUFFLE_get_palign_imm : SDNodeXForm<vector_shuffle, [{
210 return getI8Imm(X86::getShufflePALIGNRImmediate(N));
211}]>;
212
Nate Begeman543d2142009-04-27 18:41:29 +0000213def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
214 (vector_shuffle node:$lhs, node:$rhs), [{
215 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
216 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
217}]>;
218
219def movddup : PatFrag<(ops node:$lhs, node:$rhs),
220 (vector_shuffle node:$lhs, node:$rhs), [{
221 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
222}]>;
223
224def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
225 (vector_shuffle node:$lhs, node:$rhs), [{
226 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
227}]>;
228
229def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
230 (vector_shuffle node:$lhs, node:$rhs), [{
231 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
232}]>;
233
Nate Begemanb13034d2009-11-07 23:17:15 +0000234def movlhps : PatFrag<(ops node:$lhs, node:$rhs),
235 (vector_shuffle node:$lhs, node:$rhs), [{
236 return X86::isMOVLHPSMask(cast<ShuffleVectorSDNode>(N));
Nate Begeman543d2142009-04-27 18:41:29 +0000237}]>;
238
239def movlp : PatFrag<(ops node:$lhs, node:$rhs),
240 (vector_shuffle node:$lhs, node:$rhs), [{
241 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
242}]>;
243
244def movl : PatFrag<(ops node:$lhs, node:$rhs),
245 (vector_shuffle node:$lhs, node:$rhs), [{
246 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
247}]>;
248
249def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
250 (vector_shuffle node:$lhs, node:$rhs), [{
251 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
252}]>;
253
254def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
255 (vector_shuffle node:$lhs, node:$rhs), [{
256 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
257}]>;
258
259def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
260 (vector_shuffle node:$lhs, node:$rhs), [{
261 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
262}]>;
263
264def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
265 (vector_shuffle node:$lhs, node:$rhs), [{
266 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
267}]>;
268
269def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
270 (vector_shuffle node:$lhs, node:$rhs), [{
271 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
272}]>;
273
274def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
275 (vector_shuffle node:$lhs, node:$rhs), [{
276 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
277}]>;
278
279def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
280 (vector_shuffle node:$lhs, node:$rhs), [{
281 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282}], SHUFFLE_get_shuf_imm>;
283
Nate Begeman543d2142009-04-27 18:41:29 +0000284def shufp : PatFrag<(ops node:$lhs, node:$rhs),
285 (vector_shuffle node:$lhs, node:$rhs), [{
286 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287}], SHUFFLE_get_shuf_imm>;
288
Nate Begeman543d2142009-04-27 18:41:29 +0000289def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
290 (vector_shuffle node:$lhs, node:$rhs), [{
291 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000292}], SHUFFLE_get_pshufhw_imm>;
293
Nate Begeman543d2142009-04-27 18:41:29 +0000294def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
295 (vector_shuffle node:$lhs, node:$rhs), [{
296 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000297}], SHUFFLE_get_pshuflw_imm>;
298
Nate Begeman080f8e22009-10-19 02:17:23 +0000299def palign : PatFrag<(ops node:$lhs, node:$rhs),
300 (vector_shuffle node:$lhs, node:$rhs), [{
301 return X86::isPALIGNRMask(cast<ShuffleVectorSDNode>(N));
302}], SHUFFLE_get_palign_imm>;
303
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304//===----------------------------------------------------------------------===//
305// SSE scalar FP Instructions
306//===----------------------------------------------------------------------===//
307
Dan Gohman30afe012009-10-29 18:10:34 +0000308// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded after
309// instruction selection into a branch sequence.
310let Uses = [EFLAGS], usesCustomInserter = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311 def CMOV_FR32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000312 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 "#CMOV_FR32 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000314 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
315 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000317 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318 "#CMOV_FR64 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000319 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
320 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000321 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000322 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323 "#CMOV_V4F32 PSEUDO!",
324 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000325 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
326 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327 def CMOV_V2F64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000328 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329 "#CMOV_V2F64 PSEUDO!",
330 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000331 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
332 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 def CMOV_V2I64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000334 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335 "#CMOV_V2I64 PSEUDO!",
336 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000337 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng950aac02007-09-25 01:57:46 +0000338 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000339}
340
341//===----------------------------------------------------------------------===//
342// SSE1 Instructions
343//===----------------------------------------------------------------------===//
344
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000346let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000347def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000348 "movss\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000349let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000350def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000351 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000352 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000353def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000354 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000355 [(store FR32:$src, addr:$dst)]>;
356
357// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000358def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000359 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000360 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000361def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000362 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000363 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000364def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000365 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000366 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000367def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000368 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
370
371// Match intrinsics which expect XMM operand(s).
Sean Callanan2c48df22009-12-18 00:01:26 +0000372def CVTSS2SIrr: SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
373 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
374def CVTSS2SIrm: SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
375 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
376
Evan Chengb783fa32007-07-19 01:14:50 +0000377def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000378 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000379 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000380def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 [(set GR32:$dst, (int_x86_sse_cvtss2si
383 (load addr:$src)))]>;
384
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000385// Match intrinisics which expect MM and XMM operand(s).
386def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
387 "cvtps2pi\t{$src, $dst|$dst, $src}",
388 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
389def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
390 "cvtps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000391 [(set VR64:$dst, (int_x86_sse_cvtps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000392 (load addr:$src)))]>;
393def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
394 "cvttps2pi\t{$src, $dst|$dst, $src}",
395 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
396def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
397 "cvttps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000398 [(set VR64:$dst, (int_x86_sse_cvttps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000399 (load addr:$src)))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +0000400let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000401 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000402 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
403 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
404 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
405 VR64:$src2))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000406 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000407 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
408 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000409 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000410 (load addr:$src2)))]>;
411}
412
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000414def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000415 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416 [(set GR32:$dst,
417 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000418def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000419 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420 [(set GR32:$dst,
421 (int_x86_sse_cvttss2si(load addr:$src)))]>;
422
Evan Cheng3ea4d672008-03-05 08:19:16 +0000423let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000425 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000426 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000427 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
428 GR32:$src2))]>;
429 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000430 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000431 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000432 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
433 (loadi32 addr:$src2)))]>;
434}
435
436// Comparison instructions
Dan Gohmanf221da12009-01-09 02:27:34 +0000437let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000438 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000439 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000440 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000441let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000442 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000443 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000444 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445}
446
Evan Cheng55687072007-09-14 21:48:26 +0000447let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000448def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000449 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000450 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000451def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000452 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000453 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000454 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000455
456def COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
457 "comiss\t{$src2, $src1|$src1, $src2}", []>;
458def COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
459 "comiss\t{$src2, $src1|$src1, $src2}", []>;
460
Evan Cheng55687072007-09-14 21:48:26 +0000461} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000462
463// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +0000464let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000465 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Sean Callanan2c48df22009-12-18 00:01:26 +0000466 (outs VR128:$dst),
467 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000468 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Sean Callanan2c48df22009-12-18 00:01:26 +0000469 [(set VR128:$dst, (int_x86_sse_cmp_ss
470 VR128:$src1,
471 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000472 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Sean Callanan2c48df22009-12-18 00:01:26 +0000473 (outs VR128:$dst),
474 (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000475 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
477 (load addr:$src), imm:$cc))]>;
478}
479
Evan Cheng55687072007-09-14 21:48:26 +0000480let Defs = [EFLAGS] in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000481def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000482 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000483 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000484 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000485def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000486 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000487 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000488 (implicit EFLAGS)]>;
489
Dan Gohmanf221da12009-01-09 02:27:34 +0000490def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000491 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000492 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000493 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000494def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000495 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000496 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000497 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000498} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000500// Aliases of packed SSE1 instructions for scalar use. These all have names
501// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502
503// Alias instructions that map fld0 to pxor for sse.
Dan Gohman51dbce62009-09-21 18:30:38 +0000504let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
505 canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000506def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000507 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508 Requires<[HasSSE1]>, TB, OpSize;
509
510// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
511// disregarded.
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000512let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000513def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000514 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515
516// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
517// disregarded.
Evan Cheng8e664712009-11-17 09:51:18 +0000518let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000519def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000520 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000521 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522
523// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +0000524let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525let isCommutable = 1 in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000526 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
527 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000528 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000530 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
531 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000532 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000533 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000534 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
535 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000536 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
538}
539
Dan Gohmanf221da12009-01-09 02:27:34 +0000540def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
541 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000542 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000544 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000545def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
546 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000547 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000549 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000550def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
551 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000552 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000553 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000554 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000555
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000556let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000558 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000559 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000560let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000562 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000563 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000565}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566
567/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
568///
569/// In addition, we also have a special variant of the scalar form here to
570/// represent the associated intrinsic operation. This form is unlike the
571/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000572/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573///
574/// These three forms can each be reg+reg or reg+mem, so there are a total of
575/// six "instructions".
576///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000577let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000578multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
579 SDNode OpNode, Intrinsic F32Int,
580 bit Commutable = 0> {
581 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000582 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000583 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
585 let isCommutable = Commutable;
586 }
587
588 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000589 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
590 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000591 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000593
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000595 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
596 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000597 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
599 let isCommutable = Commutable;
600 }
601
602 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000603 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
604 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000605 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000606 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607
608 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000609 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
610 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000611 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000612 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613
614 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000615 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
616 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000617 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618 [(set VR128:$dst, (F32Int VR128:$src1,
619 sse_load_f32:$src2))]>;
620}
621}
622
623// Arithmetic instructions
624defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
625defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
626defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
627defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
628
629/// sse1_fp_binop_rm - Other SSE1 binops
630///
631/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
632/// instructions for a full-vector intrinsic form. Operations that map
633/// onto C operators don't use this form since they just use the plain
634/// vector form instead of having a separate vector intrinsic form.
635///
636/// This provides a total of eight "instructions".
637///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000638let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
640 SDNode OpNode,
641 Intrinsic F32Int,
642 Intrinsic V4F32Int,
643 bit Commutable = 0> {
644
645 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000646 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
649 let isCommutable = Commutable;
650 }
651
652 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000653 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
654 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000655 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000657
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000659 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
660 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000661 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
663 let isCommutable = Commutable;
664 }
665
666 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000667 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
668 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000669 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000670 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000671
672 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000673 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
674 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000675 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
677 let isCommutable = Commutable;
678 }
679
680 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000681 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
682 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000683 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684 [(set VR128:$dst, (F32Int VR128:$src1,
685 sse_load_f32:$src2))]>;
686
687 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000688 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
689 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000690 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
692 let isCommutable = Commutable;
693 }
694
695 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000696 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
697 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000698 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000699 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700}
701}
702
703defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
704 int_x86_sse_max_ss, int_x86_sse_max_ps>;
705defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
706 int_x86_sse_min_ss, int_x86_sse_min_ps>;
707
708//===----------------------------------------------------------------------===//
709// SSE packed FP Instructions
710
711// Move Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000712let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000713def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000714 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000715let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000716def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000717 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000718 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719
Evan Chengb783fa32007-07-19 01:14:50 +0000720def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000721 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000722 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000724let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000725def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000726 "movups\t{$src, $dst|$dst, $src}", []>;
Evan Cheng9d7cd4e2009-11-16 21:56:03 +0000727let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000728def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000729 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000730 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000731def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000732 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000733 [(store (v4f32 VR128:$src), addr:$dst)]>;
734
735// Intrinsic forms of MOVUPS load and store
Evan Cheng8e664712009-11-17 09:51:18 +0000736let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000737def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000738 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000739 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000740def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000741 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000742 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743
Evan Cheng3ea4d672008-03-05 08:19:16 +0000744let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745 let AddedComplexity = 20 in {
746 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000747 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000748 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000749 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000750 (movlp VR128:$src1,
751 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000753 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000754 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000755 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +0000756 (movlhps VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000757 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000759} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760
Evan Chengd743a5f2008-05-10 00:59:18 +0000761
Evan Chengb783fa32007-07-19 01:14:50 +0000762def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000763 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
765 (iPTR 0))), addr:$dst)]>;
766
767// v2f64 extract element 1 is always custom lowered to unpack high to low
768// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000769def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000770 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +0000772 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
773 (undef)), (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774
Evan Cheng3ea4d672008-03-05 08:19:16 +0000775let Constraints = "$src1 = $dst" in {
Evan Cheng13559d62008-09-26 23:41:32 +0000776let AddedComplexity = 20 in {
Evan Cheng7581a822009-05-12 20:17:52 +0000777def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
778 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000779 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +0000781 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782
Evan Cheng7581a822009-05-12 20:17:52 +0000783def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
784 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000785 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000787 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788} // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000789} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000790
Nate Begemanb44aad72009-04-29 22:47:44 +0000791let AddedComplexity = 20 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000792def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Evan Chenga2497eb2008-09-25 20:50:48 +0000793 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begemanb44aad72009-04-29 22:47:44 +0000794def : Pat<(v2i64 (movddup VR128:$src, (undef))),
795 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
796}
Evan Chenga2497eb2008-09-25 20:50:48 +0000797
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798
799
800// Arithmetic
801
802/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
803///
804/// In addition, we also have a special variant of the scalar form here to
805/// represent the associated intrinsic operation. This form is unlike the
806/// plain scalar form, in that it takes an entire vector (instead of a
807/// scalar) and leaves the top elements undefined.
808///
809/// And, we have a special variant form for a full-vector intrinsic form.
810///
811/// These four forms can each have a reg or a mem operand, so there are a
812/// total of eight "instructions".
813///
814multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
815 SDNode OpNode,
816 Intrinsic F32Int,
817 Intrinsic V4F32Int,
818 bit Commutable = 0> {
819 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000820 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000821 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000822 [(set FR32:$dst, (OpNode FR32:$src))]> {
823 let isCommutable = Commutable;
824 }
825
826 // Scalar operation, mem.
Evan Chengd3f27fb2009-12-18 07:40:29 +0000827 def SSm : I<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000828 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Evan Chengd3f27fb2009-12-18 07:40:29 +0000829 [(set FR32:$dst, (OpNode (load addr:$src)))]>, XS,
830 Requires<[HasSSE1, NoSSEBreakDep]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000831
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000833 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000834 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
836 let isCommutable = Commutable;
837 }
838
839 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000840 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000841 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000842 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843
844 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000845 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000846 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847 [(set VR128:$dst, (F32Int VR128:$src))]> {
848 let isCommutable = Commutable;
849 }
850
851 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000852 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000853 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
855
856 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000857 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000858 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
860 let isCommutable = Commutable;
861 }
862
863 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000864 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000865 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000866 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867}
868
869// Square root.
870defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
871 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
872
873// Reciprocal approximations. Note that these typically require refinement
874// in order to obtain suitable precision.
875defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
876 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
877defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
878 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
879
880// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +0000881let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 let isCommutable = 1 in {
883 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000884 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000885 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 [(set VR128:$dst, (v2i64
887 (and VR128:$src1, VR128:$src2)))]>;
888 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000889 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000890 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 [(set VR128:$dst, (v2i64
892 (or VR128:$src1, VR128:$src2)))]>;
893 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000894 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000895 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896 [(set VR128:$dst, (v2i64
897 (xor VR128:$src1, VR128:$src2)))]>;
898 }
899
900 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000901 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000902 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000903 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
904 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000906 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000907 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000908 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
909 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000911 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000912 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000913 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
914 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000916 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000917 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 [(set VR128:$dst,
919 (v2i64 (and (xor VR128:$src1,
920 (bc_v2i64 (v4i32 immAllOnesV))),
921 VR128:$src2)))]>;
922 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000923 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000924 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000926 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000928 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929}
930
Evan Cheng3ea4d672008-03-05 08:19:16 +0000931let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000932 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begeman061db5f2008-05-12 20:34:32 +0000933 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
934 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
935 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
936 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000937 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begeman061db5f2008-05-12 20:34:32 +0000938 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
939 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
940 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +0000941 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942}
Nate Begeman03605a02008-07-17 16:51:19 +0000943def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
944 (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>;
945def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
946 (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947
948// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +0000949let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000951 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000952 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000953 VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000954 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000956 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000957 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000958 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000959 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000960 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000962 (v4f32 (shufp:$src3
963 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964
965 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000966 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000967 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000968 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000970 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000971 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000972 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000973 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000975 (v4f32 (unpckh VR128:$src1,
976 (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000978 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000979 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000980 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000982 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000983 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000984 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000985 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000987 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000989} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990
991// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000992def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000993 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengd8296b82009-05-28 18:55:28 +0000995def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000996 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
998
Evan Chengd1d68072008-03-08 00:58:38 +0000999// Prefetch intrinsic.
1000def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
1001 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
1002def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
1003 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
1004def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
1005 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
1006def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
1007 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008
1009// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00001010def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001011 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
1013
1014// Load, store, and memory fence
Evan Cheng68cca152009-05-27 18:38:01 +00001015def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016
1017// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +00001018def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001019 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001020def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001021 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022
1023// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00001024// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00001025// load of an all-zeros value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +00001026let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
1027 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001028def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001029 "xorps\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00001030 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031
Evan Chenga15896e2008-03-12 07:02:50 +00001032let Predicates = [HasSSE1] in {
1033 def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
1034 def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1035 def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1036 def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1037 def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
1038}
1039
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040// FR32 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001041let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001042def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001043 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044 [(set VR128:$dst,
1045 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001046def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001047 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048 [(set VR128:$dst,
1049 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
1050
1051// FIXME: may not be able to eliminate this movss with coalescing the src and
1052// dest register classes are different. We really want to write this pattern
1053// like this:
1054// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1055// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001056let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001057def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001058 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
1060 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001061def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001062 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063 [(store (f32 (vector_extract (v4f32 VR128:$src),
1064 (iPTR 0))), addr:$dst)]>;
1065
1066
1067// Move to lower bits of a VR128, leaving upper bits alone.
1068// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001069let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001070let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001072 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001073 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074
1075 let AddedComplexity = 15 in
1076 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001077 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001078 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001080 (v4f32 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081}
1082
1083// Move to lower bits of a VR128 and zeroing upper bits.
1084// Loading from memory automatically zeroing upper bits.
1085let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00001086def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001087 "movss\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00001088 [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001089 (loadf32 addr:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090
Evan Cheng056afe12008-05-20 18:24:47 +00001091def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
Evan Cheng40ee6e52008-05-08 00:57:18 +00001092 (MOVZSS2PSrm addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001094//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095// SSE2 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001096//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001099let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001100def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "movsd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001102let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001103def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001104 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001106def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108 [(store FR64:$src, addr:$dst)]>;
1109
1110// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001111def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001112 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001114def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001115 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001117def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001118 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengd3f27fb2009-12-18 07:40:29 +00001120def CVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001121 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Evan Chengd3f27fb2009-12-18 07:40:29 +00001122 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>, XD,
1123 Requires<[HasSSE2, NoSSEBreakDep]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001124def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001125 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001127def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001128 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1130
Sean Callanan3d5824c2009-09-16 01:13:52 +00001131def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1132 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1133def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1134 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1135def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1136 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1137def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1138 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1139def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1140 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1141def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1142 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1143def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1144 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1145def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1146 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1147def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1148 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1149def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1150 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1151
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001153def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001154 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001155 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1156 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001157def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001158 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001159 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
Evan Chengd3f27fb2009-12-18 07:40:29 +00001160 Requires<[HasSSE2, NoSSEBreakDep]>;
1161
1162def : Pat<(extloadf32 addr:$src),
1163 (CVTSS2SDrr (MOVSSrm addr:$src))>, Requires<[SSEBreakDep]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164
1165// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001166def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001167 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001169def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001170 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001171 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1172 (load addr:$src)))]>;
1173
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001174// Match intrinisics which expect MM and XMM operand(s).
1175def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1176 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1177 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1178def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1179 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001180 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001181 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001182def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1183 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1184 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1185def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1186 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001187 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001188 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001189def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1190 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1191 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1192def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1193 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001194 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001195 (load addr:$src)))]>;
1196
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001198def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001199 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200 [(set GR32:$dst,
1201 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001202def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001203 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1205 (load addr:$src)))]>;
1206
1207// Comparison instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001208let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001209 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001210 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001211 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001212let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001213 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001214 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001215 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216}
1217
Evan Cheng950aac02007-09-25 01:57:46 +00001218let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001219def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001220 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001221 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001222def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001223 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001224 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001225 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001226} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001227
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +00001229let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001230 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00001231 (outs VR128:$dst),
1232 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001233 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1235 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001236 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Sean Callanan2c48df22009-12-18 00:01:26 +00001237 (outs VR128:$dst),
1238 (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001239 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001240 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1241 (load addr:$src), imm:$cc))]>;
1242}
1243
Evan Cheng950aac02007-09-25 01:57:46 +00001244let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001245def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001246 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001247 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1248 (implicit EFLAGS)]>;
1249def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001250 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001251 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1252 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253
Evan Chengb783fa32007-07-19 01:14:50 +00001254def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001255 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001256 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1257 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001258def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001259 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001260 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001261 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001262} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001263
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001264// Aliases of packed SSE2 instructions for scalar use. These all have names
1265// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266
1267// Alias instructions that map fld0 to pxor for sse.
Dan Gohman51dbce62009-09-21 18:30:38 +00001268let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1269 canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001270def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001271 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 Requires<[HasSSE2]>, TB, OpSize;
1273
1274// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1275// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001276let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001277def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001278 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279
1280// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1281// disregarded.
Evan Cheng8e664712009-11-17 09:51:18 +00001282let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001283def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001285 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286
1287// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001288let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289let isCommutable = 1 in {
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001290 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1291 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001292 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001294 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1295 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001296 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001298 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1299 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001300 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1302}
1303
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001304def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1305 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001306 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001308 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001309def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1310 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001311 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001313 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001314def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1315 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001316 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001318 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001320let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001322 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001323 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001324let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001326 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001327 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001328}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001329}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330
1331/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1332///
1333/// In addition, we also have a special variant of the scalar form here to
1334/// represent the associated intrinsic operation. This form is unlike the
1335/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001336/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337///
1338/// These three forms can each be reg+reg or reg+mem, so there are a total of
1339/// six "instructions".
1340///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001341let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1343 SDNode OpNode, Intrinsic F64Int,
1344 bit Commutable = 0> {
1345 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001346 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001347 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1349 let isCommutable = Commutable;
1350 }
1351
1352 // Scalar operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001353 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1354 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001355 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001357
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001358 // Vector operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001359 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1360 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001361 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1363 let isCommutable = Commutable;
1364 }
1365
1366 // Vector operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001367 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1368 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001369 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf221da12009-01-09 02:27:34 +00001370 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371
1372 // Intrinsic operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001373 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1374 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001375 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001376 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377
1378 // Intrinsic operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001379 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1380 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001381 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001382 [(set VR128:$dst, (F64Int VR128:$src1,
1383 sse_load_f64:$src2))]>;
1384}
1385}
1386
1387// Arithmetic instructions
1388defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1389defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1390defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1391defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1392
1393/// sse2_fp_binop_rm - Other SSE2 binops
1394///
1395/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1396/// instructions for a full-vector intrinsic form. Operations that map
1397/// onto C operators don't use this form since they just use the plain
1398/// vector form instead of having a separate vector intrinsic form.
1399///
1400/// This provides a total of eight "instructions".
1401///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001402let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1404 SDNode OpNode,
1405 Intrinsic F64Int,
1406 Intrinsic V2F64Int,
1407 bit Commutable = 0> {
1408
1409 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001410 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001411 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1413 let isCommutable = Commutable;
1414 }
1415
1416 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001417 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1418 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001419 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001420 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001421
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001423 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1424 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1427 let isCommutable = Commutable;
1428 }
1429
1430 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001431 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1432 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001433 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001434 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001435
1436 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001437 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1438 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1441 let isCommutable = Commutable;
1442 }
1443
1444 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001445 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1446 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001448 [(set VR128:$dst, (F64Int VR128:$src1,
1449 sse_load_f64:$src2))]>;
1450
1451 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001452 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1453 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001454 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1456 let isCommutable = Commutable;
1457 }
1458
1459 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001460 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1461 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001462 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001463 [(set VR128:$dst, (V2F64Int VR128:$src1,
1464 (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001465}
1466}
1467
1468defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1469 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1470defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1471 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1472
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001473//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001474// SSE packed FP Instructions
1475
1476// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001477let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001478def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001480let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001481def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001482 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001483 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001484
Evan Chengb783fa32007-07-19 01:14:50 +00001485def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001487 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001488
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001489let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001490def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001491 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001492let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001493def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001494 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001495 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001496def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001498 [(store (v2f64 VR128:$src), addr:$dst)]>;
1499
1500// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001501def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001502 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001503 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001504def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001505 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001506 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001507
Evan Cheng3ea4d672008-03-05 08:19:16 +00001508let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001509 let AddedComplexity = 20 in {
1510 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001511 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001512 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001513 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001514 (v2f64 (movlp VR128:$src1,
1515 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001517 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001519 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +00001520 (v2f64 (movlhps VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00001521 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001523} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524
Evan Chengb783fa32007-07-19 01:14:50 +00001525def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001526 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001527 [(store (f64 (vector_extract (v2f64 VR128:$src),
1528 (iPTR 0))), addr:$dst)]>;
1529
1530// v2f64 extract element 1 is always custom lowered to unpack high to low
1531// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001532def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001533 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001534 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +00001535 (v2f64 (unpckh VR128:$src, (undef))),
1536 (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537
1538// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001539def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001540 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001541 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1542 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001543def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001544 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1545 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1546 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001547 TB, Requires<[HasSSE2]>;
1548
1549// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001550def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1553 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001554def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001555 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1556 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1557 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558 XS, Requires<[HasSSE2]>;
1559
Evan Chengb783fa32007-07-19 01:14:50 +00001560def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001561 "cvtps2dq\t{$src, $dst|$dst, $src}",
1562 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001563def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001564 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001566 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567// SSE2 packed instructions with XS prefix
Sean Callanan2c48df22009-12-18 00:01:26 +00001568def CVTTPS2DQrr : SSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1569 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1570def CVTTPS2DQrm : SSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1571 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1572
Evan Chengb783fa32007-07-19 01:14:50 +00001573def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "cvttps2dq\t{$src, $dst|$dst, $src}",
Sean Callanan2c48df22009-12-18 00:01:26 +00001575 [(set VR128:$dst,
1576 (int_x86_sse2_cvttps2dq VR128:$src))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001577 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001578def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001579 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001580 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001581 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001582 XS, Requires<[HasSSE2]>;
1583
1584// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001585def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001587 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1588 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001589def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001590 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001592 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001593 XD, Requires<[HasSSE2]>;
1594
Evan Chengb783fa32007-07-19 01:14:50 +00001595def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001596 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001597 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng14c97c32008-03-14 07:46:48 +00001598def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001599 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001601 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001602
1603// SSE2 instructions without OpSize prefix
Sean Callanan2c48df22009-12-18 00:01:26 +00001604def CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1605 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1606def CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
1607 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1608
Evan Chengb783fa32007-07-19 01:14:50 +00001609def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001610 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001611 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1612 TB, Requires<[HasSSE2]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001613def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1616 (load addr:$src)))]>,
1617 TB, Requires<[HasSSE2]>;
1618
Sean Callanan2c48df22009-12-18 00:01:26 +00001619def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1620 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1621def CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1622 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1623
1624
Evan Chengb783fa32007-07-19 01:14:50 +00001625def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001626 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001627 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001628def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001629 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001630 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Cheng00b66ef2008-05-23 00:37:07 +00001631 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632
1633// Match intrinsics which expect XMM operand(s).
1634// Aliases for intrinsics
Evan Cheng3ea4d672008-03-05 08:19:16 +00001635let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001637 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001638 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1640 GR32:$src2))]>;
1641def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001642 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001643 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1645 (loadi32 addr:$src2)))]>;
1646def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001647 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001648 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001649 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1650 VR128:$src2))]>;
1651def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001652 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001653 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001654 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1655 (load addr:$src2)))]>;
1656def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001657 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1660 VR128:$src2))]>, XS,
1661 Requires<[HasSSE2]>;
1662def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001663 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1666 (load addr:$src2)))]>, XS,
1667 Requires<[HasSSE2]>;
1668}
1669
1670// Arithmetic
1671
1672/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1673///
1674/// In addition, we also have a special variant of the scalar form here to
1675/// represent the associated intrinsic operation. This form is unlike the
1676/// plain scalar form, in that it takes an entire vector (instead of a
1677/// scalar) and leaves the top elements undefined.
1678///
1679/// And, we have a special variant form for a full-vector intrinsic form.
1680///
1681/// These four forms can each have a reg or a mem operand, so there are a
1682/// total of eight "instructions".
1683///
1684multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1685 SDNode OpNode,
1686 Intrinsic F64Int,
1687 Intrinsic V2F64Int,
1688 bit Commutable = 0> {
1689 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001690 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001691 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 [(set FR64:$dst, (OpNode FR64:$src))]> {
1693 let isCommutable = Commutable;
1694 }
1695
1696 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001697 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001700
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001702 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001704 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1705 let isCommutable = Commutable;
1706 }
1707
1708 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001709 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001710 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001711 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712
1713 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001714 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001715 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716 [(set VR128:$dst, (F64Int VR128:$src))]> {
1717 let isCommutable = Commutable;
1718 }
1719
1720 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001721 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001722 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001723 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1724
1725 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001726 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001727 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001728 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1729 let isCommutable = Commutable;
1730 }
1731
1732 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001733 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001734 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001735 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001736}
1737
1738// Square root.
1739defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1740 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1741
1742// There is no f64 version of the reciprocal approximation instructions.
1743
1744// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +00001745let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746 let isCommutable = 1 in {
1747 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001748 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001750 [(set VR128:$dst,
1751 (and (bc_v2i64 (v2f64 VR128:$src1)),
1752 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1753 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001754 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001755 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001756 [(set VR128:$dst,
1757 (or (bc_v2i64 (v2f64 VR128:$src1)),
1758 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1759 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001760 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 [(set VR128:$dst,
1763 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1764 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1765 }
1766
1767 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001768 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 [(set VR128:$dst,
1771 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001772 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001773 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001774 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001775 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776 [(set VR128:$dst,
1777 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001778 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001780 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001782 [(set VR128:$dst,
1783 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001784 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001785 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001786 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788 [(set VR128:$dst,
1789 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1790 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1791 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001792 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001793 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001794 [(set VR128:$dst,
1795 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001796 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001797}
1798
Evan Cheng3ea4d672008-03-05 08:19:16 +00001799let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001800 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001801 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1802 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1803 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begeman061db5f2008-05-12 20:34:32 +00001804 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001805 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng14c97c32008-03-14 07:46:48 +00001806 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1807 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1808 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00001809 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810}
Evan Cheng33754092008-08-05 22:19:15 +00001811def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001812 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Cheng33754092008-08-05 22:19:15 +00001813def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001814 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001815
1816// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001817let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001818 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001819 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1820 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman543d2142009-04-27 18:41:29 +00001821 [(set VR128:$dst,
1822 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001823 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001824 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001825 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001828 (v2f64 (shufp:$src3
1829 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830
1831 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001832 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001833 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001835 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001836 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001837 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001838 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001841 (v2f64 (unpckh VR128:$src1,
1842 (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001843
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001844 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001845 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001846 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001847 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001848 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001849 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001850 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001851 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001852 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001853 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001855} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001856
1857
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001858//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001859// SSE integer instructions
1860
1861// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001862let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001863def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001864 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001865let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001866def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001868 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001869let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001870def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001872 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001873let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001874def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001876 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001877 XS, Requires<[HasSSE2]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001878let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001879def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001881 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001882 XS, Requires<[HasSSE2]>;
1883
Dan Gohman4a4f1512007-07-18 20:23:34 +00001884// Intrinsic forms of MOVDQU load and store
Dan Gohman5574cc72008-12-03 18:15:48 +00001885let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001886def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001888 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1889 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001890def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001892 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1893 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894
Evan Cheng88004752008-03-05 08:11:27 +00001895let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001896
1897multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1898 bit Commutable = 0> {
Sean Callanan2c48df22009-12-18 00:01:26 +00001899 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1900 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1903 let isCommutable = Commutable;
1904 }
Sean Callanan2c48df22009-12-18 00:01:26 +00001905 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1906 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 [(set VR128:$dst, (IntId VR128:$src1,
Sean Callanan2c48df22009-12-18 00:01:26 +00001909 (bitconvert (memopv2i64
1910 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001911}
1912
Evan Chengf90f8f82008-05-03 00:52:09 +00001913multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1914 string OpcodeStr,
1915 Intrinsic IntId, Intrinsic IntId2> {
Sean Callanan2c48df22009-12-18 00:01:26 +00001916 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1917 (ins VR128:$src1, VR128:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001918 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1919 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001920 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1921 (ins VR128:$src1, i128mem:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001922 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1923 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001924 (bitconvert (memopv2i64 addr:$src2))))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001925 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst),
1926 (ins VR128:$src1, i32i8imm:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001927 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1928 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
1929}
1930
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931/// PDI_binop_rm - Simple SSE2 binary operator.
1932multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1933 ValueType OpVT, bit Commutable = 0> {
Sean Callanan2c48df22009-12-18 00:01:26 +00001934 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1935 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001936 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1938 let isCommutable = Commutable;
1939 }
Sean Callanan2c48df22009-12-18 00:01:26 +00001940 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1941 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001942 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001944 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945}
1946
1947/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1948///
1949/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1950/// to collapse (bitconvert VT to VT) into its operand.
1951///
1952multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1953 bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001954 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00001955 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001956 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001957 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1958 let isCommutable = Commutable;
1959 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001960 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00001961 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001963 [(set VR128:$dst, (OpNode VR128:$src1,
Sean Callanan2c48df22009-12-18 00:01:26 +00001964 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001965}
1966
Evan Cheng3ea4d672008-03-05 08:19:16 +00001967} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968
1969// 128-bit Integer Arithmetic
1970
1971defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1972defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1973defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1974defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1975
1976defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1977defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1978defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1979defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1980
1981defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1982defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1983defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1984defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1985
1986defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1987defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1988defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1989defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1990
1991defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1992
1993defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1994defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1995defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1996
1997defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1998
1999defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
2000defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
2001
2002
2003defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
2004defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
2005defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
2006defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling953ad2e2009-05-28 02:04:00 +00002007defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002008
2009
Evan Chengf90f8f82008-05-03 00:52:09 +00002010defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
2011 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
2012defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
2013 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
2014defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
2015 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016
Evan Chengf90f8f82008-05-03 00:52:09 +00002017defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
2018 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
2019defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
2020 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begemanc2ca5f62008-05-13 17:52:09 +00002021defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Chengf90f8f82008-05-03 00:52:09 +00002022 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023
Evan Chengf90f8f82008-05-03 00:52:09 +00002024defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
2025 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemand66fc342008-05-13 01:47:52 +00002026defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Chengf90f8f82008-05-03 00:52:09 +00002027 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028
2029// 128-bit logical shifts.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002030let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002031 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002032 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00002035 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002036 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002037 // PSRADQri doesn't exist in SSE[1-3].
2038}
2039
2040let Predicates = [HasSSE2] in {
2041 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
Evan Cheng06cd2072009-10-28 06:30:34 +00002042 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
Evan Cheng06cd2072009-10-28 06:30:34 +00002044 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Bill Wendling314ee052008-10-02 05:56:52 +00002045 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2046 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2047 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2048 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002050 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Evan Chengdea99362008-05-29 08:22:04 +00002051
2052 // Shift up / down and insert zero's.
2053 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
Evan Cheng06cd2072009-10-28 06:30:34 +00002054 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Evan Chengdea99362008-05-29 08:22:04 +00002055 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
Evan Cheng06cd2072009-10-28 06:30:34 +00002056 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057}
2058
2059// Logical
2060defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2061defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2062defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2063
Evan Cheng3ea4d672008-03-05 08:19:16 +00002064let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002066 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002067 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002068 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2069 VR128:$src2)))]>;
2070
2071 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002072 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00002075 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076}
2077
2078// SSE2 Integer comparison
2079defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2080defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2081defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2082defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2083defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2084defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2085
Nate Begeman03605a02008-07-17 16:51:19 +00002086def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002087 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002088def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002089 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002090def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002091 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002092def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002093 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002094def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002095 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002096def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002097 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2098
Nate Begeman03605a02008-07-17 16:51:19 +00002099def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002100 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002101def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002102 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002103def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002104 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002105def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002106 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002107def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002108 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002109def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002110 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2111
2112
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113// Pack instructions
2114defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2115defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2116defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2117
2118// Shuffle and unpack instructions
Nate Begeman080f8e22009-10-19 02:17:23 +00002119let AddedComplexity = 5 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002120def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002121 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002123 [(set VR128:$dst, (v4i32 (pshufd:$src2
2124 VR128:$src1, (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002125def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002126 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002127 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002128 [(set VR128:$dst, (v4i32 (pshufd:$src2
Evan Chenge31a26a2009-12-09 21:00:30 +00002129 (bc_v4i32 (memopv2i64 addr:$src1)),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002130 (undef))))]>;
Eric Christopherf3650292009-11-07 08:45:53 +00002131}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002132
2133// SSE2 with ImmT == Imm8 and XS prefix.
2134def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002135 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002136 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002137 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2138 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 XS, Requires<[HasSSE2]>;
2140def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002141 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002143 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002144 (bc_v8i16 (memopv2i64 addr:$src1)),
2145 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002146 XS, Requires<[HasSSE2]>;
2147
2148// SSE2 with ImmT == Imm8 and XD prefix.
2149def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman543d2142009-04-27 18:41:29 +00002150 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002152 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2153 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002154 XD, Requires<[HasSSE2]>;
2155def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman543d2142009-04-27 18:41:29 +00002156 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002158 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2159 (bc_v8i16 (memopv2i64 addr:$src1)),
2160 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002161 XD, Requires<[HasSSE2]>;
2162
2163
Evan Cheng3ea4d672008-03-05 08:19:16 +00002164let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002165 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002166 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002169 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002170 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002171 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002172 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002173 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002174 (unpckl VR128:$src1,
2175 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002176 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002177 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002178 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002180 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002181 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002182 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002183 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002185 (unpckl VR128:$src1,
2186 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002187 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002188 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002190 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002191 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002192 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002193 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002194 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002195 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002196 (unpckl VR128:$src1,
2197 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002198 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002199 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002200 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002201 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002202 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002203 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002204 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002207 (v2i64 (unpckl VR128:$src1,
2208 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002209
2210 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002211 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002212 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002213 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002214 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002215 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002216 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002218 [(set VR128:$dst,
2219 (unpckh VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002220 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002221 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002222 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002224 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002225 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002226 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002227 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002230 (unpckh VR128:$src1,
2231 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002232 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002233 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002234 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002235 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002236 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002237 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002238 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002239 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002240 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002241 (unpckh VR128:$src1,
2242 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002243 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002244 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002247 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002248 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002249 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002250 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002252 (v2i64 (unpckh VR128:$src1,
2253 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254}
2255
2256// Extract / Insert
2257def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002258 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002259 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002260 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begemand77e59e2008-02-11 04:19:36 +00002261 imm:$src2))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +00002262let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002264 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002265 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002266 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002268 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002270 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002271 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002273 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002274 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2275 imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002276}
2277
2278// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002279def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002280 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002281 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2282
2283// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002284let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002285def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002287 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288
Evan Cheng430de082009-02-10 22:06:28 +00002289let Uses = [RDI] in
2290def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2291 "maskmovdqu\t{$mask, $src|$src, $mask}",
2292 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2293
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002295def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002296 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002297 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002298def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002299 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002301def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002302 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002303 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002304 TB, Requires<[HasSSE2]>;
2305
2306// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002307def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002308 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002309 TB, Requires<[HasSSE2]>;
2310
2311// Load, store, and memory fence
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002312def LFENCE : I<0xAE, MRM5r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002313 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002314def MFENCE : I<0xAE, MRM6r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002315 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2316
Andrew Lenharth785610d2008-02-16 01:24:58 +00002317//TODO: custom lower this so as to never even generate the noop
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002318def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002319 (i8 0)), (NOOP)>;
2320def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2321def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002322def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002323 (i8 1)), (MFENCE)>;
2324
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002325// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00002326// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00002327// load of an all-ones value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +00002328let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2329 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002330 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002331 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002332 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002333
2334// FR64 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002335let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002336def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002337 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002338 [(set VR128:$dst,
2339 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002340def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002341 "movsd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002342 [(set VR128:$dst,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002343 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2344
Evan Chengb783fa32007-07-19 01:14:50 +00002345def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002346 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002347 [(set VR128:$dst,
2348 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002349def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002350 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002351 [(set VR128:$dst,
2352 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2353
Evan Chengb783fa32007-07-19 01:14:50 +00002354def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002355 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2357
Evan Chengb783fa32007-07-19 01:14:50 +00002358def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002359 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002360 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2361
2362// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002363def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002364 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365 [(set VR128:$dst,
2366 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2367 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002368def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002369 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002370 [(store (i64 (vector_extract (v2i64 VR128:$src),
2371 (iPTR 0))), addr:$dst)]>;
2372
2373// FIXME: may not be able to eliminate this movss with coalescing the src and
2374// dest register classes are different. We really want to write this pattern
2375// like this:
2376// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2377// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002378let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002379def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002380 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002381 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2382 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002383def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002384 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002385 [(store (f64 (vector_extract (v2f64 VR128:$src),
2386 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002387def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002388 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002389 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2390 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002391def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002392 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002393 [(store (i32 (vector_extract (v4i32 VR128:$src),
2394 (iPTR 0))), addr:$dst)]>;
2395
Evan Chengb783fa32007-07-19 01:14:50 +00002396def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002397 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002399def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002400 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002401 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2402
2403
2404// Move to lower bits of a VR128, leaving upper bits alone.
2405// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002406let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00002407 let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002408 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002409 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002410 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002411
2412 let AddedComplexity = 15 in
2413 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002414 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002415 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002416 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002417 (v2f64 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418}
2419
2420// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002421def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002422 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002423 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2424
2425// Move to lower bits of a VR128 and zeroing upper bits.
2426// Loading from memory automatically zeroing upper bits.
Evan Chengd743a5f2008-05-10 00:59:18 +00002427let AddedComplexity = 20 in {
2428def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2429 "movsd\t{$src, $dst|$dst, $src}",
2430 [(set VR128:$dst,
2431 (v2f64 (X86vzmovl (v2f64 (scalar_to_vector
2432 (loadf64 addr:$src))))))]>;
Evan Cheng40ee6e52008-05-08 00:57:18 +00002433
Evan Cheng056afe12008-05-20 18:24:47 +00002434def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
2435 (MOVZSD2PDrm addr:$src)>;
2436def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
Evan Chengd743a5f2008-05-10 00:59:18 +00002437 (MOVZSD2PDrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002438def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002439}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002440
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002441// movd / movq to XMM register zero-extends
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002442let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002443def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002444 "movd\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002445 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002446 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002447// This is X86-64 only.
2448def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2449 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002450 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002451 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002452}
2453
2454let AddedComplexity = 20 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002455def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002456 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002457 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002458 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002459 (loadi32 addr:$src))))))]>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002460
2461def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2462 (MOVZDI2PDIrm addr:$src)>;
2463def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2464 (MOVZDI2PDIrm addr:$src)>;
Duncan Sands2418bec2008-06-13 19:07:40 +00002465def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2466 (MOVZDI2PDIrm addr:$src)>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002467
Evan Chengb783fa32007-07-19 01:14:50 +00002468def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002469 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002470 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002471 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002472 (loadi64 addr:$src))))))]>, XS,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002473 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002474
Evan Cheng3ad16c42008-05-22 18:56:56 +00002475def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2476 (MOVZQI2PQIrm addr:$src)>;
2477def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2478 (MOVZQI2PQIrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002479def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002480}
Evan Chenge9b9c672008-05-09 21:53:03 +00002481
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002482// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2483// IA32 document. movq xmm1, xmm2 does clear the high bits.
2484let AddedComplexity = 15 in
2485def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2486 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002487 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002488 XS, Requires<[HasSSE2]>;
2489
Evan Cheng056afe12008-05-20 18:24:47 +00002490let AddedComplexity = 20 in {
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002491def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2492 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002493 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng056afe12008-05-20 18:24:47 +00002494 (loadv2i64 addr:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002495 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002496
Evan Cheng056afe12008-05-20 18:24:47 +00002497def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2498 (MOVZPQILo2PQIrm addr:$src)>;
2499}
2500
Sean Callanan2c48df22009-12-18 00:01:26 +00002501// Instructions for the disassembler
2502// xr = XMM register
2503// xm = mem64
2504
2505def MOVQxrxr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2506 "movq\t{$src, $dst|$dst, $src}", []>, XS;
2507
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002508//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002509// SSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002510//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002511
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002513def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002514 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002515 [(set VR128:$dst, (v4f32 (movshdup
2516 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002517def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002518 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002519 [(set VR128:$dst, (movshdup
2520 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002521
Evan Chengb783fa32007-07-19 01:14:50 +00002522def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002523 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002524 [(set VR128:$dst, (v4f32 (movsldup
2525 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002526def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002527 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002528 [(set VR128:$dst, (movsldup
2529 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002530
Evan Chengb783fa32007-07-19 01:14:50 +00002531def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002532 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002533 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002534def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002535 "movddup\t{$src, $dst|$dst, $src}",
Evan Chenga2497eb2008-09-25 20:50:48 +00002536 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002537 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2538 (undef))))]>;
Evan Chenga2497eb2008-09-25 20:50:48 +00002539
Nate Begeman543d2142009-04-27 18:41:29 +00002540def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2541 (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002542 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002543
2544let AddedComplexity = 5 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002545def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002546 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002547def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2548 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2549def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2550 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2551def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2552 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2553}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554
2555// Arithmetic
Evan Cheng3ea4d672008-03-05 08:19:16 +00002556let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002557 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002558 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002559 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002560 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2561 VR128:$src2))]>;
2562 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002563 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002564 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002565 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002566 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002567 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002568 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002569 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2571 VR128:$src2))]>;
2572 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002573 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002574 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002575 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002576 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002577}
2578
Evan Chengb783fa32007-07-19 01:14:50 +00002579def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002580 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002581 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2582
2583// Horizontal ops
2584class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002585 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002586 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2588class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002589 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002590 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002591 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002592class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002593 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002594 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002595 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2596class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002597 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002598 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002599 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002600
Evan Cheng3ea4d672008-03-05 08:19:16 +00002601let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2603 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2604 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2605 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2606 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2607 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2608 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2609 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2610}
2611
2612// Thread synchronization
Bill Wendling6ee76552009-05-28 23:40:46 +00002613def MONITOR : I<0x01, MRM1r, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002614 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Bill Wendling6ee76552009-05-28 23:40:46 +00002615def MWAIT : I<0x01, MRM1r, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002616 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2617
2618// vector_shuffle v1, <undef> <1, 1, 3, 3>
2619let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002620def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002621 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2622let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002623def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002624 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2625
2626// vector_shuffle v1, <undef> <0, 0, 2, 2>
2627let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002628 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002629 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2630let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002631 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002632 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2633
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002634//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002635// SSSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002636//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002637
Bill Wendling98680292007-08-10 06:22:27 +00002638/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002639multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2640 Intrinsic IntId64, Intrinsic IntId128> {
2641 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2642 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2643 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002644
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002645 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2646 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2647 [(set VR64:$dst,
2648 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2649
2650 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2651 (ins VR128:$src),
2652 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2653 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2654 OpSize;
2655
2656 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2657 (ins i128mem:$src),
2658 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2659 [(set VR128:$dst,
2660 (IntId128
2661 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002662}
2663
Bill Wendling98680292007-08-10 06:22:27 +00002664/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002665multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2666 Intrinsic IntId64, Intrinsic IntId128> {
2667 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2668 (ins VR64:$src),
2669 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2670 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002671
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002672 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2673 (ins i64mem:$src),
2674 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2675 [(set VR64:$dst,
2676 (IntId64
2677 (bitconvert (memopv4i16 addr:$src))))]>;
2678
2679 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2680 (ins VR128:$src),
2681 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2682 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2683 OpSize;
2684
2685 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2686 (ins i128mem:$src),
2687 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2688 [(set VR128:$dst,
2689 (IntId128
2690 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002691}
2692
2693/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002694multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2695 Intrinsic IntId64, Intrinsic IntId128> {
2696 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2697 (ins VR64:$src),
2698 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2699 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002700
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002701 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2702 (ins i64mem:$src),
2703 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2704 [(set VR64:$dst,
2705 (IntId64
2706 (bitconvert (memopv2i32 addr:$src))))]>;
2707
2708 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2709 (ins VR128:$src),
2710 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2711 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2712 OpSize;
2713
2714 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2715 (ins i128mem:$src),
2716 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2717 [(set VR128:$dst,
2718 (IntId128
2719 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002720}
2721
2722defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2723 int_x86_ssse3_pabs_b,
2724 int_x86_ssse3_pabs_b_128>;
2725defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2726 int_x86_ssse3_pabs_w,
2727 int_x86_ssse3_pabs_w_128>;
2728defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2729 int_x86_ssse3_pabs_d,
2730 int_x86_ssse3_pabs_d_128>;
2731
2732/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002733let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002734 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2735 Intrinsic IntId64, Intrinsic IntId128,
2736 bit Commutable = 0> {
2737 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2738 (ins VR64:$src1, VR64:$src2),
2739 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2740 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2741 let isCommutable = Commutable;
2742 }
2743 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2744 (ins VR64:$src1, i64mem:$src2),
2745 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2746 [(set VR64:$dst,
2747 (IntId64 VR64:$src1,
2748 (bitconvert (memopv8i8 addr:$src2))))]>;
2749
2750 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2751 (ins VR128:$src1, VR128:$src2),
2752 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2753 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2754 OpSize {
2755 let isCommutable = Commutable;
2756 }
2757 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2758 (ins VR128:$src1, i128mem:$src2),
2759 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2760 [(set VR128:$dst,
2761 (IntId128 VR128:$src1,
2762 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2763 }
2764}
2765
2766/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002767let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002768 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2769 Intrinsic IntId64, Intrinsic IntId128,
2770 bit Commutable = 0> {
2771 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2772 (ins VR64:$src1, VR64:$src2),
2773 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2774 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2775 let isCommutable = Commutable;
2776 }
2777 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2778 (ins VR64:$src1, i64mem:$src2),
2779 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2780 [(set VR64:$dst,
2781 (IntId64 VR64:$src1,
2782 (bitconvert (memopv4i16 addr:$src2))))]>;
2783
2784 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2785 (ins VR128:$src1, VR128:$src2),
2786 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2787 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2788 OpSize {
2789 let isCommutable = Commutable;
2790 }
2791 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2792 (ins VR128:$src1, i128mem:$src2),
2793 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2794 [(set VR128:$dst,
2795 (IntId128 VR128:$src1,
2796 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2797 }
2798}
2799
2800/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002801let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002802 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2803 Intrinsic IntId64, Intrinsic IntId128,
2804 bit Commutable = 0> {
2805 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2806 (ins VR64:$src1, VR64:$src2),
2807 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2808 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2809 let isCommutable = Commutable;
2810 }
2811 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2812 (ins VR64:$src1, i64mem:$src2),
2813 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2814 [(set VR64:$dst,
2815 (IntId64 VR64:$src1,
2816 (bitconvert (memopv2i32 addr:$src2))))]>;
2817
2818 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2819 (ins VR128:$src1, VR128:$src2),
2820 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2821 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2822 OpSize {
2823 let isCommutable = Commutable;
2824 }
2825 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2826 (ins VR128:$src1, i128mem:$src2),
2827 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2828 [(set VR128:$dst,
2829 (IntId128 VR128:$src1,
2830 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2831 }
2832}
2833
2834defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2835 int_x86_ssse3_phadd_w,
Evan Cheng944e4412008-06-16 21:16:24 +00002836 int_x86_ssse3_phadd_w_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002837defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2838 int_x86_ssse3_phadd_d,
Evan Cheng944e4412008-06-16 21:16:24 +00002839 int_x86_ssse3_phadd_d_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002840defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2841 int_x86_ssse3_phadd_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002842 int_x86_ssse3_phadd_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002843defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2844 int_x86_ssse3_phsub_w,
2845 int_x86_ssse3_phsub_w_128>;
2846defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2847 int_x86_ssse3_phsub_d,
2848 int_x86_ssse3_phsub_d_128>;
2849defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2850 int_x86_ssse3_phsub_sw,
2851 int_x86_ssse3_phsub_sw_128>;
2852defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2853 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002854 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002855defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2856 int_x86_ssse3_pmul_hr_sw,
2857 int_x86_ssse3_pmul_hr_sw_128, 1>;
2858defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2859 int_x86_ssse3_pshuf_b,
2860 int_x86_ssse3_pshuf_b_128>;
2861defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2862 int_x86_ssse3_psign_b,
2863 int_x86_ssse3_psign_b_128>;
2864defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2865 int_x86_ssse3_psign_w,
2866 int_x86_ssse3_psign_w_128>;
Evan Chengabfed472009-05-28 18:48:53 +00002867defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling98680292007-08-10 06:22:27 +00002868 int_x86_ssse3_psign_d,
2869 int_x86_ssse3_psign_d_128>;
2870
Evan Cheng3ea4d672008-03-05 08:19:16 +00002871let Constraints = "$src1 = $dst" in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002872 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002873 (ins VR64:$src1, VR64:$src2, i8imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002874 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002875 []>;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002876 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002877 (ins VR64:$src1, i64mem:$src2, i8imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002878 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002879 []>;
Bill Wendling98680292007-08-10 06:22:27 +00002880
Bill Wendling1dc817c2007-08-10 09:00:17 +00002881 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002882 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002883 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002884 []>, OpSize;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002885 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002886 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002887 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002888 []>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002889}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002890
Nate Begeman080f8e22009-10-19 02:17:23 +00002891// palignr patterns.
Sean Callananb02aec52009-11-20 22:28:42 +00002892def : Pat<(int_x86_ssse3_palign_r VR64:$src1, VR64:$src2, (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002893 (PALIGNR64rr VR64:$src1, VR64:$src2, (BYTE_imm imm:$src3))>,
2894 Requires<[HasSSSE3]>;
2895def : Pat<(int_x86_ssse3_palign_r VR64:$src1,
2896 (memop64 addr:$src2),
Sean Callananb02aec52009-11-20 22:28:42 +00002897 (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002898 (PALIGNR64rm VR64:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2899 Requires<[HasSSSE3]>;
2900
Sean Callananb02aec52009-11-20 22:28:42 +00002901def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1, VR128:$src2, (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002902 (PALIGNR128rr VR128:$src1, VR128:$src2, (BYTE_imm imm:$src3))>,
2903 Requires<[HasSSSE3]>;
2904def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1,
2905 (memopv2i64 addr:$src2),
Sean Callananb02aec52009-11-20 22:28:42 +00002906 (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002907 (PALIGNR128rm VR128:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2908 Requires<[HasSSSE3]>;
2909
Nate Begeman080f8e22009-10-19 02:17:23 +00002910let AddedComplexity = 5 in {
2911def : Pat<(v4i32 (palign:$src3 VR128:$src1, VR128:$src2)),
2912 (PALIGNR128rr VR128:$src2, VR128:$src1,
2913 (SHUFFLE_get_palign_imm VR128:$src3))>,
2914 Requires<[HasSSSE3]>;
2915def : Pat<(v4f32 (palign:$src3 VR128:$src1, VR128:$src2)),
2916 (PALIGNR128rr VR128:$src2, VR128:$src1,
2917 (SHUFFLE_get_palign_imm VR128:$src3))>,
2918 Requires<[HasSSSE3]>;
2919def : Pat<(v8i16 (palign:$src3 VR128:$src1, VR128:$src2)),
2920 (PALIGNR128rr VR128:$src2, VR128:$src1,
2921 (SHUFFLE_get_palign_imm VR128:$src3))>,
2922 Requires<[HasSSSE3]>;
2923def : Pat<(v16i8 (palign:$src3 VR128:$src1, VR128:$src2)),
2924 (PALIGNR128rr VR128:$src2, VR128:$src1,
2925 (SHUFFLE_get_palign_imm VR128:$src3))>,
2926 Requires<[HasSSSE3]>;
Eric Christopherf3650292009-11-07 08:45:53 +00002927}
Nate Begeman080f8e22009-10-19 02:17:23 +00002928
Nate Begeman2c87c422009-02-23 08:49:38 +00002929def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2930 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2931def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2932 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2933
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002934//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002935// Non-Instruction Patterns
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002936//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002938// extload f32 -> f64. This matches load+fextend because we have a hack in
2939// the isel (PreprocessForFPConvert) that can introduce loads after dag
2940// combine.
Chris Lattnerdec9cb52008-01-24 08:07:48 +00002941// Since these loads aren't folded into the fextend, we have to match it
2942// explicitly here.
2943let Predicates = [HasSSE2] in
2944 def : Pat<(fextend (loadf32 addr:$src)),
2945 (CVTSS2SDrm addr:$src)>;
2946
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002947// bit_convert
2948let Predicates = [HasSSE2] in {
2949 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2950 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2951 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2952 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2953 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2954 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2955 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2956 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2957 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2958 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2959 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2960 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2961 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2962 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2963 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2964 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2965 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2966 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2967 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2968 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2969 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2970 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2971 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2972 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2973 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2974 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2975 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2976 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2977 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2978 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2979}
2980
2981// Move scalar to XMM zero-extended
2982// movd to XMM register zero-extends
2983let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002984// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chenge9b9c672008-05-09 21:53:03 +00002985def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002986 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002987def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002988 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>;
Evan Chenge259e872008-05-09 23:37:55 +00002989def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002990 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Evan Cheng7fe0ff02008-07-10 01:08:23 +00002991def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002992 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002993}
2994
2995// Splat v2f64 / v2i64
2996let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002997def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002998 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002999def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003000 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003001def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003002 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003003def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003004 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
3005}
3006
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003007// Special unary SHUFPSrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00003008def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
3009 (SHUFPSrri VR128:$src1, VR128:$src1,
3010 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003011 Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003012let AddedComplexity = 5 in
3013def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
3014 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3015 Requires<[HasSSE2]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00003016// Special unary SHUFPDrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00003017def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003018 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00003019 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3020 Requires<[HasSSE2]>;
3021// Special unary SHUFPDrri case.
3022def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003023 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00003024 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7dc19012007-08-02 21:17:01 +00003025 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003026// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman543d2142009-04-27 18:41:29 +00003027def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
3028 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003029 Requires<[HasSSE2]>;
Evan Cheng13559d62008-09-26 23:41:32 +00003030
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003031// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman543d2142009-04-27 18:41:29 +00003032def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003033 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00003034 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003035 Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003036def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003037 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00003038 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003039 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003040// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman543d2142009-04-27 18:41:29 +00003041def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003042 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00003043 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003044 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003045
3046// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00003047let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003048def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
3049 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003050 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003051def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
3052 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003053 Requires<[OptForSpeed, HasSSE2]>;
3054}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003055let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003056def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003057 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003058def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003059 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003060def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003061 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003062def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003063 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003064}
3065
3066// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00003067let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003068def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
3069 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003070 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003071def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
3072 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003073 Requires<[OptForSpeed, HasSSE2]>;
3074}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003075let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003076def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003077 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003078def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003079 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003080def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003081 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003082def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003083 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003084}
3085
Evan Cheng13559d62008-09-26 23:41:32 +00003086let AddedComplexity = 20 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003087// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begemanb13034d2009-11-07 23:17:15 +00003088def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003089 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
3090
3091// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003092def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003093 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
3094
3095// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003096def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003097 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman543d2142009-04-27 18:41:29 +00003098def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003099 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
3100}
3101
3102let AddedComplexity = 20 in {
3103// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003104def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003105 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003106def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003107 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003108def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003110def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003111 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003112}
3113
Evan Cheng2b2a7012008-05-23 21:23:16 +00003114// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003115def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003116 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003117def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003118 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003119def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3120 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003121 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003122def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003123 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2b2a7012008-05-23 21:23:16 +00003124
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003125let AddedComplexity = 15 in {
3126// Setting the lowest element in the vector.
Nate Begeman543d2142009-04-27 18:41:29 +00003127def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003128 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003129def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003130 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3131
3132// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
Nate Begeman543d2142009-04-27 18:41:29 +00003133def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003134 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003135def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003136 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3137}
3138
Eli Friedman27d19742009-06-19 07:00:55 +00003139// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3140// fall back to this for SSE1)
3141def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003142 (SHUFPSrri VR128:$src2, VR128:$src1,
Eli Friedman27d19742009-06-19 07:00:55 +00003143 (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>;
3144
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003145// Set lowest element and zero upper elements.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003146let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00003147def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003148 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00003149def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengd09a8a02008-05-08 22:35:02 +00003150 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003151
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003152// Some special case pandn patterns.
3153def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3154 VR128:$src2)),
3155 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3156def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3157 VR128:$src2)),
3158 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3159def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3160 VR128:$src2)),
3161 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3162
3163def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003164 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003165 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3166def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003167 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003168 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3169def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003170 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003171 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3172
Nate Begeman78246ca2007-11-17 03:58:34 +00003173// vector -> vector casts
3174def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3175 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3176def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3177 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedman7fa52ca2008-09-05 23:07:03 +00003178def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3179 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3180def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3181 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman78246ca2007-11-17 03:58:34 +00003182
Evan Cheng51a49b22007-07-20 00:27:43 +00003183// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00003184def : Pat<(alignedloadv4i32 addr:$src),
3185 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3186def : Pat<(loadv4i32 addr:$src),
3187 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00003188def : Pat<(alignedloadv2i64 addr:$src),
3189 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3190def : Pat<(loadv2i64 addr:$src),
3191 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3192
3193def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3194 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3195def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3196 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3197def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3198 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3199def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3200 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3201def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3202 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3203def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3204 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3205def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3206 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3207def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3208 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003209
Nate Begemanb2975562008-02-03 07:18:54 +00003210//===----------------------------------------------------------------------===//
3211// SSE4.1 Instructions
3212//===----------------------------------------------------------------------===//
3213
Dale Johannesena7d2b442008-10-10 23:51:03 +00003214multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begemanb2975562008-02-03 07:18:54 +00003215 string OpcodeStr,
Nate Begemanb2975562008-02-03 07:18:54 +00003216 Intrinsic V4F32Int,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003217 Intrinsic V2F64Int> {
Nate Begemanb2975562008-02-03 07:18:54 +00003218 // Intrinsic operation, reg.
Nate Begemanb2975562008-02-03 07:18:54 +00003219 // Vector intrinsic operation, reg
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003220 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003221 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003222 !strconcat(OpcodeStr,
3223 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003224 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3225 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003226
3227 // Vector intrinsic operation, mem
Evan Chengd3f27fb2009-12-18 07:40:29 +00003228 def PSm_Int : Ii8<opcps, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003229 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003230 !strconcat(OpcodeStr,
3231 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003232 [(set VR128:$dst,
3233 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Evan Chengd3f27fb2009-12-18 07:40:29 +00003234 TA, OpSize,
3235 Requires<[HasSSE41, NoSSEBreakDep]>;
Nate Begemanb2975562008-02-03 07:18:54 +00003236
Nate Begemanb2975562008-02-03 07:18:54 +00003237 // Vector intrinsic operation, reg
Evan Cheng78d00612008-03-14 07:39:27 +00003238 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003239 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003240 !strconcat(OpcodeStr,
3241 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003242 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3243 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003244
3245 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003246 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003247 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003248 !strconcat(OpcodeStr,
3249 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003250 [(set VR128:$dst,
3251 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003252 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003253}
3254
Dale Johannesena7d2b442008-10-10 23:51:03 +00003255let Constraints = "$src1 = $dst" in {
3256multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3257 string OpcodeStr,
3258 Intrinsic F32Int,
3259 Intrinsic F64Int> {
3260 // Intrinsic operation, reg.
3261 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003262 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003263 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3264 !strconcat(OpcodeStr,
3265 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003266 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003267 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3268 OpSize;
3269
3270 // Intrinsic operation, mem.
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003271 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3272 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003273 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003274 !strconcat(OpcodeStr,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003275 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003276 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003277 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3278 OpSize;
3279
3280 // Intrinsic operation, reg.
3281 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003282 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003283 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3284 !strconcat(OpcodeStr,
3285 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003286 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003287 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3288 OpSize;
3289
3290 // Intrinsic operation, mem.
3291 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003292 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003293 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3294 !strconcat(OpcodeStr,
3295 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003296 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003297 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3298 OpSize;
3299}
3300}
3301
Nate Begemanb2975562008-02-03 07:18:54 +00003302// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesena7d2b442008-10-10 23:51:03 +00003303defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3304 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3305defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3306 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003307
3308// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3309multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3310 Intrinsic IntId128> {
3311 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3312 (ins VR128:$src),
3313 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3314 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3315 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3316 (ins i128mem:$src),
3317 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3318 [(set VR128:$dst,
3319 (IntId128
3320 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3321}
3322
3323defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3324 int_x86_sse41_phminposuw>;
3325
3326/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003327let Constraints = "$src1 = $dst" in {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003328 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3329 Intrinsic IntId128, bit Commutable = 0> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003330 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3331 (ins VR128:$src1, VR128:$src2),
3332 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3333 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3334 OpSize {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003335 let isCommutable = Commutable;
3336 }
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003337 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3338 (ins VR128:$src1, i128mem:$src2),
3339 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3340 [(set VR128:$dst,
3341 (IntId128 VR128:$src1,
3342 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003343 }
3344}
3345
3346defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3347 int_x86_sse41_pcmpeqq, 1>;
3348defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3349 int_x86_sse41_packusdw, 0>;
3350defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3351 int_x86_sse41_pminsb, 1>;
3352defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3353 int_x86_sse41_pminsd, 1>;
3354defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3355 int_x86_sse41_pminud, 1>;
3356defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3357 int_x86_sse41_pminuw, 1>;
3358defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3359 int_x86_sse41_pmaxsb, 1>;
3360defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3361 int_x86_sse41_pmaxsd, 1>;
3362defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3363 int_x86_sse41_pmaxud, 1>;
3364defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3365 int_x86_sse41_pmaxuw, 1>;
Nate Begeman72d802a2008-02-04 06:00:24 +00003366
Mon P Wang14edb092008-12-18 21:42:19 +00003367defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3368
Nate Begeman03605a02008-07-17 16:51:19 +00003369def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3370 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3371def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3372 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3373
Nate Begeman58057962008-02-09 01:38:08 +00003374/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003375let Constraints = "$src1 = $dst" in {
Dan Gohmane3731f52008-05-23 17:49:40 +00003376 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3377 SDNode OpNode, Intrinsic IntId128,
3378 bit Commutable = 0> {
Nate Begeman58057962008-02-09 01:38:08 +00003379 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3380 (ins VR128:$src1, VR128:$src2),
3381 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmane3731f52008-05-23 17:49:40 +00003382 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3383 VR128:$src2))]>, OpSize {
Nate Begeman58057962008-02-09 01:38:08 +00003384 let isCommutable = Commutable;
3385 }
3386 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3387 (ins VR128:$src1, VR128:$src2),
3388 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3389 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3390 OpSize {
3391 let isCommutable = Commutable;
3392 }
3393 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3394 (ins VR128:$src1, i128mem:$src2),
3395 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3396 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003397 (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003398 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3399 (ins VR128:$src1, i128mem:$src2),
3400 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3401 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003402 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman58057962008-02-09 01:38:08 +00003403 OpSize;
3404 }
3405}
Dan Gohmane3731f52008-05-23 17:49:40 +00003406defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
Nate Begeman58057962008-02-09 01:38:08 +00003407 int_x86_sse41_pmulld, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003408
Evan Cheng78d00612008-03-14 07:39:27 +00003409/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Cheng3ea4d672008-03-05 08:19:16 +00003410let Constraints = "$src1 = $dst" in {
Nate Begeman72d802a2008-02-04 06:00:24 +00003411 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3412 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng78d00612008-03-14 07:39:27 +00003413 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003414 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003415 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003416 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003417 [(set VR128:$dst,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003418 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3419 OpSize {
Nate Begeman72d802a2008-02-04 06:00:24 +00003420 let isCommutable = Commutable;
3421 }
Evan Cheng78d00612008-03-14 07:39:27 +00003422 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003423 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3424 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003425 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003426 [(set VR128:$dst,
3427 (IntId128 VR128:$src1,
3428 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3429 OpSize;
Nate Begeman72d802a2008-02-04 06:00:24 +00003430 }
3431}
3432
3433defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3434 int_x86_sse41_blendps, 0>;
3435defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3436 int_x86_sse41_blendpd, 0>;
3437defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3438 int_x86_sse41_pblendw, 0>;
3439defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3440 int_x86_sse41_dpps, 1>;
3441defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3442 int_x86_sse41_dppd, 1>;
3443defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng81ed9852008-06-16 20:25:59 +00003444 int_x86_sse41_mpsadbw, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003445
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003446
Evan Cheng78d00612008-03-14 07:39:27 +00003447/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003448let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanb4e9a042008-02-10 18:47:57 +00003449 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3450 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3451 (ins VR128:$src1, VR128:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003452 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003453 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3454 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3455 OpSize;
3456
3457 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3458 (ins VR128:$src1, i128mem:$src2),
3459 !strconcat(OpcodeStr,
3460 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3461 [(set VR128:$dst,
3462 (IntId VR128:$src1,
3463 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3464 }
3465}
3466
3467defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3468defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3469defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3470
3471
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003472multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3473 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3474 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3475 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3476
3477 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3478 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003479 [(set VR128:$dst,
3480 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3481 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003482}
3483
3484defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3485defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3486defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3487defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3488defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3489defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3490
Evan Cheng56ec77b2008-09-24 23:27:55 +00003491// Common patterns involving scalar load.
3492def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3493 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3494def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3495 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3496
3497def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3498 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3499def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3500 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3501
3502def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3503 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3504def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3505 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3506
3507def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3508 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3509def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3510 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3511
3512def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3513 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3514def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3515 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3516
3517def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3518 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3519def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3520 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3521
3522
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003523multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3524 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3525 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3526 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3527
3528 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3529 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003530 [(set VR128:$dst,
3531 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3532 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003533}
3534
3535defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3536defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3537defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3538defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3539
Evan Cheng56ec77b2008-09-24 23:27:55 +00003540// Common patterns involving scalar load
3541def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003542 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003543def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003544 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003545
3546def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003547 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003548def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003549 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003550
3551
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003552multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3553 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3554 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3555 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3556
Evan Cheng56ec77b2008-09-24 23:27:55 +00003557 // Expecting a i16 load any extended to i32 value.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003558 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3559 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003560 [(set VR128:$dst, (IntId (bitconvert
3561 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3562 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003563}
3564
3565defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman75a89d62009-06-06 05:55:37 +00003566defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003567
Evan Cheng56ec77b2008-09-24 23:27:55 +00003568// Common patterns involving scalar load
3569def : Pat<(int_x86_sse41_pmovsxbq
3570 (bitconvert (v4i32 (X86vzmovl
3571 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003572 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003573
3574def : Pat<(int_x86_sse41_pmovzxbq
3575 (bitconvert (v4i32 (X86vzmovl
3576 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003577 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003578
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003579
Nate Begemand77e59e2008-02-11 04:19:36 +00003580/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3581multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003582 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003583 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003584 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003585 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003586 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3587 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003588 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003589 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003590 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003591 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003592 []>, OpSize;
3593// FIXME:
3594// There's an AssertZext in the way of writing the store pattern
3595// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003596}
3597
Nate Begemand77e59e2008-02-11 04:19:36 +00003598defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003599
Nate Begemand77e59e2008-02-11 04:19:36 +00003600
3601/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3602multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003603 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemand77e59e2008-02-11 04:19:36 +00003604 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003605 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003606 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3607 []>, OpSize;
3608// FIXME:
3609// There's an AssertZext in the way of writing the store pattern
3610// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3611}
3612
3613defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3614
3615
3616/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3617multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003618 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003619 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003620 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003621 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3622 [(set GR32:$dst,
3623 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003624 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003625 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003626 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003627 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3628 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3629 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003630}
3631
Nate Begemand77e59e2008-02-11 04:19:36 +00003632defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman58057962008-02-09 01:38:08 +00003633
Nate Begemand77e59e2008-02-11 04:19:36 +00003634
Evan Cheng6c249332008-03-24 21:52:23 +00003635/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3636/// destination
Nate Begemand77e59e2008-02-11 04:19:36 +00003637multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003638 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003639 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003640 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003641 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman788db592008-04-16 02:32:24 +00003642 [(set GR32:$dst,
3643 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng6c249332008-03-24 21:52:23 +00003644 OpSize;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003645 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003646 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003647 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003648 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng6c249332008-03-24 21:52:23 +00003649 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003650 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003651}
3652
Nate Begemand77e59e2008-02-11 04:19:36 +00003653defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003654
Dan Gohmana41862a2008-08-08 18:30:21 +00003655// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3656def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3657 imm:$src2))),
3658 addr:$dst),
3659 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3660 Requires<[HasSSE41]>;
3661
Evan Cheng3ea4d672008-03-05 08:19:16 +00003662let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003663 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003664 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003665 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003666 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003667 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003668 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003669 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003670 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003671 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3672 !strconcat(OpcodeStr,
3673 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003674 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003675 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3676 imm:$src3))]>, OpSize;
3677 }
3678}
3679
3680defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3681
Evan Cheng3ea4d672008-03-05 08:19:16 +00003682let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003683 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003684 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003685 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003686 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003687 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003688 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003689 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3690 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003691 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003692 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3693 !strconcat(OpcodeStr,
3694 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003695 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003696 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3697 imm:$src3)))]>, OpSize;
3698 }
3699}
3700
3701defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3702
Eric Christophera0443602009-07-23 02:22:41 +00003703// insertps has a few different modes, there's the first two here below which
3704// are optimized inserts that won't zero arbitrary elements in the destination
3705// vector. The next one matches the intrinsic and could zero arbitrary elements
3706// in the target vector.
Evan Cheng3ea4d672008-03-05 08:19:16 +00003707let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003708 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherefb657e2009-07-24 00:33:09 +00003709 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3710 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003711 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003712 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003713 [(set VR128:$dst,
3714 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
Sean Callanan2c48df22009-12-18 00:01:26 +00003715 OpSize;
Eric Christopherefb657e2009-07-24 00:33:09 +00003716 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003717 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3718 !strconcat(OpcodeStr,
3719 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003720 [(set VR128:$dst,
Eric Christopherefb657e2009-07-24 00:33:09 +00003721 (X86insrtps VR128:$src1,
3722 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begemand77e59e2008-02-11 04:19:36 +00003723 imm:$src3))]>, OpSize;
3724 }
3725}
3726
Evan Chengc2054be2008-03-26 08:11:49 +00003727defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003728
Eric Christopherefb657e2009-07-24 00:33:09 +00003729def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3730 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3731
Eric Christopher95d79262009-07-29 00:28:05 +00003732// ptest instruction we'll lower to this in X86ISelLowering primarily from
3733// the intel intrinsic that corresponds to this.
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003734let Defs = [EFLAGS] in {
3735def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003736 "ptest \t{$src2, $src1|$src1, $src2}",
3737 [(X86ptest VR128:$src1, VR128:$src2),
3738 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003739def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003740 "ptest \t{$src2, $src1|$src1, $src2}",
3741 [(X86ptest VR128:$src1, (load addr:$src2)),
3742 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003743}
3744
3745def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3746 "movntdqa\t{$src, $dst|$dst, $src}",
3747 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>;
Nate Begeman03605a02008-07-17 16:51:19 +00003748
Eric Christopher22a39402009-08-18 22:50:32 +00003749
3750//===----------------------------------------------------------------------===//
3751// SSE4.2 Instructions
3752//===----------------------------------------------------------------------===//
3753
Nate Begeman03605a02008-07-17 16:51:19 +00003754/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3755let Constraints = "$src1 = $dst" in {
3756 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3757 Intrinsic IntId128, bit Commutable = 0> {
3758 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3759 (ins VR128:$src1, VR128:$src2),
3760 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3761 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3762 OpSize {
3763 let isCommutable = Commutable;
3764 }
3765 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3766 (ins VR128:$src1, i128mem:$src2),
3767 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3768 [(set VR128:$dst,
3769 (IntId128 VR128:$src1,
3770 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3771 }
3772}
3773
Nate Begeman235666b2008-07-17 17:04:58 +00003774defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman03605a02008-07-17 16:51:19 +00003775
3776def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3777 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3778def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3779 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003780
3781// crc intrinsic instruction
3782// This set of instructions are only rm, the only difference is the size
3783// of r and m.
3784let Constraints = "$src1 = $dst" in {
Eric Christopher85f187b2009-08-10 21:48:58 +00003785 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003786 (ins GR32:$src1, i8mem:$src2),
3787 "crc32 \t{$src2, $src1|$src1, $src2}",
3788 [(set GR32:$dst,
3789 (int_x86_sse42_crc32_8 GR32:$src1,
3790 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003791 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003792 (ins GR32:$src1, GR8:$src2),
3793 "crc32 \t{$src2, $src1|$src1, $src2}",
3794 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003795 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003796 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003797 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003798 (ins GR32:$src1, i16mem:$src2),
3799 "crc32 \t{$src2, $src1|$src1, $src2}",
3800 [(set GR32:$dst,
3801 (int_x86_sse42_crc32_16 GR32:$src1,
3802 (load addr:$src2)))]>,
3803 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003804 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003805 (ins GR32:$src1, GR16:$src2),
3806 "crc32 \t{$src2, $src1|$src1, $src2}",
3807 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003808 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003809 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003810 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003811 (ins GR32:$src1, i32mem:$src2),
3812 "crc32 \t{$src2, $src1|$src1, $src2}",
3813 [(set GR32:$dst,
3814 (int_x86_sse42_crc32_32 GR32:$src1,
3815 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003816 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003817 (ins GR32:$src1, GR32:$src2),
3818 "crc32 \t{$src2, $src1|$src1, $src2}",
3819 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003820 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003821 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003822 def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003823 (ins GR64:$src1, i64mem:$src2),
3824 "crc32 \t{$src2, $src1|$src1, $src2}",
3825 [(set GR64:$dst,
3826 (int_x86_sse42_crc32_64 GR64:$src1,
3827 (load addr:$src2)))]>,
3828 OpSize, REX_W;
Eric Christopher85f187b2009-08-10 21:48:58 +00003829 def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003830 (ins GR64:$src1, GR64:$src2),
3831 "crc32 \t{$src2, $src1|$src1, $src2}",
3832 [(set GR64:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003833 (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003834 OpSize, REX_W;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003835}
Eric Christopher22a39402009-08-18 22:50:32 +00003836
3837// String/text processing instructions.
Dan Gohman30afe012009-10-29 18:10:34 +00003838let Defs = [EFLAGS], usesCustomInserter = 1 in {
Eric Christopher22a39402009-08-18 22:50:32 +00003839def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003840 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3841 "#PCMPISTRM128rr PSEUDO!",
3842 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
3843 imm:$src3))]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003844def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003845 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3846 "#PCMPISTRM128rm PSEUDO!",
3847 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, (load addr:$src2),
3848 imm:$src3))]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003849}
3850
3851let Defs = [XMM0, EFLAGS] in {
3852def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003853 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3854 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003855def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003856 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3857 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003858}
3859
Sean Callanan2c48df22009-12-18 00:01:26 +00003860let Defs = [EFLAGS], Uses = [EAX, EDX], usesCustomInserter = 1 in {
Eric Christopher22a39402009-08-18 22:50:32 +00003861def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003862 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3863 "#PCMPESTRM128rr PSEUDO!",
3864 [(set VR128:$dst,
3865 (int_x86_sse42_pcmpestrm128
3866 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5))]>, OpSize;
3867
Eric Christopher22a39402009-08-18 22:50:32 +00003868def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003869 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3870 "#PCMPESTRM128rm PSEUDO!",
3871 [(set VR128:$dst, (int_x86_sse42_pcmpestrm128
3872 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5))]>,
3873 OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003874}
3875
3876let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
Sean Callananc5a05b72009-08-20 18:24:27 +00003877def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003878 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3879 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Sean Callananc5a05b72009-08-20 18:24:27 +00003880def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003881 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3882 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003883}
3884
3885let Defs = [ECX, EFLAGS] in {
3886 multiclass SS42AI_pcmpistri<Intrinsic IntId128> {
Sean Callanan2c48df22009-12-18 00:01:26 +00003887 def rr : SS42AI<0x63, MRMSrcReg, (outs),
3888 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3889 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3890 [(set ECX, (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
3891 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003892 def rm : SS42AI<0x63, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003893 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3894 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3895 [(set ECX, (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
3896 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003897 }
3898}
3899
3900defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
3901defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
3902defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
3903defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
3904defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
3905defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
3906
3907let Defs = [ECX, EFLAGS] in {
3908let Uses = [EAX, EDX] in {
3909 multiclass SS42AI_pcmpestri<Intrinsic IntId128> {
3910 def rr : SS42AI<0x61, MRMSrcReg, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003911 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3912 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3913 [(set ECX, (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
3914 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003915 def rm : SS42AI<0x61, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003916 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3917 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3918 [(set ECX,
3919 (IntId128 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5)),
3920 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003921 }
3922}
3923}
3924
3925defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
3926defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
3927defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
3928defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
3929defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
3930defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;