blob: da09a936303724d1cd07834a7fc497e760b8c510 [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
177def PSxLDQ_imm : SDNodeXForm<imm, [{
178 // Transformation function: imm >> 3
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000179 return getI32Imm(N->getZExtValue() >> 3);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000180}]>;
181
182// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
183// SHUFP* etc. imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000184def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 return getI8Imm(X86::getShuffleSHUFImmediate(N));
186}]>;
187
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000188// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189// PSHUFHW imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000190def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
192}]>;
193
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000194// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195// PSHUFLW imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000196def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000197 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
198}]>;
199
Nate Begeman543d2142009-04-27 18:41:29 +0000200def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
201 (vector_shuffle node:$lhs, node:$rhs), [{
202 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
203 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
204}]>;
205
206def movddup : PatFrag<(ops node:$lhs, node:$rhs),
207 (vector_shuffle node:$lhs, node:$rhs), [{
208 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
209}]>;
210
211def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
212 (vector_shuffle node:$lhs, node:$rhs), [{
213 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
214}]>;
215
216def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
217 (vector_shuffle node:$lhs, node:$rhs), [{
218 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
219}]>;
220
221def movhp : PatFrag<(ops node:$lhs, node:$rhs),
222 (vector_shuffle node:$lhs, node:$rhs), [{
223 return X86::isMOVHPMask(cast<ShuffleVectorSDNode>(N));
224}]>;
225
226def movlp : PatFrag<(ops node:$lhs, node:$rhs),
227 (vector_shuffle node:$lhs, node:$rhs), [{
228 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
229}]>;
230
231def movl : PatFrag<(ops node:$lhs, node:$rhs),
232 (vector_shuffle node:$lhs, node:$rhs), [{
233 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
234}]>;
235
236def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
237 (vector_shuffle node:$lhs, node:$rhs), [{
238 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
239}]>;
240
241def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
242 (vector_shuffle node:$lhs, node:$rhs), [{
243 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
244}]>;
245
246def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
247 (vector_shuffle node:$lhs, node:$rhs), [{
248 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
249}]>;
250
251def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
252 (vector_shuffle node:$lhs, node:$rhs), [{
253 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
254}]>;
255
256def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
257 (vector_shuffle node:$lhs, node:$rhs), [{
258 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
259}]>;
260
261def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
262 (vector_shuffle node:$lhs, node:$rhs), [{
263 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
264}]>;
265
266def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
267 (vector_shuffle node:$lhs, node:$rhs), [{
268 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269}], SHUFFLE_get_shuf_imm>;
270
Nate Begeman543d2142009-04-27 18:41:29 +0000271def shufp : PatFrag<(ops node:$lhs, node:$rhs),
272 (vector_shuffle node:$lhs, node:$rhs), [{
273 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274}], SHUFFLE_get_shuf_imm>;
275
Nate Begeman543d2142009-04-27 18:41:29 +0000276def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
277 (vector_shuffle node:$lhs, node:$rhs), [{
278 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000279}], SHUFFLE_get_pshufhw_imm>;
280
Nate Begeman543d2142009-04-27 18:41:29 +0000281def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
282 (vector_shuffle node:$lhs, node:$rhs), [{
283 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284}], SHUFFLE_get_pshuflw_imm>;
285
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000286//===----------------------------------------------------------------------===//
287// SSE scalar FP Instructions
288//===----------------------------------------------------------------------===//
289
290// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
291// scheduler into a branch sequence.
Evan Cheng950aac02007-09-25 01:57:46 +0000292// These are expanded by the scheduler.
293let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294 def CMOV_FR32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000295 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000296 "#CMOV_FR32 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000297 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
298 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000299 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000300 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000301 "#CMOV_FR64 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000302 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
303 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000305 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306 "#CMOV_V4F32 PSEUDO!",
307 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000308 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
309 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310 def CMOV_V2F64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000311 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312 "#CMOV_V2F64 PSEUDO!",
313 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000314 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
315 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316 def CMOV_V2I64 : 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_V2I64 PSEUDO!",
319 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000320 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng950aac02007-09-25 01:57:46 +0000321 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322}
323
324//===----------------------------------------------------------------------===//
325// SSE1 Instructions
326//===----------------------------------------------------------------------===//
327
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000329let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000330def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000331 "movss\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000332let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000333def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000334 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000336def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000337 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000338 [(store FR32:$src, addr:$dst)]>;
339
340// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000341def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000342 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000343 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000344def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000345 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000347def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000348 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000350def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000351 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000352 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
353
354// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000355def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000356 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000358def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000359 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000360 [(set GR32:$dst, (int_x86_sse_cvtss2si
361 (load addr:$src)))]>;
362
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000363// Match intrinisics which expect MM and XMM operand(s).
364def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
365 "cvtps2pi\t{$src, $dst|$dst, $src}",
366 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
367def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
368 "cvtps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000369 [(set VR64:$dst, (int_x86_sse_cvtps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000370 (load addr:$src)))]>;
371def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
372 "cvttps2pi\t{$src, $dst|$dst, $src}",
373 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
374def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
375 "cvttps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000376 [(set VR64:$dst, (int_x86_sse_cvttps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000377 (load addr:$src)))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +0000378let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000379 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000380 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
381 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
382 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
383 VR64:$src2))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000384 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000385 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
386 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000387 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000388 (load addr:$src2)))]>;
389}
390
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000392def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000393 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394 [(set GR32:$dst,
395 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000396def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000397 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398 [(set GR32:$dst,
399 (int_x86_sse_cvttss2si(load addr:$src)))]>;
400
Evan Cheng3ea4d672008-03-05 08:19:16 +0000401let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000402 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000403 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000404 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
406 GR32:$src2))]>;
407 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000408 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000409 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
411 (loadi32 addr:$src2)))]>;
412}
413
414// Comparison instructions
Dan Gohmanf221da12009-01-09 02:27:34 +0000415let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000416 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000417 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000418 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000419let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000420 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000421 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000422 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423}
424
Evan Cheng55687072007-09-14 21:48:26 +0000425let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000426def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000427 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000428 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000429def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000430 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000431 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000432 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000433} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434
435// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +0000436let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000437 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
438 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
439 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000440 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000442 VR128:$src, imm:$cc))]>;
443 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
444 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src,
445 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000446 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000447 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
448 (load addr:$src), imm:$cc))]>;
449}
450
Evan Cheng55687072007-09-14 21:48:26 +0000451let Defs = [EFLAGS] in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000452def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000453 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000454 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000455 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000456def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000457 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000458 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000459 (implicit EFLAGS)]>;
460
Dan Gohmanf221da12009-01-09 02:27:34 +0000461def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000462 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000463 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000464 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000465def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000466 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000467 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000468 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000469} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000471// Aliases of packed SSE1 instructions for scalar use. These all have names
472// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473
474// Alias instructions that map fld0 to pxor for sse.
Daniel Dunbara0e62002009-08-11 22:17:52 +0000475let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000476def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000477 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478 Requires<[HasSSE1]>, TB, OpSize;
479
480// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
481// disregarded.
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000482let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000483def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000484 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485
486// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
487// disregarded.
Dan Gohman5574cc72008-12-03 18:15:48 +0000488let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000489def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000490 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000491 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492
493// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +0000494let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495let isCommutable = 1 in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000496 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
497 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000498 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000500 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
501 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000502 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000504 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
505 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000506 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
508}
509
Dan Gohmanf221da12009-01-09 02:27:34 +0000510def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
511 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000512 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000513 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000514 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000515def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
516 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000517 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000518 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000519 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000520def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
521 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000522 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000524 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000525
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000526let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000528 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000529 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000530let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000532 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000533 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000535}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536
537/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
538///
539/// In addition, we also have a special variant of the scalar form here to
540/// represent the associated intrinsic operation. This form is unlike the
541/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000542/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543///
544/// These three forms can each be reg+reg or reg+mem, so there are a total of
545/// six "instructions".
546///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000547let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
549 SDNode OpNode, Intrinsic F32Int,
550 bit Commutable = 0> {
551 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000552 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000553 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000554 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
555 let isCommutable = Commutable;
556 }
557
558 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000559 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
560 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000561 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000562 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000563
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000565 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
566 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000567 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
569 let isCommutable = Commutable;
570 }
571
572 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000573 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
574 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000575 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000576 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577
578 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000579 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
580 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000581 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000582 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000583
584 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000585 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
586 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000587 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588 [(set VR128:$dst, (F32Int VR128:$src1,
589 sse_load_f32:$src2))]>;
590}
591}
592
593// Arithmetic instructions
594defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
595defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
596defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
597defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
598
599/// sse1_fp_binop_rm - Other SSE1 binops
600///
601/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
602/// instructions for a full-vector intrinsic form. Operations that map
603/// onto C operators don't use this form since they just use the plain
604/// vector form instead of having a separate vector intrinsic form.
605///
606/// This provides a total of eight "instructions".
607///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000608let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
610 SDNode OpNode,
611 Intrinsic F32Int,
612 Intrinsic V4F32Int,
613 bit Commutable = 0> {
614
615 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000616 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000617 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
619 let isCommutable = Commutable;
620 }
621
622 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000623 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
624 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000625 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000626 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000627
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000628 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000629 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
630 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000631 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000632 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
633 let isCommutable = Commutable;
634 }
635
636 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000637 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
638 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000639 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000640 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641
642 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000643 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
644 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000645 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000646 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
647 let isCommutable = Commutable;
648 }
649
650 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000651 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
652 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000653 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654 [(set VR128:$dst, (F32Int VR128:$src1,
655 sse_load_f32:$src2))]>;
656
657 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000658 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
659 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000660 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
662 let isCommutable = Commutable;
663 }
664
665 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000666 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
667 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000668 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000669 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670}
671}
672
673defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
674 int_x86_sse_max_ss, int_x86_sse_max_ps>;
675defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
676 int_x86_sse_min_ss, int_x86_sse_min_ps>;
677
678//===----------------------------------------------------------------------===//
679// SSE packed FP Instructions
680
681// Move Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000682let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000683def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000684 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000685let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000686def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000687 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000688 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689
Evan Chengb783fa32007-07-19 01:14:50 +0000690def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000691 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000692 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000694let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000695def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000696 "movups\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000697let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000698def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000699 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000700 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000701def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000702 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000703 [(store (v4f32 VR128:$src), addr:$dst)]>;
704
705// Intrinsic forms of MOVUPS load and store
Dan Gohman5574cc72008-12-03 18:15:48 +0000706let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000707def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000709 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000710def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000711 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000712 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713
Evan Cheng3ea4d672008-03-05 08:19:16 +0000714let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715 let AddedComplexity = 20 in {
716 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000717 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000718 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000719 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000720 (movlp VR128:$src1,
721 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000723 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000724 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000725 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000726 (movhp VR128:$src1,
727 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000729} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730
Evan Chengd743a5f2008-05-10 00:59:18 +0000731
Evan Chengb783fa32007-07-19 01:14:50 +0000732def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000733 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
735 (iPTR 0))), addr:$dst)]>;
736
737// v2f64 extract element 1 is always custom lowered to unpack high to low
738// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000739def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000740 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +0000742 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
743 (undef)), (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000744
Evan Cheng3ea4d672008-03-05 08:19:16 +0000745let Constraints = "$src1 = $dst" in {
Evan Cheng13559d62008-09-26 23:41:32 +0000746let AddedComplexity = 20 in {
Evan Cheng7581a822009-05-12 20:17:52 +0000747def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
748 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000749 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000750 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000751 (v4f32 (movhp VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752
Evan Cheng7581a822009-05-12 20:17:52 +0000753def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
754 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000755 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000757 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758} // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000759} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760
Nate Begemanb44aad72009-04-29 22:47:44 +0000761let AddedComplexity = 20 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000762def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Evan Chenga2497eb2008-09-25 20:50:48 +0000763 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begemanb44aad72009-04-29 22:47:44 +0000764def : Pat<(v2i64 (movddup VR128:$src, (undef))),
765 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
766}
Evan Chenga2497eb2008-09-25 20:50:48 +0000767
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768
769
770// Arithmetic
771
772/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
773///
774/// In addition, we also have a special variant of the scalar form here to
775/// represent the associated intrinsic operation. This form is unlike the
776/// plain scalar form, in that it takes an entire vector (instead of a
777/// scalar) and leaves the top elements undefined.
778///
779/// And, we have a special variant form for a full-vector intrinsic form.
780///
781/// These four forms can each have a reg or a mem operand, so there are a
782/// total of eight "instructions".
783///
784multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
785 SDNode OpNode,
786 Intrinsic F32Int,
787 Intrinsic V4F32Int,
788 bit Commutable = 0> {
789 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000790 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000791 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 [(set FR32:$dst, (OpNode FR32:$src))]> {
793 let isCommutable = Commutable;
794 }
795
796 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000797 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000798 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000799 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000800
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000802 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000803 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
805 let isCommutable = Commutable;
806 }
807
808 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000809 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000810 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000811 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812
813 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000814 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000815 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816 [(set VR128:$dst, (F32Int VR128:$src))]> {
817 let isCommutable = Commutable;
818 }
819
820 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000821 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000822 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
824
825 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000826 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
829 let isCommutable = Commutable;
830 }
831
832 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000833 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000834 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000835 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836}
837
838// Square root.
839defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
840 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
841
842// Reciprocal approximations. Note that these typically require refinement
843// in order to obtain suitable precision.
844defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
845 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
846defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
847 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
848
849// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +0000850let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851 let isCommutable = 1 in {
852 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000853 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000854 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 [(set VR128:$dst, (v2i64
856 (and VR128:$src1, VR128:$src2)))]>;
857 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000858 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000859 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 [(set VR128:$dst, (v2i64
861 (or VR128:$src1, VR128:$src2)))]>;
862 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000863 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000864 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865 [(set VR128:$dst, (v2i64
866 (xor VR128:$src1, VR128:$src2)))]>;
867 }
868
869 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000870 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000871 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000872 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
873 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000875 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000876 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000877 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
878 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000880 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000881 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000882 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
883 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000885 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000886 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 [(set VR128:$dst,
888 (v2i64 (and (xor VR128:$src1,
889 (bc_v2i64 (v4i32 immAllOnesV))),
890 VR128:$src2)))]>;
891 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000892 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000893 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000895 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000897 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898}
899
Evan Cheng3ea4d672008-03-05 08:19:16 +0000900let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000901 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begeman061db5f2008-05-12 20:34:32 +0000902 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
903 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
904 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
905 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000906 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begeman061db5f2008-05-12 20:34:32 +0000907 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
908 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
909 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +0000910 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911}
Nate Begeman03605a02008-07-17 16:51:19 +0000912def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
913 (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>;
914def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
915 (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916
917// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +0000918let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000920 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000921 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000922 VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000923 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000925 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000926 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000927 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000928 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000929 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000931 (v4f32 (shufp:$src3
932 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933
934 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000935 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000936 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000937 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000939 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000940 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000941 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000942 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000944 (v4f32 (unpckh VR128:$src1,
945 (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000947 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000948 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000949 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000951 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000952 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000953 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000954 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000956 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000958} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959
960// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000961def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengd8296b82009-05-28 18:55:28 +0000964def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000965 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
967
Evan Chengd1d68072008-03-08 00:58:38 +0000968// Prefetch intrinsic.
969def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
970 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
971def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
972 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
973def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
974 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
975def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
976 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977
978// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000979def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000980 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
982
983// Load, store, and memory fence
Evan Cheng68cca152009-05-27 18:38:01 +0000984def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985
986// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000987def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000988 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000989def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000990 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991
992// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +0000993// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +0000994// load of an all-zeros value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +0000995let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
996 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000997def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000998 "xorps\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000999 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000
Evan Chenga15896e2008-03-12 07:02:50 +00001001let Predicates = [HasSSE1] in {
1002 def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
1003 def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1004 def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1005 def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1006 def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
1007}
1008
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009// FR32 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001010let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001011def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001012 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 [(set VR128:$dst,
1014 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001015def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001016 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017 [(set VR128:$dst,
1018 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
1019
1020// FIXME: may not be able to eliminate this movss with coalescing the src and
1021// dest register classes are different. We really want to write this pattern
1022// like this:
1023// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1024// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001025let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001026def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
1029 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001030def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001031 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 [(store (f32 (vector_extract (v4f32 VR128:$src),
1033 (iPTR 0))), addr:$dst)]>;
1034
1035
1036// Move to lower bits of a VR128, leaving upper bits alone.
1037// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001038let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001039let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001041 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001042 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043
1044 let AddedComplexity = 15 in
1045 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001046 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001047 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001049 (v4f32 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050}
1051
1052// Move to lower bits of a VR128 and zeroing upper bits.
1053// Loading from memory automatically zeroing upper bits.
1054let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00001055def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001056 "movss\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00001057 [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001058 (loadf32 addr:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059
Evan Cheng056afe12008-05-20 18:24:47 +00001060def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
Evan Cheng40ee6e52008-05-08 00:57:18 +00001061 (MOVZSS2PSrm addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001063//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064// SSE2 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001065//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001068let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001069def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001070 "movsd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001071let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001072def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001073 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001075def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001076 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 [(store FR64:$src, addr:$dst)]>;
1078
1079// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001080def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001081 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001083def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001084 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001086def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001087 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001088 [(set FR32:$dst, (fround FR64:$src))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001089def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001090 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001092def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001093 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001095def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001096 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1098
Sean Callanan3d5824c2009-09-16 01:13:52 +00001099def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1100 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1101def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1102 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1103def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1104 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1105def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1106 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1107def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1108 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1109def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1110 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1111def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1112 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1113def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1114 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1115def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1116 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1117def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1118 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1119
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001120// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001121def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001122 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001123 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1124 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001125def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001126 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1128 Requires<[HasSSE2]>;
1129
1130// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001131def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001132 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001134def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001135 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1137 (load addr:$src)))]>;
1138
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001139// Match intrinisics which expect MM and XMM operand(s).
1140def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1141 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1142 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1143def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1144 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001145 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001146 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001147def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1148 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1149 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1150def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1151 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001152 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001153 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001154def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1155 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1156 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1157def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1158 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001159 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001160 (load addr:$src)))]>;
1161
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001163def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001164 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 [(set GR32:$dst,
1166 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001167def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001168 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1170 (load addr:$src)))]>;
1171
1172// Comparison instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001173let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001174 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001175 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001176 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001177let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001178 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001179 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001180 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181}
1182
Evan Cheng950aac02007-09-25 01:57:46 +00001183let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001184def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001185 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001186 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001187def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001188 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001189 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001190 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001191} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001192
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +00001194let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001195 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
1196 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
1197 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001198 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1200 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001201 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
1202 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src,
1203 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001204 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1206 (load addr:$src), imm:$cc))]>;
1207}
1208
Evan Cheng950aac02007-09-25 01:57:46 +00001209let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001210def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001211 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001212 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1213 (implicit EFLAGS)]>;
1214def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001215 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001216 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1217 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218
Evan Chengb783fa32007-07-19 01:14:50 +00001219def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001220 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001221 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1222 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001223def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001224 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001225 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001226 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001227} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001228
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001229// Aliases of packed SSE2 instructions for scalar use. These all have names
1230// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001231
1232// Alias instructions that map fld0 to pxor for sse.
Daniel Dunbara0e62002009-08-11 22:17:52 +00001233let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001234def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001235 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236 Requires<[HasSSE2]>, TB, OpSize;
1237
1238// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1239// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001240let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001241def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001242 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243
1244// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1245// disregarded.
Dan Gohman5574cc72008-12-03 18:15:48 +00001246let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001247def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001248 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001249 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250
1251// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001252let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253let isCommutable = 1 in {
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001254 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1255 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001256 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001258 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1259 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001260 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001262 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1263 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001264 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1266}
1267
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001268def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1269 (ins FR64:$src1, f128mem:$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,
Dan Gohman11821702007-07-27 17:16:43 +00001272 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001273def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1274 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001275 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001277 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001278def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1279 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001282 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001284let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001286 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001287 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001288let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001290 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001291 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001292}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001293}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294
1295/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1296///
1297/// In addition, we also have a special variant of the scalar form here to
1298/// represent the associated intrinsic operation. This form is unlike the
1299/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001300/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301///
1302/// These three forms can each be reg+reg or reg+mem, so there are a total of
1303/// six "instructions".
1304///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001305let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1307 SDNode OpNode, Intrinsic F64Int,
1308 bit Commutable = 0> {
1309 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001310 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001311 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1313 let isCommutable = Commutable;
1314 }
1315
1316 // Scalar operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001317 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1318 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001319 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001321
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322 // Vector operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001323 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1324 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001325 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1327 let isCommutable = Commutable;
1328 }
1329
1330 // Vector operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001331 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1332 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001333 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf221da12009-01-09 02:27:34 +00001334 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335
1336 // Intrinsic operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001337 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1338 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001339 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001340 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341
1342 // Intrinsic operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001343 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1344 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001345 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(set VR128:$dst, (F64Int VR128:$src1,
1347 sse_load_f64:$src2))]>;
1348}
1349}
1350
1351// Arithmetic instructions
1352defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1353defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1354defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1355defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1356
1357/// sse2_fp_binop_rm - Other SSE2 binops
1358///
1359/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1360/// instructions for a full-vector intrinsic form. Operations that map
1361/// onto C operators don't use this form since they just use the plain
1362/// vector form instead of having a separate vector intrinsic form.
1363///
1364/// This provides a total of eight "instructions".
1365///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001366let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1368 SDNode OpNode,
1369 Intrinsic F64Int,
1370 Intrinsic V2F64Int,
1371 bit Commutable = 0> {
1372
1373 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001374 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001375 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1377 let isCommutable = Commutable;
1378 }
1379
1380 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001381 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1382 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001383 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001385
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001387 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1388 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001389 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1391 let isCommutable = Commutable;
1392 }
1393
1394 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001395 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1396 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001397 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001398 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399
1400 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001401 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1402 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001403 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1405 let isCommutable = Commutable;
1406 }
1407
1408 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001409 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1410 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001411 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412 [(set VR128:$dst, (F64Int VR128:$src1,
1413 sse_load_f64:$src2))]>;
1414
1415 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001416 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1417 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001418 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1420 let isCommutable = Commutable;
1421 }
1422
1423 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001424 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1425 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001426 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001427 [(set VR128:$dst, (V2F64Int VR128:$src1,
1428 (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001429}
1430}
1431
1432defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1433 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1434defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1435 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1436
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001437//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438// SSE packed FP Instructions
1439
1440// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001441let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001442def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001443 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001444let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001445def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001446 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001447 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001448
Evan Chengb783fa32007-07-19 01:14:50 +00001449def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001451 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001452
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001453let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001454def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001455 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001456let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001457def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001459 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001460def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001461 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001462 [(store (v2f64 VR128:$src), addr:$dst)]>;
1463
1464// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001465def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001466 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001467 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001468def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001470 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471
Evan Cheng3ea4d672008-03-05 08:19:16 +00001472let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473 let AddedComplexity = 20 in {
1474 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001475 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001476 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001477 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001478 (v2f64 (movlp VR128:$src1,
1479 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001480 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001481 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001482 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001483 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001484 (v2f64 (movhp VR128:$src1,
1485 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001487} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001488
Evan Chengb783fa32007-07-19 01:14:50 +00001489def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001490 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001491 [(store (f64 (vector_extract (v2f64 VR128:$src),
1492 (iPTR 0))), addr:$dst)]>;
1493
1494// v2f64 extract element 1 is always custom lowered to unpack high to low
1495// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001496def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001498 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +00001499 (v2f64 (unpckh VR128:$src, (undef))),
1500 (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501
1502// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001503def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001504 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1506 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001507def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001508 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1509 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1510 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511 TB, Requires<[HasSSE2]>;
1512
1513// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001514def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001515 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1517 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001518def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001519 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1520 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1521 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 XS, Requires<[HasSSE2]>;
1523
Evan Chengb783fa32007-07-19 01:14:50 +00001524def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001525 "cvtps2dq\t{$src, $dst|$dst, $src}",
1526 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001527def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001529 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001530 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001532def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001533 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001534 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1535 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001536def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001537 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001538 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001539 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540 XS, Requires<[HasSSE2]>;
1541
1542// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001543def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001544 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001545 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1546 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001547def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001550 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551 XD, Requires<[HasSSE2]>;
1552
Evan Chengb783fa32007-07-19 01:14:50 +00001553def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001554 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001555 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng14c97c32008-03-14 07:46:48 +00001556def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001557 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001559 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560
1561// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001562def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001563 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1565 TB, Requires<[HasSSE2]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001566def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1569 (load addr:$src)))]>,
1570 TB, Requires<[HasSSE2]>;
1571
Evan Chengb783fa32007-07-19 01:14:50 +00001572def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001573 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001574 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001575def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001577 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Cheng00b66ef2008-05-23 00:37:07 +00001578 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001579
1580// Match intrinsics which expect XMM operand(s).
1581// Aliases for intrinsics
Evan Cheng3ea4d672008-03-05 08:19:16 +00001582let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001584 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001585 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001586 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1587 GR32:$src2))]>;
1588def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001589 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001590 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1592 (loadi32 addr:$src2)))]>;
1593def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001594 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001595 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001596 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1597 VR128:$src2))]>;
1598def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001599 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1602 (load addr:$src2)))]>;
1603def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001604 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1607 VR128:$src2))]>, XS,
1608 Requires<[HasSSE2]>;
1609def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001610 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001611 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001612 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1613 (load addr:$src2)))]>, XS,
1614 Requires<[HasSSE2]>;
1615}
1616
1617// Arithmetic
1618
1619/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1620///
1621/// In addition, we also have a special variant of the scalar form here to
1622/// represent the associated intrinsic operation. This form is unlike the
1623/// plain scalar form, in that it takes an entire vector (instead of a
1624/// scalar) and leaves the top elements undefined.
1625///
1626/// And, we have a special variant form for a full-vector intrinsic form.
1627///
1628/// These four forms can each have a reg or a mem operand, so there are a
1629/// total of eight "instructions".
1630///
1631multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1632 SDNode OpNode,
1633 Intrinsic F64Int,
1634 Intrinsic V2F64Int,
1635 bit Commutable = 0> {
1636 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001637 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001638 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639 [(set FR64:$dst, (OpNode FR64:$src))]> {
1640 let isCommutable = Commutable;
1641 }
1642
1643 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001644 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001645 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001646 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001647
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001649 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001650 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001651 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1652 let isCommutable = Commutable;
1653 }
1654
1655 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001656 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001657 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001658 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659
1660 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001661 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001662 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001663 [(set VR128:$dst, (F64Int VR128:$src))]> {
1664 let isCommutable = Commutable;
1665 }
1666
1667 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001668 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1671
1672 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001673 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001675 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1676 let isCommutable = Commutable;
1677 }
1678
1679 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001680 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001681 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001682 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001683}
1684
1685// Square root.
1686defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1687 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1688
1689// There is no f64 version of the reciprocal approximation instructions.
1690
1691// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +00001692let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693 let isCommutable = 1 in {
1694 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001695 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001696 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697 [(set VR128:$dst,
1698 (and (bc_v2i64 (v2f64 VR128:$src1)),
1699 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1700 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001701 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 [(set VR128:$dst,
1704 (or (bc_v2i64 (v2f64 VR128:$src1)),
1705 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1706 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001707 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001709 [(set VR128:$dst,
1710 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1711 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1712 }
1713
1714 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001715 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 [(set VR128:$dst,
1718 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001719 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001720 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001721 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001722 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001723 [(set VR128:$dst,
1724 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001725 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001726 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001727 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001728 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001729 [(set VR128:$dst,
1730 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001731 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001733 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001734 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001735 [(set VR128:$dst,
1736 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1737 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1738 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001739 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741 [(set VR128:$dst,
1742 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001743 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001744}
1745
Evan Cheng3ea4d672008-03-05 08:19:16 +00001746let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001747 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001748 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1749 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1750 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begeman061db5f2008-05-12 20:34:32 +00001751 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001752 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng14c97c32008-03-14 07:46:48 +00001753 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1754 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1755 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00001756 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757}
Evan Cheng33754092008-08-05 22:19:15 +00001758def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001759 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Cheng33754092008-08-05 22:19:15 +00001760def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001761 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762
1763// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001764let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001765 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001766 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1767 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman543d2142009-04-27 18:41:29 +00001768 [(set VR128:$dst,
1769 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001770 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001771 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001775 (v2f64 (shufp:$src3
1776 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001777
1778 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001779 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001780 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001782 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001783 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001784 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001785 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001788 (v2f64 (unpckh VR128:$src1,
1789 (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001791 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001792 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001793 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001794 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001795 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001796 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001797 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001798 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001800 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001802} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803
1804
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001805//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806// SSE integer instructions
1807
1808// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001809let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001810def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001811 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001812let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001813def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001814 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001815 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001816let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001817def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001818 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001819 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001820let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001821def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001823 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824 XS, Requires<[HasSSE2]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001825let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001826def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001827 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001828 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 XS, Requires<[HasSSE2]>;
1830
Dan Gohman4a4f1512007-07-18 20:23:34 +00001831// Intrinsic forms of MOVDQU load and store
Dan Gohman5574cc72008-12-03 18:15:48 +00001832let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001833def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001835 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1836 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001837def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001838 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001839 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1840 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001841
Evan Cheng88004752008-03-05 08:11:27 +00001842let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001843
1844multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1845 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001846 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001847 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001848 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1849 let isCommutable = Commutable;
1850 }
Evan Chengb783fa32007-07-19 01:14:50 +00001851 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001853 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001854 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855}
1856
Evan Chengf90f8f82008-05-03 00:52:09 +00001857multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1858 string OpcodeStr,
1859 Intrinsic IntId, Intrinsic IntId2> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001860 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1861 VR128:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001862 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1863 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001864 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1865 i128mem:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001866 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1867 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001868 (bitconvert (memopv2i64 addr:$src2))))]>;
1869 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1,
1870 i32i8imm:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001871 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1872 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
1873}
1874
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875/// PDI_binop_rm - Simple SSE2 binary operator.
1876multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1877 ValueType OpVT, bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001878 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1879 VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001881 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1882 let isCommutable = Commutable;
1883 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001884 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1885 i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001886 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001887 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001888 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001889}
1890
1891/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1892///
1893/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1894/// to collapse (bitconvert VT to VT) into its operand.
1895///
1896multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1897 bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001898 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1899 (ins VR128:$src1, VR128:$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, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1902 let isCommutable = Commutable;
1903 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001904 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1905 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001907 [(set VR128:$dst, (OpNode VR128:$src1,
1908 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909}
1910
Evan Cheng3ea4d672008-03-05 08:19:16 +00001911} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001912
1913// 128-bit Integer Arithmetic
1914
1915defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1916defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1917defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1918defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1919
1920defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1921defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1922defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1923defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1924
1925defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1926defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1927defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1928defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1929
1930defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1931defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1932defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1933defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1934
1935defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1936
1937defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1938defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1939defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1940
1941defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1942
1943defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1944defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1945
1946
1947defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1948defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1949defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1950defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling953ad2e2009-05-28 02:04:00 +00001951defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001952
1953
Evan Chengf90f8f82008-05-03 00:52:09 +00001954defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
1955 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
1956defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
1957 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
1958defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
1959 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960
Evan Chengf90f8f82008-05-03 00:52:09 +00001961defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
1962 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
1963defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
1964 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begemanc2ca5f62008-05-13 17:52:09 +00001965defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Chengf90f8f82008-05-03 00:52:09 +00001966 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967
Evan Chengf90f8f82008-05-03 00:52:09 +00001968defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
1969 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemand66fc342008-05-13 01:47:52 +00001970defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Chengf90f8f82008-05-03 00:52:09 +00001971 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972
1973// 128-bit logical shifts.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001974let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001976 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001977 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001979 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001980 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001981 // PSRADQri doesn't exist in SSE[1-3].
1982}
1983
1984let Predicates = [HasSSE2] in {
1985 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1986 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1987 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1988 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
Bill Wendling314ee052008-10-02 05:56:52 +00001989 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
1990 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
1991 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
1992 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1994 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
Evan Chengdea99362008-05-29 08:22:04 +00001995
1996 // Shift up / down and insert zero's.
1997 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
1998 (v2i64 (PSLLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
1999 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
2000 (v2i64 (PSRLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001}
2002
2003// Logical
2004defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2005defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2006defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2007
Evan Cheng3ea4d672008-03-05 08:19:16 +00002008let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002010 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002011 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002012 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2013 VR128:$src2)))]>;
2014
2015 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002016 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002017 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002018 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00002019 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020}
2021
2022// SSE2 Integer comparison
2023defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2024defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2025defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2026defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2027defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2028defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2029
Nate Begeman03605a02008-07-17 16:51:19 +00002030def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002031 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002032def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002033 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002034def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002035 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002036def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002037 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002038def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002039 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002040def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002041 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2042
Nate Begeman03605a02008-07-17 16:51:19 +00002043def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002044 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002045def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002046 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002047def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002048 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002049def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002050 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002051def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002052 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002053def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002054 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2055
2056
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057// Pack instructions
2058defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2059defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2060defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2061
2062// Shuffle and unpack instructions
2063def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002064 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002065 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002066 [(set VR128:$dst, (v4i32 (pshufd:$src2
2067 VR128:$src1, (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002068def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002069 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002070 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002071 [(set VR128:$dst, (v4i32 (pshufd:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002072 (bc_v4i32(memopv2i64 addr:$src1)),
2073 (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074
2075// SSE2 with ImmT == Imm8 and XS prefix.
2076def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002077 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002079 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2080 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081 XS, Requires<[HasSSE2]>;
2082def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002083 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002085 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002086 (bc_v8i16 (memopv2i64 addr:$src1)),
2087 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088 XS, Requires<[HasSSE2]>;
2089
2090// SSE2 with ImmT == Imm8 and XD prefix.
2091def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman543d2142009-04-27 18:41:29 +00002092 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002093 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002094 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2095 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096 XD, Requires<[HasSSE2]>;
2097def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman543d2142009-04-27 18:41:29 +00002098 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002099 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002100 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2101 (bc_v8i16 (memopv2i64 addr:$src1)),
2102 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 XD, Requires<[HasSSE2]>;
2104
2105
Evan Cheng3ea4d672008-03-05 08:19:16 +00002106let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002107 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002108 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002109 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002110 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002111 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002112 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002113 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002114 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002115 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002116 (unpckl VR128:$src1,
2117 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002118 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002119 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002120 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002122 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002123 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002124 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002125 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002127 (unpckl VR128:$src1,
2128 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002129 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002130 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002131 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002132 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002133 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002134 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002135 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002136 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002138 (unpckl VR128:$src1,
2139 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002140 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002141 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002143 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002144 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002145 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002146 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002149 (v2i64 (unpckl VR128:$src1,
2150 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002151
2152 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002153 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002156 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002157 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002158 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002160 [(set VR128:$dst,
2161 (unpckh VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002162 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002163 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002164 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002165 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002166 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002167 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002168 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002169 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002170 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002172 (unpckh VR128:$src1,
2173 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002174 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002175 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002176 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002177 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002178 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002179 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002180 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002181 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002183 (unpckh VR128:$src1,
2184 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002185 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002186 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002189 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002190 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002191 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002192 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002194 (v2i64 (unpckh VR128:$src1,
2195 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196}
2197
2198// Extract / Insert
2199def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002200 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begemand77e59e2008-02-11 04:19:36 +00002203 imm:$src2))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +00002204let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002206 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002207 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002208 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002209 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002210 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002212 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002213 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002214 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002215 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002216 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2217 imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002218}
2219
2220// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002221def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002222 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002223 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2224
2225// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002226let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002227def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002229 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230
Evan Cheng430de082009-02-10 22:06:28 +00002231let Uses = [RDI] in
2232def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2233 "maskmovdqu\t{$mask, $src|$src, $mask}",
2234 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2235
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002237def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002238 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002239 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002240def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002241 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002243def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002245 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246 TB, Requires<[HasSSE2]>;
2247
2248// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002249def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002250 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251 TB, Requires<[HasSSE2]>;
2252
2253// Load, store, and memory fence
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002254def LFENCE : I<0xAE, MRM5r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002255 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002256def MFENCE : I<0xAE, MRM6r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2258
Andrew Lenharth785610d2008-02-16 01:24:58 +00002259//TODO: custom lower this so as to never even generate the noop
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002260def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002261 (i8 0)), (NOOP)>;
2262def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2263def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002264def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002265 (i8 1)), (MFENCE)>;
2266
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00002268// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00002269// load of an all-ones value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +00002270let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2271 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002272 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002274 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002275
2276// FR64 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002277let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002278def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002279 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280 [(set VR128:$dst,
2281 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002282def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002283 "movsd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002284 [(set VR128:$dst,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002285 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2286
Evan Chengb783fa32007-07-19 01:14:50 +00002287def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289 [(set VR128:$dst,
2290 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002291def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002292 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002293 [(set VR128:$dst,
2294 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2295
Evan Chengb783fa32007-07-19 01:14:50 +00002296def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002297 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002298 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2299
Evan Chengb783fa32007-07-19 01:14:50 +00002300def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002302 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2303
2304// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002305def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002306 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002307 [(set VR128:$dst,
2308 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2309 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002310def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002311 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002312 [(store (i64 (vector_extract (v2i64 VR128:$src),
2313 (iPTR 0))), addr:$dst)]>;
2314
2315// FIXME: may not be able to eliminate this movss with coalescing the src and
2316// dest register classes are different. We really want to write this pattern
2317// like this:
2318// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2319// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002320let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002321def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002322 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2324 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002325def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327 [(store (f64 (vector_extract (v2f64 VR128:$src),
2328 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002329def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002330 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2332 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002333def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002334 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002335 [(store (i32 (vector_extract (v4i32 VR128:$src),
2336 (iPTR 0))), addr:$dst)]>;
2337
Evan Chengb783fa32007-07-19 01:14:50 +00002338def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002340 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002341def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002342 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002343 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2344
2345
2346// Move to lower bits of a VR128, leaving upper bits alone.
2347// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002348let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00002349 let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002350 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002351 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002353
2354 let AddedComplexity = 15 in
2355 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002356 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002358 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002359 (v2f64 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002360}
2361
2362// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002363def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002364 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2366
2367// Move to lower bits of a VR128 and zeroing upper bits.
2368// Loading from memory automatically zeroing upper bits.
Evan Chengd743a5f2008-05-10 00:59:18 +00002369let AddedComplexity = 20 in {
2370def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2371 "movsd\t{$src, $dst|$dst, $src}",
2372 [(set VR128:$dst,
2373 (v2f64 (X86vzmovl (v2f64 (scalar_to_vector
2374 (loadf64 addr:$src))))))]>;
Evan Cheng40ee6e52008-05-08 00:57:18 +00002375
Evan Cheng056afe12008-05-20 18:24:47 +00002376def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
2377 (MOVZSD2PDrm addr:$src)>;
2378def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
Evan Chengd743a5f2008-05-10 00:59:18 +00002379 (MOVZSD2PDrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002380def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002381}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002382
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002383// movd / movq to XMM register zero-extends
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002384let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002385def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002386 "movd\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002387 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002388 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002389// This is X86-64 only.
2390def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2391 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002392 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002393 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002394}
2395
2396let AddedComplexity = 20 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002397def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002398 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002399 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002400 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002401 (loadi32 addr:$src))))))]>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002402
2403def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2404 (MOVZDI2PDIrm addr:$src)>;
2405def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2406 (MOVZDI2PDIrm addr:$src)>;
Duncan Sands2418bec2008-06-13 19:07:40 +00002407def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2408 (MOVZDI2PDIrm addr:$src)>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002409
Evan Chengb783fa32007-07-19 01:14:50 +00002410def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002411 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002412 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002413 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002414 (loadi64 addr:$src))))))]>, XS,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002415 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002416
Evan Cheng3ad16c42008-05-22 18:56:56 +00002417def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2418 (MOVZQI2PQIrm addr:$src)>;
2419def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2420 (MOVZQI2PQIrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002421def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002422}
Evan Chenge9b9c672008-05-09 21:53:03 +00002423
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002424// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2425// IA32 document. movq xmm1, xmm2 does clear the high bits.
2426let AddedComplexity = 15 in
2427def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2428 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002429 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002430 XS, Requires<[HasSSE2]>;
2431
Evan Cheng056afe12008-05-20 18:24:47 +00002432let AddedComplexity = 20 in {
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002433def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2434 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002435 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng056afe12008-05-20 18:24:47 +00002436 (loadv2i64 addr:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002437 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002438
Evan Cheng056afe12008-05-20 18:24:47 +00002439def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2440 (MOVZPQILo2PQIrm addr:$src)>;
2441}
2442
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002443//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002444// SSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002445//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002446
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002448def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002449 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002450 [(set VR128:$dst, (v4f32 (movshdup
2451 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002452def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002453 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002454 [(set VR128:$dst, (movshdup
2455 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002456
Evan Chengb783fa32007-07-19 01:14:50 +00002457def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002458 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002459 [(set VR128:$dst, (v4f32 (movsldup
2460 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002461def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002462 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002463 [(set VR128:$dst, (movsldup
2464 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002465
Evan Chengb783fa32007-07-19 01:14:50 +00002466def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002467 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002468 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002469def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002470 "movddup\t{$src, $dst|$dst, $src}",
Evan Chenga2497eb2008-09-25 20:50:48 +00002471 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002472 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2473 (undef))))]>;
Evan Chenga2497eb2008-09-25 20:50:48 +00002474
Nate Begeman543d2142009-04-27 18:41:29 +00002475def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2476 (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002477 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002478
2479let AddedComplexity = 5 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002480def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002481 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002482def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2483 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2484def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2485 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2486def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2487 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2488}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002489
2490// Arithmetic
Evan Cheng3ea4d672008-03-05 08:19:16 +00002491let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002492 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002493 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002494 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002495 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2496 VR128:$src2))]>;
2497 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002498 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002499 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002500 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002501 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002502 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002503 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002504 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002505 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2506 VR128:$src2))]>;
2507 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002508 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002509 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002510 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002511 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512}
2513
Evan Chengb783fa32007-07-19 01:14:50 +00002514def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002515 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002516 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2517
2518// Horizontal ops
2519class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002520 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002521 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002522 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2523class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002524 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002525 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002526 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002527class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002528 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002529 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002530 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2531class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002532 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002533 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002534 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002535
Evan Cheng3ea4d672008-03-05 08:19:16 +00002536let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002537 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2538 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2539 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2540 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2541 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2542 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2543 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2544 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2545}
2546
2547// Thread synchronization
Bill Wendling6ee76552009-05-28 23:40:46 +00002548def MONITOR : I<0x01, MRM1r, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002549 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Bill Wendling6ee76552009-05-28 23:40:46 +00002550def MWAIT : I<0x01, MRM1r, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002551 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2552
2553// vector_shuffle v1, <undef> <1, 1, 3, 3>
2554let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002555def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002556 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2557let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002558def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002559 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2560
2561// vector_shuffle v1, <undef> <0, 0, 2, 2>
2562let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002563 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002564 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2565let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002566 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002567 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2568
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002569//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570// SSSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002571//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002572
Bill Wendling98680292007-08-10 06:22:27 +00002573/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002574multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2575 Intrinsic IntId64, Intrinsic IntId128> {
2576 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2577 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2578 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002579
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002580 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2581 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2582 [(set VR64:$dst,
2583 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2584
2585 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2586 (ins VR128:$src),
2587 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2588 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2589 OpSize;
2590
2591 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2592 (ins i128mem:$src),
2593 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2594 [(set VR128:$dst,
2595 (IntId128
2596 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002597}
2598
Bill Wendling98680292007-08-10 06:22:27 +00002599/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002600multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2601 Intrinsic IntId64, Intrinsic IntId128> {
2602 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2603 (ins VR64:$src),
2604 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2605 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002606
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002607 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2608 (ins i64mem:$src),
2609 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2610 [(set VR64:$dst,
2611 (IntId64
2612 (bitconvert (memopv4i16 addr:$src))))]>;
2613
2614 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2615 (ins VR128:$src),
2616 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2617 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2618 OpSize;
2619
2620 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2621 (ins i128mem:$src),
2622 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2623 [(set VR128:$dst,
2624 (IntId128
2625 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002626}
2627
2628/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002629multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2630 Intrinsic IntId64, Intrinsic IntId128> {
2631 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2632 (ins VR64:$src),
2633 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2634 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002635
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002636 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2637 (ins i64mem:$src),
2638 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2639 [(set VR64:$dst,
2640 (IntId64
2641 (bitconvert (memopv2i32 addr:$src))))]>;
2642
2643 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2644 (ins VR128:$src),
2645 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2646 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2647 OpSize;
2648
2649 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2650 (ins i128mem:$src),
2651 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2652 [(set VR128:$dst,
2653 (IntId128
2654 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002655}
2656
2657defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2658 int_x86_ssse3_pabs_b,
2659 int_x86_ssse3_pabs_b_128>;
2660defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2661 int_x86_ssse3_pabs_w,
2662 int_x86_ssse3_pabs_w_128>;
2663defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2664 int_x86_ssse3_pabs_d,
2665 int_x86_ssse3_pabs_d_128>;
2666
2667/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002668let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002669 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2670 Intrinsic IntId64, Intrinsic IntId128,
2671 bit Commutable = 0> {
2672 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2673 (ins VR64:$src1, VR64:$src2),
2674 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2675 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2676 let isCommutable = Commutable;
2677 }
2678 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2679 (ins VR64:$src1, i64mem:$src2),
2680 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2681 [(set VR64:$dst,
2682 (IntId64 VR64:$src1,
2683 (bitconvert (memopv8i8 addr:$src2))))]>;
2684
2685 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2686 (ins VR128:$src1, VR128:$src2),
2687 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2688 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2689 OpSize {
2690 let isCommutable = Commutable;
2691 }
2692 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2693 (ins VR128:$src1, i128mem:$src2),
2694 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2695 [(set VR128:$dst,
2696 (IntId128 VR128:$src1,
2697 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2698 }
2699}
2700
2701/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002702let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002703 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2704 Intrinsic IntId64, Intrinsic IntId128,
2705 bit Commutable = 0> {
2706 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2707 (ins VR64:$src1, VR64:$src2),
2708 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2709 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2710 let isCommutable = Commutable;
2711 }
2712 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2713 (ins VR64:$src1, i64mem:$src2),
2714 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2715 [(set VR64:$dst,
2716 (IntId64 VR64:$src1,
2717 (bitconvert (memopv4i16 addr:$src2))))]>;
2718
2719 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2720 (ins VR128:$src1, VR128:$src2),
2721 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2722 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2723 OpSize {
2724 let isCommutable = Commutable;
2725 }
2726 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2727 (ins VR128:$src1, i128mem:$src2),
2728 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2729 [(set VR128:$dst,
2730 (IntId128 VR128:$src1,
2731 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2732 }
2733}
2734
2735/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002736let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002737 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2738 Intrinsic IntId64, Intrinsic IntId128,
2739 bit Commutable = 0> {
2740 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2741 (ins VR64:$src1, VR64:$src2),
2742 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2743 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2744 let isCommutable = Commutable;
2745 }
2746 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2747 (ins VR64:$src1, i64mem:$src2),
2748 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2749 [(set VR64:$dst,
2750 (IntId64 VR64:$src1,
2751 (bitconvert (memopv2i32 addr:$src2))))]>;
2752
2753 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2754 (ins VR128:$src1, VR128:$src2),
2755 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2756 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2757 OpSize {
2758 let isCommutable = Commutable;
2759 }
2760 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2761 (ins VR128:$src1, i128mem:$src2),
2762 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2763 [(set VR128:$dst,
2764 (IntId128 VR128:$src1,
2765 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2766 }
2767}
2768
2769defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2770 int_x86_ssse3_phadd_w,
Evan Cheng944e4412008-06-16 21:16:24 +00002771 int_x86_ssse3_phadd_w_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002772defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2773 int_x86_ssse3_phadd_d,
Evan Cheng944e4412008-06-16 21:16:24 +00002774 int_x86_ssse3_phadd_d_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002775defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2776 int_x86_ssse3_phadd_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002777 int_x86_ssse3_phadd_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002778defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2779 int_x86_ssse3_phsub_w,
2780 int_x86_ssse3_phsub_w_128>;
2781defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2782 int_x86_ssse3_phsub_d,
2783 int_x86_ssse3_phsub_d_128>;
2784defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2785 int_x86_ssse3_phsub_sw,
2786 int_x86_ssse3_phsub_sw_128>;
2787defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2788 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002789 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002790defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2791 int_x86_ssse3_pmul_hr_sw,
2792 int_x86_ssse3_pmul_hr_sw_128, 1>;
2793defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2794 int_x86_ssse3_pshuf_b,
2795 int_x86_ssse3_pshuf_b_128>;
2796defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2797 int_x86_ssse3_psign_b,
2798 int_x86_ssse3_psign_b_128>;
2799defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2800 int_x86_ssse3_psign_w,
2801 int_x86_ssse3_psign_w_128>;
Evan Chengabfed472009-05-28 18:48:53 +00002802defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling98680292007-08-10 06:22:27 +00002803 int_x86_ssse3_psign_d,
2804 int_x86_ssse3_psign_d_128>;
2805
Evan Cheng3ea4d672008-03-05 08:19:16 +00002806let Constraints = "$src1 = $dst" in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002807 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2808 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002809 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002810 [(set VR64:$dst,
2811 (int_x86_ssse3_palign_r
2812 VR64:$src1, VR64:$src2,
2813 imm:$src3))]>;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002814 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Bill Wendling1dc817c2007-08-10 09:00:17 +00002815 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002816 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002817 [(set VR64:$dst,
2818 (int_x86_ssse3_palign_r
2819 VR64:$src1,
2820 (bitconvert (memopv2i32 addr:$src2)),
2821 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002822
Bill Wendling1dc817c2007-08-10 09:00:17 +00002823 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2824 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002825 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002826 [(set VR128:$dst,
2827 (int_x86_ssse3_palign_r_128
2828 VR128:$src1, VR128:$src2,
2829 imm:$src3))]>, OpSize;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002830 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Bill Wendling1dc817c2007-08-10 09:00:17 +00002831 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002832 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002833 [(set VR128:$dst,
2834 (int_x86_ssse3_palign_r_128
2835 VR128:$src1,
2836 (bitconvert (memopv4i32 addr:$src2)),
2837 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002838}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002839
Nate Begeman2c87c422009-02-23 08:49:38 +00002840def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2841 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2842def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2843 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2844
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002845//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002846// Non-Instruction Patterns
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002847//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002848
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002849// extload f32 -> f64. This matches load+fextend because we have a hack in
2850// the isel (PreprocessForFPConvert) that can introduce loads after dag
2851// combine.
Chris Lattnerdec9cb52008-01-24 08:07:48 +00002852// Since these loads aren't folded into the fextend, we have to match it
2853// explicitly here.
2854let Predicates = [HasSSE2] in
2855 def : Pat<(fextend (loadf32 addr:$src)),
2856 (CVTSS2SDrm addr:$src)>;
2857
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002858// bit_convert
2859let Predicates = [HasSSE2] in {
2860 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2861 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2862 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2863 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2864 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2865 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2866 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2867 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2868 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2869 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2870 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2871 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2872 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2873 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2874 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2875 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2876 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2877 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2878 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2879 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2880 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2881 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2882 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2883 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2884 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2885 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2886 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2887 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2888 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2889 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2890}
2891
2892// Move scalar to XMM zero-extended
2893// movd to XMM register zero-extends
2894let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002895// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chenge9b9c672008-05-09 21:53:03 +00002896def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002897 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002898def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002899 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>;
Evan Chenge259e872008-05-09 23:37:55 +00002900def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002901 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Evan Cheng7fe0ff02008-07-10 01:08:23 +00002902def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002903 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002904}
2905
2906// Splat v2f64 / v2i64
2907let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002908def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002909 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002910def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002912def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002913 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002914def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002915 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2916}
2917
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002918// Special unary SHUFPSrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00002919def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
2920 (SHUFPSrri VR128:$src1, VR128:$src1,
2921 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002922 Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002923let AddedComplexity = 5 in
2924def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
2925 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2926 Requires<[HasSSE2]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002927// Special unary SHUFPDrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00002928def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002929 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002930 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2931 Requires<[HasSSE2]>;
2932// Special unary SHUFPDrri case.
2933def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002934 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002935 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7dc19012007-08-02 21:17:01 +00002936 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman543d2142009-04-27 18:41:29 +00002938def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
2939 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002940 Requires<[HasSSE2]>;
Evan Cheng13559d62008-09-26 23:41:32 +00002941
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002942// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman543d2142009-04-27 18:41:29 +00002943def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002944 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002945 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002946 Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002947def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002948 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002949 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002950 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002951// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman543d2142009-04-27 18:41:29 +00002952def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002953 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002954 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002955 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002956
2957// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00002958let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002959def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
2960 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002961 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002962def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
2963 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002964 Requires<[OptForSpeed, HasSSE2]>;
2965}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002966let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002967def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002968 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002969def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002970 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002971def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002972 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002973def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002974 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002975}
2976
2977// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00002978let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002979def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
2980 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002981 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002982def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
2983 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002984 Requires<[OptForSpeed, HasSSE2]>;
2985}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002986let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002987def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002988 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002989def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002990 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002991def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002992 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002993def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002994 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002995}
2996
Evan Cheng13559d62008-09-26 23:41:32 +00002997let AddedComplexity = 20 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002998// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begeman543d2142009-04-27 18:41:29 +00002999def : Pat<(v4i32 (movhp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003000 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
3001
3002// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003003def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003004 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
3005
3006// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003007def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003008 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman543d2142009-04-27 18:41:29 +00003009def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003010 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
3011}
3012
3013let AddedComplexity = 20 in {
3014// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
3015// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Nate Begeman543d2142009-04-27 18:41:29 +00003016def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003017 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003018def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003019 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003020def : Pat<(v4f32 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003021 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003022def : Pat<(v2f64 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003023 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3024
Nate Begeman543d2142009-04-27 18:41:29 +00003025def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003026 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003027def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003028 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003029def : Pat<(v4i32 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003030 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003031def : Pat<(v2i64 (movhp VR128:$src1, (load addr:$src2))),
Evan Cheng1ff2ea52008-05-23 18:00:18 +00003032 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003033}
3034
Evan Cheng2b2a7012008-05-23 21:23:16 +00003035// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
3036// (store (vector_shuffle (load addr), v2, <0, 1, 4, 5>), addr) using MOVHPS
Nate Begeman543d2142009-04-27 18:41:29 +00003037def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003038 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003039def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003040 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003041def : Pat<(store (v4f32 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003042 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003043def : Pat<(store (v2f64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003044 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3045
Nate Begeman543d2142009-04-27 18:41:29 +00003046def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3047 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003048 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003049def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003050 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003051def : Pat<(store (v4i32 (movhp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3052 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003053 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003054def : Pat<(store (v2i64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003055 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3056
3057
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003058let AddedComplexity = 15 in {
3059// Setting the lowest element in the vector.
Nate Begeman543d2142009-04-27 18:41:29 +00003060def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003061 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003062def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003063 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3064
3065// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
Nate Begeman543d2142009-04-27 18:41:29 +00003066def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003067 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003068def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003069 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3070}
3071
Eli Friedman27d19742009-06-19 07:00:55 +00003072// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3073// fall back to this for SSE1)
3074def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003075 (SHUFPSrri VR128:$src2, VR128:$src1,
Eli Friedman27d19742009-06-19 07:00:55 +00003076 (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>;
3077
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003078// Set lowest element and zero upper elements.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003079let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00003080def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003081 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00003082def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengd09a8a02008-05-08 22:35:02 +00003083 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003084
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003085// Some special case pandn patterns.
3086def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3087 VR128:$src2)),
3088 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3089def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3090 VR128:$src2)),
3091 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3092def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3093 VR128:$src2)),
3094 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3095
3096def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003097 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003098 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3099def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003100 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003101 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3102def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003103 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003104 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3105
Nate Begeman78246ca2007-11-17 03:58:34 +00003106// vector -> vector casts
3107def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3108 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3109def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3110 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedman7fa52ca2008-09-05 23:07:03 +00003111def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3112 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3113def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3114 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman78246ca2007-11-17 03:58:34 +00003115
Evan Cheng51a49b22007-07-20 00:27:43 +00003116// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00003117def : Pat<(alignedloadv4i32 addr:$src),
3118 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3119def : Pat<(loadv4i32 addr:$src),
3120 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00003121def : Pat<(alignedloadv2i64 addr:$src),
3122 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3123def : Pat<(loadv2i64 addr:$src),
3124 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3125
3126def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3127 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3128def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3129 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3130def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3131 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3132def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3133 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3134def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3135 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3136def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3137 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3138def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3139 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3140def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3141 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003142
Nate Begemanb2975562008-02-03 07:18:54 +00003143//===----------------------------------------------------------------------===//
3144// SSE4.1 Instructions
3145//===----------------------------------------------------------------------===//
3146
Dale Johannesena7d2b442008-10-10 23:51:03 +00003147multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begemanb2975562008-02-03 07:18:54 +00003148 string OpcodeStr,
Nate Begemanb2975562008-02-03 07:18:54 +00003149 Intrinsic V4F32Int,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003150 Intrinsic V2F64Int> {
Nate Begemanb2975562008-02-03 07:18:54 +00003151 // Intrinsic operation, reg.
Nate Begemanb2975562008-02-03 07:18:54 +00003152 // Vector intrinsic operation, reg
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003153 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003154 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003155 !strconcat(OpcodeStr,
3156 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003157 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3158 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003159
3160 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003161 def PSm_Int : SS4AIi8<opcps, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003162 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003163 !strconcat(OpcodeStr,
3164 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003165 [(set VR128:$dst,
3166 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003167 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003168
Nate Begemanb2975562008-02-03 07:18:54 +00003169 // Vector intrinsic operation, reg
Evan Cheng78d00612008-03-14 07:39:27 +00003170 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003171 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003172 !strconcat(OpcodeStr,
3173 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003174 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3175 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003176
3177 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003178 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003179 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003180 !strconcat(OpcodeStr,
3181 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003182 [(set VR128:$dst,
3183 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003184 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003185}
3186
Dale Johannesena7d2b442008-10-10 23:51:03 +00003187let Constraints = "$src1 = $dst" in {
3188multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3189 string OpcodeStr,
3190 Intrinsic F32Int,
3191 Intrinsic F64Int> {
3192 // Intrinsic operation, reg.
3193 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003194 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003195 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3196 !strconcat(OpcodeStr,
3197 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003198 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003199 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3200 OpSize;
3201
3202 // Intrinsic operation, mem.
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003203 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3204 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003205 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003206 !strconcat(OpcodeStr,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003207 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003208 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003209 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3210 OpSize;
3211
3212 // Intrinsic operation, reg.
3213 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003214 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003215 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3216 !strconcat(OpcodeStr,
3217 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003218 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003219 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3220 OpSize;
3221
3222 // Intrinsic operation, mem.
3223 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003224 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003225 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3226 !strconcat(OpcodeStr,
3227 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003228 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003229 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3230 OpSize;
3231}
3232}
3233
Nate Begemanb2975562008-02-03 07:18:54 +00003234// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesena7d2b442008-10-10 23:51:03 +00003235defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3236 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3237defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3238 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003239
3240// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3241multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3242 Intrinsic IntId128> {
3243 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3244 (ins VR128:$src),
3245 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3246 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3247 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3248 (ins i128mem:$src),
3249 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3250 [(set VR128:$dst,
3251 (IntId128
3252 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3253}
3254
3255defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3256 int_x86_sse41_phminposuw>;
3257
3258/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003259let Constraints = "$src1 = $dst" in {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003260 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3261 Intrinsic IntId128, bit Commutable = 0> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003262 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3263 (ins VR128:$src1, VR128:$src2),
3264 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3265 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3266 OpSize {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003267 let isCommutable = Commutable;
3268 }
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003269 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3270 (ins VR128:$src1, i128mem:$src2),
3271 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3272 [(set VR128:$dst,
3273 (IntId128 VR128:$src1,
3274 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003275 }
3276}
3277
3278defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3279 int_x86_sse41_pcmpeqq, 1>;
3280defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3281 int_x86_sse41_packusdw, 0>;
3282defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3283 int_x86_sse41_pminsb, 1>;
3284defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3285 int_x86_sse41_pminsd, 1>;
3286defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3287 int_x86_sse41_pminud, 1>;
3288defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3289 int_x86_sse41_pminuw, 1>;
3290defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3291 int_x86_sse41_pmaxsb, 1>;
3292defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3293 int_x86_sse41_pmaxsd, 1>;
3294defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3295 int_x86_sse41_pmaxud, 1>;
3296defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3297 int_x86_sse41_pmaxuw, 1>;
Nate Begeman72d802a2008-02-04 06:00:24 +00003298
Mon P Wang14edb092008-12-18 21:42:19 +00003299defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3300
Nate Begeman03605a02008-07-17 16:51:19 +00003301def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3302 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3303def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3304 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3305
Nate Begeman58057962008-02-09 01:38:08 +00003306/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003307let Constraints = "$src1 = $dst" in {
Dan Gohmane3731f52008-05-23 17:49:40 +00003308 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3309 SDNode OpNode, Intrinsic IntId128,
3310 bit Commutable = 0> {
Nate Begeman58057962008-02-09 01:38:08 +00003311 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3312 (ins VR128:$src1, VR128:$src2),
3313 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmane3731f52008-05-23 17:49:40 +00003314 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3315 VR128:$src2))]>, OpSize {
Nate Begeman58057962008-02-09 01:38:08 +00003316 let isCommutable = Commutable;
3317 }
3318 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3319 (ins VR128:$src1, VR128:$src2),
3320 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3321 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3322 OpSize {
3323 let isCommutable = Commutable;
3324 }
3325 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3326 (ins VR128:$src1, i128mem:$src2),
3327 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3328 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003329 (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003330 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3331 (ins VR128:$src1, i128mem:$src2),
3332 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3333 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003334 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman58057962008-02-09 01:38:08 +00003335 OpSize;
3336 }
3337}
Dan Gohmane3731f52008-05-23 17:49:40 +00003338defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
Nate Begeman58057962008-02-09 01:38:08 +00003339 int_x86_sse41_pmulld, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003340
Evan Cheng78d00612008-03-14 07:39:27 +00003341/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Cheng3ea4d672008-03-05 08:19:16 +00003342let Constraints = "$src1 = $dst" in {
Nate Begeman72d802a2008-02-04 06:00:24 +00003343 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3344 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng78d00612008-03-14 07:39:27 +00003345 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003346 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003347 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003348 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003349 [(set VR128:$dst,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003350 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3351 OpSize {
Nate Begeman72d802a2008-02-04 06:00:24 +00003352 let isCommutable = Commutable;
3353 }
Evan Cheng78d00612008-03-14 07:39:27 +00003354 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003355 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3356 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003357 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003358 [(set VR128:$dst,
3359 (IntId128 VR128:$src1,
3360 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3361 OpSize;
Nate Begeman72d802a2008-02-04 06:00:24 +00003362 }
3363}
3364
3365defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3366 int_x86_sse41_blendps, 0>;
3367defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3368 int_x86_sse41_blendpd, 0>;
3369defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3370 int_x86_sse41_pblendw, 0>;
3371defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3372 int_x86_sse41_dpps, 1>;
3373defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3374 int_x86_sse41_dppd, 1>;
3375defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng81ed9852008-06-16 20:25:59 +00003376 int_x86_sse41_mpsadbw, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003377
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003378
Evan Cheng78d00612008-03-14 07:39:27 +00003379/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003380let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanb4e9a042008-02-10 18:47:57 +00003381 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3382 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3383 (ins VR128:$src1, VR128:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003384 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003385 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3386 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3387 OpSize;
3388
3389 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3390 (ins VR128:$src1, i128mem:$src2),
3391 !strconcat(OpcodeStr,
3392 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3393 [(set VR128:$dst,
3394 (IntId VR128:$src1,
3395 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3396 }
3397}
3398
3399defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3400defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3401defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3402
3403
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003404multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3405 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3406 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3407 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3408
3409 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3410 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003411 [(set VR128:$dst,
3412 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3413 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003414}
3415
3416defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3417defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3418defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3419defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3420defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3421defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3422
Evan Cheng56ec77b2008-09-24 23:27:55 +00003423// Common patterns involving scalar load.
3424def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3425 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3426def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3427 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3428
3429def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3430 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3431def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3432 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3433
3434def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3435 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3436def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3437 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3438
3439def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3440 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3441def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3442 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3443
3444def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3445 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3446def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3447 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3448
3449def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3450 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3451def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3452 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3453
3454
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003455multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3456 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3457 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3458 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3459
3460 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3461 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003462 [(set VR128:$dst,
3463 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3464 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003465}
3466
3467defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3468defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3469defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3470defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3471
Evan Cheng56ec77b2008-09-24 23:27:55 +00003472// Common patterns involving scalar load
3473def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003474 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003475def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003476 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003477
3478def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003479 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003480def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003481 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003482
3483
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003484multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3485 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3486 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3487 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3488
Evan Cheng56ec77b2008-09-24 23:27:55 +00003489 // Expecting a i16 load any extended to i32 value.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003490 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3491 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003492 [(set VR128:$dst, (IntId (bitconvert
3493 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3494 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003495}
3496
3497defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman75a89d62009-06-06 05:55:37 +00003498defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003499
Evan Cheng56ec77b2008-09-24 23:27:55 +00003500// Common patterns involving scalar load
3501def : Pat<(int_x86_sse41_pmovsxbq
3502 (bitconvert (v4i32 (X86vzmovl
3503 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003504 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003505
3506def : Pat<(int_x86_sse41_pmovzxbq
3507 (bitconvert (v4i32 (X86vzmovl
3508 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003509 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003510
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003511
Nate Begemand77e59e2008-02-11 04:19:36 +00003512/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3513multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003514 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003515 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003516 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003517 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003518 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3519 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003520 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003521 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003522 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003523 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003524 []>, OpSize;
3525// FIXME:
3526// There's an AssertZext in the way of writing the store pattern
3527// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003528}
3529
Nate Begemand77e59e2008-02-11 04:19:36 +00003530defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003531
Nate Begemand77e59e2008-02-11 04:19:36 +00003532
3533/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3534multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003535 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemand77e59e2008-02-11 04:19:36 +00003536 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003537 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003538 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3539 []>, OpSize;
3540// FIXME:
3541// There's an AssertZext in the way of writing the store pattern
3542// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3543}
3544
3545defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3546
3547
3548/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3549multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003550 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003551 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003552 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003553 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3554 [(set GR32:$dst,
3555 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003556 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003557 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003558 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003559 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3560 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3561 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003562}
3563
Nate Begemand77e59e2008-02-11 04:19:36 +00003564defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman58057962008-02-09 01:38:08 +00003565
Nate Begemand77e59e2008-02-11 04:19:36 +00003566
Evan Cheng6c249332008-03-24 21:52:23 +00003567/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3568/// destination
Nate Begemand77e59e2008-02-11 04:19:36 +00003569multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003570 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003571 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003572 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003573 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman788db592008-04-16 02:32:24 +00003574 [(set GR32:$dst,
3575 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng6c249332008-03-24 21:52:23 +00003576 OpSize;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003577 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003578 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003579 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003580 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng6c249332008-03-24 21:52:23 +00003581 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003582 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003583}
3584
Nate Begemand77e59e2008-02-11 04:19:36 +00003585defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003586
Dan Gohmana41862a2008-08-08 18:30:21 +00003587// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3588def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3589 imm:$src2))),
3590 addr:$dst),
3591 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3592 Requires<[HasSSE41]>;
3593
Evan Cheng3ea4d672008-03-05 08:19:16 +00003594let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003595 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003596 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003597 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003598 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003599 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003600 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003601 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003602 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003603 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3604 !strconcat(OpcodeStr,
3605 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003606 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003607 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3608 imm:$src3))]>, OpSize;
3609 }
3610}
3611
3612defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3613
Evan Cheng3ea4d672008-03-05 08:19:16 +00003614let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003615 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003616 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003617 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003618 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003619 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003620 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003621 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3622 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003623 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003624 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3625 !strconcat(OpcodeStr,
3626 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003627 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003628 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3629 imm:$src3)))]>, OpSize;
3630 }
3631}
3632
3633defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3634
Eric Christophera0443602009-07-23 02:22:41 +00003635// insertps has a few different modes, there's the first two here below which
3636// are optimized inserts that won't zero arbitrary elements in the destination
3637// vector. The next one matches the intrinsic and could zero arbitrary elements
3638// in the target vector.
Evan Cheng3ea4d672008-03-05 08:19:16 +00003639let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003640 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherefb657e2009-07-24 00:33:09 +00003641 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3642 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003643 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003644 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003645 [(set VR128:$dst,
3646 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
3647 OpSize;
Eric Christopherefb657e2009-07-24 00:33:09 +00003648 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003649 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3650 !strconcat(OpcodeStr,
3651 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003652 [(set VR128:$dst,
Eric Christopherefb657e2009-07-24 00:33:09 +00003653 (X86insrtps VR128:$src1,
3654 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begemand77e59e2008-02-11 04:19:36 +00003655 imm:$src3))]>, OpSize;
3656 }
3657}
3658
Evan Chengc2054be2008-03-26 08:11:49 +00003659defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003660
Eric Christopherefb657e2009-07-24 00:33:09 +00003661def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3662 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3663
Eric Christopher95d79262009-07-29 00:28:05 +00003664// ptest instruction we'll lower to this in X86ISelLowering primarily from
3665// the intel intrinsic that corresponds to this.
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003666let Defs = [EFLAGS] in {
3667def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003668 "ptest \t{$src2, $src1|$src1, $src2}",
3669 [(X86ptest VR128:$src1, VR128:$src2),
3670 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003671def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003672 "ptest \t{$src2, $src1|$src1, $src2}",
3673 [(X86ptest VR128:$src1, (load addr:$src2)),
3674 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003675}
3676
3677def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3678 "movntdqa\t{$src, $dst|$dst, $src}",
3679 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>;
Nate Begeman03605a02008-07-17 16:51:19 +00003680
Eric Christopher22a39402009-08-18 22:50:32 +00003681
3682//===----------------------------------------------------------------------===//
3683// SSE4.2 Instructions
3684//===----------------------------------------------------------------------===//
3685
Nate Begeman03605a02008-07-17 16:51:19 +00003686/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3687let Constraints = "$src1 = $dst" in {
3688 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3689 Intrinsic IntId128, bit Commutable = 0> {
3690 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3691 (ins VR128:$src1, VR128:$src2),
3692 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3693 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3694 OpSize {
3695 let isCommutable = Commutable;
3696 }
3697 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3698 (ins VR128:$src1, i128mem:$src2),
3699 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3700 [(set VR128:$dst,
3701 (IntId128 VR128:$src1,
3702 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3703 }
3704}
3705
Nate Begeman235666b2008-07-17 17:04:58 +00003706defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman03605a02008-07-17 16:51:19 +00003707
3708def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3709 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3710def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3711 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003712
3713// crc intrinsic instruction
3714// This set of instructions are only rm, the only difference is the size
3715// of r and m.
3716let Constraints = "$src1 = $dst" in {
Eric Christopher85f187b2009-08-10 21:48:58 +00003717 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003718 (ins GR32:$src1, i8mem:$src2),
3719 "crc32 \t{$src2, $src1|$src1, $src2}",
3720 [(set GR32:$dst,
3721 (int_x86_sse42_crc32_8 GR32:$src1,
3722 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003723 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003724 (ins GR32:$src1, GR8:$src2),
3725 "crc32 \t{$src2, $src1|$src1, $src2}",
3726 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003727 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003728 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003729 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003730 (ins GR32:$src1, i16mem:$src2),
3731 "crc32 \t{$src2, $src1|$src1, $src2}",
3732 [(set GR32:$dst,
3733 (int_x86_sse42_crc32_16 GR32:$src1,
3734 (load addr:$src2)))]>,
3735 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003736 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003737 (ins GR32:$src1, GR16:$src2),
3738 "crc32 \t{$src2, $src1|$src1, $src2}",
3739 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003740 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003741 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003742 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003743 (ins GR32:$src1, i32mem:$src2),
3744 "crc32 \t{$src2, $src1|$src1, $src2}",
3745 [(set GR32:$dst,
3746 (int_x86_sse42_crc32_32 GR32:$src1,
3747 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003748 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003749 (ins GR32:$src1, GR32:$src2),
3750 "crc32 \t{$src2, $src1|$src1, $src2}",
3751 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003752 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003753 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003754 def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003755 (ins GR64:$src1, i64mem:$src2),
3756 "crc32 \t{$src2, $src1|$src1, $src2}",
3757 [(set GR64:$dst,
3758 (int_x86_sse42_crc32_64 GR64:$src1,
3759 (load addr:$src2)))]>,
3760 OpSize, REX_W;
Eric Christopher85f187b2009-08-10 21:48:58 +00003761 def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003762 (ins GR64:$src1, GR64:$src2),
3763 "crc32 \t{$src2, $src1|$src1, $src2}",
3764 [(set GR64:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003765 (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003766 OpSize, REX_W;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003767}
Eric Christopher22a39402009-08-18 22:50:32 +00003768
3769// String/text processing instructions.
3770let Defs = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
3771def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
3772 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3773 "#PCMPISTRM128rr PSEUDO!",
3774 [(set VR128:$dst,
3775 (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
3776 imm:$src3))]>, OpSize;
3777def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
3778 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3779 "#PCMPISTRM128rm PSEUDO!",
3780 [(set VR128:$dst,
3781 (int_x86_sse42_pcmpistrm128 VR128:$src1,
3782 (load addr:$src2),
3783 imm:$src3))]>, OpSize;
3784}
3785
3786let Defs = [XMM0, EFLAGS] in {
3787def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
3788 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3789 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3790 []>, OpSize;
3791def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
3792 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3793 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3794 []>, OpSize;
3795}
3796
3797let Defs = [EFLAGS], Uses = [EAX, EDX],
3798 usesCustomDAGSchedInserter = 1 in {
3799def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
3800 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3801 "#PCMPESTRM128rr PSEUDO!",
3802 [(set VR128:$dst,
3803 (int_x86_sse42_pcmpestrm128 VR128:$src1, EAX,
3804 VR128:$src3,
3805 EDX, imm:$src5))]>, OpSize;
3806def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
3807 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3808 "#PCMPESTRM128rm PSEUDO!",
3809 [(set VR128:$dst,
3810 (int_x86_sse42_pcmpestrm128 VR128:$src1, EAX,
3811 (load addr:$src3),
3812 EDX, imm:$src5))]>, OpSize;
3813}
3814
3815let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
Sean Callananc5a05b72009-08-20 18:24:27 +00003816def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
Eric Christopher22a39402009-08-18 22:50:32 +00003817 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3818 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3819 []>, OpSize;
Sean Callananc5a05b72009-08-20 18:24:27 +00003820def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
Eric Christopher22a39402009-08-18 22:50:32 +00003821 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3822 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3823 []>, OpSize;
3824}
3825
3826let Defs = [ECX, EFLAGS] in {
3827 multiclass SS42AI_pcmpistri<Intrinsic IntId128> {
3828 def rr : SS42AI<0x63, MRMSrcReg, (outs),
3829 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3830 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3831 [(set ECX,
3832 (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
3833 (implicit EFLAGS)]>,
3834 OpSize;
3835 def rm : SS42AI<0x63, MRMSrcMem, (outs),
3836 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3837 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3838 [(set ECX,
3839 (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
3840 (implicit EFLAGS)]>,
3841 OpSize;
3842 }
3843}
3844
3845defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
3846defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
3847defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
3848defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
3849defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
3850defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
3851
3852let Defs = [ECX, EFLAGS] in {
3853let Uses = [EAX, EDX] in {
3854 multiclass SS42AI_pcmpestri<Intrinsic IntId128> {
3855 def rr : SS42AI<0x61, MRMSrcReg, (outs),
3856 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3857 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3858 [(set ECX,
3859 (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
3860 (implicit EFLAGS)]>,
3861 OpSize;
3862 def rm : SS42AI<0x61, MRMSrcMem, (outs),
3863 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3864 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3865 [(set ECX,
3866 (IntId128 VR128:$src1, EAX, (load addr:$src3),
3867 EDX, imm:$src5)),
3868 (implicit EFLAGS)]>,
3869 OpSize;
3870 }
3871}
3872}
3873
3874defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
3875defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
3876defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
3877defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
3878defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
3879defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;