blob: 3ab3bff75b9b57d4b08299a6146463c60d3256a3 [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
228def movhp : PatFrag<(ops node:$lhs, node:$rhs),
229 (vector_shuffle node:$lhs, node:$rhs), [{
230 return X86::isMOVHPMask(cast<ShuffleVectorSDNode>(N));
231}]>;
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
302// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
303// scheduler into a branch sequence.
Evan Cheng950aac02007-09-25 01:57:46 +0000304// These are expanded by the scheduler.
305let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306 def CMOV_FR32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000307 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000308 "#CMOV_FR32 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000309 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
310 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000312 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 "#CMOV_FR64 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000314 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
315 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000317 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318 "#CMOV_V4F32 PSEUDO!",
319 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000320 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
321 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322 def CMOV_V2F64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000323 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000324 "#CMOV_V2F64 PSEUDO!",
325 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000326 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
327 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328 def CMOV_V2I64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000329 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000330 "#CMOV_V2I64 PSEUDO!",
331 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000332 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng950aac02007-09-25 01:57:46 +0000333 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334}
335
336//===----------------------------------------------------------------------===//
337// SSE1 Instructions
338//===----------------------------------------------------------------------===//
339
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000341let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000342def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000343 "movss\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000344let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000345def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000346 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000347 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000348def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000349 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000350 [(store FR32:$src, addr:$dst)]>;
351
352// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000353def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000354 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000355 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000356def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000357 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000358 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000359def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000360 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000362def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000363 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
365
366// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000367def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000368 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000370def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000371 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000372 [(set GR32:$dst, (int_x86_sse_cvtss2si
373 (load addr:$src)))]>;
374
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000375// Match intrinisics which expect MM and XMM operand(s).
376def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
377 "cvtps2pi\t{$src, $dst|$dst, $src}",
378 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
379def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
380 "cvtps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000381 [(set VR64:$dst, (int_x86_sse_cvtps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000382 (load addr:$src)))]>;
383def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
384 "cvttps2pi\t{$src, $dst|$dst, $src}",
385 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
386def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
387 "cvttps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000388 [(set VR64:$dst, (int_x86_sse_cvttps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000389 (load addr:$src)))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +0000390let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000391 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000392 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
393 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
394 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
395 VR64:$src2))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000396 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000397 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
398 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000399 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000400 (load addr:$src2)))]>;
401}
402
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000403// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000404def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000405 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406 [(set GR32:$dst,
407 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000408def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000409 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410 [(set GR32:$dst,
411 (int_x86_sse_cvttss2si(load addr:$src)))]>;
412
Evan Cheng3ea4d672008-03-05 08:19:16 +0000413let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000414 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000415 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000416 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
418 GR32:$src2))]>;
419 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000420 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000421 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
423 (loadi32 addr:$src2)))]>;
424}
425
426// Comparison instructions
Dan Gohmanf221da12009-01-09 02:27:34 +0000427let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000428 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000429 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000430 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000431let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000432 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000433 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000434 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435}
436
Evan Cheng55687072007-09-14 21:48:26 +0000437let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000438def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000439 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000440 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000441def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000442 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000443 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000444 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000445} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446
447// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +0000448let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000449 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
450 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
451 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000452 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000454 VR128:$src, imm:$cc))]>;
455 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
456 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src,
457 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000458 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000459 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
460 (load addr:$src), imm:$cc))]>;
461}
462
Evan Cheng55687072007-09-14 21:48:26 +0000463let Defs = [EFLAGS] in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000464def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000465 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000466 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000467 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000468def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000469 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000470 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000471 (implicit EFLAGS)]>;
472
Dan Gohmanf221da12009-01-09 02:27:34 +0000473def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000474 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000475 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000476 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000477def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000478 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000479 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000480 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000481} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000482
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000483// Aliases of packed SSE1 instructions for scalar use. These all have names
484// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485
486// Alias instructions that map fld0 to pxor for sse.
Dan Gohman51dbce62009-09-21 18:30:38 +0000487let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
488 canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000489def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000490 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491 Requires<[HasSSE1]>, TB, OpSize;
492
493// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
494// disregarded.
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000495let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000496def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000497 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000498
499// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
500// disregarded.
Dan Gohman5574cc72008-12-03 18:15:48 +0000501let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000502def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000503 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000504 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000505
506// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +0000507let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508let isCommutable = 1 in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000509 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
510 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000511 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000513 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
514 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000515 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000517 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
518 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000519 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
521}
522
Dan Gohmanf221da12009-01-09 02:27:34 +0000523def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
524 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000525 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000527 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000528def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
529 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000530 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000532 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000533def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
534 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000535 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000537 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000538
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000539let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000541 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000542 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000543let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000545 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000546 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000548}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549
550/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
551///
552/// In addition, we also have a special variant of the scalar form here to
553/// represent the associated intrinsic operation. This form is unlike the
554/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000555/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556///
557/// These three forms can each be reg+reg or reg+mem, so there are a total of
558/// six "instructions".
559///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000560let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
562 SDNode OpNode, Intrinsic F32Int,
563 bit Commutable = 0> {
564 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000565 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000566 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000567 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
568 let isCommutable = Commutable;
569 }
570
571 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000572 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
573 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000574 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000576
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000578 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
579 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000580 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000581 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
582 let isCommutable = Commutable;
583 }
584
585 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000586 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
587 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000588 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000589 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590
591 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000592 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
593 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000594 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000595 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596
597 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000598 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
599 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000600 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000601 [(set VR128:$dst, (F32Int VR128:$src1,
602 sse_load_f32:$src2))]>;
603}
604}
605
606// Arithmetic instructions
607defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
608defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
609defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
610defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
611
612/// sse1_fp_binop_rm - Other SSE1 binops
613///
614/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
615/// instructions for a full-vector intrinsic form. Operations that map
616/// onto C operators don't use this form since they just use the plain
617/// vector form instead of having a separate vector intrinsic form.
618///
619/// This provides a total of eight "instructions".
620///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000621let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000622multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
623 SDNode OpNode,
624 Intrinsic F32Int,
625 Intrinsic V4F32Int,
626 bit Commutable = 0> {
627
628 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000629 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000630 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000631 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
632 let isCommutable = Commutable;
633 }
634
635 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000636 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
637 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000638 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000640
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000642 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
643 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000644 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
646 let isCommutable = Commutable;
647 }
648
649 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000650 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
651 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000652 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000653 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654
655 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000656 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
657 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000658 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
660 let isCommutable = Commutable;
661 }
662
663 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000664 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
665 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000666 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000667 [(set VR128:$dst, (F32Int VR128:$src1,
668 sse_load_f32:$src2))]>;
669
670 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000671 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
672 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000673 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000674 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
675 let isCommutable = Commutable;
676 }
677
678 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000679 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
680 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000681 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000682 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683}
684}
685
686defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
687 int_x86_sse_max_ss, int_x86_sse_max_ps>;
688defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
689 int_x86_sse_min_ss, int_x86_sse_min_ps>;
690
691//===----------------------------------------------------------------------===//
692// SSE packed FP Instructions
693
694// Move Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000695let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000696def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000697 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000698let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000699def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000700 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000701 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702
Evan Chengb783fa32007-07-19 01:14:50 +0000703def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000704 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000705 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000707let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000708def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000709 "movups\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000710let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000711def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000712 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000713 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000714def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000715 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000716 [(store (v4f32 VR128:$src), addr:$dst)]>;
717
718// Intrinsic forms of MOVUPS load and store
Dan Gohman5574cc72008-12-03 18:15:48 +0000719let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000720def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000721 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000722 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000723def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000724 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000725 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726
Evan Cheng3ea4d672008-03-05 08:19:16 +0000727let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728 let AddedComplexity = 20 in {
729 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000730 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000731 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000732 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000733 (movlp VR128:$src1,
734 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000736 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000737 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000738 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000739 (movhp VR128:$src1,
740 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000742} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743
Evan Chengd743a5f2008-05-10 00:59:18 +0000744
Evan Chengb783fa32007-07-19 01:14:50 +0000745def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000746 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
748 (iPTR 0))), addr:$dst)]>;
749
750// v2f64 extract element 1 is always custom lowered to unpack high to low
751// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000752def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000753 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +0000755 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
756 (undef)), (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757
Evan Cheng3ea4d672008-03-05 08:19:16 +0000758let Constraints = "$src1 = $dst" in {
Evan Cheng13559d62008-09-26 23:41:32 +0000759let AddedComplexity = 20 in {
Evan Cheng7581a822009-05-12 20:17:52 +0000760def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
761 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000762 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000764 (v4f32 (movhp VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765
Evan Cheng7581a822009-05-12 20:17:52 +0000766def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
767 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000768 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000770 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771} // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000772} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773
Nate Begemanb44aad72009-04-29 22:47:44 +0000774let AddedComplexity = 20 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000775def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Evan Chenga2497eb2008-09-25 20:50:48 +0000776 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begemanb44aad72009-04-29 22:47:44 +0000777def : Pat<(v2i64 (movddup VR128:$src, (undef))),
778 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
779}
Evan Chenga2497eb2008-09-25 20:50:48 +0000780
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000781
782
783// Arithmetic
784
785/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
786///
787/// In addition, we also have a special variant of the scalar form here to
788/// represent the associated intrinsic operation. This form is unlike the
789/// plain scalar form, in that it takes an entire vector (instead of a
790/// scalar) and leaves the top elements undefined.
791///
792/// And, we have a special variant form for a full-vector intrinsic form.
793///
794/// These four forms can each have a reg or a mem operand, so there are a
795/// total of eight "instructions".
796///
797multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
798 SDNode OpNode,
799 Intrinsic F32Int,
800 Intrinsic V4F32Int,
801 bit Commutable = 0> {
802 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000803 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000804 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805 [(set FR32:$dst, (OpNode FR32:$src))]> {
806 let isCommutable = Commutable;
807 }
808
809 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000810 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000811 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000813
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000815 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000816 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
818 let isCommutable = Commutable;
819 }
820
821 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000822 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000823 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000824 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825
826 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000827 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000828 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829 [(set VR128:$dst, (F32Int VR128:$src))]> {
830 let isCommutable = Commutable;
831 }
832
833 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000834 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000835 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
837
838 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000839 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000840 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
842 let isCommutable = Commutable;
843 }
844
845 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000846 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000847 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000848 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849}
850
851// Square root.
852defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
853 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
854
855// Reciprocal approximations. Note that these typically require refinement
856// in order to obtain suitable precision.
857defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
858 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
859defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
860 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
861
862// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +0000863let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 let isCommutable = 1 in {
865 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000866 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000867 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868 [(set VR128:$dst, (v2i64
869 (and VR128:$src1, VR128:$src2)))]>;
870 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000871 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000872 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873 [(set VR128:$dst, (v2i64
874 (or VR128:$src1, VR128:$src2)))]>;
875 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000876 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000877 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878 [(set VR128:$dst, (v2i64
879 (xor VR128:$src1, VR128:$src2)))]>;
880 }
881
882 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000883 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000884 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000885 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
886 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000888 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000889 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000890 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
891 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000893 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000894 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000895 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
896 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000898 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000899 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 [(set VR128:$dst,
901 (v2i64 (and (xor VR128:$src1,
902 (bc_v2i64 (v4i32 immAllOnesV))),
903 VR128:$src2)))]>;
904 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000905 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000906 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000908 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000910 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911}
912
Evan Cheng3ea4d672008-03-05 08:19:16 +0000913let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000914 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begeman061db5f2008-05-12 20:34:32 +0000915 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
916 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
917 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
918 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000919 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begeman061db5f2008-05-12 20:34:32 +0000920 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
921 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
922 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +0000923 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924}
Nate Begeman03605a02008-07-17 16:51:19 +0000925def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
926 (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>;
927def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
928 (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929
930// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +0000931let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000933 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000934 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000935 VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000936 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000938 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000939 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000940 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000941 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000942 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000944 (v4f32 (shufp:$src3
945 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946
947 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000948 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000949 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000950 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000952 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000953 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000954 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000955 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000957 (v4f32 (unpckh VR128:$src1,
958 (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000960 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000961 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000964 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000965 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000966 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000967 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000969 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000971} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972
973// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000974def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000975 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengd8296b82009-05-28 18:55:28 +0000977def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000978 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
980
Evan Chengd1d68072008-03-08 00:58:38 +0000981// Prefetch intrinsic.
982def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
983 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
984def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
985 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
986def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
987 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
988def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
989 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990
991// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000992def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000993 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
995
996// Load, store, and memory fence
Evan Cheng68cca152009-05-27 18:38:01 +0000997def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998
999// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +00001000def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001001 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001002def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001003 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004
1005// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00001006// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00001007// load of an all-zeros value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +00001008let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
1009 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001010def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001011 "xorps\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00001012 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013
Evan Chenga15896e2008-03-12 07:02:50 +00001014let Predicates = [HasSSE1] in {
1015 def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
1016 def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1017 def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1018 def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1019 def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
1020}
1021
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022// FR32 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001023let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001024def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001025 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 [(set VR128:$dst,
1027 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001028def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001029 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030 [(set VR128:$dst,
1031 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
1032
1033// FIXME: may not be able to eliminate this movss with coalescing the src and
1034// dest register classes are different. We really want to write this pattern
1035// like this:
1036// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1037// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001038let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001039def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001040 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
1042 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001043def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001044 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 [(store (f32 (vector_extract (v4f32 VR128:$src),
1046 (iPTR 0))), addr:$dst)]>;
1047
1048
1049// Move to lower bits of a VR128, leaving upper bits alone.
1050// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001051let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001052let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001054 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001055 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056
1057 let AddedComplexity = 15 in
1058 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001059 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001060 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001062 (v4f32 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063}
1064
1065// Move to lower bits of a VR128 and zeroing upper bits.
1066// Loading from memory automatically zeroing upper bits.
1067let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00001068def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001069 "movss\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00001070 [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001071 (loadf32 addr:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072
Evan Cheng056afe12008-05-20 18:24:47 +00001073def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
Evan Cheng40ee6e52008-05-08 00:57:18 +00001074 (MOVZSS2PSrm addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001076//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077// SSE2 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001078//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001080// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001081let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001082def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001083 "movsd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001084let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001085def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001086 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001088def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001089 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090 [(store FR64:$src, addr:$dst)]>;
1091
1092// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001093def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001094 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001096def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001097 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001099def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001100 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001101 [(set FR32:$dst, (fround FR64:$src))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001102def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001103 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001105def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001106 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001107 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001108def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001109 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1111
Sean Callanan3d5824c2009-09-16 01:13:52 +00001112def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1113 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1114def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1115 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1116def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1117 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1118def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1119 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1120def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1121 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1122def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1123 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1124def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1125 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1126def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1127 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1128def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1129 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1130def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1131 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1132
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001134def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001135 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1137 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001138def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001139 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1141 Requires<[HasSSE2]>;
1142
1143// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001144def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001145 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001147def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001148 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001149 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1150 (load addr:$src)))]>;
1151
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001152// Match intrinisics which expect MM and XMM operand(s).
1153def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1154 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1155 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1156def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1157 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001158 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001159 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001160def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1161 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1162 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1163def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1164 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001165 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001166 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001167def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1168 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1169 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1170def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1171 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001172 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001173 (load addr:$src)))]>;
1174
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001176def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001177 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001178 [(set GR32:$dst,
1179 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001180def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001181 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1183 (load addr:$src)))]>;
1184
1185// Comparison instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001186let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001187 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001188 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001189 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001190let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001191 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001192 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001193 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194}
1195
Evan Cheng950aac02007-09-25 01:57:46 +00001196let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001197def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001198 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001199 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001200def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001201 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001202 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001203 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001204} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001205
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +00001207let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001208 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
1209 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
1210 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001211 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1213 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001214 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
1215 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src,
1216 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001217 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1219 (load addr:$src), imm:$cc))]>;
1220}
1221
Evan Cheng950aac02007-09-25 01:57:46 +00001222let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001223def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001224 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001225 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1226 (implicit EFLAGS)]>;
1227def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001228 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001229 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1230 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001231
Evan Chengb783fa32007-07-19 01:14:50 +00001232def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001233 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001234 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1235 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001236def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001237 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001238 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001239 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001240} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001241
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001242// Aliases of packed SSE2 instructions for scalar use. These all have names
1243// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001244
1245// Alias instructions that map fld0 to pxor for sse.
Dan Gohman51dbce62009-09-21 18:30:38 +00001246let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1247 canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001248def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001249 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250 Requires<[HasSSE2]>, TB, OpSize;
1251
1252// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1253// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001254let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001255def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001256 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257
1258// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1259// disregarded.
Dan Gohman5574cc72008-12-03 18:15:48 +00001260let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001261def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001263 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264
1265// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001266let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267let isCommutable = 1 in {
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001268 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1269 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001270 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001272 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1273 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001274 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001276 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1277 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001278 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1280}
1281
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001282def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1283 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001286 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001287def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1288 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001289 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001291 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001292def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1293 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001294 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001296 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001298let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001300 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001301 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001302let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001303def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001304 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001305 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001307}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308
1309/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1310///
1311/// In addition, we also have a special variant of the scalar form here to
1312/// represent the associated intrinsic operation. This form is unlike the
1313/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001314/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001315///
1316/// These three forms can each be reg+reg or reg+mem, so there are a total of
1317/// six "instructions".
1318///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001319let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1321 SDNode OpNode, Intrinsic F64Int,
1322 bit Commutable = 0> {
1323 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001324 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001325 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1327 let isCommutable = Commutable;
1328 }
1329
1330 // Scalar operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001331 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1332 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001333 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001335
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336 // Vector operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001337 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1338 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001339 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1341 let isCommutable = Commutable;
1342 }
1343
1344 // Vector operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001345 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1346 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001347 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf221da12009-01-09 02:27:34 +00001348 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349
1350 // Intrinsic operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001351 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1352 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001353 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001354 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355
1356 // Intrinsic operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001357 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1358 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001359 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360 [(set VR128:$dst, (F64Int VR128:$src1,
1361 sse_load_f64:$src2))]>;
1362}
1363}
1364
1365// Arithmetic instructions
1366defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1367defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1368defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1369defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1370
1371/// sse2_fp_binop_rm - Other SSE2 binops
1372///
1373/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1374/// instructions for a full-vector intrinsic form. Operations that map
1375/// onto C operators don't use this form since they just use the plain
1376/// vector form instead of having a separate vector intrinsic form.
1377///
1378/// This provides a total of eight "instructions".
1379///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001380let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1382 SDNode OpNode,
1383 Intrinsic F64Int,
1384 Intrinsic V2F64Int,
1385 bit Commutable = 0> {
1386
1387 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001388 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001389 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1391 let isCommutable = Commutable;
1392 }
1393
1394 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001395 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1396 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001397 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001398 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001399
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001401 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1402 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001403 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1405 let isCommutable = Commutable;
1406 }
1407
1408 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001409 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1410 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001411 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001412 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413
1414 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001415 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1416 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1419 let isCommutable = Commutable;
1420 }
1421
1422 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001423 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1424 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 [(set VR128:$dst, (F64Int VR128:$src1,
1427 sse_load_f64:$src2))]>;
1428
1429 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001430 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1431 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001432 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001433 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1434 let isCommutable = Commutable;
1435 }
1436
1437 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001438 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1439 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001440 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001441 [(set VR128:$dst, (V2F64Int VR128:$src1,
1442 (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443}
1444}
1445
1446defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1447 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1448defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1449 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1450
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001451//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001452// SSE packed FP Instructions
1453
1454// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001455let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001456def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001457 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001458let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001459def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001460 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001461 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001462
Evan Chengb783fa32007-07-19 01:14:50 +00001463def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001465 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001466
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001467let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001468def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001470let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001471def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001472 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001473 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001474def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001476 [(store (v2f64 VR128:$src), addr:$dst)]>;
1477
1478// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001479def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001480 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001481 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001482def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001483 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001484 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001485
Evan Cheng3ea4d672008-03-05 08:19:16 +00001486let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001487 let AddedComplexity = 20 in {
1488 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001489 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001490 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001491 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001492 (v2f64 (movlp VR128:$src1,
1493 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001495 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001497 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001498 (v2f64 (movhp VR128:$src1,
1499 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001500 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001501} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001502
Evan Chengb783fa32007-07-19 01:14:50 +00001503def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001504 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505 [(store (f64 (vector_extract (v2f64 VR128:$src),
1506 (iPTR 0))), addr:$dst)]>;
1507
1508// v2f64 extract element 1 is always custom lowered to unpack high to low
1509// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001510def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001512 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +00001513 (v2f64 (unpckh VR128:$src, (undef))),
1514 (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001515
1516// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001517def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001519 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1520 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001521def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001522 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1523 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1524 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525 TB, Requires<[HasSSE2]>;
1526
1527// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001528def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001529 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1531 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001532def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001533 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1534 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1535 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001536 XS, Requires<[HasSSE2]>;
1537
Evan Chengb783fa32007-07-19 01:14:50 +00001538def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001539 "cvtps2dq\t{$src, $dst|$dst, $src}",
1540 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001541def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001544 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001545// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001546def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1549 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001550def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001553 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554 XS, Requires<[HasSSE2]>;
1555
1556// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001557def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001559 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1560 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001561def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001562 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001563 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001564 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 XD, Requires<[HasSSE2]>;
1566
Evan Chengb783fa32007-07-19 01:14:50 +00001567def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001568 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng14c97c32008-03-14 07:46:48 +00001570def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001573 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001574
1575// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001576def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001577 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1579 TB, Requires<[HasSSE2]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001580def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001581 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001582 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1583 (load addr:$src)))]>,
1584 TB, Requires<[HasSSE2]>;
1585
Evan Chengb783fa32007-07-19 01:14:50 +00001586def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001587 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001588 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001589def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001590 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Cheng00b66ef2008-05-23 00:37:07 +00001592 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001593
1594// Match intrinsics which expect XMM operand(s).
1595// Aliases for intrinsics
Evan Cheng3ea4d672008-03-05 08:19:16 +00001596let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001597def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001598 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001599 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1601 GR32:$src2))]>;
1602def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001603 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001604 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001605 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1606 (loadi32 addr:$src2)))]>;
1607def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001608 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001609 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001610 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1611 VR128:$src2))]>;
1612def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001613 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1616 (load addr:$src2)))]>;
1617def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001618 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1621 VR128:$src2))]>, XS,
1622 Requires<[HasSSE2]>;
1623def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001624 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001625 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1627 (load addr:$src2)))]>, XS,
1628 Requires<[HasSSE2]>;
1629}
1630
1631// Arithmetic
1632
1633/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1634///
1635/// In addition, we also have a special variant of the scalar form here to
1636/// represent the associated intrinsic operation. This form is unlike the
1637/// plain scalar form, in that it takes an entire vector (instead of a
1638/// scalar) and leaves the top elements undefined.
1639///
1640/// And, we have a special variant form for a full-vector intrinsic form.
1641///
1642/// These four forms can each have a reg or a mem operand, so there are a
1643/// total of eight "instructions".
1644///
1645multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1646 SDNode OpNode,
1647 Intrinsic F64Int,
1648 Intrinsic V2F64Int,
1649 bit Commutable = 0> {
1650 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001651 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001652 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653 [(set FR64:$dst, (OpNode FR64:$src))]> {
1654 let isCommutable = Commutable;
1655 }
1656
1657 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001658 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001659 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001660 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001661
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001662 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001663 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1666 let isCommutable = Commutable;
1667 }
1668
1669 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001670 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001672 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001673
1674 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001675 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001676 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677 [(set VR128:$dst, (F64Int VR128:$src))]> {
1678 let isCommutable = Commutable;
1679 }
1680
1681 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001682 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1685
1686 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001687 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001688 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1690 let isCommutable = Commutable;
1691 }
1692
1693 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001694 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001696 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697}
1698
1699// Square root.
1700defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1701 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1702
1703// There is no f64 version of the reciprocal approximation instructions.
1704
1705// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +00001706let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 let isCommutable = 1 in {
1708 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001709 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001710 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 [(set VR128:$dst,
1712 (and (bc_v2i64 (v2f64 VR128:$src1)),
1713 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1714 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001715 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 [(set VR128:$dst,
1718 (or (bc_v2i64 (v2f64 VR128:$src1)),
1719 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1720 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001721 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001722 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001723 [(set VR128:$dst,
1724 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1725 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1726 }
1727
1728 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001729 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001731 [(set VR128:$dst,
1732 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001733 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001734 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001735 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737 [(set VR128:$dst,
1738 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001739 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001741 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001743 [(set VR128:$dst,
1744 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001745 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001747 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001749 [(set VR128:$dst,
1750 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1751 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1752 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001753 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001754 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755 [(set VR128:$dst,
1756 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001757 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758}
1759
Evan Cheng3ea4d672008-03-05 08:19:16 +00001760let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001761 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001762 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1763 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1764 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begeman061db5f2008-05-12 20:34:32 +00001765 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001766 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng14c97c32008-03-14 07:46:48 +00001767 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1768 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1769 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00001770 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001771}
Evan Cheng33754092008-08-05 22:19:15 +00001772def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001773 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Cheng33754092008-08-05 22:19:15 +00001774def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001775 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776
1777// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001778let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001779 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001780 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1781 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman543d2142009-04-27 18:41:29 +00001782 [(set VR128:$dst,
1783 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001784 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001785 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001789 (v2f64 (shufp:$src3
1790 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001791
1792 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001793 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001794 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001797 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001798 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001799 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001802 (v2f64 (unpckh VR128:$src1,
1803 (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001804
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001805 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001806 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001808 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001809 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001810 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001811 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001812 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001813 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001814 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001815 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001816} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001817
1818
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001819//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001820// SSE integer instructions
1821
1822// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001823let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001824def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001826let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001827def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001829 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001830let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001831def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001833 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001834let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001835def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001837 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001838 XS, Requires<[HasSSE2]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001839let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001840def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001842 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001843 XS, Requires<[HasSSE2]>;
1844
Dan Gohman4a4f1512007-07-18 20:23:34 +00001845// Intrinsic forms of MOVDQU load and store
Dan Gohman5574cc72008-12-03 18:15:48 +00001846let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001847def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001848 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001849 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1850 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001851def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001853 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1854 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855
Evan Cheng88004752008-03-05 08:11:27 +00001856let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857
1858multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1859 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001860 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1863 let isCommutable = Commutable;
1864 }
Evan Chengb783fa32007-07-19 01:14:50 +00001865 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001867 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001868 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869}
1870
Evan Chengf90f8f82008-05-03 00:52:09 +00001871multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1872 string OpcodeStr,
1873 Intrinsic IntId, Intrinsic IntId2> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001874 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1875 VR128:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001876 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1877 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001878 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1879 i128mem:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001880 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1881 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001882 (bitconvert (memopv2i64 addr:$src2))))]>;
1883 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1,
1884 i32i8imm:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001885 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1886 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
1887}
1888
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001889/// PDI_binop_rm - Simple SSE2 binary operator.
1890multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1891 ValueType OpVT, bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001892 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1893 VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1896 let isCommutable = Commutable;
1897 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001898 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1899 i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001900 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001901 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001902 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903}
1904
1905/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1906///
1907/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1908/// to collapse (bitconvert VT to VT) into its operand.
1909///
1910multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1911 bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001912 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1913 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001914 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1916 let isCommutable = Commutable;
1917 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001918 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1919 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001920 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001921 [(set VR128:$dst, (OpNode VR128:$src1,
1922 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923}
1924
Evan Cheng3ea4d672008-03-05 08:19:16 +00001925} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926
1927// 128-bit Integer Arithmetic
1928
1929defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1930defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1931defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1932defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1933
1934defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1935defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1936defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1937defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1938
1939defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1940defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1941defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1942defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1943
1944defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1945defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1946defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1947defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1948
1949defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1950
1951defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1952defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1953defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1954
1955defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1956
1957defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1958defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1959
1960
1961defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1962defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1963defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1964defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling953ad2e2009-05-28 02:04:00 +00001965defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001966
1967
Evan Chengf90f8f82008-05-03 00:52:09 +00001968defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
1969 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
1970defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
1971 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
1972defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
1973 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001974
Evan Chengf90f8f82008-05-03 00:52:09 +00001975defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
1976 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
1977defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
1978 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begemanc2ca5f62008-05-13 17:52:09 +00001979defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Chengf90f8f82008-05-03 00:52:09 +00001980 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001981
Evan Chengf90f8f82008-05-03 00:52:09 +00001982defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
1983 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemand66fc342008-05-13 01:47:52 +00001984defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Chengf90f8f82008-05-03 00:52:09 +00001985 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986
1987// 128-bit logical shifts.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001988let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001989 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001990 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001991 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001993 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001994 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001995 // PSRADQri doesn't exist in SSE[1-3].
1996}
1997
1998let Predicates = [HasSSE2] in {
1999 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
Evan Cheng06cd2072009-10-28 06:30:34 +00002000 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
Evan Cheng06cd2072009-10-28 06:30:34 +00002002 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Bill Wendling314ee052008-10-02 05:56:52 +00002003 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2004 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2005 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2006 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002007 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002008 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Evan Chengdea99362008-05-29 08:22:04 +00002009
2010 // Shift up / down and insert zero's.
2011 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
Evan Cheng06cd2072009-10-28 06:30:34 +00002012 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Evan Chengdea99362008-05-29 08:22:04 +00002013 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
Evan Cheng06cd2072009-10-28 06:30:34 +00002014 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015}
2016
2017// Logical
2018defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2019defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2020defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2021
Evan Cheng3ea4d672008-03-05 08:19:16 +00002022let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002024 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002025 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002026 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2027 VR128:$src2)))]>;
2028
2029 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002030 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002031 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002032 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00002033 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034}
2035
2036// SSE2 Integer comparison
2037defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2038defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2039defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2040defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2041defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2042defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2043
Nate Begeman03605a02008-07-17 16:51:19 +00002044def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002045 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002046def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002047 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002048def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002049 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002050def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002051 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002052def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002053 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002054def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002055 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2056
Nate Begeman03605a02008-07-17 16:51:19 +00002057def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002058 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002059def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002060 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002061def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002062 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002063def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002064 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002065def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002066 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002067def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002068 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2069
2070
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071// Pack instructions
2072defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2073defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2074defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2075
2076// Shuffle and unpack instructions
Nate Begeman080f8e22009-10-19 02:17:23 +00002077let AddedComplexity = 5 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002079 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002081 [(set VR128:$dst, (v4i32 (pshufd:$src2
2082 VR128:$src1, (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002083def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002084 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002086 [(set VR128:$dst, (v4i32 (pshufd:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002087 (bc_v4i32(memopv2i64 addr:$src1)),
2088 (undef))))]>;
Nate Begeman080f8e22009-10-19 02:17:23 +00002089}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002090
2091// SSE2 with ImmT == Imm8 and XS prefix.
2092def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002093 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002094 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002095 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2096 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002097 XS, Requires<[HasSSE2]>;
2098def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002099 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002100 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002101 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002102 (bc_v8i16 (memopv2i64 addr:$src1)),
2103 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104 XS, Requires<[HasSSE2]>;
2105
2106// SSE2 with ImmT == Imm8 and XD prefix.
2107def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman543d2142009-04-27 18:41:29 +00002108 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002109 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002110 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2111 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 XD, Requires<[HasSSE2]>;
2113def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman543d2142009-04-27 18:41:29 +00002114 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002115 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002116 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2117 (bc_v8i16 (memopv2i64 addr:$src1)),
2118 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119 XD, Requires<[HasSSE2]>;
2120
2121
Evan Cheng3ea4d672008-03-05 08:19:16 +00002122let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002123 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002124 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002125 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002127 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002128 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002129 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002130 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002131 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002132 (unpckl VR128:$src1,
2133 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002134 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002135 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002136 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002138 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002139 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002140 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002141 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002143 (unpckl VR128:$src1,
2144 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002145 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002146 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002149 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002150 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002151 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002154 (unpckl VR128:$src1,
2155 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002156 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002157 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002158 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002159 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002160 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002161 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002162 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002163 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002165 (v2i64 (unpckl VR128:$src1,
2166 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002167
2168 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002169 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002170 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002172 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002173 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002174 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002175 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002176 [(set VR128:$dst,
2177 (unpckh VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002178 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002179 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002180 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002181 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002183 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002184 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002185 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002186 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002187 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002188 (unpckh VR128:$src1,
2189 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002190 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002191 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002192 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002194 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002195 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002196 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002197 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002199 (unpckh VR128:$src1,
2200 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002201 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002202 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002205 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002206 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002207 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002208 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002209 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002210 (v2i64 (unpckh VR128:$src1,
2211 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212}
2213
2214// Extract / Insert
2215def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002216 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002218 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begemand77e59e2008-02-11 04:19:36 +00002219 imm:$src2))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +00002220let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002221 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002222 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002223 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002224 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002225 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002226 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002227 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002228 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002231 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002232 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2233 imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234}
2235
2236// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002237def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002238 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002239 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2240
2241// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002242let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002243def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002245 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246
Evan Cheng430de082009-02-10 22:06:28 +00002247let Uses = [RDI] in
2248def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2249 "maskmovdqu\t{$mask, $src|$src, $mask}",
2250 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2251
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002253def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002254 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002255 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002256def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002258 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002259def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002261 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002262 TB, Requires<[HasSSE2]>;
2263
2264// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002265def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002266 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267 TB, Requires<[HasSSE2]>;
2268
2269// Load, store, and memory fence
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002270def LFENCE : I<0xAE, MRM5r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002271 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002272def MFENCE : I<0xAE, MRM6r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2274
Andrew Lenharth785610d2008-02-16 01:24:58 +00002275//TODO: custom lower this so as to never even generate the noop
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002276def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002277 (i8 0)), (NOOP)>;
2278def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2279def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002280def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002281 (i8 1)), (MFENCE)>;
2282
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00002284// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00002285// load of an all-ones value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +00002286let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2287 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002288 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002289 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002290 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291
2292// FR64 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002293let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002294def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002295 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002296 [(set VR128:$dst,
2297 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002298def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002299 "movsd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002300 [(set VR128:$dst,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002301 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2302
Evan Chengb783fa32007-07-19 01:14:50 +00002303def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002304 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002305 [(set VR128:$dst,
2306 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002307def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002308 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002309 [(set VR128:$dst,
2310 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2311
Evan Chengb783fa32007-07-19 01:14:50 +00002312def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002313 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002314 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2315
Evan Chengb783fa32007-07-19 01:14:50 +00002316def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002317 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002318 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2319
2320// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002321def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002322 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323 [(set VR128:$dst,
2324 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2325 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002326def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002327 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002328 [(store (i64 (vector_extract (v2i64 VR128:$src),
2329 (iPTR 0))), addr:$dst)]>;
2330
2331// FIXME: may not be able to eliminate this movss with coalescing the src and
2332// dest register classes are different. We really want to write this pattern
2333// like this:
2334// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2335// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002336let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002337def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002338 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002339 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2340 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002341def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002342 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002343 [(store (f64 (vector_extract (v2f64 VR128:$src),
2344 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002345def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002346 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002347 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2348 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002349def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002350 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002351 [(store (i32 (vector_extract (v4i32 VR128:$src),
2352 (iPTR 0))), addr:$dst)]>;
2353
Evan Chengb783fa32007-07-19 01:14:50 +00002354def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002355 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002357def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002358 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002359 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2360
2361
2362// Move to lower bits of a VR128, leaving upper bits alone.
2363// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002364let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00002365 let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002366 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002367 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002368 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002369
2370 let AddedComplexity = 15 in
2371 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002372 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002373 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002374 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002375 (v2f64 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002376}
2377
2378// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002379def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002380 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002381 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2382
2383// Move to lower bits of a VR128 and zeroing upper bits.
2384// Loading from memory automatically zeroing upper bits.
Evan Chengd743a5f2008-05-10 00:59:18 +00002385let AddedComplexity = 20 in {
2386def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2387 "movsd\t{$src, $dst|$dst, $src}",
2388 [(set VR128:$dst,
2389 (v2f64 (X86vzmovl (v2f64 (scalar_to_vector
2390 (loadf64 addr:$src))))))]>;
Evan Cheng40ee6e52008-05-08 00:57:18 +00002391
Evan Cheng056afe12008-05-20 18:24:47 +00002392def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
2393 (MOVZSD2PDrm addr:$src)>;
2394def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
Evan Chengd743a5f2008-05-10 00:59:18 +00002395 (MOVZSD2PDrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002396def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002397}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002399// movd / movq to XMM register zero-extends
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002400let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002401def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002402 "movd\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002403 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002404 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002405// This is X86-64 only.
2406def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2407 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002408 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002409 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002410}
2411
2412let AddedComplexity = 20 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002413def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002414 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002415 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002416 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002417 (loadi32 addr:$src))))))]>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002418
2419def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2420 (MOVZDI2PDIrm addr:$src)>;
2421def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2422 (MOVZDI2PDIrm addr:$src)>;
Duncan Sands2418bec2008-06-13 19:07:40 +00002423def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2424 (MOVZDI2PDIrm addr:$src)>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002425
Evan Chengb783fa32007-07-19 01:14:50 +00002426def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002427 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002428 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002429 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002430 (loadi64 addr:$src))))))]>, XS,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002431 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002432
Evan Cheng3ad16c42008-05-22 18:56:56 +00002433def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2434 (MOVZQI2PQIrm addr:$src)>;
2435def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2436 (MOVZQI2PQIrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002437def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002438}
Evan Chenge9b9c672008-05-09 21:53:03 +00002439
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002440// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2441// IA32 document. movq xmm1, xmm2 does clear the high bits.
2442let AddedComplexity = 15 in
2443def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2444 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002445 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002446 XS, Requires<[HasSSE2]>;
2447
Evan Cheng056afe12008-05-20 18:24:47 +00002448let AddedComplexity = 20 in {
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002449def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2450 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002451 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng056afe12008-05-20 18:24:47 +00002452 (loadv2i64 addr:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002453 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002454
Evan Cheng056afe12008-05-20 18:24:47 +00002455def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2456 (MOVZPQILo2PQIrm addr:$src)>;
2457}
2458
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002459//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002460// SSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002461//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002462
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002463// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002464def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002465 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002466 [(set VR128:$dst, (v4f32 (movshdup
2467 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002468def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002469 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002470 [(set VR128:$dst, (movshdup
2471 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002472
Evan Chengb783fa32007-07-19 01:14:50 +00002473def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002474 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002475 [(set VR128:$dst, (v4f32 (movsldup
2476 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002477def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002478 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002479 [(set VR128:$dst, (movsldup
2480 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002481
Evan Chengb783fa32007-07-19 01:14:50 +00002482def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002483 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002484 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002485def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002486 "movddup\t{$src, $dst|$dst, $src}",
Evan Chenga2497eb2008-09-25 20:50:48 +00002487 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002488 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2489 (undef))))]>;
Evan Chenga2497eb2008-09-25 20:50:48 +00002490
Nate Begeman543d2142009-04-27 18:41:29 +00002491def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2492 (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002493 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002494
2495let AddedComplexity = 5 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002496def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002497 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002498def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2499 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2500def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2501 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2502def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2503 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2504}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002505
2506// Arithmetic
Evan Cheng3ea4d672008-03-05 08:19:16 +00002507let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002508 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002509 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002510 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002511 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2512 VR128:$src2))]>;
2513 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002514 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002515 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002516 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002517 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002518 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002519 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002520 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002521 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2522 VR128:$src2))]>;
2523 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002524 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002525 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002526 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002527 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002528}
2529
Evan Chengb783fa32007-07-19 01:14:50 +00002530def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002531 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002532 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2533
2534// Horizontal ops
2535class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002536 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002537 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002538 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2539class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002540 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002541 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002542 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002543class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002544 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002545 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002546 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2547class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002548 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002549 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002550 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002551
Evan Cheng3ea4d672008-03-05 08:19:16 +00002552let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002553 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2554 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2555 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2556 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2557 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2558 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2559 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2560 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2561}
2562
2563// Thread synchronization
Bill Wendling6ee76552009-05-28 23:40:46 +00002564def MONITOR : I<0x01, MRM1r, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002565 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Bill Wendling6ee76552009-05-28 23:40:46 +00002566def MWAIT : I<0x01, MRM1r, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002567 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2568
2569// vector_shuffle v1, <undef> <1, 1, 3, 3>
2570let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002571def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002572 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2573let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002574def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002575 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2576
2577// vector_shuffle v1, <undef> <0, 0, 2, 2>
2578let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002579 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002580 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2581let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002582 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2584
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002585//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002586// SSSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002587//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002588
Bill Wendling98680292007-08-10 06:22:27 +00002589/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002590multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2591 Intrinsic IntId64, Intrinsic IntId128> {
2592 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2593 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2594 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002595
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002596 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2597 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2598 [(set VR64:$dst,
2599 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2600
2601 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2602 (ins VR128:$src),
2603 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2604 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2605 OpSize;
2606
2607 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2608 (ins i128mem:$src),
2609 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2610 [(set VR128:$dst,
2611 (IntId128
2612 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613}
2614
Bill Wendling98680292007-08-10 06:22:27 +00002615/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002616multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2617 Intrinsic IntId64, Intrinsic IntId128> {
2618 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2619 (ins VR64:$src),
2620 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2621 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002622
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002623 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2624 (ins i64mem:$src),
2625 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2626 [(set VR64:$dst,
2627 (IntId64
2628 (bitconvert (memopv4i16 addr:$src))))]>;
2629
2630 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2631 (ins VR128:$src),
2632 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2633 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2634 OpSize;
2635
2636 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2637 (ins i128mem:$src),
2638 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2639 [(set VR128:$dst,
2640 (IntId128
2641 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002642}
2643
2644/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002645multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2646 Intrinsic IntId64, Intrinsic IntId128> {
2647 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2648 (ins VR64:$src),
2649 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2650 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002651
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002652 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2653 (ins i64mem:$src),
2654 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2655 [(set VR64:$dst,
2656 (IntId64
2657 (bitconvert (memopv2i32 addr:$src))))]>;
2658
2659 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2660 (ins VR128:$src),
2661 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2662 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2663 OpSize;
2664
2665 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2666 (ins i128mem:$src),
2667 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2668 [(set VR128:$dst,
2669 (IntId128
2670 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002671}
2672
2673defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2674 int_x86_ssse3_pabs_b,
2675 int_x86_ssse3_pabs_b_128>;
2676defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2677 int_x86_ssse3_pabs_w,
2678 int_x86_ssse3_pabs_w_128>;
2679defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2680 int_x86_ssse3_pabs_d,
2681 int_x86_ssse3_pabs_d_128>;
2682
2683/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002684let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002685 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2686 Intrinsic IntId64, Intrinsic IntId128,
2687 bit Commutable = 0> {
2688 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2689 (ins VR64:$src1, VR64:$src2),
2690 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2691 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2692 let isCommutable = Commutable;
2693 }
2694 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2695 (ins VR64:$src1, i64mem:$src2),
2696 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2697 [(set VR64:$dst,
2698 (IntId64 VR64:$src1,
2699 (bitconvert (memopv8i8 addr:$src2))))]>;
2700
2701 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2702 (ins VR128:$src1, VR128:$src2),
2703 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2704 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2705 OpSize {
2706 let isCommutable = Commutable;
2707 }
2708 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2709 (ins VR128:$src1, i128mem:$src2),
2710 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2711 [(set VR128:$dst,
2712 (IntId128 VR128:$src1,
2713 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2714 }
2715}
2716
2717/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002718let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002719 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2720 Intrinsic IntId64, Intrinsic IntId128,
2721 bit Commutable = 0> {
2722 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2723 (ins VR64:$src1, VR64:$src2),
2724 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2725 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2726 let isCommutable = Commutable;
2727 }
2728 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2729 (ins VR64:$src1, i64mem:$src2),
2730 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2731 [(set VR64:$dst,
2732 (IntId64 VR64:$src1,
2733 (bitconvert (memopv4i16 addr:$src2))))]>;
2734
2735 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2736 (ins VR128:$src1, VR128:$src2),
2737 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2738 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2739 OpSize {
2740 let isCommutable = Commutable;
2741 }
2742 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2743 (ins VR128:$src1, i128mem:$src2),
2744 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2745 [(set VR128:$dst,
2746 (IntId128 VR128:$src1,
2747 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2748 }
2749}
2750
2751/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002752let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002753 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2754 Intrinsic IntId64, Intrinsic IntId128,
2755 bit Commutable = 0> {
2756 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2757 (ins VR64:$src1, VR64:$src2),
2758 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2759 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2760 let isCommutable = Commutable;
2761 }
2762 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2763 (ins VR64:$src1, i64mem:$src2),
2764 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2765 [(set VR64:$dst,
2766 (IntId64 VR64:$src1,
2767 (bitconvert (memopv2i32 addr:$src2))))]>;
2768
2769 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2770 (ins VR128:$src1, VR128:$src2),
2771 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2772 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2773 OpSize {
2774 let isCommutable = Commutable;
2775 }
2776 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2777 (ins VR128:$src1, i128mem:$src2),
2778 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2779 [(set VR128:$dst,
2780 (IntId128 VR128:$src1,
2781 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2782 }
2783}
2784
2785defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2786 int_x86_ssse3_phadd_w,
Evan Cheng944e4412008-06-16 21:16:24 +00002787 int_x86_ssse3_phadd_w_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002788defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2789 int_x86_ssse3_phadd_d,
Evan Cheng944e4412008-06-16 21:16:24 +00002790 int_x86_ssse3_phadd_d_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002791defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2792 int_x86_ssse3_phadd_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002793 int_x86_ssse3_phadd_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002794defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2795 int_x86_ssse3_phsub_w,
2796 int_x86_ssse3_phsub_w_128>;
2797defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2798 int_x86_ssse3_phsub_d,
2799 int_x86_ssse3_phsub_d_128>;
2800defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2801 int_x86_ssse3_phsub_sw,
2802 int_x86_ssse3_phsub_sw_128>;
2803defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2804 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002805 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002806defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2807 int_x86_ssse3_pmul_hr_sw,
2808 int_x86_ssse3_pmul_hr_sw_128, 1>;
2809defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2810 int_x86_ssse3_pshuf_b,
2811 int_x86_ssse3_pshuf_b_128>;
2812defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2813 int_x86_ssse3_psign_b,
2814 int_x86_ssse3_psign_b_128>;
2815defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2816 int_x86_ssse3_psign_w,
2817 int_x86_ssse3_psign_w_128>;
Evan Chengabfed472009-05-28 18:48:53 +00002818defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling98680292007-08-10 06:22:27 +00002819 int_x86_ssse3_psign_d,
2820 int_x86_ssse3_psign_d_128>;
2821
Evan Cheng3ea4d672008-03-05 08:19:16 +00002822let Constraints = "$src1 = $dst" in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002823 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2824 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002825 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002826 []>;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002827 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Bill Wendling1dc817c2007-08-10 09:00:17 +00002828 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002829 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002830 []>;
Bill Wendling98680292007-08-10 06:22:27 +00002831
Bill Wendling1dc817c2007-08-10 09:00:17 +00002832 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2833 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002834 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002835 []>, OpSize;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002836 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Bill Wendling1dc817c2007-08-10 09:00:17 +00002837 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002838 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002839 []>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002840}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002841
Nate Begeman080f8e22009-10-19 02:17:23 +00002842// palignr patterns.
Evan Cheng06cd2072009-10-28 06:30:34 +00002843def : Pat<(int_x86_ssse3_palign_r VR64:$src1, VR64:$src2, (i16 imm:$src3)),
2844 (PALIGNR64rr VR64:$src1, VR64:$src2, (BYTE_imm imm:$src3))>,
2845 Requires<[HasSSSE3]>;
2846def : Pat<(int_x86_ssse3_palign_r VR64:$src1,
2847 (memop64 addr:$src2),
2848 (i16 imm:$src3)),
2849 (PALIGNR64rm VR64:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2850 Requires<[HasSSSE3]>;
2851
2852def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1, VR128:$src2, (i32 imm:$src3)),
2853 (PALIGNR128rr VR128:$src1, VR128:$src2, (BYTE_imm imm:$src3))>,
2854 Requires<[HasSSSE3]>;
2855def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1,
2856 (memopv2i64 addr:$src2),
2857 (i32 imm:$src3)),
2858 (PALIGNR128rm VR128:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2859 Requires<[HasSSSE3]>;
2860
Nate Begeman080f8e22009-10-19 02:17:23 +00002861let AddedComplexity = 5 in {
2862def : Pat<(v4i32 (palign:$src3 VR128:$src1, VR128:$src2)),
2863 (PALIGNR128rr VR128:$src2, VR128:$src1,
2864 (SHUFFLE_get_palign_imm VR128:$src3))>,
2865 Requires<[HasSSSE3]>;
2866def : Pat<(v4f32 (palign:$src3 VR128:$src1, VR128:$src2)),
2867 (PALIGNR128rr VR128:$src2, VR128:$src1,
2868 (SHUFFLE_get_palign_imm VR128:$src3))>,
2869 Requires<[HasSSSE3]>;
2870def : Pat<(v8i16 (palign:$src3 VR128:$src1, VR128:$src2)),
2871 (PALIGNR128rr VR128:$src2, VR128:$src1,
2872 (SHUFFLE_get_palign_imm VR128:$src3))>,
2873 Requires<[HasSSSE3]>;
2874def : Pat<(v16i8 (palign:$src3 VR128:$src1, VR128:$src2)),
2875 (PALIGNR128rr VR128:$src2, VR128:$src1,
2876 (SHUFFLE_get_palign_imm VR128:$src3))>,
2877 Requires<[HasSSSE3]>;
2878}
2879
Nate Begeman2c87c422009-02-23 08:49:38 +00002880def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2881 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2882def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2883 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2884
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002885//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002886// Non-Instruction Patterns
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002887//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002888
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002889// extload f32 -> f64. This matches load+fextend because we have a hack in
2890// the isel (PreprocessForFPConvert) that can introduce loads after dag
2891// combine.
Chris Lattnerdec9cb52008-01-24 08:07:48 +00002892// Since these loads aren't folded into the fextend, we have to match it
2893// explicitly here.
2894let Predicates = [HasSSE2] in
2895 def : Pat<(fextend (loadf32 addr:$src)),
2896 (CVTSS2SDrm addr:$src)>;
2897
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002898// bit_convert
2899let Predicates = [HasSSE2] in {
2900 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2901 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2902 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2903 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2904 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2905 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2906 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2907 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2908 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2909 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2910 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2911 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2912 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2913 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2914 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2915 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2916 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2917 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2918 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2919 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2920 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2921 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2922 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2923 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2924 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2925 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2926 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2927 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2928 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2929 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2930}
2931
2932// Move scalar to XMM zero-extended
2933// movd to XMM register zero-extends
2934let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002935// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chenge9b9c672008-05-09 21:53:03 +00002936def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002938def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002939 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>;
Evan Chenge259e872008-05-09 23:37:55 +00002940def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002941 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Evan Cheng7fe0ff02008-07-10 01:08:23 +00002942def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002943 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002944}
2945
2946// Splat v2f64 / v2i64
2947let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002948def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002949 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002950def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002951 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002952def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002953 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002954def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002955 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2956}
2957
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002958// Special unary SHUFPSrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00002959def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
2960 (SHUFPSrri VR128:$src1, VR128:$src1,
2961 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002962 Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002963let AddedComplexity = 5 in
2964def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
2965 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2966 Requires<[HasSSE2]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002967// Special unary SHUFPDrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00002968def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002969 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002970 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2971 Requires<[HasSSE2]>;
2972// Special unary SHUFPDrri case.
2973def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002974 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002975 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7dc19012007-08-02 21:17:01 +00002976 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002977// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman543d2142009-04-27 18:41:29 +00002978def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
2979 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002980 Requires<[HasSSE2]>;
Evan Cheng13559d62008-09-26 23:41:32 +00002981
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002982// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman543d2142009-04-27 18:41:29 +00002983def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002984 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002985 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002986 Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002987def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002988 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002989 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002990 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002991// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman543d2142009-04-27 18:41:29 +00002992def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002993 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002994 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002995 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002996
2997// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00002998let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002999def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
3000 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003001 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003002def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
3003 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003004 Requires<[OptForSpeed, HasSSE2]>;
3005}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003006let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003007def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003008 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003009def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003010 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003011def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003012 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003013def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003014 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003015}
3016
3017// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00003018let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003019def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
3020 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003021 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003022def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
3023 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003024 Requires<[OptForSpeed, HasSSE2]>;
3025}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003026let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003027def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003028 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003029def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003030 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003031def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003032 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003033def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003034 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003035}
3036
Evan Cheng13559d62008-09-26 23:41:32 +00003037let AddedComplexity = 20 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003038// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begeman543d2142009-04-27 18:41:29 +00003039def : Pat<(v4i32 (movhp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003040 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
3041
3042// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003043def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003044 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
3045
3046// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003047def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003048 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman543d2142009-04-27 18:41:29 +00003049def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003050 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
3051}
3052
3053let AddedComplexity = 20 in {
3054// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
3055// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Nate Begeman543d2142009-04-27 18:41:29 +00003056def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003057 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003058def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003059 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003060def : Pat<(v4f32 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003061 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003062def : Pat<(v2f64 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003063 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3064
Nate Begeman543d2142009-04-27 18:41:29 +00003065def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003066 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003067def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003068 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003069def : Pat<(v4i32 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003070 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003071def : Pat<(v2i64 (movhp VR128:$src1, (load addr:$src2))),
Evan Cheng1ff2ea52008-05-23 18:00:18 +00003072 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003073}
3074
Evan Cheng2b2a7012008-05-23 21:23:16 +00003075// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
3076// (store (vector_shuffle (load addr), v2, <0, 1, 4, 5>), addr) using MOVHPS
Nate Begeman543d2142009-04-27 18:41:29 +00003077def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003078 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003079def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003080 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003081def : Pat<(store (v4f32 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003082 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003083def : Pat<(store (v2f64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003084 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3085
Nate Begeman543d2142009-04-27 18:41:29 +00003086def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3087 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003088 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003089def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003090 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003091def : Pat<(store (v4i32 (movhp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3092 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003093 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003094def : Pat<(store (v2i64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003095 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3096
3097
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003098let AddedComplexity = 15 in {
3099// Setting the lowest element in the vector.
Nate Begeman543d2142009-04-27 18:41:29 +00003100def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003101 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003102def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003103 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3104
3105// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
Nate Begeman543d2142009-04-27 18:41:29 +00003106def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003107 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003108def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3110}
3111
Eli Friedman27d19742009-06-19 07:00:55 +00003112// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3113// fall back to this for SSE1)
3114def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003115 (SHUFPSrri VR128:$src2, VR128:$src1,
Eli Friedman27d19742009-06-19 07:00:55 +00003116 (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>;
3117
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003118// Set lowest element and zero upper elements.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003119let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00003120def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003121 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00003122def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengd09a8a02008-05-08 22:35:02 +00003123 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003124
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003125// Some special case pandn patterns.
3126def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3127 VR128:$src2)),
3128 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3129def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3130 VR128:$src2)),
3131 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3132def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3133 VR128:$src2)),
3134 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3135
3136def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003137 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003138 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3139def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003140 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003141 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3142def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003143 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003144 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3145
Nate Begeman78246ca2007-11-17 03:58:34 +00003146// vector -> vector casts
3147def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3148 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3149def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3150 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedman7fa52ca2008-09-05 23:07:03 +00003151def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3152 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3153def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3154 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman78246ca2007-11-17 03:58:34 +00003155
Evan Cheng51a49b22007-07-20 00:27:43 +00003156// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00003157def : Pat<(alignedloadv4i32 addr:$src),
3158 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3159def : Pat<(loadv4i32 addr:$src),
3160 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00003161def : Pat<(alignedloadv2i64 addr:$src),
3162 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3163def : Pat<(loadv2i64 addr:$src),
3164 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3165
3166def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3167 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3168def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3169 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3170def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3171 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3172def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3173 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3174def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3175 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3176def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3177 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3178def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3179 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3180def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3181 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003182
Nate Begemanb2975562008-02-03 07:18:54 +00003183//===----------------------------------------------------------------------===//
3184// SSE4.1 Instructions
3185//===----------------------------------------------------------------------===//
3186
Dale Johannesena7d2b442008-10-10 23:51:03 +00003187multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begemanb2975562008-02-03 07:18:54 +00003188 string OpcodeStr,
Nate Begemanb2975562008-02-03 07:18:54 +00003189 Intrinsic V4F32Int,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003190 Intrinsic V2F64Int> {
Nate Begemanb2975562008-02-03 07:18:54 +00003191 // Intrinsic operation, reg.
Nate Begemanb2975562008-02-03 07:18:54 +00003192 // Vector intrinsic operation, reg
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003193 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003194 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003195 !strconcat(OpcodeStr,
3196 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003197 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3198 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003199
3200 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003201 def PSm_Int : SS4AIi8<opcps, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003202 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003203 !strconcat(OpcodeStr,
3204 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003205 [(set VR128:$dst,
3206 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003207 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003208
Nate Begemanb2975562008-02-03 07:18:54 +00003209 // Vector intrinsic operation, reg
Evan Cheng78d00612008-03-14 07:39:27 +00003210 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003211 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003212 !strconcat(OpcodeStr,
3213 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003214 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3215 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003216
3217 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003218 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003219 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003220 !strconcat(OpcodeStr,
3221 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003222 [(set VR128:$dst,
3223 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003224 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003225}
3226
Dale Johannesena7d2b442008-10-10 23:51:03 +00003227let Constraints = "$src1 = $dst" in {
3228multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3229 string OpcodeStr,
3230 Intrinsic F32Int,
3231 Intrinsic F64Int> {
3232 // Intrinsic operation, reg.
3233 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003234 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003235 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3236 !strconcat(OpcodeStr,
3237 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003238 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003239 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3240 OpSize;
3241
3242 // Intrinsic operation, mem.
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003243 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3244 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003245 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003246 !strconcat(OpcodeStr,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003247 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003248 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003249 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3250 OpSize;
3251
3252 // Intrinsic operation, reg.
3253 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003254 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003255 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3256 !strconcat(OpcodeStr,
3257 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003258 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003259 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3260 OpSize;
3261
3262 // Intrinsic operation, mem.
3263 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003264 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003265 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3266 !strconcat(OpcodeStr,
3267 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003268 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003269 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3270 OpSize;
3271}
3272}
3273
Nate Begemanb2975562008-02-03 07:18:54 +00003274// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesena7d2b442008-10-10 23:51:03 +00003275defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3276 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3277defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3278 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003279
3280// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3281multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3282 Intrinsic IntId128> {
3283 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3284 (ins VR128:$src),
3285 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3286 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3287 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3288 (ins i128mem:$src),
3289 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3290 [(set VR128:$dst,
3291 (IntId128
3292 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3293}
3294
3295defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3296 int_x86_sse41_phminposuw>;
3297
3298/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003299let Constraints = "$src1 = $dst" in {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003300 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3301 Intrinsic IntId128, bit Commutable = 0> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003302 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3303 (ins VR128:$src1, VR128:$src2),
3304 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3305 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3306 OpSize {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003307 let isCommutable = Commutable;
3308 }
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003309 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3310 (ins VR128:$src1, i128mem:$src2),
3311 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3312 [(set VR128:$dst,
3313 (IntId128 VR128:$src1,
3314 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003315 }
3316}
3317
3318defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3319 int_x86_sse41_pcmpeqq, 1>;
3320defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3321 int_x86_sse41_packusdw, 0>;
3322defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3323 int_x86_sse41_pminsb, 1>;
3324defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3325 int_x86_sse41_pminsd, 1>;
3326defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3327 int_x86_sse41_pminud, 1>;
3328defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3329 int_x86_sse41_pminuw, 1>;
3330defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3331 int_x86_sse41_pmaxsb, 1>;
3332defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3333 int_x86_sse41_pmaxsd, 1>;
3334defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3335 int_x86_sse41_pmaxud, 1>;
3336defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3337 int_x86_sse41_pmaxuw, 1>;
Nate Begeman72d802a2008-02-04 06:00:24 +00003338
Mon P Wang14edb092008-12-18 21:42:19 +00003339defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3340
Nate Begeman03605a02008-07-17 16:51:19 +00003341def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3342 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3343def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3344 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3345
Nate Begeman58057962008-02-09 01:38:08 +00003346/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003347let Constraints = "$src1 = $dst" in {
Dan Gohmane3731f52008-05-23 17:49:40 +00003348 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3349 SDNode OpNode, Intrinsic IntId128,
3350 bit Commutable = 0> {
Nate Begeman58057962008-02-09 01:38:08 +00003351 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3352 (ins VR128:$src1, VR128:$src2),
3353 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmane3731f52008-05-23 17:49:40 +00003354 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3355 VR128:$src2))]>, OpSize {
Nate Begeman58057962008-02-09 01:38:08 +00003356 let isCommutable = Commutable;
3357 }
3358 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3359 (ins VR128:$src1, VR128:$src2),
3360 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3361 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3362 OpSize {
3363 let isCommutable = Commutable;
3364 }
3365 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3366 (ins VR128:$src1, i128mem:$src2),
3367 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3368 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003369 (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003370 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3371 (ins VR128:$src1, i128mem:$src2),
3372 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3373 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003374 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman58057962008-02-09 01:38:08 +00003375 OpSize;
3376 }
3377}
Dan Gohmane3731f52008-05-23 17:49:40 +00003378defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
Nate Begeman58057962008-02-09 01:38:08 +00003379 int_x86_sse41_pmulld, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003380
Evan Cheng78d00612008-03-14 07:39:27 +00003381/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Cheng3ea4d672008-03-05 08:19:16 +00003382let Constraints = "$src1 = $dst" in {
Nate Begeman72d802a2008-02-04 06:00:24 +00003383 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3384 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng78d00612008-03-14 07:39:27 +00003385 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003386 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003387 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003388 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003389 [(set VR128:$dst,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003390 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3391 OpSize {
Nate Begeman72d802a2008-02-04 06:00:24 +00003392 let isCommutable = Commutable;
3393 }
Evan Cheng78d00612008-03-14 07:39:27 +00003394 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003395 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3396 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003397 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003398 [(set VR128:$dst,
3399 (IntId128 VR128:$src1,
3400 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3401 OpSize;
Nate Begeman72d802a2008-02-04 06:00:24 +00003402 }
3403}
3404
3405defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3406 int_x86_sse41_blendps, 0>;
3407defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3408 int_x86_sse41_blendpd, 0>;
3409defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3410 int_x86_sse41_pblendw, 0>;
3411defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3412 int_x86_sse41_dpps, 1>;
3413defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3414 int_x86_sse41_dppd, 1>;
3415defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng81ed9852008-06-16 20:25:59 +00003416 int_x86_sse41_mpsadbw, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003417
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003418
Evan Cheng78d00612008-03-14 07:39:27 +00003419/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003420let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanb4e9a042008-02-10 18:47:57 +00003421 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3422 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3423 (ins VR128:$src1, VR128:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003424 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003425 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3426 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3427 OpSize;
3428
3429 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3430 (ins VR128:$src1, i128mem:$src2),
3431 !strconcat(OpcodeStr,
3432 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3433 [(set VR128:$dst,
3434 (IntId VR128:$src1,
3435 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3436 }
3437}
3438
3439defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3440defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3441defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3442
3443
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003444multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3445 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3446 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3447 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3448
3449 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3450 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003451 [(set VR128:$dst,
3452 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3453 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003454}
3455
3456defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3457defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3458defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3459defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3460defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3461defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3462
Evan Cheng56ec77b2008-09-24 23:27:55 +00003463// Common patterns involving scalar load.
3464def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3465 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3466def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3467 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3468
3469def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3470 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3471def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3472 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3473
3474def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3475 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3476def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3477 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3478
3479def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3480 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3481def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3482 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3483
3484def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3485 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3486def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3487 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3488
3489def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3490 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3491def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3492 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3493
3494
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003495multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3496 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3497 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3498 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3499
3500 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3501 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003502 [(set VR128:$dst,
3503 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3504 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003505}
3506
3507defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3508defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3509defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3510defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3511
Evan Cheng56ec77b2008-09-24 23:27:55 +00003512// Common patterns involving scalar load
3513def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003514 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003515def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003516 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003517
3518def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003519 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003520def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003521 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003522
3523
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003524multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3525 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3526 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3527 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3528
Evan Cheng56ec77b2008-09-24 23:27:55 +00003529 // Expecting a i16 load any extended to i32 value.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003530 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3531 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003532 [(set VR128:$dst, (IntId (bitconvert
3533 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3534 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003535}
3536
3537defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman75a89d62009-06-06 05:55:37 +00003538defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003539
Evan Cheng56ec77b2008-09-24 23:27:55 +00003540// Common patterns involving scalar load
3541def : Pat<(int_x86_sse41_pmovsxbq
3542 (bitconvert (v4i32 (X86vzmovl
3543 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003544 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003545
3546def : Pat<(int_x86_sse41_pmovzxbq
3547 (bitconvert (v4i32 (X86vzmovl
3548 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003549 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003550
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003551
Nate Begemand77e59e2008-02-11 04:19:36 +00003552/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3553multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003554 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003555 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003556 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003557 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003558 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3559 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003560 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003561 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003562 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003563 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003564 []>, OpSize;
3565// FIXME:
3566// There's an AssertZext in the way of writing the store pattern
3567// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003568}
3569
Nate Begemand77e59e2008-02-11 04:19:36 +00003570defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003571
Nate Begemand77e59e2008-02-11 04:19:36 +00003572
3573/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3574multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003575 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemand77e59e2008-02-11 04:19:36 +00003576 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003577 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003578 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3579 []>, OpSize;
3580// FIXME:
3581// There's an AssertZext in the way of writing the store pattern
3582// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3583}
3584
3585defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3586
3587
3588/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3589multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003590 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003591 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003592 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003593 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3594 [(set GR32:$dst,
3595 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003596 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003597 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003598 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003599 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3600 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3601 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003602}
3603
Nate Begemand77e59e2008-02-11 04:19:36 +00003604defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman58057962008-02-09 01:38:08 +00003605
Nate Begemand77e59e2008-02-11 04:19:36 +00003606
Evan Cheng6c249332008-03-24 21:52:23 +00003607/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3608/// destination
Nate Begemand77e59e2008-02-11 04:19:36 +00003609multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003610 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003611 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003612 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003613 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman788db592008-04-16 02:32:24 +00003614 [(set GR32:$dst,
3615 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng6c249332008-03-24 21:52:23 +00003616 OpSize;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003617 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003618 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003619 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003620 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng6c249332008-03-24 21:52:23 +00003621 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003622 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003623}
3624
Nate Begemand77e59e2008-02-11 04:19:36 +00003625defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003626
Dan Gohmana41862a2008-08-08 18:30:21 +00003627// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3628def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3629 imm:$src2))),
3630 addr:$dst),
3631 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3632 Requires<[HasSSE41]>;
3633
Evan Cheng3ea4d672008-03-05 08:19:16 +00003634let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003635 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003636 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003637 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003638 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003639 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003640 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003641 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003642 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003643 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3644 !strconcat(OpcodeStr,
3645 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003646 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003647 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3648 imm:$src3))]>, OpSize;
3649 }
3650}
3651
3652defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3653
Evan Cheng3ea4d672008-03-05 08:19:16 +00003654let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003655 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003656 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003657 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003658 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003659 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003660 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003661 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3662 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003663 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003664 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3665 !strconcat(OpcodeStr,
3666 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003667 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003668 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3669 imm:$src3)))]>, OpSize;
3670 }
3671}
3672
3673defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3674
Eric Christophera0443602009-07-23 02:22:41 +00003675// insertps has a few different modes, there's the first two here below which
3676// are optimized inserts that won't zero arbitrary elements in the destination
3677// vector. The next one matches the intrinsic and could zero arbitrary elements
3678// in the target vector.
Evan Cheng3ea4d672008-03-05 08:19:16 +00003679let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003680 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherefb657e2009-07-24 00:33:09 +00003681 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3682 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003683 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003684 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003685 [(set VR128:$dst,
3686 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
3687 OpSize;
Eric Christopherefb657e2009-07-24 00:33:09 +00003688 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003689 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3690 !strconcat(OpcodeStr,
3691 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003692 [(set VR128:$dst,
Eric Christopherefb657e2009-07-24 00:33:09 +00003693 (X86insrtps VR128:$src1,
3694 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begemand77e59e2008-02-11 04:19:36 +00003695 imm:$src3))]>, OpSize;
3696 }
3697}
3698
Evan Chengc2054be2008-03-26 08:11:49 +00003699defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003700
Eric Christopherefb657e2009-07-24 00:33:09 +00003701def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3702 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3703
Eric Christopher95d79262009-07-29 00:28:05 +00003704// ptest instruction we'll lower to this in X86ISelLowering primarily from
3705// the intel intrinsic that corresponds to this.
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003706let Defs = [EFLAGS] in {
3707def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003708 "ptest \t{$src2, $src1|$src1, $src2}",
3709 [(X86ptest VR128:$src1, VR128:$src2),
3710 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003711def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003712 "ptest \t{$src2, $src1|$src1, $src2}",
3713 [(X86ptest VR128:$src1, (load addr:$src2)),
3714 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003715}
3716
3717def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3718 "movntdqa\t{$src, $dst|$dst, $src}",
3719 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>;
Nate Begeman03605a02008-07-17 16:51:19 +00003720
Eric Christopher22a39402009-08-18 22:50:32 +00003721
3722//===----------------------------------------------------------------------===//
3723// SSE4.2 Instructions
3724//===----------------------------------------------------------------------===//
3725
Nate Begeman03605a02008-07-17 16:51:19 +00003726/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3727let Constraints = "$src1 = $dst" in {
3728 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3729 Intrinsic IntId128, bit Commutable = 0> {
3730 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3731 (ins VR128:$src1, VR128:$src2),
3732 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3733 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3734 OpSize {
3735 let isCommutable = Commutable;
3736 }
3737 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3738 (ins VR128:$src1, i128mem:$src2),
3739 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3740 [(set VR128:$dst,
3741 (IntId128 VR128:$src1,
3742 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3743 }
3744}
3745
Nate Begeman235666b2008-07-17 17:04:58 +00003746defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman03605a02008-07-17 16:51:19 +00003747
3748def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3749 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3750def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3751 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003752
3753// crc intrinsic instruction
3754// This set of instructions are only rm, the only difference is the size
3755// of r and m.
3756let Constraints = "$src1 = $dst" in {
Eric Christopher85f187b2009-08-10 21:48:58 +00003757 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003758 (ins GR32:$src1, i8mem:$src2),
3759 "crc32 \t{$src2, $src1|$src1, $src2}",
3760 [(set GR32:$dst,
3761 (int_x86_sse42_crc32_8 GR32:$src1,
3762 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003763 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003764 (ins GR32:$src1, GR8:$src2),
3765 "crc32 \t{$src2, $src1|$src1, $src2}",
3766 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003767 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003768 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003769 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003770 (ins GR32:$src1, i16mem:$src2),
3771 "crc32 \t{$src2, $src1|$src1, $src2}",
3772 [(set GR32:$dst,
3773 (int_x86_sse42_crc32_16 GR32:$src1,
3774 (load addr:$src2)))]>,
3775 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003776 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003777 (ins GR32:$src1, GR16:$src2),
3778 "crc32 \t{$src2, $src1|$src1, $src2}",
3779 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003780 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003781 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003782 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003783 (ins GR32:$src1, i32mem:$src2),
3784 "crc32 \t{$src2, $src1|$src1, $src2}",
3785 [(set GR32:$dst,
3786 (int_x86_sse42_crc32_32 GR32:$src1,
3787 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003788 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003789 (ins GR32:$src1, GR32:$src2),
3790 "crc32 \t{$src2, $src1|$src1, $src2}",
3791 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003792 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003793 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003794 def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003795 (ins GR64:$src1, i64mem:$src2),
3796 "crc32 \t{$src2, $src1|$src1, $src2}",
3797 [(set GR64:$dst,
3798 (int_x86_sse42_crc32_64 GR64:$src1,
3799 (load addr:$src2)))]>,
3800 OpSize, REX_W;
Eric Christopher85f187b2009-08-10 21:48:58 +00003801 def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003802 (ins GR64:$src1, GR64:$src2),
3803 "crc32 \t{$src2, $src1|$src1, $src2}",
3804 [(set GR64:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003805 (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003806 OpSize, REX_W;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003807}
Eric Christopher22a39402009-08-18 22:50:32 +00003808
3809// String/text processing instructions.
3810let Defs = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
3811def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
3812 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3813 "#PCMPISTRM128rr PSEUDO!",
3814 [(set VR128:$dst,
3815 (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
3816 imm:$src3))]>, OpSize;
3817def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
3818 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3819 "#PCMPISTRM128rm PSEUDO!",
3820 [(set VR128:$dst,
3821 (int_x86_sse42_pcmpistrm128 VR128:$src1,
3822 (load addr:$src2),
3823 imm:$src3))]>, OpSize;
3824}
3825
3826let Defs = [XMM0, EFLAGS] in {
3827def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
3828 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3829 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3830 []>, OpSize;
3831def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
3832 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3833 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3834 []>, OpSize;
3835}
3836
3837let Defs = [EFLAGS], Uses = [EAX, EDX],
3838 usesCustomDAGSchedInserter = 1 in {
3839def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
3840 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3841 "#PCMPESTRM128rr PSEUDO!",
3842 [(set VR128:$dst,
3843 (int_x86_sse42_pcmpestrm128 VR128:$src1, EAX,
3844 VR128:$src3,
3845 EDX, imm:$src5))]>, OpSize;
3846def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
3847 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3848 "#PCMPESTRM128rm PSEUDO!",
3849 [(set VR128:$dst,
3850 (int_x86_sse42_pcmpestrm128 VR128:$src1, EAX,
3851 (load addr:$src3),
3852 EDX, imm:$src5))]>, OpSize;
3853}
3854
3855let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
Sean Callananc5a05b72009-08-20 18:24:27 +00003856def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
Eric Christopher22a39402009-08-18 22:50:32 +00003857 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3858 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3859 []>, OpSize;
Sean Callananc5a05b72009-08-20 18:24:27 +00003860def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
Eric Christopher22a39402009-08-18 22:50:32 +00003861 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3862 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3863 []>, OpSize;
3864}
3865
3866let Defs = [ECX, EFLAGS] in {
3867 multiclass SS42AI_pcmpistri<Intrinsic IntId128> {
3868 def rr : SS42AI<0x63, MRMSrcReg, (outs),
3869 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3870 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3871 [(set ECX,
3872 (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
3873 (implicit EFLAGS)]>,
3874 OpSize;
3875 def rm : SS42AI<0x63, MRMSrcMem, (outs),
3876 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3877 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3878 [(set ECX,
3879 (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
3880 (implicit EFLAGS)]>,
3881 OpSize;
3882 }
3883}
3884
3885defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
3886defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
3887defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
3888defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
3889defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
3890defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
3891
3892let Defs = [ECX, EFLAGS] in {
3893let Uses = [EAX, EDX] in {
3894 multiclass SS42AI_pcmpestri<Intrinsic IntId128> {
3895 def rr : SS42AI<0x61, MRMSrcReg, (outs),
3896 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3897 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3898 [(set ECX,
3899 (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
3900 (implicit EFLAGS)]>,
3901 OpSize;
3902 def rm : SS42AI<0x61, MRMSrcMem, (outs),
3903 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3904 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3905 [(set ECX,
3906 (IntId128 VR128:$src1, EAX, (load addr:$src3),
3907 EDX, imm:$src5)),
3908 (implicit EFLAGS)]>,
3909 OpSize;
3910 }
3911}
3912}
3913
3914defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
3915defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
3916defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
3917defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
3918defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
3919defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;