blob: ee63d56f3f1712fd8b9b41a9c7da29c52400ac78 [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>,
73 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
Dan Gohman11821702007-07-27 17:16:43 +0000119def alignedloadfsf32 : PatFrag<(ops node:$ptr), (f32 (alignedload node:$ptr))>;
120def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000121def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>;
122def alignedloadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (alignedload node:$ptr))>;
123def alignedloadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (alignedload node:$ptr))>;
124def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>;
125
126// Like 'load', but uses special alignment checks suitable for use in
127// memory operands in most SSE instructions, which are required to
128// be naturally aligned on some targets but not on others.
129// FIXME: Actually implement support for targets that don't require the
130// alignment. This probably wants a subtarget predicate.
Dan Gohman2a174122008-10-15 06:50:19 +0000131def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{
132 return cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000133}]>;
134
Dan Gohman11821702007-07-27 17:16:43 +0000135def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
136def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000137def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
138def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
139def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
140def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +0000141def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000142
Bill Wendling3b15d722007-08-11 09:52:53 +0000143// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
144// 16-byte boundary.
Nate Begeman9a58b8a2008-02-09 23:46:37 +0000145// FIXME: 8 byte alignment for mmx reads is not required
Dan Gohman61efc5a2008-10-16 00:03:00 +0000146def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Dan Gohman2a174122008-10-15 06:50:19 +0000147 return cast<LoadSDNode>(N)->getAlignment() >= 8;
Bill Wendling3b15d722007-08-11 09:52:53 +0000148}]>;
149
150def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
Bill Wendling3b15d722007-08-11 09:52:53 +0000151def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
152def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
153def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
154
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000155def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
156def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
157def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
158def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
159def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
160def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
161
Evan Cheng56ec77b2008-09-24 23:27:55 +0000162def vzmovl_v2i64 : PatFrag<(ops node:$src),
163 (bitconvert (v2i64 (X86vzmovl
164 (v2i64 (scalar_to_vector (loadi64 node:$src))))))>;
165def vzmovl_v4i32 : PatFrag<(ops node:$src),
166 (bitconvert (v4i32 (X86vzmovl
167 (v4i32 (scalar_to_vector (loadi32 node:$src))))))>;
168
169def vzload_v2i64 : PatFrag<(ops node:$src),
170 (bitconvert (v2i64 (X86vzload node:$src)))>;
171
172
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173def fp32imm0 : PatLeaf<(f32 fpimm), [{
174 return N->isExactlyValue(+0.0);
175}]>;
176
Evan Cheng06cd2072009-10-28 06:30:34 +0000177// BYTE_imm - Transform bit immediates into byte immediates.
178def BYTE_imm : SDNodeXForm<imm, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179 // Transformation function: imm >> 3
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000180 return getI32Imm(N->getZExtValue() >> 3);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181}]>;
182
183// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
184// SHUFP* etc. imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000185def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186 return getI8Imm(X86::getShuffleSHUFImmediate(N));
187}]>;
188
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000189// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190// PSHUFHW imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000191def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
193}]>;
194
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000195// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196// PSHUFLW imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000197def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
199}]>;
200
Nate Begeman080f8e22009-10-19 02:17:23 +0000201// SHUFFLE_get_palign_imm xform function: convert vector_shuffle mask to
202// a PALIGNR imm.
203def SHUFFLE_get_palign_imm : SDNodeXForm<vector_shuffle, [{
204 return getI8Imm(X86::getShufflePALIGNRImmediate(N));
205}]>;
206
Nate Begeman543d2142009-04-27 18:41:29 +0000207def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
208 (vector_shuffle node:$lhs, node:$rhs), [{
209 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
210 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
211}]>;
212
213def movddup : PatFrag<(ops node:$lhs, node:$rhs),
214 (vector_shuffle node:$lhs, node:$rhs), [{
215 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
216}]>;
217
218def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
219 (vector_shuffle node:$lhs, node:$rhs), [{
220 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
221}]>;
222
223def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
224 (vector_shuffle node:$lhs, node:$rhs), [{
225 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
226}]>;
227
Nate Begemanb13034d2009-11-07 23:17:15 +0000228def movlhps : PatFrag<(ops node:$lhs, node:$rhs),
229 (vector_shuffle node:$lhs, node:$rhs), [{
230 return X86::isMOVLHPSMask(cast<ShuffleVectorSDNode>(N));
Nate Begeman543d2142009-04-27 18:41:29 +0000231}]>;
232
233def movlp : PatFrag<(ops node:$lhs, node:$rhs),
234 (vector_shuffle node:$lhs, node:$rhs), [{
235 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
236}]>;
237
238def movl : PatFrag<(ops node:$lhs, node:$rhs),
239 (vector_shuffle node:$lhs, node:$rhs), [{
240 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
241}]>;
242
243def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
244 (vector_shuffle node:$lhs, node:$rhs), [{
245 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
246}]>;
247
248def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
249 (vector_shuffle node:$lhs, node:$rhs), [{
250 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
251}]>;
252
253def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
254 (vector_shuffle node:$lhs, node:$rhs), [{
255 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
256}]>;
257
258def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
259 (vector_shuffle node:$lhs, node:$rhs), [{
260 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
261}]>;
262
263def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
264 (vector_shuffle node:$lhs, node:$rhs), [{
265 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
266}]>;
267
268def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
269 (vector_shuffle node:$lhs, node:$rhs), [{
270 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
271}]>;
272
273def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
274 (vector_shuffle node:$lhs, node:$rhs), [{
275 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276}], SHUFFLE_get_shuf_imm>;
277
Nate Begeman543d2142009-04-27 18:41:29 +0000278def shufp : PatFrag<(ops node:$lhs, node:$rhs),
279 (vector_shuffle node:$lhs, node:$rhs), [{
280 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000281}], SHUFFLE_get_shuf_imm>;
282
Nate Begeman543d2142009-04-27 18:41:29 +0000283def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
284 (vector_shuffle node:$lhs, node:$rhs), [{
285 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000286}], SHUFFLE_get_pshufhw_imm>;
287
Nate Begeman543d2142009-04-27 18:41:29 +0000288def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
289 (vector_shuffle node:$lhs, node:$rhs), [{
290 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291}], SHUFFLE_get_pshuflw_imm>;
292
Nate Begeman080f8e22009-10-19 02:17:23 +0000293def palign : PatFrag<(ops node:$lhs, node:$rhs),
294 (vector_shuffle node:$lhs, node:$rhs), [{
295 return X86::isPALIGNRMask(cast<ShuffleVectorSDNode>(N));
296}], SHUFFLE_get_palign_imm>;
297
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298//===----------------------------------------------------------------------===//
299// SSE scalar FP Instructions
300//===----------------------------------------------------------------------===//
301
Dan Gohman30afe012009-10-29 18:10:34 +0000302// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded after
303// instruction selection into a branch sequence.
304let Uses = [EFLAGS], usesCustomInserter = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305 def CMOV_FR32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000306 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307 "#CMOV_FR32 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000308 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
309 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000311 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312 "#CMOV_FR64 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000313 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
314 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000316 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317 "#CMOV_V4F32 PSEUDO!",
318 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000319 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
320 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000321 def CMOV_V2F64 : 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_V2F64 PSEUDO!",
324 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000325 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
326 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327 def CMOV_V2I64 : 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_V2I64 PSEUDO!",
330 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000331 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng950aac02007-09-25 01:57:46 +0000332 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333}
334
335//===----------------------------------------------------------------------===//
336// SSE1 Instructions
337//===----------------------------------------------------------------------===//
338
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000339// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000340let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000341def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000342 "movss\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000343let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000344def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000345 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000347def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000348 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349 [(store FR32:$src, addr:$dst)]>;
350
351// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000352def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000353 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000355def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000356 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000358def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000359 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000360 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000361def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000362 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000363 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
364
365// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000366def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000367 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000368 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000369def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000370 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371 [(set GR32:$dst, (int_x86_sse_cvtss2si
372 (load addr:$src)))]>;
373
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000374// Match intrinisics which expect MM and XMM operand(s).
375def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
376 "cvtps2pi\t{$src, $dst|$dst, $src}",
377 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
378def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
379 "cvtps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000380 [(set VR64:$dst, (int_x86_sse_cvtps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000381 (load addr:$src)))]>;
382def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
383 "cvttps2pi\t{$src, $dst|$dst, $src}",
384 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
385def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
386 "cvttps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000387 [(set VR64:$dst, (int_x86_sse_cvttps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000388 (load addr:$src)))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +0000389let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000390 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000391 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
392 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
393 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
394 VR64:$src2))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000395 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000396 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
397 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000398 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000399 (load addr:$src2)))]>;
400}
401
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000402// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000403def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000404 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405 [(set GR32:$dst,
406 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000407def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000408 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409 [(set GR32:$dst,
410 (int_x86_sse_cvttss2si(load addr:$src)))]>;
411
Evan Cheng3ea4d672008-03-05 08:19:16 +0000412let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000414 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000415 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
417 GR32:$src2))]>;
418 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000419 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000420 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000421 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
422 (loadi32 addr:$src2)))]>;
423}
424
425// Comparison instructions
Dan Gohmanf221da12009-01-09 02:27:34 +0000426let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000427 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000428 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000429 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000430let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000431 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000432 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000433 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434}
435
Evan Cheng55687072007-09-14 21:48:26 +0000436let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000437def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000438 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000439 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000440def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000441 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000442 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000443 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000444} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445
446// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +0000447let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000448 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
449 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
450 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000451 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000453 VR128:$src, imm:$cc))]>;
454 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
455 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src,
456 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000457 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
459 (load addr:$src), imm:$cc))]>;
460}
461
Evan Cheng55687072007-09-14 21:48:26 +0000462let Defs = [EFLAGS] in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000463def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000464 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000465 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000466 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000467def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000468 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000469 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000470 (implicit EFLAGS)]>;
471
Dan Gohmanf221da12009-01-09 02:27:34 +0000472def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000473 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000474 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000475 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000476def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000477 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000478 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000479 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000480} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000482// Aliases of packed SSE1 instructions for scalar use. These all have names
483// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000484
485// Alias instructions that map fld0 to pxor for sse.
Dan Gohman51dbce62009-09-21 18:30:38 +0000486let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
487 canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000488def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000489 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000490 Requires<[HasSSE1]>, TB, OpSize;
491
492// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
493// disregarded.
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000494let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000495def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000496 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000497
498// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
499// disregarded.
Evan Cheng8e664712009-11-17 09:51:18 +0000500let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000501def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000502 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000503 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504
505// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +0000506let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507let isCommutable = 1 in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000508 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
509 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000510 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000511 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000512 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
513 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000514 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000516 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
517 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000518 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
520}
521
Dan Gohmanf221da12009-01-09 02:27:34 +0000522def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
523 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000524 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000526 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000527def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
528 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000529 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000531 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000532def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
533 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000534 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000536 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000537
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000538let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000540 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000541 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000542let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000544 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000545 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000546}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000547}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548
549/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
550///
551/// In addition, we also have a special variant of the scalar form here to
552/// represent the associated intrinsic operation. This form is unlike the
553/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000554/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555///
556/// These three forms can each be reg+reg or reg+mem, so there are a total of
557/// six "instructions".
558///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000559let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000560multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
561 SDNode OpNode, Intrinsic F32Int,
562 bit Commutable = 0> {
563 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000564 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000565 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
567 let isCommutable = Commutable;
568 }
569
570 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000571 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
572 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000573 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000574 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000575
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000577 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
578 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000579 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
581 let isCommutable = Commutable;
582 }
583
584 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000585 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
586 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000587 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000588 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000589
590 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000591 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
592 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000593 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000594 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595
596 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000597 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
598 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000599 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600 [(set VR128:$dst, (F32Int VR128:$src1,
601 sse_load_f32:$src2))]>;
602}
603}
604
605// Arithmetic instructions
606defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
607defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
608defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
609defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
610
611/// sse1_fp_binop_rm - Other SSE1 binops
612///
613/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
614/// instructions for a full-vector intrinsic form. Operations that map
615/// onto C operators don't use this form since they just use the plain
616/// vector form instead of having a separate vector intrinsic form.
617///
618/// This provides a total of eight "instructions".
619///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000620let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
622 SDNode OpNode,
623 Intrinsic F32Int,
624 Intrinsic V4F32Int,
625 bit Commutable = 0> {
626
627 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000628 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000629 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
631 let isCommutable = Commutable;
632 }
633
634 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000635 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
636 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000637 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000638 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000639
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000641 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
642 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000643 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000644 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
645 let isCommutable = Commutable;
646 }
647
648 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000649 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
650 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000651 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000652 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653
654 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000655 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
656 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000657 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
659 let isCommutable = Commutable;
660 }
661
662 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000663 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
664 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000665 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666 [(set VR128:$dst, (F32Int VR128:$src1,
667 sse_load_f32:$src2))]>;
668
669 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000670 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
671 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000672 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
674 let isCommutable = Commutable;
675 }
676
677 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000678 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
679 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000680 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000681 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000682}
683}
684
685defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
686 int_x86_sse_max_ss, int_x86_sse_max_ps>;
687defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
688 int_x86_sse_min_ss, int_x86_sse_min_ps>;
689
690//===----------------------------------------------------------------------===//
691// SSE packed FP Instructions
692
693// Move Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000694let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000695def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000696 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000697let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000698def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000699 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000700 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000701
Evan Chengb783fa32007-07-19 01:14:50 +0000702def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000703 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000704 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000706let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000707def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "movups\t{$src, $dst|$dst, $src}", []>;
Evan Cheng9d7cd4e2009-11-16 21:56:03 +0000709let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000710def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000711 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000712 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000713def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000714 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000715 [(store (v4f32 VR128:$src), addr:$dst)]>;
716
717// Intrinsic forms of MOVUPS load and store
Evan Cheng8e664712009-11-17 09:51:18 +0000718let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000719def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000720 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000721 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000722def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000723 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000724 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725
Evan Cheng3ea4d672008-03-05 08:19:16 +0000726let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727 let AddedComplexity = 20 in {
728 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000729 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000730 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000731 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000732 (movlp VR128:$src1,
733 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000735 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000736 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000737 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +0000738 (movlhps VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000739 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000741} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742
Evan Chengd743a5f2008-05-10 00:59:18 +0000743
Evan Chengb783fa32007-07-19 01:14:50 +0000744def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000745 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
747 (iPTR 0))), addr:$dst)]>;
748
749// v2f64 extract element 1 is always custom lowered to unpack high to low
750// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000751def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000752 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +0000754 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
755 (undef)), (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756
Evan Cheng3ea4d672008-03-05 08:19:16 +0000757let Constraints = "$src1 = $dst" in {
Evan Cheng13559d62008-09-26 23:41:32 +0000758let AddedComplexity = 20 in {
Evan Cheng7581a822009-05-12 20:17:52 +0000759def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
760 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +0000763 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764
Evan Cheng7581a822009-05-12 20:17:52 +0000765def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
766 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000767 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000769 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770} // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000771} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772
Nate Begemanb44aad72009-04-29 22:47:44 +0000773let AddedComplexity = 20 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000774def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Evan Chenga2497eb2008-09-25 20:50:48 +0000775 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begemanb44aad72009-04-29 22:47:44 +0000776def : Pat<(v2i64 (movddup VR128:$src, (undef))),
777 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
778}
Evan Chenga2497eb2008-09-25 20:50:48 +0000779
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780
781
782// Arithmetic
783
784/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
785///
786/// In addition, we also have a special variant of the scalar form here to
787/// represent the associated intrinsic operation. This form is unlike the
788/// plain scalar form, in that it takes an entire vector (instead of a
789/// scalar) and leaves the top elements undefined.
790///
791/// And, we have a special variant form for a full-vector intrinsic form.
792///
793/// These four forms can each have a reg or a mem operand, so there are a
794/// total of eight "instructions".
795///
796multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
797 SDNode OpNode,
798 Intrinsic F32Int,
799 Intrinsic V4F32Int,
800 bit Commutable = 0> {
801 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000802 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000803 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804 [(set FR32:$dst, (OpNode FR32:$src))]> {
805 let isCommutable = Commutable;
806 }
807
808 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000809 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000810 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000812
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000814 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000815 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
817 let isCommutable = Commutable;
818 }
819
820 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000821 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000822 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000823 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000824
825 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000826 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 [(set VR128:$dst, (F32Int VR128:$src))]> {
829 let isCommutable = Commutable;
830 }
831
832 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000833 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000834 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
836
837 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000838 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000839 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
841 let isCommutable = Commutable;
842 }
843
844 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000845 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000846 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000847 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848}
849
850// Square root.
851defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
852 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
853
854// Reciprocal approximations. Note that these typically require refinement
855// in order to obtain suitable precision.
856defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
857 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
858defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
859 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
860
861// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +0000862let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000863 let isCommutable = 1 in {
864 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000865 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000866 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867 [(set VR128:$dst, (v2i64
868 (and VR128:$src1, VR128:$src2)))]>;
869 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000870 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000871 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 [(set VR128:$dst, (v2i64
873 (or VR128:$src1, VR128:$src2)))]>;
874 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000875 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000876 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 [(set VR128:$dst, (v2i64
878 (xor VR128:$src1, VR128:$src2)))]>;
879 }
880
881 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000882 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000883 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000884 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
885 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000887 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000888 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000889 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
890 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000892 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000893 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000894 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
895 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000897 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000898 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899 [(set VR128:$dst,
900 (v2i64 (and (xor VR128:$src1,
901 (bc_v2i64 (v4i32 immAllOnesV))),
902 VR128:$src2)))]>;
903 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000904 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000905 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000907 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000909 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910}
911
Evan Cheng3ea4d672008-03-05 08:19:16 +0000912let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000913 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begeman061db5f2008-05-12 20:34:32 +0000914 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
915 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
916 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
917 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000918 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begeman061db5f2008-05-12 20:34:32 +0000919 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
920 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
921 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +0000922 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923}
Nate Begeman03605a02008-07-17 16:51:19 +0000924def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
925 (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>;
926def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
927 (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928
929// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +0000930let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000932 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000933 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000934 VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000935 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000937 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000938 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000939 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000940 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000941 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000943 (v4f32 (shufp:$src3
944 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945
946 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000947 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000948 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000949 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000951 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000952 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000953 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000954 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000956 (v4f32 (unpckh VR128:$src1,
957 (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000959 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000960 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000961 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000963 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000964 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000965 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000966 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000968 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000970} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971
972// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000973def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000974 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengd8296b82009-05-28 18:55:28 +0000976def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000977 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
979
Evan Chengd1d68072008-03-08 00:58:38 +0000980// Prefetch intrinsic.
981def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
982 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
983def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
984 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
985def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
986 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
987def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
988 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989
990// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000991def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000992 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
994
995// Load, store, and memory fence
Evan Cheng68cca152009-05-27 18:38:01 +0000996def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997
998// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000999def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001000 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001001def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001002 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003
1004// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00001005// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00001006// load of an all-zeros value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +00001007let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
1008 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001009def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001010 "xorps\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00001011 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012
Evan Chenga15896e2008-03-12 07:02:50 +00001013let Predicates = [HasSSE1] in {
1014 def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
1015 def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1016 def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1017 def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1018 def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
1019}
1020
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021// FR32 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001022let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001023def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001024 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025 [(set VR128:$dst,
1026 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001027def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 [(set VR128:$dst,
1030 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
1031
1032// FIXME: may not be able to eliminate this movss with coalescing the src and
1033// dest register classes are different. We really want to write this pattern
1034// like this:
1035// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1036// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001037let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001038def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001039 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
1041 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001042def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001043 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044 [(store (f32 (vector_extract (v4f32 VR128:$src),
1045 (iPTR 0))), addr:$dst)]>;
1046
1047
1048// Move to lower bits of a VR128, leaving upper bits alone.
1049// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001050let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001051let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001053 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001054 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055
1056 let AddedComplexity = 15 in
1057 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001058 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001059 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001061 (v4f32 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062}
1063
1064// Move to lower bits of a VR128 and zeroing upper bits.
1065// Loading from memory automatically zeroing upper bits.
1066let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00001067def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001068 "movss\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00001069 [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001070 (loadf32 addr:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071
Evan Cheng056afe12008-05-20 18:24:47 +00001072def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
Evan Cheng40ee6e52008-05-08 00:57:18 +00001073 (MOVZSS2PSrm addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001075//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076// SSE2 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001077//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001080let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001081def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001082 "movsd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001083let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001084def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001085 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001087def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001088 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(store FR64:$src, addr:$dst)]>;
1090
1091// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001092def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001093 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001095def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001096 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001098def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001099 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100 [(set FR32:$dst, (fround FR64:$src))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001101def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001102 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001104def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001105 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001107def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001108 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1110
Sean Callanan3d5824c2009-09-16 01:13:52 +00001111def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1112 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1113def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1114 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1115def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1116 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1117def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1118 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1119def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1120 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1121def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1122 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1123def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1124 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1125def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1126 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1127def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1128 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1129def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1130 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1131
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001132// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001133def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001134 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1136 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001137def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001138 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1140 Requires<[HasSSE2]>;
1141
1142// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001143def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001144 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001146def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001147 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1149 (load addr:$src)))]>;
1150
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001151// Match intrinisics which expect MM and XMM operand(s).
1152def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1153 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1154 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1155def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1156 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001157 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001158 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001159def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1160 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1161 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1162def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1163 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001164 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001165 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001166def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1167 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1168 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1169def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1170 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001171 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001172 (load addr:$src)))]>;
1173
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001175def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001176 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177 [(set GR32:$dst,
1178 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001179def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001180 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1182 (load addr:$src)))]>;
1183
1184// Comparison instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001185let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001186 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001187 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001188 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001189let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001190 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001191 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001192 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193}
1194
Evan Cheng950aac02007-09-25 01:57:46 +00001195let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001196def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001197 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001198 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001199def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001200 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001201 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001202 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001203} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001204
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +00001206let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001207 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
1208 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
1209 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001210 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1212 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001213 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
1214 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src,
1215 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001216 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1218 (load addr:$src), imm:$cc))]>;
1219}
1220
Evan Cheng950aac02007-09-25 01:57:46 +00001221let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001222def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001223 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001224 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1225 (implicit EFLAGS)]>;
1226def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001227 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001228 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1229 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230
Evan Chengb783fa32007-07-19 01:14:50 +00001231def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001232 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001233 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1234 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001235def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001236 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001237 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001238 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001239} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001240
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001241// Aliases of packed SSE2 instructions for scalar use. These all have names
1242// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243
1244// Alias instructions that map fld0 to pxor for sse.
Dan Gohman51dbce62009-09-21 18:30:38 +00001245let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1246 canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001247def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001248 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249 Requires<[HasSSE2]>, TB, OpSize;
1250
1251// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1252// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001253let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001254def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001255 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256
1257// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1258// disregarded.
Evan Cheng8e664712009-11-17 09:51:18 +00001259let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001260def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001261 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001262 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263
1264// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001265let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266let isCommutable = 1 in {
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001267 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1268 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001269 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001271 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1272 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001273 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001274 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001275 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1276 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001277 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1279}
1280
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001281def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1282 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001283 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001285 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001286def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1287 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001288 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001290 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001291def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1292 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001293 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001295 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001297let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001298def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001299 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001300 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001301let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001303 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001304 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001306}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307
1308/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1309///
1310/// In addition, we also have a special variant of the scalar form here to
1311/// represent the associated intrinsic operation. This form is unlike the
1312/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001313/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314///
1315/// These three forms can each be reg+reg or reg+mem, so there are a total of
1316/// six "instructions".
1317///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001318let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1320 SDNode OpNode, Intrinsic F64Int,
1321 bit Commutable = 0> {
1322 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001323 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001324 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1326 let isCommutable = Commutable;
1327 }
1328
1329 // Scalar operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001330 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1331 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001332 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001334
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 // Vector operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001336 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1337 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001338 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1340 let isCommutable = Commutable;
1341 }
1342
1343 // Vector operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001344 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1345 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001346 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf221da12009-01-09 02:27:34 +00001347 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348
1349 // Intrinsic operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001350 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1351 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001352 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001353 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354
1355 // Intrinsic operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001356 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1357 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001358 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(set VR128:$dst, (F64Int VR128:$src1,
1360 sse_load_f64:$src2))]>;
1361}
1362}
1363
1364// Arithmetic instructions
1365defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1366defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1367defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1368defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1369
1370/// sse2_fp_binop_rm - Other SSE2 binops
1371///
1372/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1373/// instructions for a full-vector intrinsic form. Operations that map
1374/// onto C operators don't use this form since they just use the plain
1375/// vector form instead of having a separate vector intrinsic form.
1376///
1377/// This provides a total of eight "instructions".
1378///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001379let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1381 SDNode OpNode,
1382 Intrinsic F64Int,
1383 Intrinsic V2F64Int,
1384 bit Commutable = 0> {
1385
1386 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001387 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001388 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1390 let isCommutable = Commutable;
1391 }
1392
1393 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001394 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1395 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001396 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001398
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001400 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1401 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001402 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1404 let isCommutable = Commutable;
1405 }
1406
1407 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001408 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1409 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001410 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001411 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412
1413 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001414 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1415 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001416 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001417 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1418 let isCommutable = Commutable;
1419 }
1420
1421 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001422 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1423 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001424 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001425 [(set VR128:$dst, (F64Int VR128:$src1,
1426 sse_load_f64:$src2))]>;
1427
1428 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001429 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1430 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001431 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001432 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1433 let isCommutable = Commutable;
1434 }
1435
1436 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001437 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1438 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001440 [(set VR128:$dst, (V2F64Int VR128:$src1,
1441 (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442}
1443}
1444
1445defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1446 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1447defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1448 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1449
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001450//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451// SSE packed FP Instructions
1452
1453// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001454let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001455def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001456 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001457let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001458def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001459 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001460 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461
Evan Chengb783fa32007-07-19 01:14:50 +00001462def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001463 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001464 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001465
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001466let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001467def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001468 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001469let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001470def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001471 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001472 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001473def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001474 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001475 [(store (v2f64 VR128:$src), addr:$dst)]>;
1476
1477// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001478def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001480 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001481def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001482 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001483 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001484
Evan Cheng3ea4d672008-03-05 08:19:16 +00001485let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486 let AddedComplexity = 20 in {
1487 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001488 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001489 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001490 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001491 (v2f64 (movlp VR128:$src1,
1492 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001493 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001494 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001495 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001496 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +00001497 (v2f64 (movlhps VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00001498 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001499 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001500} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501
Evan Chengb783fa32007-07-19 01:14:50 +00001502def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504 [(store (f64 (vector_extract (v2f64 VR128:$src),
1505 (iPTR 0))), addr:$dst)]>;
1506
1507// v2f64 extract element 1 is always custom lowered to unpack high to low
1508// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001509def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001510 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +00001512 (v2f64 (unpckh VR128:$src, (undef))),
1513 (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001514
1515// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001516def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001517 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001518 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1519 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001520def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001521 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1522 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1523 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524 TB, Requires<[HasSSE2]>;
1525
1526// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001527def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001529 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1530 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001531def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001532 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1533 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1534 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001535 XS, Requires<[HasSSE2]>;
1536
Evan Chengb783fa32007-07-19 01:14:50 +00001537def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001538 "cvtps2dq\t{$src, $dst|$dst, $src}",
1539 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001540def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001542 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001543 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001544// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001545def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001546 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001547 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1548 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001549def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001550 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001552 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001553 XS, Requires<[HasSSE2]>;
1554
1555// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001556def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001557 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1559 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001560def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001562 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001563 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564 XD, Requires<[HasSSE2]>;
1565
Evan Chengb783fa32007-07-19 01:14:50 +00001566def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng14c97c32008-03-14 07:46:48 +00001569def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001570 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001572 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001573
1574// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001575def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001577 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1578 TB, Requires<[HasSSE2]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001579def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1582 (load addr:$src)))]>,
1583 TB, Requires<[HasSSE2]>;
1584
Evan Chengb783fa32007-07-19 01:14:50 +00001585def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001587 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001588def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001590 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Cheng00b66ef2008-05-23 00:37:07 +00001591 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001592
1593// Match intrinsics which expect XMM operand(s).
1594// Aliases for intrinsics
Evan Cheng3ea4d672008-03-05 08:19:16 +00001595let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001596def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001597 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001598 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1600 GR32:$src2))]>;
1601def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001602 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001603 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001604 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1605 (loadi32 addr:$src2)))]>;
1606def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001607 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001608 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1610 VR128:$src2))]>;
1611def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001612 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1615 (load addr:$src2)))]>;
1616def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001617 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001618 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001619 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1620 VR128:$src2))]>, XS,
1621 Requires<[HasSSE2]>;
1622def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001623 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001624 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1626 (load addr:$src2)))]>, XS,
1627 Requires<[HasSSE2]>;
1628}
1629
1630// Arithmetic
1631
1632/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1633///
1634/// In addition, we also have a special variant of the scalar form here to
1635/// represent the associated intrinsic operation. This form is unlike the
1636/// plain scalar form, in that it takes an entire vector (instead of a
1637/// scalar) and leaves the top elements undefined.
1638///
1639/// And, we have a special variant form for a full-vector intrinsic form.
1640///
1641/// These four forms can each have a reg or a mem operand, so there are a
1642/// total of eight "instructions".
1643///
1644multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1645 SDNode OpNode,
1646 Intrinsic F64Int,
1647 Intrinsic V2F64Int,
1648 bit Commutable = 0> {
1649 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001650 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001651 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652 [(set FR64:$dst, (OpNode FR64:$src))]> {
1653 let isCommutable = Commutable;
1654 }
1655
1656 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001657 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001660
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001662 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001664 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1665 let isCommutable = Commutable;
1666 }
1667
1668 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001669 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001670 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001671 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672
1673 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001674 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001675 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001676 [(set VR128:$dst, (F64Int VR128:$src))]> {
1677 let isCommutable = Commutable;
1678 }
1679
1680 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001681 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001682 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001683 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1684
1685 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001686 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001687 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001688 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1689 let isCommutable = Commutable;
1690 }
1691
1692 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001693 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001694 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001695 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001696}
1697
1698// Square root.
1699defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1700 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1701
1702// There is no f64 version of the reciprocal approximation instructions.
1703
1704// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +00001705let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001706 let isCommutable = 1 in {
1707 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001708 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001710 [(set VR128:$dst,
1711 (and (bc_v2i64 (v2f64 VR128:$src1)),
1712 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1713 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001714 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001715 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716 [(set VR128:$dst,
1717 (or (bc_v2i64 (v2f64 VR128:$src1)),
1718 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1719 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001720 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001721 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722 [(set VR128:$dst,
1723 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1724 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1725 }
1726
1727 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001728 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001730 [(set VR128:$dst,
1731 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001732 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001734 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001736 [(set VR128:$dst,
1737 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001738 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001739 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001740 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001741 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742 [(set VR128:$dst,
1743 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001744 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001745 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001746 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001747 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001748 [(set VR128:$dst,
1749 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1750 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1751 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001752 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001753 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001754 [(set VR128:$dst,
1755 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001756 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757}
1758
Evan Cheng3ea4d672008-03-05 08:19:16 +00001759let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001760 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001761 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1762 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1763 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begeman061db5f2008-05-12 20:34:32 +00001764 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001765 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng14c97c32008-03-14 07:46:48 +00001766 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1767 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1768 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00001769 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770}
Evan Cheng33754092008-08-05 22:19:15 +00001771def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001772 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Cheng33754092008-08-05 22:19:15 +00001773def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001774 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775
1776// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001777let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001778 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001779 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1780 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman543d2142009-04-27 18:41:29 +00001781 [(set VR128:$dst,
1782 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001783 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001784 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001785 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001788 (v2f64 (shufp:$src3
1789 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790
1791 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001792 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001793 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001796 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001797 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001798 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001799 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001800 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001801 (v2f64 (unpckh VR128:$src1,
1802 (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001804 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001805 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001808 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001809 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001810 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001811 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001813 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001814 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001815} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816
1817
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001818//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001819// SSE integer instructions
1820
1821// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001822let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001823def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001824 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001825let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001826def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001827 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001828 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001829let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001830def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001832 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001833let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001834def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001836 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 XS, Requires<[HasSSE2]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001838let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001839def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001840 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001841 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001842 XS, Requires<[HasSSE2]>;
1843
Dan Gohman4a4f1512007-07-18 20:23:34 +00001844// Intrinsic forms of MOVDQU load and store
Dan Gohman5574cc72008-12-03 18:15:48 +00001845let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001846def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001847 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001848 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1849 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001850def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001851 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001852 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1853 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854
Evan Cheng88004752008-03-05 08:11:27 +00001855let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001856
1857multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1858 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001859 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001860 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001861 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1862 let isCommutable = Commutable;
1863 }
Evan Chengb783fa32007-07-19 01:14:50 +00001864 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001865 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001867 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001868}
1869
Evan Chengf90f8f82008-05-03 00:52:09 +00001870multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1871 string OpcodeStr,
1872 Intrinsic IntId, Intrinsic IntId2> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001873 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1874 VR128:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001875 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1876 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001877 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1878 i128mem:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001879 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1880 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001881 (bitconvert (memopv2i64 addr:$src2))))]>;
1882 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1,
1883 i32i8imm:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001884 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1885 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
1886}
1887
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888/// PDI_binop_rm - Simple SSE2 binary operator.
1889multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1890 ValueType OpVT, bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001891 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1892 VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1895 let isCommutable = Commutable;
1896 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001897 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1898 i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001901 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902}
1903
1904/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1905///
1906/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1907/// to collapse (bitconvert VT to VT) into its operand.
1908///
1909multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1910 bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001911 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1912 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001913 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001914 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1915 let isCommutable = Commutable;
1916 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001917 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1918 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001920 [(set VR128:$dst, (OpNode VR128:$src1,
1921 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922}
1923
Evan Cheng3ea4d672008-03-05 08:19:16 +00001924} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001925
1926// 128-bit Integer Arithmetic
1927
1928defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1929defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1930defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1931defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1932
1933defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1934defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1935defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1936defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1937
1938defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1939defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1940defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1941defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1942
1943defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1944defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1945defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1946defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1947
1948defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1949
1950defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1951defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1952defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1953
1954defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1955
1956defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1957defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1958
1959
1960defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1961defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1962defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1963defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling953ad2e2009-05-28 02:04:00 +00001964defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001965
1966
Evan Chengf90f8f82008-05-03 00:52:09 +00001967defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
1968 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
1969defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
1970 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
1971defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
1972 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973
Evan Chengf90f8f82008-05-03 00:52:09 +00001974defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
1975 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
1976defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
1977 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begemanc2ca5f62008-05-13 17:52:09 +00001978defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Chengf90f8f82008-05-03 00:52:09 +00001979 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980
Evan Chengf90f8f82008-05-03 00:52:09 +00001981defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
1982 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemand66fc342008-05-13 01:47:52 +00001983defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Chengf90f8f82008-05-03 00:52:09 +00001984 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985
1986// 128-bit logical shifts.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001987let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001988 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001989 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001990 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001992 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994 // PSRADQri doesn't exist in SSE[1-3].
1995}
1996
1997let Predicates = [HasSSE2] in {
1998 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
Evan Cheng06cd2072009-10-28 06:30:34 +00001999 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002000 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
Evan Cheng06cd2072009-10-28 06:30:34 +00002001 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Bill Wendling314ee052008-10-02 05:56:52 +00002002 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2003 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2004 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2005 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002006 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002007 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Evan Chengdea99362008-05-29 08:22:04 +00002008
2009 // Shift up / down and insert zero's.
2010 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
Evan Cheng06cd2072009-10-28 06:30:34 +00002011 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Evan Chengdea99362008-05-29 08:22:04 +00002012 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
Evan Cheng06cd2072009-10-28 06:30:34 +00002013 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014}
2015
2016// Logical
2017defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2018defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2019defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2020
Evan Cheng3ea4d672008-03-05 08:19:16 +00002021let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002023 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2026 VR128:$src2)))]>;
2027
2028 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002029 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002030 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002031 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00002032 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033}
2034
2035// SSE2 Integer comparison
2036defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2037defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2038defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2039defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2040defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2041defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2042
Nate Begeman03605a02008-07-17 16:51:19 +00002043def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002044 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002045def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002046 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002047def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002048 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002049def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002050 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002051def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002052 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002053def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002054 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2055
Nate Begeman03605a02008-07-17 16:51:19 +00002056def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002057 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002058def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002059 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002060def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002061 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002062def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002063 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002064def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002065 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002066def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002067 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2068
2069
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070// Pack instructions
2071defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2072defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2073defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2074
2075// Shuffle and unpack instructions
Nate Begeman080f8e22009-10-19 02:17:23 +00002076let AddedComplexity = 5 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002078 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002080 [(set VR128:$dst, (v4i32 (pshufd:$src2
2081 VR128:$src1, (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002083 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002085 [(set VR128:$dst, (v4i32 (pshufd:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002086 (bc_v4i32(memopv2i64 addr:$src1)),
2087 (undef))))]>;
Eric Christopherf3650292009-11-07 08:45:53 +00002088}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089
2090// SSE2 with ImmT == Imm8 and XS prefix.
2091def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002092 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002093 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002094 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2095 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096 XS, Requires<[HasSSE2]>;
2097def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002098 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002099 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002100 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002101 (bc_v8i16 (memopv2i64 addr:$src1)),
2102 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 XS, Requires<[HasSSE2]>;
2104
2105// SSE2 with ImmT == Imm8 and XD prefix.
2106def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman543d2142009-04-27 18:41:29 +00002107 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002109 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2110 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002111 XD, Requires<[HasSSE2]>;
2112def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman543d2142009-04-27 18:41:29 +00002113 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002114 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002115 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2116 (bc_v8i16 (memopv2i64 addr:$src1)),
2117 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118 XD, Requires<[HasSSE2]>;
2119
2120
Evan Cheng3ea4d672008-03-05 08:19:16 +00002121let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002122 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002123 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002124 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002125 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002126 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002127 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002128 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002129 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002131 (unpckl VR128:$src1,
2132 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002133 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002134 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002135 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002137 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002138 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002139 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002142 (unpckl VR128:$src1,
2143 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002144 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002145 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002146 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002147 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002148 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002149 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002150 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002153 (unpckl VR128:$src1,
2154 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002155 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002156 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002159 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002160 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002161 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002162 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002164 (v2i64 (unpckl VR128:$src1,
2165 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002166
2167 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002168 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002169 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002170 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002171 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002172 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002173 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002174 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002175 [(set VR128:$dst,
2176 (unpckh VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002177 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002178 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002179 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002181 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002182 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002183 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002184 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002187 (unpckh VR128:$src1,
2188 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002189 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002190 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002191 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002193 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002194 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002195 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002197 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002198 (unpckh VR128:$src1,
2199 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002200 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002201 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002202 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002203 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002204 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002205 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002206 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002208 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002209 (v2i64 (unpckh VR128:$src1,
2210 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211}
2212
2213// Extract / Insert
2214def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002215 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002216 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begemand77e59e2008-02-11 04:19:36 +00002218 imm:$src2))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +00002219let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002220 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002221 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002222 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002224 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002225 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002227 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002228 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002229 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002230 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002231 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2232 imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002233}
2234
2235// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002236def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002237 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2239
2240// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002241let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002242def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002243 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002244 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002245
Evan Cheng430de082009-02-10 22:06:28 +00002246let Uses = [RDI] in
2247def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2248 "maskmovdqu\t{$mask, $src|$src, $mask}",
2249 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2250
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002252def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002253 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002255def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002258def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002259 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002260 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 TB, Requires<[HasSSE2]>;
2262
2263// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002264def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002266 TB, Requires<[HasSSE2]>;
2267
2268// Load, store, and memory fence
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002269def LFENCE : I<0xAE, MRM5r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002270 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002271def MFENCE : I<0xAE, MRM6r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002272 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2273
Andrew Lenharth785610d2008-02-16 01:24:58 +00002274//TODO: custom lower this so as to never even generate the noop
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002275def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002276 (i8 0)), (NOOP)>;
2277def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2278def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002279def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002280 (i8 1)), (MFENCE)>;
2281
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00002283// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00002284// load of an all-ones value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +00002285let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2286 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002287 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002289 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290
2291// FR64 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002292let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002293def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295 [(set VR128:$dst,
2296 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002297def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002298 "movsd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002299 [(set VR128:$dst,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2301
Evan Chengb783fa32007-07-19 01:14:50 +00002302def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002303 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002304 [(set VR128:$dst,
2305 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002306def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002307 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002308 [(set VR128:$dst,
2309 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2310
Evan Chengb783fa32007-07-19 01:14:50 +00002311def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002312 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002313 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2314
Evan Chengb783fa32007-07-19 01:14:50 +00002315def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2318
2319// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002320def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322 [(set VR128:$dst,
2323 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2324 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002325def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327 [(store (i64 (vector_extract (v2i64 VR128:$src),
2328 (iPTR 0))), addr:$dst)]>;
2329
2330// FIXME: may not be able to eliminate this movss with coalescing the src and
2331// dest register classes are different. We really want to write this pattern
2332// like this:
2333// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2334// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002335let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002336def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002337 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002338 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2339 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002340def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002341 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002342 [(store (f64 (vector_extract (v2f64 VR128:$src),
2343 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002344def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002345 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002346 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2347 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002348def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002350 [(store (i32 (vector_extract (v4i32 VR128:$src),
2351 (iPTR 0))), addr:$dst)]>;
2352
Evan Chengb783fa32007-07-19 01:14:50 +00002353def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002354 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002355 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002356def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002358 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2359
2360
2361// Move to lower bits of a VR128, leaving upper bits alone.
2362// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002363let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00002364 let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002366 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002367 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002368
2369 let AddedComplexity = 15 in
2370 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002371 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002372 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002373 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002374 (v2f64 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002375}
2376
2377// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002378def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002379 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002380 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2381
2382// Move to lower bits of a VR128 and zeroing upper bits.
2383// Loading from memory automatically zeroing upper bits.
Evan Chengd743a5f2008-05-10 00:59:18 +00002384let AddedComplexity = 20 in {
2385def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2386 "movsd\t{$src, $dst|$dst, $src}",
2387 [(set VR128:$dst,
2388 (v2f64 (X86vzmovl (v2f64 (scalar_to_vector
2389 (loadf64 addr:$src))))))]>;
Evan Cheng40ee6e52008-05-08 00:57:18 +00002390
Evan Cheng056afe12008-05-20 18:24:47 +00002391def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
2392 (MOVZSD2PDrm addr:$src)>;
2393def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
Evan Chengd743a5f2008-05-10 00:59:18 +00002394 (MOVZSD2PDrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002395def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002396}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002397
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398// movd / movq to XMM register zero-extends
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002399let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002400def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002401 "movd\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002402 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002403 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002404// This is X86-64 only.
2405def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2406 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002407 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002408 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002409}
2410
2411let AddedComplexity = 20 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002412def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002413 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002414 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002415 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002416 (loadi32 addr:$src))))))]>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002417
2418def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2419 (MOVZDI2PDIrm addr:$src)>;
2420def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2421 (MOVZDI2PDIrm addr:$src)>;
Duncan Sands2418bec2008-06-13 19:07:40 +00002422def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2423 (MOVZDI2PDIrm addr:$src)>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002424
Evan Chengb783fa32007-07-19 01:14:50 +00002425def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002426 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002427 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002428 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002429 (loadi64 addr:$src))))))]>, XS,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002430 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002431
Evan Cheng3ad16c42008-05-22 18:56:56 +00002432def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2433 (MOVZQI2PQIrm addr:$src)>;
2434def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2435 (MOVZQI2PQIrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002436def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002437}
Evan Chenge9b9c672008-05-09 21:53:03 +00002438
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002439// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2440// IA32 document. movq xmm1, xmm2 does clear the high bits.
2441let AddedComplexity = 15 in
2442def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2443 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002444 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002445 XS, Requires<[HasSSE2]>;
2446
Evan Cheng056afe12008-05-20 18:24:47 +00002447let AddedComplexity = 20 in {
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002448def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2449 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002450 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng056afe12008-05-20 18:24:47 +00002451 (loadv2i64 addr:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002452 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002453
Evan Cheng056afe12008-05-20 18:24:47 +00002454def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2455 (MOVZPQILo2PQIrm addr:$src)>;
2456}
2457
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002458//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002459// SSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002460//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002461
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002462// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002463def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002464 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002465 [(set VR128:$dst, (v4f32 (movshdup
2466 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002467def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002468 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002469 [(set VR128:$dst, (movshdup
2470 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002471
Evan Chengb783fa32007-07-19 01:14:50 +00002472def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002473 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002474 [(set VR128:$dst, (v4f32 (movsldup
2475 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002476def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002477 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002478 [(set VR128:$dst, (movsldup
2479 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002480
Evan Chengb783fa32007-07-19 01:14:50 +00002481def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002482 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002483 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002484def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002485 "movddup\t{$src, $dst|$dst, $src}",
Evan Chenga2497eb2008-09-25 20:50:48 +00002486 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002487 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2488 (undef))))]>;
Evan Chenga2497eb2008-09-25 20:50:48 +00002489
Nate Begeman543d2142009-04-27 18:41:29 +00002490def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2491 (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002492 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002493
2494let AddedComplexity = 5 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002495def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002496 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002497def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2498 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2499def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2500 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2501def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2502 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2503}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504
2505// Arithmetic
Evan Cheng3ea4d672008-03-05 08:19:16 +00002506let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002507 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002508 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002509 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002510 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2511 VR128:$src2))]>;
2512 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002513 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002514 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002515 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002516 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002517 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002518 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002519 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002520 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2521 VR128:$src2))]>;
2522 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002523 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002524 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002525 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002526 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002527}
2528
Evan Chengb783fa32007-07-19 01:14:50 +00002529def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002530 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002531 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2532
2533// Horizontal ops
2534class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002535 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002536 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002537 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2538class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002539 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002540 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002541 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002542class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002543 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002544 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002545 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2546class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002547 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002548 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002549 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002550
Evan Cheng3ea4d672008-03-05 08:19:16 +00002551let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002552 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2553 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2554 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2555 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2556 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2557 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2558 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2559 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2560}
2561
2562// Thread synchronization
Bill Wendling6ee76552009-05-28 23:40:46 +00002563def MONITOR : I<0x01, MRM1r, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002564 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Bill Wendling6ee76552009-05-28 23:40:46 +00002565def MWAIT : I<0x01, MRM1r, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002566 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2567
2568// vector_shuffle v1, <undef> <1, 1, 3, 3>
2569let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002570def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002571 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2572let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002573def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002574 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2575
2576// vector_shuffle v1, <undef> <0, 0, 2, 2>
2577let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002578 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002579 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2580let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002581 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002582 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2583
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002584//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002585// SSSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002586//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587
Bill Wendling98680292007-08-10 06:22:27 +00002588/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002589multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2590 Intrinsic IntId64, Intrinsic IntId128> {
2591 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2592 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2593 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002594
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002595 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2596 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2597 [(set VR64:$dst,
2598 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2599
2600 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2601 (ins VR128:$src),
2602 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2603 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2604 OpSize;
2605
2606 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2607 (ins i128mem:$src),
2608 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2609 [(set VR128:$dst,
2610 (IntId128
2611 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002612}
2613
Bill Wendling98680292007-08-10 06:22:27 +00002614/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002615multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2616 Intrinsic IntId64, Intrinsic IntId128> {
2617 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2618 (ins VR64:$src),
2619 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2620 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002621
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002622 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2623 (ins i64mem:$src),
2624 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2625 [(set VR64:$dst,
2626 (IntId64
2627 (bitconvert (memopv4i16 addr:$src))))]>;
2628
2629 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2630 (ins VR128:$src),
2631 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2632 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2633 OpSize;
2634
2635 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2636 (ins i128mem:$src),
2637 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2638 [(set VR128:$dst,
2639 (IntId128
2640 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002641}
2642
2643/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002644multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2645 Intrinsic IntId64, Intrinsic IntId128> {
2646 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2647 (ins VR64:$src),
2648 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2649 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002650
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002651 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2652 (ins i64mem:$src),
2653 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2654 [(set VR64:$dst,
2655 (IntId64
2656 (bitconvert (memopv2i32 addr:$src))))]>;
2657
2658 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2659 (ins VR128:$src),
2660 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2661 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2662 OpSize;
2663
2664 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2665 (ins i128mem:$src),
2666 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2667 [(set VR128:$dst,
2668 (IntId128
2669 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002670}
2671
2672defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2673 int_x86_ssse3_pabs_b,
2674 int_x86_ssse3_pabs_b_128>;
2675defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2676 int_x86_ssse3_pabs_w,
2677 int_x86_ssse3_pabs_w_128>;
2678defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2679 int_x86_ssse3_pabs_d,
2680 int_x86_ssse3_pabs_d_128>;
2681
2682/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002683let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002684 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2685 Intrinsic IntId64, Intrinsic IntId128,
2686 bit Commutable = 0> {
2687 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2688 (ins VR64:$src1, VR64:$src2),
2689 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2690 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2691 let isCommutable = Commutable;
2692 }
2693 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2694 (ins VR64:$src1, i64mem:$src2),
2695 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2696 [(set VR64:$dst,
2697 (IntId64 VR64:$src1,
2698 (bitconvert (memopv8i8 addr:$src2))))]>;
2699
2700 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2701 (ins VR128:$src1, VR128:$src2),
2702 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2703 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2704 OpSize {
2705 let isCommutable = Commutable;
2706 }
2707 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2708 (ins VR128:$src1, i128mem:$src2),
2709 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2710 [(set VR128:$dst,
2711 (IntId128 VR128:$src1,
2712 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2713 }
2714}
2715
2716/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002717let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002718 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2719 Intrinsic IntId64, Intrinsic IntId128,
2720 bit Commutable = 0> {
2721 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2722 (ins VR64:$src1, VR64:$src2),
2723 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2724 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2725 let isCommutable = Commutable;
2726 }
2727 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2728 (ins VR64:$src1, i64mem:$src2),
2729 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2730 [(set VR64:$dst,
2731 (IntId64 VR64:$src1,
2732 (bitconvert (memopv4i16 addr:$src2))))]>;
2733
2734 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2735 (ins VR128:$src1, VR128:$src2),
2736 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2737 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2738 OpSize {
2739 let isCommutable = Commutable;
2740 }
2741 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2742 (ins VR128:$src1, i128mem:$src2),
2743 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2744 [(set VR128:$dst,
2745 (IntId128 VR128:$src1,
2746 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2747 }
2748}
2749
2750/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002751let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002752 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2753 Intrinsic IntId64, Intrinsic IntId128,
2754 bit Commutable = 0> {
2755 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2756 (ins VR64:$src1, VR64:$src2),
2757 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2758 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2759 let isCommutable = Commutable;
2760 }
2761 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2762 (ins VR64:$src1, i64mem:$src2),
2763 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2764 [(set VR64:$dst,
2765 (IntId64 VR64:$src1,
2766 (bitconvert (memopv2i32 addr:$src2))))]>;
2767
2768 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2769 (ins VR128:$src1, VR128:$src2),
2770 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2771 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2772 OpSize {
2773 let isCommutable = Commutable;
2774 }
2775 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2776 (ins VR128:$src1, i128mem:$src2),
2777 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2778 [(set VR128:$dst,
2779 (IntId128 VR128:$src1,
2780 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2781 }
2782}
2783
2784defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2785 int_x86_ssse3_phadd_w,
Evan Cheng944e4412008-06-16 21:16:24 +00002786 int_x86_ssse3_phadd_w_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002787defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2788 int_x86_ssse3_phadd_d,
Evan Cheng944e4412008-06-16 21:16:24 +00002789 int_x86_ssse3_phadd_d_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002790defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2791 int_x86_ssse3_phadd_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002792 int_x86_ssse3_phadd_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002793defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2794 int_x86_ssse3_phsub_w,
2795 int_x86_ssse3_phsub_w_128>;
2796defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2797 int_x86_ssse3_phsub_d,
2798 int_x86_ssse3_phsub_d_128>;
2799defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2800 int_x86_ssse3_phsub_sw,
2801 int_x86_ssse3_phsub_sw_128>;
2802defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2803 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002804 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002805defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2806 int_x86_ssse3_pmul_hr_sw,
2807 int_x86_ssse3_pmul_hr_sw_128, 1>;
2808defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2809 int_x86_ssse3_pshuf_b,
2810 int_x86_ssse3_pshuf_b_128>;
2811defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2812 int_x86_ssse3_psign_b,
2813 int_x86_ssse3_psign_b_128>;
2814defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2815 int_x86_ssse3_psign_w,
2816 int_x86_ssse3_psign_w_128>;
Evan Chengabfed472009-05-28 18:48:53 +00002817defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling98680292007-08-10 06:22:27 +00002818 int_x86_ssse3_psign_d,
2819 int_x86_ssse3_psign_d_128>;
2820
Evan Cheng3ea4d672008-03-05 08:19:16 +00002821let Constraints = "$src1 = $dst" in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002822 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2823 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002824 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002825 []>;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002826 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Bill Wendling1dc817c2007-08-10 09:00:17 +00002827 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002828 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002829 []>;
Bill Wendling98680292007-08-10 06:22:27 +00002830
Bill Wendling1dc817c2007-08-10 09:00:17 +00002831 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2832 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002833 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002834 []>, OpSize;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002835 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Bill Wendling1dc817c2007-08-10 09:00:17 +00002836 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002837 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002838 []>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002839}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002840
Nate Begeman080f8e22009-10-19 02:17:23 +00002841// palignr patterns.
Evan Cheng06cd2072009-10-28 06:30:34 +00002842def : Pat<(int_x86_ssse3_palign_r VR64:$src1, VR64:$src2, (i16 imm:$src3)),
2843 (PALIGNR64rr VR64:$src1, VR64:$src2, (BYTE_imm imm:$src3))>,
2844 Requires<[HasSSSE3]>;
2845def : Pat<(int_x86_ssse3_palign_r VR64:$src1,
2846 (memop64 addr:$src2),
2847 (i16 imm:$src3)),
2848 (PALIGNR64rm VR64:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2849 Requires<[HasSSSE3]>;
2850
2851def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1, VR128:$src2, (i32 imm:$src3)),
2852 (PALIGNR128rr VR128:$src1, VR128:$src2, (BYTE_imm imm:$src3))>,
2853 Requires<[HasSSSE3]>;
2854def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1,
2855 (memopv2i64 addr:$src2),
2856 (i32 imm:$src3)),
2857 (PALIGNR128rm VR128:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2858 Requires<[HasSSSE3]>;
2859
Nate Begeman080f8e22009-10-19 02:17:23 +00002860let AddedComplexity = 5 in {
2861def : Pat<(v4i32 (palign:$src3 VR128:$src1, VR128:$src2)),
2862 (PALIGNR128rr VR128:$src2, VR128:$src1,
2863 (SHUFFLE_get_palign_imm VR128:$src3))>,
2864 Requires<[HasSSSE3]>;
2865def : Pat<(v4f32 (palign:$src3 VR128:$src1, VR128:$src2)),
2866 (PALIGNR128rr VR128:$src2, VR128:$src1,
2867 (SHUFFLE_get_palign_imm VR128:$src3))>,
2868 Requires<[HasSSSE3]>;
2869def : Pat<(v8i16 (palign:$src3 VR128:$src1, VR128:$src2)),
2870 (PALIGNR128rr VR128:$src2, VR128:$src1,
2871 (SHUFFLE_get_palign_imm VR128:$src3))>,
2872 Requires<[HasSSSE3]>;
2873def : Pat<(v16i8 (palign:$src3 VR128:$src1, VR128:$src2)),
2874 (PALIGNR128rr VR128:$src2, VR128:$src1,
2875 (SHUFFLE_get_palign_imm VR128:$src3))>,
2876 Requires<[HasSSSE3]>;
Eric Christopherf3650292009-11-07 08:45:53 +00002877}
Nate Begeman080f8e22009-10-19 02:17:23 +00002878
Nate Begeman2c87c422009-02-23 08:49:38 +00002879def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2880 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2881def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2882 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2883
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002884//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002885// Non-Instruction Patterns
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002886//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002887
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002888// extload f32 -> f64. This matches load+fextend because we have a hack in
2889// the isel (PreprocessForFPConvert) that can introduce loads after dag
2890// combine.
Chris Lattnerdec9cb52008-01-24 08:07:48 +00002891// Since these loads aren't folded into the fextend, we have to match it
2892// explicitly here.
2893let Predicates = [HasSSE2] in
2894 def : Pat<(fextend (loadf32 addr:$src)),
2895 (CVTSS2SDrm addr:$src)>;
2896
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002897// bit_convert
2898let Predicates = [HasSSE2] in {
2899 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2900 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2901 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2902 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2903 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2904 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2905 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2906 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2907 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2908 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2909 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2910 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2911 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2912 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2913 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2914 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2915 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2916 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2917 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2918 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2919 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2920 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2921 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2922 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2923 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2924 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2925 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2926 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2927 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2928 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2929}
2930
2931// Move scalar to XMM zero-extended
2932// movd to XMM register zero-extends
2933let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002934// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chenge9b9c672008-05-09 21:53:03 +00002935def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002936 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002937def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002938 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>;
Evan Chenge259e872008-05-09 23:37:55 +00002939def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002940 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Evan Cheng7fe0ff02008-07-10 01:08:23 +00002941def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002942 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002943}
2944
2945// Splat v2f64 / v2i64
2946let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002947def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002948 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002949def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002950 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002951def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002952 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002953def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002954 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2955}
2956
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002957// Special unary SHUFPSrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00002958def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
2959 (SHUFPSrri VR128:$src1, VR128:$src1,
2960 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002961 Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002962let AddedComplexity = 5 in
2963def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
2964 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2965 Requires<[HasSSE2]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002966// Special unary SHUFPDrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00002967def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002968 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002969 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2970 Requires<[HasSSE2]>;
2971// Special unary SHUFPDrri case.
2972def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002973 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002974 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7dc19012007-08-02 21:17:01 +00002975 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002976// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman543d2142009-04-27 18:41:29 +00002977def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
2978 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002979 Requires<[HasSSE2]>;
Evan Cheng13559d62008-09-26 23:41:32 +00002980
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002981// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman543d2142009-04-27 18:41:29 +00002982def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002983 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002984 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002985 Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002986def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002987 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002988 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002989 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002990// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman543d2142009-04-27 18:41:29 +00002991def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002992 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002993 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002994 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002995
2996// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00002997let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002998def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
2999 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003000 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003001def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
3002 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003003 Requires<[OptForSpeed, HasSSE2]>;
3004}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003005let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003006def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003007 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003008def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003009 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003010def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003011 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003012def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003013 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003014}
3015
3016// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00003017let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003018def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
3019 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003020 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003021def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
3022 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003023 Requires<[OptForSpeed, HasSSE2]>;
3024}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003025let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003026def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003027 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003028def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003029 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003030def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003031 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003032def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003033 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003034}
3035
Evan Cheng13559d62008-09-26 23:41:32 +00003036let AddedComplexity = 20 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003037// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begemanb13034d2009-11-07 23:17:15 +00003038def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003039 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
3040
3041// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003042def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003043 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
3044
3045// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003046def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003047 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman543d2142009-04-27 18:41:29 +00003048def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003049 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
3050}
3051
3052let AddedComplexity = 20 in {
3053// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003054def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003055 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003056def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003057 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003058def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003059 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003060def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003061 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003062}
3063
Evan Cheng2b2a7012008-05-23 21:23:16 +00003064// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003065def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003066 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003067def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003068 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003069def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3070 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003071 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003072def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003073 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2b2a7012008-05-23 21:23:16 +00003074
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003075let AddedComplexity = 15 in {
3076// Setting the lowest element in the vector.
Nate Begeman543d2142009-04-27 18:41:29 +00003077def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003078 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003079def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003080 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3081
3082// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
Nate Begeman543d2142009-04-27 18:41:29 +00003083def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003084 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003085def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003086 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3087}
3088
Eli Friedman27d19742009-06-19 07:00:55 +00003089// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3090// fall back to this for SSE1)
3091def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003092 (SHUFPSrri VR128:$src2, VR128:$src1,
Eli Friedman27d19742009-06-19 07:00:55 +00003093 (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>;
3094
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003095// Set lowest element and zero upper elements.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003096let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00003097def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003098 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00003099def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengd09a8a02008-05-08 22:35:02 +00003100 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003101
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003102// Some special case pandn patterns.
3103def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3104 VR128:$src2)),
3105 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3106def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3107 VR128:$src2)),
3108 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3109def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3110 VR128:$src2)),
3111 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3112
3113def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003114 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003115 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3116def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003117 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003118 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3119def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003120 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003121 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3122
Nate Begeman78246ca2007-11-17 03:58:34 +00003123// vector -> vector casts
3124def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3125 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3126def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3127 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedman7fa52ca2008-09-05 23:07:03 +00003128def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3129 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3130def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3131 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman78246ca2007-11-17 03:58:34 +00003132
Evan Cheng51a49b22007-07-20 00:27:43 +00003133// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00003134def : Pat<(alignedloadv4i32 addr:$src),
3135 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3136def : Pat<(loadv4i32 addr:$src),
3137 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00003138def : Pat<(alignedloadv2i64 addr:$src),
3139 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3140def : Pat<(loadv2i64 addr:$src),
3141 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3142
3143def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3144 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3145def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3146 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3147def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3148 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3149def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3150 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3151def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3152 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3153def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3154 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3155def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3156 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3157def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3158 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003159
Nate Begemanb2975562008-02-03 07:18:54 +00003160//===----------------------------------------------------------------------===//
3161// SSE4.1 Instructions
3162//===----------------------------------------------------------------------===//
3163
Dale Johannesena7d2b442008-10-10 23:51:03 +00003164multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begemanb2975562008-02-03 07:18:54 +00003165 string OpcodeStr,
Nate Begemanb2975562008-02-03 07:18:54 +00003166 Intrinsic V4F32Int,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003167 Intrinsic V2F64Int> {
Nate Begemanb2975562008-02-03 07:18:54 +00003168 // Intrinsic operation, reg.
Nate Begemanb2975562008-02-03 07:18:54 +00003169 // Vector intrinsic operation, reg
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003170 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003171 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003172 !strconcat(OpcodeStr,
3173 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003174 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3175 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003176
3177 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003178 def PSm_Int : SS4AIi8<opcps, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003179 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003180 !strconcat(OpcodeStr,
3181 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003182 [(set VR128:$dst,
3183 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003184 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003185
Nate Begemanb2975562008-02-03 07:18:54 +00003186 // Vector intrinsic operation, reg
Evan Cheng78d00612008-03-14 07:39:27 +00003187 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003188 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003189 !strconcat(OpcodeStr,
3190 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003191 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3192 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003193
3194 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003195 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003196 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003197 !strconcat(OpcodeStr,
3198 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003199 [(set VR128:$dst,
3200 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003201 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003202}
3203
Dale Johannesena7d2b442008-10-10 23:51:03 +00003204let Constraints = "$src1 = $dst" in {
3205multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3206 string OpcodeStr,
3207 Intrinsic F32Int,
3208 Intrinsic F64Int> {
3209 // Intrinsic operation, reg.
3210 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003211 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003212 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3213 !strconcat(OpcodeStr,
3214 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003215 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003216 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3217 OpSize;
3218
3219 // Intrinsic operation, mem.
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003220 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3221 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003222 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003223 !strconcat(OpcodeStr,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003224 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003225 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003226 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3227 OpSize;
3228
3229 // Intrinsic operation, reg.
3230 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003231 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003232 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3233 !strconcat(OpcodeStr,
3234 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003235 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003236 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3237 OpSize;
3238
3239 // Intrinsic operation, mem.
3240 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003241 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003242 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3243 !strconcat(OpcodeStr,
3244 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003245 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003246 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3247 OpSize;
3248}
3249}
3250
Nate Begemanb2975562008-02-03 07:18:54 +00003251// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesena7d2b442008-10-10 23:51:03 +00003252defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3253 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3254defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3255 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003256
3257// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3258multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3259 Intrinsic IntId128> {
3260 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3261 (ins VR128:$src),
3262 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3263 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3264 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3265 (ins i128mem:$src),
3266 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3267 [(set VR128:$dst,
3268 (IntId128
3269 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3270}
3271
3272defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3273 int_x86_sse41_phminposuw>;
3274
3275/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003276let Constraints = "$src1 = $dst" in {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003277 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3278 Intrinsic IntId128, bit Commutable = 0> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003279 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3280 (ins VR128:$src1, VR128:$src2),
3281 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3282 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3283 OpSize {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003284 let isCommutable = Commutable;
3285 }
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003286 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3287 (ins VR128:$src1, i128mem:$src2),
3288 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3289 [(set VR128:$dst,
3290 (IntId128 VR128:$src1,
3291 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003292 }
3293}
3294
3295defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3296 int_x86_sse41_pcmpeqq, 1>;
3297defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3298 int_x86_sse41_packusdw, 0>;
3299defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3300 int_x86_sse41_pminsb, 1>;
3301defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3302 int_x86_sse41_pminsd, 1>;
3303defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3304 int_x86_sse41_pminud, 1>;
3305defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3306 int_x86_sse41_pminuw, 1>;
3307defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3308 int_x86_sse41_pmaxsb, 1>;
3309defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3310 int_x86_sse41_pmaxsd, 1>;
3311defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3312 int_x86_sse41_pmaxud, 1>;
3313defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3314 int_x86_sse41_pmaxuw, 1>;
Nate Begeman72d802a2008-02-04 06:00:24 +00003315
Mon P Wang14edb092008-12-18 21:42:19 +00003316defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3317
Nate Begeman03605a02008-07-17 16:51:19 +00003318def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3319 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3320def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3321 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3322
Nate Begeman58057962008-02-09 01:38:08 +00003323/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003324let Constraints = "$src1 = $dst" in {
Dan Gohmane3731f52008-05-23 17:49:40 +00003325 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3326 SDNode OpNode, Intrinsic IntId128,
3327 bit Commutable = 0> {
Nate Begeman58057962008-02-09 01:38:08 +00003328 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3329 (ins VR128:$src1, VR128:$src2),
3330 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmane3731f52008-05-23 17:49:40 +00003331 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3332 VR128:$src2))]>, OpSize {
Nate Begeman58057962008-02-09 01:38:08 +00003333 let isCommutable = Commutable;
3334 }
3335 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3336 (ins VR128:$src1, VR128:$src2),
3337 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3338 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3339 OpSize {
3340 let isCommutable = Commutable;
3341 }
3342 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3343 (ins VR128:$src1, i128mem:$src2),
3344 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3345 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003346 (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003347 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3348 (ins VR128:$src1, i128mem:$src2),
3349 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3350 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003351 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman58057962008-02-09 01:38:08 +00003352 OpSize;
3353 }
3354}
Dan Gohmane3731f52008-05-23 17:49:40 +00003355defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
Nate Begeman58057962008-02-09 01:38:08 +00003356 int_x86_sse41_pmulld, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003357
Evan Cheng78d00612008-03-14 07:39:27 +00003358/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Cheng3ea4d672008-03-05 08:19:16 +00003359let Constraints = "$src1 = $dst" in {
Nate Begeman72d802a2008-02-04 06:00:24 +00003360 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3361 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng78d00612008-03-14 07:39:27 +00003362 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003363 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003364 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003365 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003366 [(set VR128:$dst,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003367 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3368 OpSize {
Nate Begeman72d802a2008-02-04 06:00:24 +00003369 let isCommutable = Commutable;
3370 }
Evan Cheng78d00612008-03-14 07:39:27 +00003371 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003372 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3373 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003374 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003375 [(set VR128:$dst,
3376 (IntId128 VR128:$src1,
3377 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3378 OpSize;
Nate Begeman72d802a2008-02-04 06:00:24 +00003379 }
3380}
3381
3382defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3383 int_x86_sse41_blendps, 0>;
3384defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3385 int_x86_sse41_blendpd, 0>;
3386defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3387 int_x86_sse41_pblendw, 0>;
3388defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3389 int_x86_sse41_dpps, 1>;
3390defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3391 int_x86_sse41_dppd, 1>;
3392defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng81ed9852008-06-16 20:25:59 +00003393 int_x86_sse41_mpsadbw, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003394
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003395
Evan Cheng78d00612008-03-14 07:39:27 +00003396/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003397let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanb4e9a042008-02-10 18:47:57 +00003398 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3399 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3400 (ins VR128:$src1, VR128:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003401 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003402 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3403 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3404 OpSize;
3405
3406 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3407 (ins VR128:$src1, i128mem:$src2),
3408 !strconcat(OpcodeStr,
3409 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3410 [(set VR128:$dst,
3411 (IntId VR128:$src1,
3412 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3413 }
3414}
3415
3416defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3417defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3418defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3419
3420
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003421multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3422 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3423 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3424 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3425
3426 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3427 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003428 [(set VR128:$dst,
3429 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3430 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003431}
3432
3433defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3434defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3435defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3436defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3437defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3438defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3439
Evan Cheng56ec77b2008-09-24 23:27:55 +00003440// Common patterns involving scalar load.
3441def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3442 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3443def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3444 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3445
3446def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3447 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3448def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3449 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3450
3451def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3452 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3453def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3454 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3455
3456def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3457 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3458def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3459 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3460
3461def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3462 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3463def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3464 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3465
3466def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3467 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3468def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3469 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3470
3471
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003472multiclass SS41I_binop_rm_int4<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 i32mem:$src),
3478 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003479 [(set VR128:$dst,
3480 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3481 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003482}
3483
3484defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3485defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3486defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3487defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3488
Evan Cheng56ec77b2008-09-24 23:27:55 +00003489// Common patterns involving scalar load
3490def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003491 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003492def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003493 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003494
3495def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003496 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003497def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003498 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003499
3500
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003501multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3502 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3503 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3504 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3505
Evan Cheng56ec77b2008-09-24 23:27:55 +00003506 // Expecting a i16 load any extended to i32 value.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003507 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3508 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003509 [(set VR128:$dst, (IntId (bitconvert
3510 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3511 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003512}
3513
3514defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman75a89d62009-06-06 05:55:37 +00003515defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003516
Evan Cheng56ec77b2008-09-24 23:27:55 +00003517// Common patterns involving scalar load
3518def : Pat<(int_x86_sse41_pmovsxbq
3519 (bitconvert (v4i32 (X86vzmovl
3520 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003521 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003522
3523def : Pat<(int_x86_sse41_pmovzxbq
3524 (bitconvert (v4i32 (X86vzmovl
3525 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003526 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003527
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003528
Nate Begemand77e59e2008-02-11 04:19:36 +00003529/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3530multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003531 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003532 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003533 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003534 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003535 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3536 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003537 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003538 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003539 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003540 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003541 []>, OpSize;
3542// FIXME:
3543// There's an AssertZext in the way of writing the store pattern
3544// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003545}
3546
Nate Begemand77e59e2008-02-11 04:19:36 +00003547defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003548
Nate Begemand77e59e2008-02-11 04:19:36 +00003549
3550/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3551multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003552 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemand77e59e2008-02-11 04:19:36 +00003553 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003554 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003555 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3556 []>, OpSize;
3557// FIXME:
3558// There's an AssertZext in the way of writing the store pattern
3559// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3560}
3561
3562defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3563
3564
3565/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3566multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003567 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003568 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003569 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003570 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3571 [(set GR32:$dst,
3572 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003573 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003574 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003575 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003576 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3577 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3578 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003579}
3580
Nate Begemand77e59e2008-02-11 04:19:36 +00003581defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman58057962008-02-09 01:38:08 +00003582
Nate Begemand77e59e2008-02-11 04:19:36 +00003583
Evan Cheng6c249332008-03-24 21:52:23 +00003584/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3585/// destination
Nate Begemand77e59e2008-02-11 04:19:36 +00003586multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003587 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003588 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003589 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003590 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman788db592008-04-16 02:32:24 +00003591 [(set GR32:$dst,
3592 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng6c249332008-03-24 21:52:23 +00003593 OpSize;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003594 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003595 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003596 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003597 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng6c249332008-03-24 21:52:23 +00003598 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003599 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003600}
3601
Nate Begemand77e59e2008-02-11 04:19:36 +00003602defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003603
Dan Gohmana41862a2008-08-08 18:30:21 +00003604// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3605def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3606 imm:$src2))),
3607 addr:$dst),
3608 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3609 Requires<[HasSSE41]>;
3610
Evan Cheng3ea4d672008-03-05 08:19:16 +00003611let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003612 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003613 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003614 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003615 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003616 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003617 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003618 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003619 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003620 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3621 !strconcat(OpcodeStr,
3622 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003623 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003624 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3625 imm:$src3))]>, OpSize;
3626 }
3627}
3628
3629defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3630
Evan Cheng3ea4d672008-03-05 08:19:16 +00003631let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003632 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003633 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003634 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003635 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003636 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003637 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003638 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3639 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003640 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003641 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3642 !strconcat(OpcodeStr,
3643 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003644 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003645 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3646 imm:$src3)))]>, OpSize;
3647 }
3648}
3649
3650defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3651
Eric Christophera0443602009-07-23 02:22:41 +00003652// insertps has a few different modes, there's the first two here below which
3653// are optimized inserts that won't zero arbitrary elements in the destination
3654// vector. The next one matches the intrinsic and could zero arbitrary elements
3655// in the target vector.
Evan Cheng3ea4d672008-03-05 08:19:16 +00003656let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003657 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherefb657e2009-07-24 00:33:09 +00003658 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3659 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003660 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003661 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003662 [(set VR128:$dst,
3663 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
3664 OpSize;
Eric Christopherefb657e2009-07-24 00:33:09 +00003665 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003666 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3667 !strconcat(OpcodeStr,
3668 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003669 [(set VR128:$dst,
Eric Christopherefb657e2009-07-24 00:33:09 +00003670 (X86insrtps VR128:$src1,
3671 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begemand77e59e2008-02-11 04:19:36 +00003672 imm:$src3))]>, OpSize;
3673 }
3674}
3675
Evan Chengc2054be2008-03-26 08:11:49 +00003676defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003677
Eric Christopherefb657e2009-07-24 00:33:09 +00003678def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3679 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3680
Eric Christopher95d79262009-07-29 00:28:05 +00003681// ptest instruction we'll lower to this in X86ISelLowering primarily from
3682// the intel intrinsic that corresponds to this.
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003683let Defs = [EFLAGS] in {
3684def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003685 "ptest \t{$src2, $src1|$src1, $src2}",
3686 [(X86ptest VR128:$src1, VR128:$src2),
3687 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003688def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003689 "ptest \t{$src2, $src1|$src1, $src2}",
3690 [(X86ptest VR128:$src1, (load addr:$src2)),
3691 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003692}
3693
3694def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3695 "movntdqa\t{$src, $dst|$dst, $src}",
3696 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>;
Nate Begeman03605a02008-07-17 16:51:19 +00003697
Eric Christopher22a39402009-08-18 22:50:32 +00003698
3699//===----------------------------------------------------------------------===//
3700// SSE4.2 Instructions
3701//===----------------------------------------------------------------------===//
3702
Nate Begeman03605a02008-07-17 16:51:19 +00003703/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3704let Constraints = "$src1 = $dst" in {
3705 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3706 Intrinsic IntId128, bit Commutable = 0> {
3707 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3708 (ins VR128:$src1, VR128:$src2),
3709 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3710 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3711 OpSize {
3712 let isCommutable = Commutable;
3713 }
3714 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3715 (ins VR128:$src1, i128mem:$src2),
3716 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3717 [(set VR128:$dst,
3718 (IntId128 VR128:$src1,
3719 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3720 }
3721}
3722
Nate Begeman235666b2008-07-17 17:04:58 +00003723defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman03605a02008-07-17 16:51:19 +00003724
3725def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3726 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3727def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3728 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003729
3730// crc intrinsic instruction
3731// This set of instructions are only rm, the only difference is the size
3732// of r and m.
3733let Constraints = "$src1 = $dst" in {
Eric Christopher85f187b2009-08-10 21:48:58 +00003734 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003735 (ins GR32:$src1, i8mem:$src2),
3736 "crc32 \t{$src2, $src1|$src1, $src2}",
3737 [(set GR32:$dst,
3738 (int_x86_sse42_crc32_8 GR32:$src1,
3739 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003740 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003741 (ins GR32:$src1, GR8:$src2),
3742 "crc32 \t{$src2, $src1|$src1, $src2}",
3743 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003744 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003745 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003746 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003747 (ins GR32:$src1, i16mem:$src2),
3748 "crc32 \t{$src2, $src1|$src1, $src2}",
3749 [(set GR32:$dst,
3750 (int_x86_sse42_crc32_16 GR32:$src1,
3751 (load addr:$src2)))]>,
3752 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003753 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003754 (ins GR32:$src1, GR16:$src2),
3755 "crc32 \t{$src2, $src1|$src1, $src2}",
3756 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003757 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003758 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003759 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003760 (ins GR32:$src1, i32mem:$src2),
3761 "crc32 \t{$src2, $src1|$src1, $src2}",
3762 [(set GR32:$dst,
3763 (int_x86_sse42_crc32_32 GR32:$src1,
3764 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003765 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003766 (ins GR32:$src1, GR32:$src2),
3767 "crc32 \t{$src2, $src1|$src1, $src2}",
3768 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003769 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003770 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003771 def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003772 (ins GR64:$src1, i64mem:$src2),
3773 "crc32 \t{$src2, $src1|$src1, $src2}",
3774 [(set GR64:$dst,
3775 (int_x86_sse42_crc32_64 GR64:$src1,
3776 (load addr:$src2)))]>,
3777 OpSize, REX_W;
Eric Christopher85f187b2009-08-10 21:48:58 +00003778 def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003779 (ins GR64:$src1, GR64:$src2),
3780 "crc32 \t{$src2, $src1|$src1, $src2}",
3781 [(set GR64:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003782 (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003783 OpSize, REX_W;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003784}
Eric Christopher22a39402009-08-18 22:50:32 +00003785
3786// String/text processing instructions.
Dan Gohman30afe012009-10-29 18:10:34 +00003787let Defs = [EFLAGS], usesCustomInserter = 1 in {
Eric Christopher22a39402009-08-18 22:50:32 +00003788def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
3789 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3790 "#PCMPISTRM128rr PSEUDO!",
3791 [(set VR128:$dst,
3792 (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
3793 imm:$src3))]>, OpSize;
3794def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
3795 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3796 "#PCMPISTRM128rm PSEUDO!",
3797 [(set VR128:$dst,
3798 (int_x86_sse42_pcmpistrm128 VR128:$src1,
3799 (load addr:$src2),
3800 imm:$src3))]>, OpSize;
3801}
3802
3803let Defs = [XMM0, EFLAGS] in {
3804def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
3805 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3806 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3807 []>, OpSize;
3808def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
3809 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3810 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3811 []>, OpSize;
3812}
3813
3814let Defs = [EFLAGS], Uses = [EAX, EDX],
Dan Gohman30afe012009-10-29 18:10:34 +00003815 usesCustomInserter = 1 in {
Eric Christopher22a39402009-08-18 22:50:32 +00003816def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
3817 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3818 "#PCMPESTRM128rr PSEUDO!",
3819 [(set VR128:$dst,
3820 (int_x86_sse42_pcmpestrm128 VR128:$src1, EAX,
3821 VR128:$src3,
3822 EDX, imm:$src5))]>, OpSize;
3823def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
3824 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3825 "#PCMPESTRM128rm PSEUDO!",
3826 [(set VR128:$dst,
3827 (int_x86_sse42_pcmpestrm128 VR128:$src1, EAX,
3828 (load addr:$src3),
3829 EDX, imm:$src5))]>, OpSize;
3830}
3831
3832let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
Sean Callananc5a05b72009-08-20 18:24:27 +00003833def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
Eric Christopher22a39402009-08-18 22:50:32 +00003834 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3835 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3836 []>, OpSize;
Sean Callananc5a05b72009-08-20 18:24:27 +00003837def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
Eric Christopher22a39402009-08-18 22:50:32 +00003838 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3839 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3840 []>, OpSize;
3841}
3842
3843let Defs = [ECX, EFLAGS] in {
3844 multiclass SS42AI_pcmpistri<Intrinsic IntId128> {
3845 def rr : SS42AI<0x63, MRMSrcReg, (outs),
3846 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3847 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3848 [(set ECX,
3849 (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
3850 (implicit EFLAGS)]>,
3851 OpSize;
3852 def rm : SS42AI<0x63, MRMSrcMem, (outs),
3853 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3854 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3855 [(set ECX,
3856 (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
3857 (implicit EFLAGS)]>,
3858 OpSize;
3859 }
3860}
3861
3862defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
3863defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
3864defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
3865defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
3866defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
3867defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
3868
3869let Defs = [ECX, EFLAGS] in {
3870let Uses = [EAX, EDX] in {
3871 multiclass SS42AI_pcmpestri<Intrinsic IntId128> {
3872 def rr : SS42AI<0x61, MRMSrcReg, (outs),
3873 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3874 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3875 [(set ECX,
3876 (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
3877 (implicit EFLAGS)]>,
3878 OpSize;
3879 def rm : SS42AI<0x61, MRMSrcMem, (outs),
3880 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3881 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3882 [(set ECX,
3883 (IntId128 VR128:$src1, EAX, (load addr:$src3),
3884 EDX, imm:$src5)),
3885 (implicit EFLAGS)]>,
3886 OpSize;
3887 }
3888}
3889}
3890
3891defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
3892defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
3893defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
3894defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
3895defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
3896defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;