blob: 96fc932fc88c0ef999cbde7e2b46eb7dc30102ba [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.
Dan Gohman51dbce62009-09-21 18:30:38 +0000475let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
476 canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000477def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000478 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000479 Requires<[HasSSE1]>, TB, OpSize;
480
481// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
482// disregarded.
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000483let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000484def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000485 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000486
487// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
488// disregarded.
Dan Gohman5574cc72008-12-03 18:15:48 +0000489let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000490def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000491 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000492 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493
494// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +0000495let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000496let isCommutable = 1 in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000497 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
498 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000499 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000501 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
502 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000503 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000505 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
506 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000507 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
509}
510
Dan Gohmanf221da12009-01-09 02:27:34 +0000511def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
512 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000513 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000514 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000515 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000516def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
517 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000518 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000520 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000521def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
522 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000523 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000524 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000525 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000526
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000527let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000529 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000530 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000531let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000533 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000534 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000536}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537
538/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
539///
540/// In addition, we also have a special variant of the scalar form here to
541/// represent the associated intrinsic operation. This form is unlike the
542/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000543/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544///
545/// These three forms can each be reg+reg or reg+mem, so there are a total of
546/// six "instructions".
547///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000548let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
550 SDNode OpNode, Intrinsic F32Int,
551 bit Commutable = 0> {
552 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000553 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000554 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
556 let isCommutable = Commutable;
557 }
558
559 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000560 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
561 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000562 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000564
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000566 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
567 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000568 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
570 let isCommutable = Commutable;
571 }
572
573 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000574 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
575 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000576 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000577 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000578
579 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000580 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
581 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000582 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000583 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584
585 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000586 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
587 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000588 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000589 [(set VR128:$dst, (F32Int VR128:$src1,
590 sse_load_f32:$src2))]>;
591}
592}
593
594// Arithmetic instructions
595defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
596defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
597defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
598defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
599
600/// sse1_fp_binop_rm - Other SSE1 binops
601///
602/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
603/// instructions for a full-vector intrinsic form. Operations that map
604/// onto C operators don't use this form since they just use the plain
605/// vector form instead of having a separate vector intrinsic form.
606///
607/// This provides a total of eight "instructions".
608///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000609let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000610multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
611 SDNode OpNode,
612 Intrinsic F32Int,
613 Intrinsic V4F32Int,
614 bit Commutable = 0> {
615
616 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000617 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000618 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
620 let isCommutable = Commutable;
621 }
622
623 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000624 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
625 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000626 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000628
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000629 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000630 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
631 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000632 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000633 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
634 let isCommutable = Commutable;
635 }
636
637 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000638 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
639 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000640 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000641 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642
643 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000644 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
645 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000646 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000647 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
648 let isCommutable = Commutable;
649 }
650
651 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000652 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
653 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000654 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000655 [(set VR128:$dst, (F32Int VR128:$src1,
656 sse_load_f32:$src2))]>;
657
658 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000659 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
660 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000661 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
663 let isCommutable = Commutable;
664 }
665
666 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000667 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
668 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000669 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000670 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000671}
672}
673
674defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
675 int_x86_sse_max_ss, int_x86_sse_max_ps>;
676defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
677 int_x86_sse_min_ss, int_x86_sse_min_ps>;
678
679//===----------------------------------------------------------------------===//
680// SSE packed FP Instructions
681
682// Move Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000683let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000684def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000685 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000686let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000687def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000688 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000689 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690
Evan Chengb783fa32007-07-19 01:14:50 +0000691def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000692 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000693 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000695let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000696def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000697 "movups\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000698let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000699def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000700 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000701 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000702def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000703 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000704 [(store (v4f32 VR128:$src), addr:$dst)]>;
705
706// Intrinsic forms of MOVUPS load and store
Dan Gohman5574cc72008-12-03 18:15:48 +0000707let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000708def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000709 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000710 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000711def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000712 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000713 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714
Evan Cheng3ea4d672008-03-05 08:19:16 +0000715let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716 let AddedComplexity = 20 in {
717 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000718 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000719 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000720 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000721 (movlp VR128:$src1,
722 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000724 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000725 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000726 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000727 (movhp VR128:$src1,
728 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000730} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731
Evan Chengd743a5f2008-05-10 00:59:18 +0000732
Evan Chengb783fa32007-07-19 01:14:50 +0000733def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000734 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
736 (iPTR 0))), addr:$dst)]>;
737
738// v2f64 extract element 1 is always custom lowered to unpack high to low
739// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000740def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000741 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +0000743 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
744 (undef)), (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745
Evan Cheng3ea4d672008-03-05 08:19:16 +0000746let Constraints = "$src1 = $dst" in {
Evan Cheng13559d62008-09-26 23:41:32 +0000747let AddedComplexity = 20 in {
Evan Cheng7581a822009-05-12 20:17:52 +0000748def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
749 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000750 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000752 (v4f32 (movhp VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753
Evan Cheng7581a822009-05-12 20:17:52 +0000754def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
755 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000756 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000758 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759} // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000760} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761
Nate Begemanb44aad72009-04-29 22:47:44 +0000762let AddedComplexity = 20 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000763def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Evan Chenga2497eb2008-09-25 20:50:48 +0000764 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begemanb44aad72009-04-29 22:47:44 +0000765def : Pat<(v2i64 (movddup VR128:$src, (undef))),
766 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
767}
Evan Chenga2497eb2008-09-25 20:50:48 +0000768
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769
770
771// Arithmetic
772
773/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
774///
775/// In addition, we also have a special variant of the scalar form here to
776/// represent the associated intrinsic operation. This form is unlike the
777/// plain scalar form, in that it takes an entire vector (instead of a
778/// scalar) and leaves the top elements undefined.
779///
780/// And, we have a special variant form for a full-vector intrinsic form.
781///
782/// These four forms can each have a reg or a mem operand, so there are a
783/// total of eight "instructions".
784///
785multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
786 SDNode OpNode,
787 Intrinsic F32Int,
788 Intrinsic V4F32Int,
789 bit Commutable = 0> {
790 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000791 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000792 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000793 [(set FR32:$dst, (OpNode FR32:$src))]> {
794 let isCommutable = Commutable;
795 }
796
797 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000798 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000799 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000801
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000803 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000804 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
806 let isCommutable = Commutable;
807 }
808
809 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000810 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000811 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000812 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813
814 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000815 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000816 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 [(set VR128:$dst, (F32Int VR128:$src))]> {
818 let isCommutable = Commutable;
819 }
820
821 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000822 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000823 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000824 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
825
826 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000827 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000828 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
830 let isCommutable = Commutable;
831 }
832
833 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000834 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000835 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000836 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837}
838
839// Square root.
840defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
841 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
842
843// Reciprocal approximations. Note that these typically require refinement
844// in order to obtain suitable precision.
845defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
846 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
847defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
848 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
849
850// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +0000851let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 let isCommutable = 1 in {
853 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000854 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000855 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 [(set VR128:$dst, (v2i64
857 (and VR128:$src1, VR128:$src2)))]>;
858 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000859 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000860 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861 [(set VR128:$dst, (v2i64
862 (or VR128:$src1, VR128:$src2)))]>;
863 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000864 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000865 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866 [(set VR128:$dst, (v2i64
867 (xor VR128:$src1, VR128:$src2)))]>;
868 }
869
870 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000871 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000872 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000873 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
874 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000876 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000877 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000878 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
879 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000881 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000882 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000883 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
884 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000886 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000887 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888 [(set VR128:$dst,
889 (v2i64 (and (xor VR128:$src1,
890 (bc_v2i64 (v4i32 immAllOnesV))),
891 VR128:$src2)))]>;
892 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000893 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000894 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000896 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000898 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899}
900
Evan Cheng3ea4d672008-03-05 08:19:16 +0000901let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000902 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begeman061db5f2008-05-12 20:34:32 +0000903 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
904 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
905 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
906 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000907 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begeman061db5f2008-05-12 20:34:32 +0000908 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
909 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
910 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +0000911 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912}
Nate Begeman03605a02008-07-17 16:51:19 +0000913def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
914 (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>;
915def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
916 (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917
918// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +0000919let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000921 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000922 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000923 VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000924 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000926 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000927 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000928 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000929 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000930 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000932 (v4f32 (shufp:$src3
933 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934
935 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000936 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000937 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000940 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000941 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000942 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000943 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000945 (v4f32 (unpckh VR128:$src1,
946 (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000948 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000949 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000950 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000952 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000953 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000954 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000955 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000957 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000959} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960
961// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000962def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000963 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengd8296b82009-05-28 18:55:28 +0000965def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000966 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
968
Evan Chengd1d68072008-03-08 00:58:38 +0000969// Prefetch intrinsic.
970def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
971 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
972def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
973 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
974def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
975 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
976def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
977 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978
979// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000980def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000981 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
983
984// Load, store, and memory fence
Evan Cheng68cca152009-05-27 18:38:01 +0000985def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986
987// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000988def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000989 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000990def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000991 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992
993// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +0000994// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +0000995// load of an all-zeros value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +0000996let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
997 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000998def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000999 "xorps\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00001000 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001
Evan Chenga15896e2008-03-12 07:02:50 +00001002let Predicates = [HasSSE1] in {
1003 def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
1004 def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1005 def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1006 def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1007 def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
1008}
1009
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010// FR32 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001011let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001012def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001013 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014 [(set VR128:$dst,
1015 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001016def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001017 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 [(set VR128:$dst,
1019 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
1020
1021// FIXME: may not be able to eliminate this movss with coalescing the src and
1022// dest register classes are different. We really want to write this pattern
1023// like this:
1024// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1025// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001026let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001027def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
1030 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001031def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001032 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 [(store (f32 (vector_extract (v4f32 VR128:$src),
1034 (iPTR 0))), addr:$dst)]>;
1035
1036
1037// Move to lower bits of a VR128, leaving upper bits alone.
1038// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001039let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001040let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001042 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001043 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044
1045 let AddedComplexity = 15 in
1046 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001047 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001048 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001050 (v4f32 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001051}
1052
1053// Move to lower bits of a VR128 and zeroing upper bits.
1054// Loading from memory automatically zeroing upper bits.
1055let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00001056def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001057 "movss\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00001058 [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001059 (loadf32 addr:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060
Evan Cheng056afe12008-05-20 18:24:47 +00001061def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
Evan Cheng40ee6e52008-05-08 00:57:18 +00001062 (MOVZSS2PSrm addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001064//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065// SSE2 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001066//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001069let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001070def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001071 "movsd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001072let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001073def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001074 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001076def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001077 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078 [(store FR64:$src, addr:$dst)]>;
1079
1080// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001081def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001082 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001084def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001085 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001087def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001088 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(set FR32:$dst, (fround FR64:$src))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001090def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001091 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001093def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001094 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001096def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001097 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1099
Sean Callanan3d5824c2009-09-16 01:13:52 +00001100def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1101 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1102def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1103 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1104def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1105 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1106def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1107 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1108def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1109 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1110def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1111 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1112def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1113 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1114def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1115 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1116def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1117 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1118def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1119 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1120
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001122def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001123 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1125 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001126def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001127 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001128 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1129 Requires<[HasSSE2]>;
1130
1131// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001132def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001133 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001135def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001136 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1138 (load addr:$src)))]>;
1139
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001140// Match intrinisics which expect MM and XMM operand(s).
1141def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1142 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1143 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1144def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1145 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001146 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001147 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001148def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1149 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1150 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1151def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1152 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001153 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001154 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001155def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1156 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1157 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1158def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1159 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001160 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001161 (load addr:$src)))]>;
1162
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001164def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001165 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166 [(set GR32:$dst,
1167 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001168def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001169 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1171 (load addr:$src)))]>;
1172
1173// Comparison instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001174let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001175 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001176 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001177 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001178let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001179 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001180 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001181 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182}
1183
Evan Cheng950aac02007-09-25 01:57:46 +00001184let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001185def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001186 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001187 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001188def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001189 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001190 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001191 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001192} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001193
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +00001195let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001196 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
1197 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
1198 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001199 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1201 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001202 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
1203 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src,
1204 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001205 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1207 (load addr:$src), imm:$cc))]>;
1208}
1209
Evan Cheng950aac02007-09-25 01:57:46 +00001210let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001211def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001212 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001213 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1214 (implicit EFLAGS)]>;
1215def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001216 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001217 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1218 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219
Evan Chengb783fa32007-07-19 01:14:50 +00001220def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001221 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001222 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1223 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001224def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001225 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001226 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001227 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001228} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001229
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001230// Aliases of packed SSE2 instructions for scalar use. These all have names
1231// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001232
1233// Alias instructions that map fld0 to pxor for sse.
Dan Gohman51dbce62009-09-21 18:30:38 +00001234let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1235 canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001236def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001237 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001238 Requires<[HasSSE2]>, TB, OpSize;
1239
1240// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1241// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001242let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001243def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001244 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245
1246// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1247// disregarded.
Dan Gohman5574cc72008-12-03 18:15:48 +00001248let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001249def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001250 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001251 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252
1253// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001254let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001255let isCommutable = 1 in {
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001256 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1257 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001258 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001260 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1261 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001264 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1265 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001266 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1268}
1269
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001270def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1271 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001272 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001274 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001275def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1276 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001277 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001279 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001280def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1281 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001282 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001284 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001286let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001288 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001289 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001290let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001292 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001293 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001295}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296
1297/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1298///
1299/// In addition, we also have a special variant of the scalar form here to
1300/// represent the associated intrinsic operation. This form is unlike the
1301/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001302/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001303///
1304/// These three forms can each be reg+reg or reg+mem, so there are a total of
1305/// six "instructions".
1306///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001307let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1309 SDNode OpNode, Intrinsic F64Int,
1310 bit Commutable = 0> {
1311 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001312 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001313 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1315 let isCommutable = Commutable;
1316 }
1317
1318 // Scalar operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001319 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1320 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001321 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001323
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324 // Vector operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001325 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1326 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001327 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001328 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1329 let isCommutable = Commutable;
1330 }
1331
1332 // Vector operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001333 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1334 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001335 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf221da12009-01-09 02:27:34 +00001336 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337
1338 // Intrinsic operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001339 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1340 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001341 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001342 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343
1344 // Intrinsic operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001345 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1346 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001347 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348 [(set VR128:$dst, (F64Int VR128:$src1,
1349 sse_load_f64:$src2))]>;
1350}
1351}
1352
1353// Arithmetic instructions
1354defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1355defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1356defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1357defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1358
1359/// sse2_fp_binop_rm - Other SSE2 binops
1360///
1361/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1362/// instructions for a full-vector intrinsic form. Operations that map
1363/// onto C operators don't use this form since they just use the plain
1364/// vector form instead of having a separate vector intrinsic form.
1365///
1366/// This provides a total of eight "instructions".
1367///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001368let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1370 SDNode OpNode,
1371 Intrinsic F64Int,
1372 Intrinsic V2F64Int,
1373 bit Commutable = 0> {
1374
1375 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001376 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001377 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1379 let isCommutable = Commutable;
1380 }
1381
1382 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001383 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1384 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001385 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001387
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001388 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001389 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1390 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001391 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001392 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1393 let isCommutable = Commutable;
1394 }
1395
1396 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001397 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1398 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001399 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001400 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001401
1402 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001403 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1404 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001405 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1407 let isCommutable = Commutable;
1408 }
1409
1410 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001411 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1412 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001413 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001414 [(set VR128:$dst, (F64Int VR128:$src1,
1415 sse_load_f64:$src2))]>;
1416
1417 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001418 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1419 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001420 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001421 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1422 let isCommutable = Commutable;
1423 }
1424
1425 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001426 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1427 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001428 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001429 [(set VR128:$dst, (V2F64Int VR128:$src1,
1430 (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001431}
1432}
1433
1434defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1435 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1436defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1437 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1438
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001439//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440// SSE packed FP Instructions
1441
1442// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001443let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001444def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001445 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001446let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001447def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001448 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001449 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001450
Evan Chengb783fa32007-07-19 01:14:50 +00001451def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001452 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001453 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001454
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001455let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001456def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001457 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001458let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001459def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001460 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001461 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001462def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001463 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001464 [(store (v2f64 VR128:$src), addr:$dst)]>;
1465
1466// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001467def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001468 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001469 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001470def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001471 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001472 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473
Evan Cheng3ea4d672008-03-05 08:19:16 +00001474let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001475 let AddedComplexity = 20 in {
1476 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001477 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001478 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001479 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001480 (v2f64 (movlp VR128:$src1,
1481 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001483 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001485 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001486 (v2f64 (movhp VR128:$src1,
1487 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001488 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001489} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001490
Evan Chengb783fa32007-07-19 01:14:50 +00001491def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001492 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001493 [(store (f64 (vector_extract (v2f64 VR128:$src),
1494 (iPTR 0))), addr:$dst)]>;
1495
1496// v2f64 extract element 1 is always custom lowered to unpack high to low
1497// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001498def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001499 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001500 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +00001501 (v2f64 (unpckh VR128:$src, (undef))),
1502 (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001503
1504// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001505def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001507 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1508 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001509def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001510 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1511 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1512 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001513 TB, Requires<[HasSSE2]>;
1514
1515// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001516def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001517 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001518 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1519 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001520def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001521 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1522 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1523 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524 XS, Requires<[HasSSE2]>;
1525
Evan Chengb783fa32007-07-19 01:14:50 +00001526def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001527 "cvtps2dq\t{$src, $dst|$dst, $src}",
1528 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001529def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001532 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001534def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001535 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001536 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1537 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001538def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001539 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001541 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001542 XS, Requires<[HasSSE2]>;
1543
1544// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001545def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001546 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001547 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1548 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001549def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001550 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001552 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001553 XD, Requires<[HasSSE2]>;
1554
Evan Chengb783fa32007-07-19 01:14:50 +00001555def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng14c97c32008-03-14 07:46:48 +00001558def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001561 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001562
1563// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001564def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001565 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001566 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1567 TB, Requires<[HasSSE2]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001568def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001569 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1571 (load addr:$src)))]>,
1572 TB, Requires<[HasSSE2]>;
1573
Evan Chengb783fa32007-07-19 01:14:50 +00001574def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001576 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001577def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001578 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001579 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Cheng00b66ef2008-05-23 00:37:07 +00001580 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581
1582// Match intrinsics which expect XMM operand(s).
1583// Aliases for intrinsics
Evan Cheng3ea4d672008-03-05 08:19:16 +00001584let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001585def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001586 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001587 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001588 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1589 GR32:$src2))]>;
1590def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001591 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001592 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001593 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1594 (loadi32 addr:$src2)))]>;
1595def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001596 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001598 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1599 VR128:$src2))]>;
1600def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001601 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1604 (load addr:$src2)))]>;
1605def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001606 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001607 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001608 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1609 VR128:$src2))]>, XS,
1610 Requires<[HasSSE2]>;
1611def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001612 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1615 (load addr:$src2)))]>, XS,
1616 Requires<[HasSSE2]>;
1617}
1618
1619// Arithmetic
1620
1621/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1622///
1623/// In addition, we also have a special variant of the scalar form here to
1624/// represent the associated intrinsic operation. This form is unlike the
1625/// plain scalar form, in that it takes an entire vector (instead of a
1626/// scalar) and leaves the top elements undefined.
1627///
1628/// And, we have a special variant form for a full-vector intrinsic form.
1629///
1630/// These four forms can each have a reg or a mem operand, so there are a
1631/// total of eight "instructions".
1632///
1633multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1634 SDNode OpNode,
1635 Intrinsic F64Int,
1636 Intrinsic V2F64Int,
1637 bit Commutable = 0> {
1638 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001639 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001640 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641 [(set FR64:$dst, (OpNode FR64:$src))]> {
1642 let isCommutable = Commutable;
1643 }
1644
1645 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001646 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001649
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001651 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001652 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1654 let isCommutable = Commutable;
1655 }
1656
1657 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001658 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001659 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001660 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661
1662 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001663 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 [(set VR128:$dst, (F64Int VR128:$src))]> {
1666 let isCommutable = Commutable;
1667 }
1668
1669 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001670 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1673
1674 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001675 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001676 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1678 let isCommutable = Commutable;
1679 }
1680
1681 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001682 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001684 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685}
1686
1687// Square root.
1688defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1689 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1690
1691// There is no f64 version of the reciprocal approximation instructions.
1692
1693// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +00001694let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001695 let isCommutable = 1 in {
1696 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001697 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699 [(set VR128:$dst,
1700 (and (bc_v2i64 (v2f64 VR128:$src1)),
1701 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1702 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001703 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001704 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705 [(set VR128:$dst,
1706 (or (bc_v2i64 (v2f64 VR128:$src1)),
1707 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1708 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001709 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001710 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 [(set VR128:$dst,
1712 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1713 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1714 }
1715
1716 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001717 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001718 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001719 [(set VR128:$dst,
1720 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001721 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001723 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725 [(set VR128:$dst,
1726 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001727 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001728 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001729 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001731 [(set VR128:$dst,
1732 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001733 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001734 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001735 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737 [(set VR128:$dst,
1738 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1739 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1740 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001741 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001743 [(set VR128:$dst,
1744 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001745 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746}
1747
Evan Cheng3ea4d672008-03-05 08:19:16 +00001748let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001749 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001750 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1751 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1752 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begeman061db5f2008-05-12 20:34:32 +00001753 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001754 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng14c97c32008-03-14 07:46:48 +00001755 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1756 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1757 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00001758 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001759}
Evan Cheng33754092008-08-05 22:19:15 +00001760def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001761 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Cheng33754092008-08-05 22:19:15 +00001762def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001763 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001764
1765// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001766let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001767 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001768 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1769 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman543d2142009-04-27 18:41:29 +00001770 [(set VR128:$dst,
1771 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001772 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001773 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001775 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001777 (v2f64 (shufp:$src3
1778 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779
1780 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001781 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001782 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001784 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001785 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001786 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001787 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001788 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001789 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001790 (v2f64 (unpckh VR128:$src1,
1791 (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001793 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001794 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001797 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001798 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001799 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001802 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001804} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805
1806
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001807//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001808// SSE integer instructions
1809
1810// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001811let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001812def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001814let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001815def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001817 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001818let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001819def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001821 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001822let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001823def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001824 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001825 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826 XS, Requires<[HasSSE2]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001827let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001828def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001830 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001831 XS, Requires<[HasSSE2]>;
1832
Dan Gohman4a4f1512007-07-18 20:23:34 +00001833// Intrinsic forms of MOVDQU load and store
Dan Gohman5574cc72008-12-03 18:15:48 +00001834let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001835def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001837 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1838 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001839def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001840 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001841 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1842 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001843
Evan Cheng88004752008-03-05 08:11:27 +00001844let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845
1846multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1847 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001848 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001849 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001850 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1851 let isCommutable = Commutable;
1852 }
Evan Chengb783fa32007-07-19 01:14:50 +00001853 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001854 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001856 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857}
1858
Evan Chengf90f8f82008-05-03 00:52:09 +00001859multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1860 string OpcodeStr,
1861 Intrinsic IntId, Intrinsic IntId2> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001862 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1863 VR128:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001864 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1865 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001866 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1867 i128mem:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001868 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1869 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001870 (bitconvert (memopv2i64 addr:$src2))))]>;
1871 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1,
1872 i32i8imm:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001873 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1874 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
1875}
1876
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001877/// PDI_binop_rm - Simple SSE2 binary operator.
1878multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1879 ValueType OpVT, bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001880 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1881 VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001882 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001883 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1884 let isCommutable = Commutable;
1885 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001886 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1887 i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001888 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001889 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001890 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891}
1892
1893/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1894///
1895/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1896/// to collapse (bitconvert VT to VT) into its operand.
1897///
1898multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1899 bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001900 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1901 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1904 let isCommutable = Commutable;
1905 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001906 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1907 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001909 [(set VR128:$dst, (OpNode VR128:$src1,
1910 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001911}
1912
Evan Cheng3ea4d672008-03-05 08:19:16 +00001913} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001914
1915// 128-bit Integer Arithmetic
1916
1917defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1918defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1919defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1920defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1921
1922defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1923defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1924defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1925defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1926
1927defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1928defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1929defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1930defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1931
1932defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1933defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1934defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1935defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1936
1937defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1938
1939defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1940defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1941defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1942
1943defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1944
1945defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1946defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1947
1948
1949defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1950defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1951defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1952defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling953ad2e2009-05-28 02:04:00 +00001953defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001954
1955
Evan Chengf90f8f82008-05-03 00:52:09 +00001956defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
1957 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
1958defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
1959 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
1960defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
1961 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001962
Evan Chengf90f8f82008-05-03 00:52:09 +00001963defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
1964 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
1965defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
1966 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begemanc2ca5f62008-05-13 17:52:09 +00001967defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Chengf90f8f82008-05-03 00:52:09 +00001968 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969
Evan Chengf90f8f82008-05-03 00:52:09 +00001970defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
1971 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemand66fc342008-05-13 01:47:52 +00001972defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Chengf90f8f82008-05-03 00:52:09 +00001973 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001974
1975// 128-bit logical shifts.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001976let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001978 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001981 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001983 // PSRADQri doesn't exist in SSE[1-3].
1984}
1985
1986let Predicates = [HasSSE2] in {
1987 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1988 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1989 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1990 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
Bill Wendling314ee052008-10-02 05:56:52 +00001991 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
1992 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
1993 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
1994 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001995 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1996 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
Evan Chengdea99362008-05-29 08:22:04 +00001997
1998 // Shift up / down and insert zero's.
1999 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
2000 (v2i64 (PSLLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
2001 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
2002 (v2i64 (PSRLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002003}
2004
2005// Logical
2006defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2007defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2008defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2009
Evan Cheng3ea4d672008-03-05 08:19:16 +00002010let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002012 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2015 VR128:$src2)))]>;
2016
2017 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002018 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002019 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00002021 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022}
2023
2024// SSE2 Integer comparison
2025defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2026defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2027defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2028defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2029defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2030defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2031
Nate Begeman03605a02008-07-17 16:51:19 +00002032def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002033 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002034def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002035 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002036def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002037 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002038def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002039 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002040def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002041 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002042def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002043 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2044
Nate Begeman03605a02008-07-17 16:51:19 +00002045def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002046 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002047def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002048 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002049def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002050 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002051def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002052 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002053def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002054 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002055def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002056 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2057
2058
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002059// Pack instructions
2060defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2061defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2062defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2063
2064// Shuffle and unpack instructions
2065def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002066 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002067 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002068 [(set VR128:$dst, (v4i32 (pshufd:$src2
2069 VR128:$src1, (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002071 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002072 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002073 [(set VR128:$dst, (v4i32 (pshufd:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002074 (bc_v4i32(memopv2i64 addr:$src1)),
2075 (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076
2077// SSE2 with ImmT == Imm8 and XS prefix.
2078def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002079 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002081 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2082 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002083 XS, Requires<[HasSSE2]>;
2084def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002085 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002086 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002087 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002088 (bc_v8i16 (memopv2i64 addr:$src1)),
2089 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002090 XS, Requires<[HasSSE2]>;
2091
2092// SSE2 with ImmT == Imm8 and XD prefix.
2093def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman543d2142009-04-27 18:41:29 +00002094 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002095 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002096 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2097 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 XD, Requires<[HasSSE2]>;
2099def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman543d2142009-04-27 18:41:29 +00002100 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002101 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002102 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2103 (bc_v8i16 (memopv2i64 addr:$src1)),
2104 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002105 XD, Requires<[HasSSE2]>;
2106
2107
Evan Cheng3ea4d672008-03-05 08:19:16 +00002108let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002109 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002110 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002113 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002114 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002115 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002116 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002118 (unpckl VR128:$src1,
2119 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002120 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002121 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002124 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002125 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002126 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002127 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002129 (unpckl VR128:$src1,
2130 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002131 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002132 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002135 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002136 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002137 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002138 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002140 (unpckl VR128:$src1,
2141 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002142 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002143 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002144 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002145 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002146 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002147 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002148 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002149 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002150 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002151 (v2i64 (unpckl VR128:$src1,
2152 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002153
2154 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002155 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002156 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002157 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002158 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002159 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002160 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002161 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002162 [(set VR128:$dst,
2163 (unpckh VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002164 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002165 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002166 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002169 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002170 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002171 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002172 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002173 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002174 (unpckh VR128:$src1,
2175 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002176 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002177 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002178 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002180 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002181 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002182 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002183 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002185 (unpckh VR128:$src1,
2186 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002187 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002188 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002190 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002191 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002192 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002193 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002194 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002195 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002196 (v2i64 (unpckh VR128:$src1,
2197 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198}
2199
2200// Extract / Insert
2201def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002202 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begemand77e59e2008-02-11 04:19:36 +00002205 imm:$src2))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +00002206let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002207 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002208 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002209 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002210 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002212 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002213 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002214 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002215 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002216 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002217 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002218 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2219 imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002220}
2221
2222// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002223def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002224 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002225 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2226
2227// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002228let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002229def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002231 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002232
Evan Cheng430de082009-02-10 22:06:28 +00002233let Uses = [RDI] in
2234def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2235 "maskmovdqu\t{$mask, $src|$src, $mask}",
2236 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2237
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002239def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002241 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002242def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002243 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002245def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002247 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002248 TB, Requires<[HasSSE2]>;
2249
2250// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002251def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002253 TB, Requires<[HasSSE2]>;
2254
2255// Load, store, and memory fence
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002256def LFENCE : I<0xAE, MRM5r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002258def MFENCE : I<0xAE, MRM6r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2260
Andrew Lenharth785610d2008-02-16 01:24:58 +00002261//TODO: custom lower this so as to never even generate the noop
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002262def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002263 (i8 0)), (NOOP)>;
2264def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2265def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002266def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002267 (i8 1)), (MFENCE)>;
2268
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00002270// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00002271// load of an all-ones value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +00002272let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2273 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002274 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002275 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002276 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002277
2278// FR64 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002279let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002280def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282 [(set VR128:$dst,
2283 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002284def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "movsd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002286 [(set VR128:$dst,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002287 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2288
Evan Chengb783fa32007-07-19 01:14:50 +00002289def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002290 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291 [(set VR128:$dst,
2292 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002293def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295 [(set VR128:$dst,
2296 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2297
Evan Chengb783fa32007-07-19 01:14:50 +00002298def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002299 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2301
Evan Chengb783fa32007-07-19 01:14:50 +00002302def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002303 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002304 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2305
2306// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002307def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002308 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002309 [(set VR128:$dst,
2310 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2311 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002312def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002313 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002314 [(store (i64 (vector_extract (v2i64 VR128:$src),
2315 (iPTR 0))), addr:$dst)]>;
2316
2317// FIXME: may not be able to eliminate this movss with coalescing the src and
2318// dest register classes are different. We really want to write this pattern
2319// like this:
2320// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2321// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002322let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002323def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002324 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002325 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2326 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002327def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002328 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002329 [(store (f64 (vector_extract (v2f64 VR128:$src),
2330 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002331def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002332 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002333 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2334 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002335def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002336 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002337 [(store (i32 (vector_extract (v4i32 VR128:$src),
2338 (iPTR 0))), addr:$dst)]>;
2339
Evan Chengb783fa32007-07-19 01:14:50 +00002340def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002341 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002342 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002343def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002344 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002345 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2346
2347
2348// Move to lower bits of a VR128, leaving upper bits alone.
2349// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002350let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00002351 let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002352 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002353 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002354 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002355
2356 let AddedComplexity = 15 in
2357 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002358 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002359 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002360 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002361 (v2f64 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002362}
2363
2364// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002365def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002366 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002367 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2368
2369// Move to lower bits of a VR128 and zeroing upper bits.
2370// Loading from memory automatically zeroing upper bits.
Evan Chengd743a5f2008-05-10 00:59:18 +00002371let AddedComplexity = 20 in {
2372def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2373 "movsd\t{$src, $dst|$dst, $src}",
2374 [(set VR128:$dst,
2375 (v2f64 (X86vzmovl (v2f64 (scalar_to_vector
2376 (loadf64 addr:$src))))))]>;
Evan Cheng40ee6e52008-05-08 00:57:18 +00002377
Evan Cheng056afe12008-05-20 18:24:47 +00002378def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
2379 (MOVZSD2PDrm addr:$src)>;
2380def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
Evan Chengd743a5f2008-05-10 00:59:18 +00002381 (MOVZSD2PDrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002382def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002383}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002385// movd / movq to XMM register zero-extends
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002386let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002387def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002388 "movd\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002389 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002390 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002391// This is X86-64 only.
2392def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2393 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002394 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002395 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002396}
2397
2398let AddedComplexity = 20 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002399def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002400 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002401 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002402 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002403 (loadi32 addr:$src))))))]>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002404
2405def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2406 (MOVZDI2PDIrm addr:$src)>;
2407def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2408 (MOVZDI2PDIrm addr:$src)>;
Duncan Sands2418bec2008-06-13 19:07:40 +00002409def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2410 (MOVZDI2PDIrm addr:$src)>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002411
Evan Chengb783fa32007-07-19 01:14:50 +00002412def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002413 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002414 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002415 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002416 (loadi64 addr:$src))))))]>, XS,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002417 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418
Evan Cheng3ad16c42008-05-22 18:56:56 +00002419def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2420 (MOVZQI2PQIrm addr:$src)>;
2421def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2422 (MOVZQI2PQIrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002423def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002424}
Evan Chenge9b9c672008-05-09 21:53:03 +00002425
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002426// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2427// IA32 document. movq xmm1, xmm2 does clear the high bits.
2428let AddedComplexity = 15 in
2429def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2430 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002431 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002432 XS, Requires<[HasSSE2]>;
2433
Evan Cheng056afe12008-05-20 18:24:47 +00002434let AddedComplexity = 20 in {
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002435def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2436 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002437 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng056afe12008-05-20 18:24:47 +00002438 (loadv2i64 addr:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002439 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002440
Evan Cheng056afe12008-05-20 18:24:47 +00002441def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2442 (MOVZPQILo2PQIrm addr:$src)>;
2443}
2444
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002445//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002446// SSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002447//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002448
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002449// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002450def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002451 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002452 [(set VR128:$dst, (v4f32 (movshdup
2453 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002454def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002455 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002456 [(set VR128:$dst, (movshdup
2457 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002458
Evan Chengb783fa32007-07-19 01:14:50 +00002459def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002460 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002461 [(set VR128:$dst, (v4f32 (movsldup
2462 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002463def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002464 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002465 [(set VR128:$dst, (movsldup
2466 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002467
Evan Chengb783fa32007-07-19 01:14:50 +00002468def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002469 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002470 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002471def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002472 "movddup\t{$src, $dst|$dst, $src}",
Evan Chenga2497eb2008-09-25 20:50:48 +00002473 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002474 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2475 (undef))))]>;
Evan Chenga2497eb2008-09-25 20:50:48 +00002476
Nate Begeman543d2142009-04-27 18:41:29 +00002477def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2478 (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002479 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002480
2481let AddedComplexity = 5 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002482def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002483 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002484def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2485 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2486def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2487 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2488def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2489 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2490}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002491
2492// Arithmetic
Evan Cheng3ea4d672008-03-05 08:19:16 +00002493let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002494 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002495 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002496 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002497 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2498 VR128:$src2))]>;
2499 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002500 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002501 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002502 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002503 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002505 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002506 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002507 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2508 VR128:$src2))]>;
2509 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002510 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002511 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002513 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002514}
2515
Evan Chengb783fa32007-07-19 01:14:50 +00002516def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002517 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002518 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2519
2520// Horizontal ops
2521class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002522 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002523 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002524 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2525class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002526 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002527 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002528 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002529class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002530 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002531 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002532 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2533class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002534 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002535 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002536 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002537
Evan Cheng3ea4d672008-03-05 08:19:16 +00002538let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002539 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2540 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2541 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2542 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2543 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2544 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2545 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2546 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2547}
2548
2549// Thread synchronization
Bill Wendling6ee76552009-05-28 23:40:46 +00002550def MONITOR : I<0x01, MRM1r, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002551 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Bill Wendling6ee76552009-05-28 23:40:46 +00002552def MWAIT : I<0x01, MRM1r, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002553 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2554
2555// vector_shuffle v1, <undef> <1, 1, 3, 3>
2556let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002557def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002558 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2559let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002560def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002561 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2562
2563// vector_shuffle v1, <undef> <0, 0, 2, 2>
2564let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002565 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002566 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2567let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002568 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002569 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2570
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002571//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002572// SSSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002573//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002574
Bill Wendling98680292007-08-10 06:22:27 +00002575/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002576multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2577 Intrinsic IntId64, Intrinsic IntId128> {
2578 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2579 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2580 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002581
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002582 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2583 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2584 [(set VR64:$dst,
2585 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2586
2587 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2588 (ins VR128:$src),
2589 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2590 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2591 OpSize;
2592
2593 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2594 (ins i128mem:$src),
2595 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2596 [(set VR128:$dst,
2597 (IntId128
2598 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002599}
2600
Bill Wendling98680292007-08-10 06:22:27 +00002601/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002602multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2603 Intrinsic IntId64, Intrinsic IntId128> {
2604 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2605 (ins VR64:$src),
2606 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2607 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002608
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002609 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2610 (ins i64mem:$src),
2611 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2612 [(set VR64:$dst,
2613 (IntId64
2614 (bitconvert (memopv4i16 addr:$src))))]>;
2615
2616 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2617 (ins VR128:$src),
2618 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2619 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2620 OpSize;
2621
2622 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2623 (ins i128mem:$src),
2624 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2625 [(set VR128:$dst,
2626 (IntId128
2627 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002628}
2629
2630/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002631multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2632 Intrinsic IntId64, Intrinsic IntId128> {
2633 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2634 (ins VR64:$src),
2635 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2636 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002637
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002638 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2639 (ins i64mem:$src),
2640 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2641 [(set VR64:$dst,
2642 (IntId64
2643 (bitconvert (memopv2i32 addr:$src))))]>;
2644
2645 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2646 (ins VR128:$src),
2647 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2648 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2649 OpSize;
2650
2651 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2652 (ins i128mem:$src),
2653 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2654 [(set VR128:$dst,
2655 (IntId128
2656 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002657}
2658
2659defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2660 int_x86_ssse3_pabs_b,
2661 int_x86_ssse3_pabs_b_128>;
2662defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2663 int_x86_ssse3_pabs_w,
2664 int_x86_ssse3_pabs_w_128>;
2665defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2666 int_x86_ssse3_pabs_d,
2667 int_x86_ssse3_pabs_d_128>;
2668
2669/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002670let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002671 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2672 Intrinsic IntId64, Intrinsic IntId128,
2673 bit Commutable = 0> {
2674 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2675 (ins VR64:$src1, VR64:$src2),
2676 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2677 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2678 let isCommutable = Commutable;
2679 }
2680 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2681 (ins VR64:$src1, i64mem:$src2),
2682 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2683 [(set VR64:$dst,
2684 (IntId64 VR64:$src1,
2685 (bitconvert (memopv8i8 addr:$src2))))]>;
2686
2687 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2688 (ins VR128:$src1, VR128:$src2),
2689 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2690 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2691 OpSize {
2692 let isCommutable = Commutable;
2693 }
2694 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2695 (ins VR128:$src1, i128mem:$src2),
2696 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2697 [(set VR128:$dst,
2698 (IntId128 VR128:$src1,
2699 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2700 }
2701}
2702
2703/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002704let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002705 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2706 Intrinsic IntId64, Intrinsic IntId128,
2707 bit Commutable = 0> {
2708 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2709 (ins VR64:$src1, VR64:$src2),
2710 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2711 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2712 let isCommutable = Commutable;
2713 }
2714 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2715 (ins VR64:$src1, i64mem:$src2),
2716 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2717 [(set VR64:$dst,
2718 (IntId64 VR64:$src1,
2719 (bitconvert (memopv4i16 addr:$src2))))]>;
2720
2721 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2722 (ins VR128:$src1, VR128:$src2),
2723 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2724 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2725 OpSize {
2726 let isCommutable = Commutable;
2727 }
2728 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2729 (ins VR128:$src1, i128mem:$src2),
2730 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2731 [(set VR128:$dst,
2732 (IntId128 VR128:$src1,
2733 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2734 }
2735}
2736
2737/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002738let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002739 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2740 Intrinsic IntId64, Intrinsic IntId128,
2741 bit Commutable = 0> {
2742 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2743 (ins VR64:$src1, VR64:$src2),
2744 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2745 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2746 let isCommutable = Commutable;
2747 }
2748 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2749 (ins VR64:$src1, i64mem:$src2),
2750 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2751 [(set VR64:$dst,
2752 (IntId64 VR64:$src1,
2753 (bitconvert (memopv2i32 addr:$src2))))]>;
2754
2755 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2756 (ins VR128:$src1, VR128:$src2),
2757 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2758 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2759 OpSize {
2760 let isCommutable = Commutable;
2761 }
2762 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2763 (ins VR128:$src1, i128mem:$src2),
2764 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2765 [(set VR128:$dst,
2766 (IntId128 VR128:$src1,
2767 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2768 }
2769}
2770
2771defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2772 int_x86_ssse3_phadd_w,
Evan Cheng944e4412008-06-16 21:16:24 +00002773 int_x86_ssse3_phadd_w_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002774defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2775 int_x86_ssse3_phadd_d,
Evan Cheng944e4412008-06-16 21:16:24 +00002776 int_x86_ssse3_phadd_d_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002777defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2778 int_x86_ssse3_phadd_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002779 int_x86_ssse3_phadd_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002780defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2781 int_x86_ssse3_phsub_w,
2782 int_x86_ssse3_phsub_w_128>;
2783defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2784 int_x86_ssse3_phsub_d,
2785 int_x86_ssse3_phsub_d_128>;
2786defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2787 int_x86_ssse3_phsub_sw,
2788 int_x86_ssse3_phsub_sw_128>;
2789defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2790 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002791 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002792defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2793 int_x86_ssse3_pmul_hr_sw,
2794 int_x86_ssse3_pmul_hr_sw_128, 1>;
2795defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2796 int_x86_ssse3_pshuf_b,
2797 int_x86_ssse3_pshuf_b_128>;
2798defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2799 int_x86_ssse3_psign_b,
2800 int_x86_ssse3_psign_b_128>;
2801defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2802 int_x86_ssse3_psign_w,
2803 int_x86_ssse3_psign_w_128>;
Evan Chengabfed472009-05-28 18:48:53 +00002804defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling98680292007-08-10 06:22:27 +00002805 int_x86_ssse3_psign_d,
2806 int_x86_ssse3_psign_d_128>;
2807
Evan Cheng3ea4d672008-03-05 08:19:16 +00002808let Constraints = "$src1 = $dst" in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002809 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2810 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002811 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002812 [(set VR64:$dst,
2813 (int_x86_ssse3_palign_r
2814 VR64:$src1, VR64:$src2,
2815 imm:$src3))]>;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002816 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Bill Wendling1dc817c2007-08-10 09:00:17 +00002817 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002818 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002819 [(set VR64:$dst,
2820 (int_x86_ssse3_palign_r
2821 VR64:$src1,
2822 (bitconvert (memopv2i32 addr:$src2)),
2823 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002824
Bill Wendling1dc817c2007-08-10 09:00:17 +00002825 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2826 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002827 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002828 [(set VR128:$dst,
2829 (int_x86_ssse3_palign_r_128
2830 VR128:$src1, VR128:$src2,
2831 imm:$src3))]>, OpSize;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002832 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Bill Wendling1dc817c2007-08-10 09:00:17 +00002833 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002834 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002835 [(set VR128:$dst,
2836 (int_x86_ssse3_palign_r_128
2837 VR128:$src1,
2838 (bitconvert (memopv4i32 addr:$src2)),
2839 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002840}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002841
Nate Begeman2c87c422009-02-23 08:49:38 +00002842def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2843 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2844def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2845 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2846
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002847//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002848// Non-Instruction Patterns
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002849//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002850
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002851// extload f32 -> f64. This matches load+fextend because we have a hack in
2852// the isel (PreprocessForFPConvert) that can introduce loads after dag
2853// combine.
Chris Lattnerdec9cb52008-01-24 08:07:48 +00002854// Since these loads aren't folded into the fextend, we have to match it
2855// explicitly here.
2856let Predicates = [HasSSE2] in
2857 def : Pat<(fextend (loadf32 addr:$src)),
2858 (CVTSS2SDrm addr:$src)>;
2859
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002860// bit_convert
2861let Predicates = [HasSSE2] in {
2862 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2863 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2864 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2865 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2866 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2867 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2868 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2869 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2870 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2871 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2872 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2873 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2874 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2875 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2876 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2877 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2878 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2879 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2880 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2881 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2882 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2883 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2884 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2885 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2886 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2887 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2888 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2889 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2890 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2891 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2892}
2893
2894// Move scalar to XMM zero-extended
2895// movd to XMM register zero-extends
2896let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002897// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chenge9b9c672008-05-09 21:53:03 +00002898def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002899 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002900def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002901 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>;
Evan Chenge259e872008-05-09 23:37:55 +00002902def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002903 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Evan Cheng7fe0ff02008-07-10 01:08:23 +00002904def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002905 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002906}
2907
2908// Splat v2f64 / v2i64
2909let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002910def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002912def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002913 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002914def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002915 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002916def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002917 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2918}
2919
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002920// Special unary SHUFPSrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00002921def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
2922 (SHUFPSrri VR128:$src1, VR128:$src1,
2923 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002924 Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002925let AddedComplexity = 5 in
2926def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
2927 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2928 Requires<[HasSSE2]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002929// Special unary SHUFPDrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00002930def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002931 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002932 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2933 Requires<[HasSSE2]>;
2934// Special unary SHUFPDrri case.
2935def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002936 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002937 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7dc19012007-08-02 21:17:01 +00002938 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002939// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman543d2142009-04-27 18:41:29 +00002940def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
2941 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002942 Requires<[HasSSE2]>;
Evan Cheng13559d62008-09-26 23:41:32 +00002943
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002944// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman543d2142009-04-27 18:41:29 +00002945def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002946 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002947 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002948 Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002949def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002950 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002951 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002952 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002953// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman543d2142009-04-27 18:41:29 +00002954def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002955 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002956 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002957 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002958
2959// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00002960let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002961def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
2962 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002963 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002964def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
2965 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002966 Requires<[OptForSpeed, HasSSE2]>;
2967}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002968let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002969def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002970 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002971def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002972 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002973def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002974 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002975def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002976 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002977}
2978
2979// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00002980let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002981def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
2982 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002983 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002984def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
2985 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002986 Requires<[OptForSpeed, HasSSE2]>;
2987}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002988let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002989def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002990 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002991def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002992 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002993def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002994 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002995def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002996 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002997}
2998
Evan Cheng13559d62008-09-26 23:41:32 +00002999let AddedComplexity = 20 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003000// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begeman543d2142009-04-27 18:41:29 +00003001def : Pat<(v4i32 (movhp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003002 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
3003
3004// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003005def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003006 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
3007
3008// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003009def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003010 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman543d2142009-04-27 18:41:29 +00003011def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003012 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
3013}
3014
3015let AddedComplexity = 20 in {
3016// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
3017// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Nate Begeman543d2142009-04-27 18:41:29 +00003018def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003019 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003020def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003021 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003022def : Pat<(v4f32 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003023 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003024def : Pat<(v2f64 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003025 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3026
Nate Begeman543d2142009-04-27 18:41:29 +00003027def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003028 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003029def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003030 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003031def : Pat<(v4i32 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003032 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003033def : Pat<(v2i64 (movhp VR128:$src1, (load addr:$src2))),
Evan Cheng1ff2ea52008-05-23 18:00:18 +00003034 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003035}
3036
Evan Cheng2b2a7012008-05-23 21:23:16 +00003037// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
3038// (store (vector_shuffle (load addr), v2, <0, 1, 4, 5>), addr) using MOVHPS
Nate Begeman543d2142009-04-27 18:41:29 +00003039def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003040 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003041def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003042 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003043def : Pat<(store (v4f32 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003044 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003045def : Pat<(store (v2f64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003046 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3047
Nate Begeman543d2142009-04-27 18:41:29 +00003048def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3049 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003050 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003051def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003052 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003053def : Pat<(store (v4i32 (movhp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3054 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003055 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003056def : Pat<(store (v2i64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003057 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3058
3059
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003060let AddedComplexity = 15 in {
3061// Setting the lowest element in the vector.
Nate Begeman543d2142009-04-27 18:41:29 +00003062def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003063 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003064def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003065 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3066
3067// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
Nate Begeman543d2142009-04-27 18:41:29 +00003068def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003069 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003070def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003071 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3072}
3073
Eli Friedman27d19742009-06-19 07:00:55 +00003074// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3075// fall back to this for SSE1)
3076def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003077 (SHUFPSrri VR128:$src2, VR128:$src1,
Eli Friedman27d19742009-06-19 07:00:55 +00003078 (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>;
3079
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003080// Set lowest element and zero upper elements.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003081let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00003082def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003083 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00003084def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengd09a8a02008-05-08 22:35:02 +00003085 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003086
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003087// Some special case pandn patterns.
3088def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3089 VR128:$src2)),
3090 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3091def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3092 VR128:$src2)),
3093 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3094def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3095 VR128:$src2)),
3096 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3097
3098def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003099 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003100 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3101def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003102 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003103 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3104def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003105 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003106 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3107
Nate Begeman78246ca2007-11-17 03:58:34 +00003108// vector -> vector casts
3109def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3110 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3111def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3112 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedman7fa52ca2008-09-05 23:07:03 +00003113def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3114 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3115def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3116 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman78246ca2007-11-17 03:58:34 +00003117
Evan Cheng51a49b22007-07-20 00:27:43 +00003118// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00003119def : Pat<(alignedloadv4i32 addr:$src),
3120 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3121def : Pat<(loadv4i32 addr:$src),
3122 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00003123def : Pat<(alignedloadv2i64 addr:$src),
3124 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3125def : Pat<(loadv2i64 addr:$src),
3126 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3127
3128def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3129 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3130def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3131 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3132def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3133 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3134def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3135 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3136def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3137 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3138def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3139 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3140def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3141 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3142def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3143 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003144
Nate Begemanb2975562008-02-03 07:18:54 +00003145//===----------------------------------------------------------------------===//
3146// SSE4.1 Instructions
3147//===----------------------------------------------------------------------===//
3148
Dale Johannesena7d2b442008-10-10 23:51:03 +00003149multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begemanb2975562008-02-03 07:18:54 +00003150 string OpcodeStr,
Nate Begemanb2975562008-02-03 07:18:54 +00003151 Intrinsic V4F32Int,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003152 Intrinsic V2F64Int> {
Nate Begemanb2975562008-02-03 07:18:54 +00003153 // Intrinsic operation, reg.
Nate Begemanb2975562008-02-03 07:18:54 +00003154 // Vector intrinsic operation, reg
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003155 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003156 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003157 !strconcat(OpcodeStr,
3158 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003159 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3160 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003161
3162 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003163 def PSm_Int : SS4AIi8<opcps, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003164 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003165 !strconcat(OpcodeStr,
3166 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003167 [(set VR128:$dst,
3168 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003169 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003170
Nate Begemanb2975562008-02-03 07:18:54 +00003171 // Vector intrinsic operation, reg
Evan Cheng78d00612008-03-14 07:39:27 +00003172 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003173 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003174 !strconcat(OpcodeStr,
3175 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003176 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3177 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003178
3179 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003180 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003181 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003182 !strconcat(OpcodeStr,
3183 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003184 [(set VR128:$dst,
3185 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003186 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003187}
3188
Dale Johannesena7d2b442008-10-10 23:51:03 +00003189let Constraints = "$src1 = $dst" in {
3190multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3191 string OpcodeStr,
3192 Intrinsic F32Int,
3193 Intrinsic F64Int> {
3194 // Intrinsic operation, reg.
3195 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003196 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003197 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3198 !strconcat(OpcodeStr,
3199 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003200 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003201 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3202 OpSize;
3203
3204 // Intrinsic operation, mem.
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003205 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3206 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003207 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003208 !strconcat(OpcodeStr,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003209 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003210 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003211 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3212 OpSize;
3213
3214 // Intrinsic operation, reg.
3215 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003216 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003217 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3218 !strconcat(OpcodeStr,
3219 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003220 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003221 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3222 OpSize;
3223
3224 // Intrinsic operation, mem.
3225 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003226 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003227 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3228 !strconcat(OpcodeStr,
3229 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003230 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003231 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3232 OpSize;
3233}
3234}
3235
Nate Begemanb2975562008-02-03 07:18:54 +00003236// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesena7d2b442008-10-10 23:51:03 +00003237defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3238 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3239defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3240 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003241
3242// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3243multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3244 Intrinsic IntId128> {
3245 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3246 (ins VR128:$src),
3247 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3248 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3249 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3250 (ins i128mem:$src),
3251 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3252 [(set VR128:$dst,
3253 (IntId128
3254 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3255}
3256
3257defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3258 int_x86_sse41_phminposuw>;
3259
3260/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003261let Constraints = "$src1 = $dst" in {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003262 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3263 Intrinsic IntId128, bit Commutable = 0> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003264 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3265 (ins VR128:$src1, VR128:$src2),
3266 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3267 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3268 OpSize {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003269 let isCommutable = Commutable;
3270 }
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003271 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3272 (ins VR128:$src1, i128mem:$src2),
3273 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3274 [(set VR128:$dst,
3275 (IntId128 VR128:$src1,
3276 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003277 }
3278}
3279
3280defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3281 int_x86_sse41_pcmpeqq, 1>;
3282defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3283 int_x86_sse41_packusdw, 0>;
3284defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3285 int_x86_sse41_pminsb, 1>;
3286defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3287 int_x86_sse41_pminsd, 1>;
3288defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3289 int_x86_sse41_pminud, 1>;
3290defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3291 int_x86_sse41_pminuw, 1>;
3292defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3293 int_x86_sse41_pmaxsb, 1>;
3294defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3295 int_x86_sse41_pmaxsd, 1>;
3296defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3297 int_x86_sse41_pmaxud, 1>;
3298defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3299 int_x86_sse41_pmaxuw, 1>;
Nate Begeman72d802a2008-02-04 06:00:24 +00003300
Mon P Wang14edb092008-12-18 21:42:19 +00003301defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3302
Nate Begeman03605a02008-07-17 16:51:19 +00003303def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3304 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3305def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3306 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3307
Nate Begeman58057962008-02-09 01:38:08 +00003308/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003309let Constraints = "$src1 = $dst" in {
Dan Gohmane3731f52008-05-23 17:49:40 +00003310 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3311 SDNode OpNode, Intrinsic IntId128,
3312 bit Commutable = 0> {
Nate Begeman58057962008-02-09 01:38:08 +00003313 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3314 (ins VR128:$src1, VR128:$src2),
3315 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmane3731f52008-05-23 17:49:40 +00003316 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3317 VR128:$src2))]>, OpSize {
Nate Begeman58057962008-02-09 01:38:08 +00003318 let isCommutable = Commutable;
3319 }
3320 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3321 (ins VR128:$src1, VR128:$src2),
3322 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3323 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3324 OpSize {
3325 let isCommutable = Commutable;
3326 }
3327 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3328 (ins VR128:$src1, i128mem:$src2),
3329 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3330 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003331 (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003332 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3333 (ins VR128:$src1, i128mem:$src2),
3334 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3335 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003336 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman58057962008-02-09 01:38:08 +00003337 OpSize;
3338 }
3339}
Dan Gohmane3731f52008-05-23 17:49:40 +00003340defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
Nate Begeman58057962008-02-09 01:38:08 +00003341 int_x86_sse41_pmulld, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003342
Evan Cheng78d00612008-03-14 07:39:27 +00003343/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Cheng3ea4d672008-03-05 08:19:16 +00003344let Constraints = "$src1 = $dst" in {
Nate Begeman72d802a2008-02-04 06:00:24 +00003345 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3346 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng78d00612008-03-14 07:39:27 +00003347 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003348 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003349 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003350 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003351 [(set VR128:$dst,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003352 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3353 OpSize {
Nate Begeman72d802a2008-02-04 06:00:24 +00003354 let isCommutable = Commutable;
3355 }
Evan Cheng78d00612008-03-14 07:39:27 +00003356 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003357 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3358 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003359 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003360 [(set VR128:$dst,
3361 (IntId128 VR128:$src1,
3362 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3363 OpSize;
Nate Begeman72d802a2008-02-04 06:00:24 +00003364 }
3365}
3366
3367defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3368 int_x86_sse41_blendps, 0>;
3369defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3370 int_x86_sse41_blendpd, 0>;
3371defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3372 int_x86_sse41_pblendw, 0>;
3373defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3374 int_x86_sse41_dpps, 1>;
3375defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3376 int_x86_sse41_dppd, 1>;
3377defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng81ed9852008-06-16 20:25:59 +00003378 int_x86_sse41_mpsadbw, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003379
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003380
Evan Cheng78d00612008-03-14 07:39:27 +00003381/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003382let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanb4e9a042008-02-10 18:47:57 +00003383 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3384 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3385 (ins VR128:$src1, VR128:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003386 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003387 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3388 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3389 OpSize;
3390
3391 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3392 (ins VR128:$src1, i128mem:$src2),
3393 !strconcat(OpcodeStr,
3394 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3395 [(set VR128:$dst,
3396 (IntId VR128:$src1,
3397 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3398 }
3399}
3400
3401defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3402defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3403defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3404
3405
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003406multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3407 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3408 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3409 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3410
3411 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3412 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003413 [(set VR128:$dst,
3414 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3415 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003416}
3417
3418defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3419defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3420defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3421defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3422defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3423defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3424
Evan Cheng56ec77b2008-09-24 23:27:55 +00003425// Common patterns involving scalar load.
3426def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3427 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3428def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3429 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3430
3431def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3432 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3433def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3434 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3435
3436def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3437 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3438def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3439 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3440
3441def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3442 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3443def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3444 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3445
3446def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3447 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3448def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3449 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3450
3451def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3452 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3453def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3454 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3455
3456
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003457multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3458 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3459 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3460 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3461
3462 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3463 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003464 [(set VR128:$dst,
3465 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3466 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003467}
3468
3469defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3470defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3471defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3472defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3473
Evan Cheng56ec77b2008-09-24 23:27:55 +00003474// Common patterns involving scalar load
3475def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003476 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003477def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003478 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003479
3480def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003481 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003482def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003483 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003484
3485
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003486multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3487 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3488 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3489 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3490
Evan Cheng56ec77b2008-09-24 23:27:55 +00003491 // Expecting a i16 load any extended to i32 value.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003492 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3493 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003494 [(set VR128:$dst, (IntId (bitconvert
3495 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3496 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003497}
3498
3499defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman75a89d62009-06-06 05:55:37 +00003500defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003501
Evan Cheng56ec77b2008-09-24 23:27:55 +00003502// Common patterns involving scalar load
3503def : Pat<(int_x86_sse41_pmovsxbq
3504 (bitconvert (v4i32 (X86vzmovl
3505 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003506 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003507
3508def : Pat<(int_x86_sse41_pmovzxbq
3509 (bitconvert (v4i32 (X86vzmovl
3510 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003511 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003512
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003513
Nate Begemand77e59e2008-02-11 04:19:36 +00003514/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3515multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003516 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003517 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003518 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003519 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003520 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3521 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003522 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003523 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003524 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003525 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003526 []>, OpSize;
3527// FIXME:
3528// There's an AssertZext in the way of writing the store pattern
3529// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003530}
3531
Nate Begemand77e59e2008-02-11 04:19:36 +00003532defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003533
Nate Begemand77e59e2008-02-11 04:19:36 +00003534
3535/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3536multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003537 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemand77e59e2008-02-11 04:19:36 +00003538 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003539 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003540 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3541 []>, OpSize;
3542// FIXME:
3543// There's an AssertZext in the way of writing the store pattern
3544// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3545}
3546
3547defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3548
3549
3550/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3551multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003552 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003553 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003554 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003555 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3556 [(set GR32:$dst,
3557 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003558 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003559 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003560 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003561 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3562 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3563 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003564}
3565
Nate Begemand77e59e2008-02-11 04:19:36 +00003566defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman58057962008-02-09 01:38:08 +00003567
Nate Begemand77e59e2008-02-11 04:19:36 +00003568
Evan Cheng6c249332008-03-24 21:52:23 +00003569/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3570/// destination
Nate Begemand77e59e2008-02-11 04:19:36 +00003571multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003572 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003573 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003574 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003575 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman788db592008-04-16 02:32:24 +00003576 [(set GR32:$dst,
3577 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng6c249332008-03-24 21:52:23 +00003578 OpSize;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003579 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003580 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003581 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003582 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng6c249332008-03-24 21:52:23 +00003583 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003584 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003585}
3586
Nate Begemand77e59e2008-02-11 04:19:36 +00003587defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003588
Dan Gohmana41862a2008-08-08 18:30:21 +00003589// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3590def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3591 imm:$src2))),
3592 addr:$dst),
3593 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3594 Requires<[HasSSE41]>;
3595
Evan Cheng3ea4d672008-03-05 08:19:16 +00003596let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003597 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003598 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003599 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003600 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003601 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003602 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003603 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003604 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003605 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3606 !strconcat(OpcodeStr,
3607 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003608 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003609 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3610 imm:$src3))]>, OpSize;
3611 }
3612}
3613
3614defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3615
Evan Cheng3ea4d672008-03-05 08:19:16 +00003616let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003617 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003618 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003619 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003620 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003621 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003622 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003623 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3624 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003625 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003626 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3627 !strconcat(OpcodeStr,
3628 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003629 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003630 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3631 imm:$src3)))]>, OpSize;
3632 }
3633}
3634
3635defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3636
Eric Christophera0443602009-07-23 02:22:41 +00003637// insertps has a few different modes, there's the first two here below which
3638// are optimized inserts that won't zero arbitrary elements in the destination
3639// vector. The next one matches the intrinsic and could zero arbitrary elements
3640// in the target vector.
Evan Cheng3ea4d672008-03-05 08:19:16 +00003641let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003642 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherefb657e2009-07-24 00:33:09 +00003643 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3644 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003645 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003646 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003647 [(set VR128:$dst,
3648 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
3649 OpSize;
Eric Christopherefb657e2009-07-24 00:33:09 +00003650 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003651 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3652 !strconcat(OpcodeStr,
3653 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003654 [(set VR128:$dst,
Eric Christopherefb657e2009-07-24 00:33:09 +00003655 (X86insrtps VR128:$src1,
3656 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begemand77e59e2008-02-11 04:19:36 +00003657 imm:$src3))]>, OpSize;
3658 }
3659}
3660
Evan Chengc2054be2008-03-26 08:11:49 +00003661defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003662
Eric Christopherefb657e2009-07-24 00:33:09 +00003663def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3664 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3665
Eric Christopher95d79262009-07-29 00:28:05 +00003666// ptest instruction we'll lower to this in X86ISelLowering primarily from
3667// the intel intrinsic that corresponds to this.
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003668let Defs = [EFLAGS] in {
3669def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003670 "ptest \t{$src2, $src1|$src1, $src2}",
3671 [(X86ptest VR128:$src1, VR128:$src2),
3672 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003673def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003674 "ptest \t{$src2, $src1|$src1, $src2}",
3675 [(X86ptest VR128:$src1, (load addr:$src2)),
3676 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003677}
3678
3679def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3680 "movntdqa\t{$src, $dst|$dst, $src}",
3681 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>;
Nate Begeman03605a02008-07-17 16:51:19 +00003682
Eric Christopher22a39402009-08-18 22:50:32 +00003683
3684//===----------------------------------------------------------------------===//
3685// SSE4.2 Instructions
3686//===----------------------------------------------------------------------===//
3687
Nate Begeman03605a02008-07-17 16:51:19 +00003688/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3689let Constraints = "$src1 = $dst" in {
3690 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3691 Intrinsic IntId128, bit Commutable = 0> {
3692 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3693 (ins VR128:$src1, VR128:$src2),
3694 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3695 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3696 OpSize {
3697 let isCommutable = Commutable;
3698 }
3699 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3700 (ins VR128:$src1, i128mem:$src2),
3701 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3702 [(set VR128:$dst,
3703 (IntId128 VR128:$src1,
3704 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3705 }
3706}
3707
Nate Begeman235666b2008-07-17 17:04:58 +00003708defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman03605a02008-07-17 16:51:19 +00003709
3710def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3711 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3712def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3713 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003714
3715// crc intrinsic instruction
3716// This set of instructions are only rm, the only difference is the size
3717// of r and m.
3718let Constraints = "$src1 = $dst" in {
Eric Christopher85f187b2009-08-10 21:48:58 +00003719 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003720 (ins GR32:$src1, i8mem:$src2),
3721 "crc32 \t{$src2, $src1|$src1, $src2}",
3722 [(set GR32:$dst,
3723 (int_x86_sse42_crc32_8 GR32:$src1,
3724 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003725 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003726 (ins GR32:$src1, GR8:$src2),
3727 "crc32 \t{$src2, $src1|$src1, $src2}",
3728 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003729 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003730 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003731 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003732 (ins GR32:$src1, i16mem:$src2),
3733 "crc32 \t{$src2, $src1|$src1, $src2}",
3734 [(set GR32:$dst,
3735 (int_x86_sse42_crc32_16 GR32:$src1,
3736 (load addr:$src2)))]>,
3737 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003738 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003739 (ins GR32:$src1, GR16:$src2),
3740 "crc32 \t{$src2, $src1|$src1, $src2}",
3741 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003742 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003743 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003744 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003745 (ins GR32:$src1, i32mem:$src2),
3746 "crc32 \t{$src2, $src1|$src1, $src2}",
3747 [(set GR32:$dst,
3748 (int_x86_sse42_crc32_32 GR32:$src1,
3749 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003750 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003751 (ins GR32:$src1, GR32:$src2),
3752 "crc32 \t{$src2, $src1|$src1, $src2}",
3753 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003754 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003755 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003756 def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003757 (ins GR64:$src1, i64mem:$src2),
3758 "crc32 \t{$src2, $src1|$src1, $src2}",
3759 [(set GR64:$dst,
3760 (int_x86_sse42_crc32_64 GR64:$src1,
3761 (load addr:$src2)))]>,
3762 OpSize, REX_W;
Eric Christopher85f187b2009-08-10 21:48:58 +00003763 def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003764 (ins GR64:$src1, GR64:$src2),
3765 "crc32 \t{$src2, $src1|$src1, $src2}",
3766 [(set GR64:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003767 (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003768 OpSize, REX_W;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003769}
Eric Christopher22a39402009-08-18 22:50:32 +00003770
3771// String/text processing instructions.
3772let Defs = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
3773def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
3774 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3775 "#PCMPISTRM128rr PSEUDO!",
3776 [(set VR128:$dst,
3777 (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
3778 imm:$src3))]>, OpSize;
3779def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
3780 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3781 "#PCMPISTRM128rm PSEUDO!",
3782 [(set VR128:$dst,
3783 (int_x86_sse42_pcmpistrm128 VR128:$src1,
3784 (load addr:$src2),
3785 imm:$src3))]>, OpSize;
3786}
3787
3788let Defs = [XMM0, EFLAGS] in {
3789def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
3790 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3791 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3792 []>, OpSize;
3793def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
3794 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3795 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3796 []>, OpSize;
3797}
3798
3799let Defs = [EFLAGS], Uses = [EAX, EDX],
3800 usesCustomDAGSchedInserter = 1 in {
3801def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
3802 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3803 "#PCMPESTRM128rr PSEUDO!",
3804 [(set VR128:$dst,
3805 (int_x86_sse42_pcmpestrm128 VR128:$src1, EAX,
3806 VR128:$src3,
3807 EDX, imm:$src5))]>, OpSize;
3808def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
3809 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3810 "#PCMPESTRM128rm PSEUDO!",
3811 [(set VR128:$dst,
3812 (int_x86_sse42_pcmpestrm128 VR128:$src1, EAX,
3813 (load addr:$src3),
3814 EDX, imm:$src5))]>, OpSize;
3815}
3816
3817let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
Sean Callananc5a05b72009-08-20 18:24:27 +00003818def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
Eric Christopher22a39402009-08-18 22:50:32 +00003819 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3820 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3821 []>, OpSize;
Sean Callananc5a05b72009-08-20 18:24:27 +00003822def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
Eric Christopher22a39402009-08-18 22:50:32 +00003823 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3824 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3825 []>, OpSize;
3826}
3827
3828let Defs = [ECX, EFLAGS] in {
3829 multiclass SS42AI_pcmpistri<Intrinsic IntId128> {
3830 def rr : SS42AI<0x63, MRMSrcReg, (outs),
3831 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3832 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3833 [(set ECX,
3834 (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
3835 (implicit EFLAGS)]>,
3836 OpSize;
3837 def rm : SS42AI<0x63, MRMSrcMem, (outs),
3838 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3839 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3840 [(set ECX,
3841 (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
3842 (implicit EFLAGS)]>,
3843 OpSize;
3844 }
3845}
3846
3847defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
3848defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
3849defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
3850defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
3851defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
3852defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
3853
3854let Defs = [ECX, EFLAGS] in {
3855let Uses = [EAX, EDX] in {
3856 multiclass SS42AI_pcmpestri<Intrinsic IntId128> {
3857 def rr : SS42AI<0x61, MRMSrcReg, (outs),
3858 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3859 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3860 [(set ECX,
3861 (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
3862 (implicit EFLAGS)]>,
3863 OpSize;
3864 def rm : SS42AI<0x61, MRMSrcMem, (outs),
3865 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3866 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3867 [(set ECX,
3868 (IntId128 VR128:$src1, EAX, (load addr:$src3),
3869 EDX, imm:$src5)),
3870 (implicit EFLAGS)]>,
3871 OpSize;
3872 }
3873}
3874}
3875
3876defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
3877defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
3878defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
3879defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
3880defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
3881defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;