blob: 40aabb4f3764ff0759e1618a5c70b8b61e5dda56 [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//====- X86InstrSSE.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Eric Christopher7f2d4f42009-07-31 20:07:27 +00007//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00008//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 SSE instruction set, defining the instructions,
11// and properties of the instructions which are needed for code generation,
12// machine code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16
17//===----------------------------------------------------------------------===//
18// SSE specific DAG Nodes.
19//===----------------------------------------------------------------------===//
20
21def SDTX86FPShiftOp : SDTypeProfile<1, 2, [ SDTCisSameAs<0, 1>,
22 SDTCisFP<0>, SDTCisInt<2> ]>;
Nate Begeman03605a02008-07-17 16:51:19 +000023def SDTX86VFCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>,
24 SDTCisFP<1>, SDTCisVT<3, i8>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000025
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026def X86fmin : SDNode<"X86ISD::FMIN", SDTFPBinOp>;
27def X86fmax : SDNode<"X86ISD::FMAX", SDTFPBinOp>;
28def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
29 [SDNPCommutative, SDNPAssociative]>;
30def X86for : SDNode<"X86ISD::FOR", SDTFPBinOp,
31 [SDNPCommutative, SDNPAssociative]>;
32def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
33 [SDNPCommutative, SDNPAssociative]>;
34def X86frsqrt : SDNode<"X86ISD::FRSQRT", SDTFPUnaryOp>;
35def X86frcp : SDNode<"X86ISD::FRCP", SDTFPUnaryOp>;
36def X86fsrl : SDNode<"X86ISD::FSRL", SDTX86FPShiftOp>;
Evan Chengf37bf452007-10-01 18:12:48 +000037def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest>;
Evan Cheng621216e2007-09-29 00:00:36 +000038def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +000039def X86pshufb : SDNode<"X86ISD::PSHUFB",
Nate Begeman2c87c422009-02-23 08:49:38 +000040 SDTypeProfile<1, 2, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
41 SDTCisSameAs<0,2>]>>;
Nate Begemand77e59e2008-02-11 04:19:36 +000042def X86pextrb : SDNode<"X86ISD::PEXTRB",
43 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
44def X86pextrw : SDNode<"X86ISD::PEXTRW",
45 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +000046def X86pinsrb : SDNode<"X86ISD::PINSRB",
Nate Begemand77e59e2008-02-11 04:19:36 +000047 SDTypeProfile<1, 3, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
48 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +000049def X86pinsrw : SDNode<"X86ISD::PINSRW",
Nate Begemand77e59e2008-02-11 04:19:36 +000050 SDTypeProfile<1, 3, [SDTCisVT<0, v8i16>, SDTCisSameAs<0,1>,
51 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +000052def X86insrtps : SDNode<"X86ISD::INSERTPS",
Nate Begemand77e59e2008-02-11 04:19:36 +000053 SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, SDTCisSameAs<0,1>,
Eric Christopherefb657e2009-07-24 00:33:09 +000054 SDTCisVT<2, v4f32>, SDTCisPtrTy<3>]>>;
Evan Chenge9b9c672008-05-09 21:53:03 +000055def X86vzmovl : SDNode<"X86ISD::VZEXT_MOVL",
56 SDTypeProfile<1, 1, [SDTCisSameAs<0,1>]>>;
57def X86vzload : SDNode<"X86ISD::VZEXT_LOAD", SDTLoad,
58 [SDNPHasChain, SDNPMayLoad]>;
Evan Chengdea99362008-05-29 08:22:04 +000059def X86vshl : SDNode<"X86ISD::VSHL", SDTIntShiftOp>;
60def X86vshr : SDNode<"X86ISD::VSRL", SDTIntShiftOp>;
Nate Begeman03605a02008-07-17 16:51:19 +000061def X86cmpps : SDNode<"X86ISD::CMPPS", SDTX86VFCMP>;
62def X86cmppd : SDNode<"X86ISD::CMPPD", SDTX86VFCMP>;
63def X86pcmpeqb : SDNode<"X86ISD::PCMPEQB", SDTIntBinOp, [SDNPCommutative]>;
64def X86pcmpeqw : SDNode<"X86ISD::PCMPEQW", SDTIntBinOp, [SDNPCommutative]>;
65def X86pcmpeqd : SDNode<"X86ISD::PCMPEQD", SDTIntBinOp, [SDNPCommutative]>;
66def X86pcmpeqq : SDNode<"X86ISD::PCMPEQQ", SDTIntBinOp, [SDNPCommutative]>;
67def X86pcmpgtb : SDNode<"X86ISD::PCMPGTB", SDTIntBinOp>;
68def X86pcmpgtw : SDNode<"X86ISD::PCMPGTW", SDTIntBinOp>;
69def X86pcmpgtd : SDNode<"X86ISD::PCMPGTD", SDTIntBinOp>;
70def X86pcmpgtq : SDNode<"X86ISD::PCMPGTQ", SDTIntBinOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000071
Eric Christopher85f187b2009-08-10 21:48:58 +000072def SDTX86CmpPTest : SDTypeProfile<0, 2, [SDTCisVT<0, v4f32>,
Sean Callanan2c48df22009-12-18 00:01:26 +000073 SDTCisVT<1, v4f32>]>;
Eric Christopher95d79262009-07-29 00:28:05 +000074def X86ptest : SDNode<"X86ISD::PTEST", SDTX86CmpPTest>;
75
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +000077// SSE Complex Patterns
78//===----------------------------------------------------------------------===//
79
80// These are 'extloads' from a scalar to the low element of a vector, zeroing
81// the top elements. These are used for the SSE 'ss' and 'sd' instruction
82// forms.
Rafael Espindolabca99f72009-04-08 21:14:34 +000083def sse_load_f32 : ComplexPattern<v4f32, 5, "SelectScalarSSELoad", [],
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000084 [SDNPHasChain, SDNPMayLoad]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +000085def sse_load_f64 : ComplexPattern<v2f64, 5, "SelectScalarSSELoad", [],
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000086 [SDNPHasChain, SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000087
88def ssmem : Operand<v4f32> {
89 let PrintMethod = "printf32mem";
Dan Gohmanfe606822009-07-30 01:56:29 +000090 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +000091 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000092}
93def sdmem : Operand<v2f64> {
94 let PrintMethod = "printf64mem";
Dan Gohmanfe606822009-07-30 01:56:29 +000095 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +000096 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097}
98
99//===----------------------------------------------------------------------===//
100// SSE pattern fragments
101//===----------------------------------------------------------------------===//
102
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000103def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
104def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
105def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
106def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
107
Dan Gohman11821702007-07-27 17:16:43 +0000108// Like 'store', but always requires vector alignment.
Dan Gohman4a4f1512007-07-18 20:23:34 +0000109def alignedstore : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman2a174122008-10-15 06:50:19 +0000110 (store node:$val, node:$ptr), [{
111 return cast<StoreSDNode>(N)->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000112}]>;
113
Dan Gohman11821702007-07-27 17:16:43 +0000114// Like 'load', but always requires vector alignment.
Dan Gohman2a174122008-10-15 06:50:19 +0000115def alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
116 return cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000117}]>;
118
Sean Callanan2c48df22009-12-18 00:01:26 +0000119def alignedloadfsf32 : PatFrag<(ops node:$ptr),
120 (f32 (alignedload node:$ptr))>;
121def alignedloadfsf64 : PatFrag<(ops node:$ptr),
122 (f64 (alignedload node:$ptr))>;
123def alignedloadv4f32 : PatFrag<(ops node:$ptr),
124 (v4f32 (alignedload node:$ptr))>;
125def alignedloadv2f64 : PatFrag<(ops node:$ptr),
126 (v2f64 (alignedload node:$ptr))>;
127def alignedloadv4i32 : PatFrag<(ops node:$ptr),
128 (v4i32 (alignedload node:$ptr))>;
129def alignedloadv2i64 : PatFrag<(ops node:$ptr),
130 (v2i64 (alignedload node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000131
132// Like 'load', but uses special alignment checks suitable for use in
133// memory operands in most SSE instructions, which are required to
David Greene5235d412010-01-11 16:29:42 +0000134// be naturally aligned on some targets but not on others. If the subtarget
135// allows unaligned accesses, match any load, though this may require
136// setting a feature bit in the processor (on startup, for example).
137// Opteron 10h and later implement such a feature.
Dan Gohman2a174122008-10-15 06:50:19 +0000138def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{
David Greene5235d412010-01-11 16:29:42 +0000139 return Subtarget->hasVectorUAMem()
140 || cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000141}]>;
142
Dan Gohman11821702007-07-27 17:16:43 +0000143def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
144def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000145def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
146def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
147def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
148def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +0000149def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000150
Bill Wendling3b15d722007-08-11 09:52:53 +0000151// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
152// 16-byte boundary.
Nate Begeman9a58b8a2008-02-09 23:46:37 +0000153// FIXME: 8 byte alignment for mmx reads is not required
Dan Gohman61efc5a2008-10-16 00:03:00 +0000154def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Dan Gohman2a174122008-10-15 06:50:19 +0000155 return cast<LoadSDNode>(N)->getAlignment() >= 8;
Bill Wendling3b15d722007-08-11 09:52:53 +0000156}]>;
157
158def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
Bill Wendling3b15d722007-08-11 09:52:53 +0000159def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
160def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
161def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
162
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
164def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
165def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
166def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
167def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
168def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
169
Evan Cheng56ec77b2008-09-24 23:27:55 +0000170def vzmovl_v2i64 : PatFrag<(ops node:$src),
171 (bitconvert (v2i64 (X86vzmovl
172 (v2i64 (scalar_to_vector (loadi64 node:$src))))))>;
173def vzmovl_v4i32 : PatFrag<(ops node:$src),
174 (bitconvert (v4i32 (X86vzmovl
175 (v4i32 (scalar_to_vector (loadi32 node:$src))))))>;
176
177def vzload_v2i64 : PatFrag<(ops node:$src),
178 (bitconvert (v2i64 (X86vzload node:$src)))>;
179
180
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181def fp32imm0 : PatLeaf<(f32 fpimm), [{
182 return N->isExactlyValue(+0.0);
183}]>;
184
Evan Cheng06cd2072009-10-28 06:30:34 +0000185// BYTE_imm - Transform bit immediates into byte immediates.
186def BYTE_imm : SDNodeXForm<imm, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187 // Transformation function: imm >> 3
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000188 return getI32Imm(N->getZExtValue() >> 3);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189}]>;
190
191// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
192// SHUFP* etc. imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000193def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000194 return getI8Imm(X86::getShuffleSHUFImmediate(N));
195}]>;
196
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000197// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198// PSHUFHW imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000199def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
201}]>;
202
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000203// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000204// PSHUFLW imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000205def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000206 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
207}]>;
208
Nate Begeman080f8e22009-10-19 02:17:23 +0000209// SHUFFLE_get_palign_imm xform function: convert vector_shuffle mask to
210// a PALIGNR imm.
211def SHUFFLE_get_palign_imm : SDNodeXForm<vector_shuffle, [{
212 return getI8Imm(X86::getShufflePALIGNRImmediate(N));
213}]>;
214
Nate Begeman543d2142009-04-27 18:41:29 +0000215def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
216 (vector_shuffle node:$lhs, node:$rhs), [{
217 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
218 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
219}]>;
220
221def movddup : PatFrag<(ops node:$lhs, node:$rhs),
222 (vector_shuffle node:$lhs, node:$rhs), [{
223 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
224}]>;
225
226def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
227 (vector_shuffle node:$lhs, node:$rhs), [{
228 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
229}]>;
230
231def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
232 (vector_shuffle node:$lhs, node:$rhs), [{
233 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
234}]>;
235
Nate Begemanb13034d2009-11-07 23:17:15 +0000236def movlhps : PatFrag<(ops node:$lhs, node:$rhs),
237 (vector_shuffle node:$lhs, node:$rhs), [{
238 return X86::isMOVLHPSMask(cast<ShuffleVectorSDNode>(N));
Nate Begeman543d2142009-04-27 18:41:29 +0000239}]>;
240
241def movlp : PatFrag<(ops node:$lhs, node:$rhs),
242 (vector_shuffle node:$lhs, node:$rhs), [{
243 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
244}]>;
245
246def movl : PatFrag<(ops node:$lhs, node:$rhs),
247 (vector_shuffle node:$lhs, node:$rhs), [{
248 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
249}]>;
250
251def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
252 (vector_shuffle node:$lhs, node:$rhs), [{
253 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
254}]>;
255
256def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
257 (vector_shuffle node:$lhs, node:$rhs), [{
258 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
259}]>;
260
261def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
262 (vector_shuffle node:$lhs, node:$rhs), [{
263 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
264}]>;
265
266def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
267 (vector_shuffle node:$lhs, node:$rhs), [{
268 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
269}]>;
270
271def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
272 (vector_shuffle node:$lhs, node:$rhs), [{
273 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
274}]>;
275
276def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
277 (vector_shuffle node:$lhs, node:$rhs), [{
278 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
279}]>;
280
281def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
282 (vector_shuffle node:$lhs, node:$rhs), [{
283 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284}], SHUFFLE_get_shuf_imm>;
285
Nate Begeman543d2142009-04-27 18:41:29 +0000286def shufp : PatFrag<(ops node:$lhs, node:$rhs),
287 (vector_shuffle node:$lhs, node:$rhs), [{
288 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000289}], SHUFFLE_get_shuf_imm>;
290
Nate Begeman543d2142009-04-27 18:41:29 +0000291def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
292 (vector_shuffle node:$lhs, node:$rhs), [{
293 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294}], SHUFFLE_get_pshufhw_imm>;
295
Nate Begeman543d2142009-04-27 18:41:29 +0000296def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
297 (vector_shuffle node:$lhs, node:$rhs), [{
298 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000299}], SHUFFLE_get_pshuflw_imm>;
300
Nate Begeman080f8e22009-10-19 02:17:23 +0000301def palign : PatFrag<(ops node:$lhs, node:$rhs),
302 (vector_shuffle node:$lhs, node:$rhs), [{
303 return X86::isPALIGNRMask(cast<ShuffleVectorSDNode>(N));
304}], SHUFFLE_get_palign_imm>;
305
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306//===----------------------------------------------------------------------===//
307// SSE scalar FP Instructions
308//===----------------------------------------------------------------------===//
309
Dan Gohman30afe012009-10-29 18:10:34 +0000310// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded after
311// instruction selection into a branch sequence.
312let Uses = [EFLAGS], usesCustomInserter = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 def CMOV_FR32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000314 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315 "#CMOV_FR32 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000316 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
317 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000319 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320 "#CMOV_FR64 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000321 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
322 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000324 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325 "#CMOV_V4F32 PSEUDO!",
326 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000327 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
328 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329 def CMOV_V2F64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000330 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 "#CMOV_V2F64 PSEUDO!",
332 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000333 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
334 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335 def CMOV_V2I64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000336 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337 "#CMOV_V2I64 PSEUDO!",
338 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000339 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng950aac02007-09-25 01:57:46 +0000340 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341}
342
343//===----------------------------------------------------------------------===//
344// SSE1 Instructions
345//===----------------------------------------------------------------------===//
346
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000347// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000348let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000349def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000350 "movss\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000351let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000352def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000353 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000355def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000356 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357 [(store FR32:$src, addr:$dst)]>;
358
359// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000360def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000361 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000363def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000364 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000366def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000367 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000368 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000369def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000370 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
372
373// Match intrinsics which expect XMM operand(s).
Sean Callanan2c48df22009-12-18 00:01:26 +0000374def CVTSS2SIrr: SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
375 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
376def CVTSS2SIrm: SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
377 "cvtss2si{l}\t{$src, $dst|$dst, $src}", []>;
378
Evan Chengb783fa32007-07-19 01:14:50 +0000379def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000380 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000381 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000382def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000383 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384 [(set GR32:$dst, (int_x86_sse_cvtss2si
385 (load addr:$src)))]>;
386
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000387// Match intrinisics which expect MM and XMM operand(s).
388def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
389 "cvtps2pi\t{$src, $dst|$dst, $src}",
390 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
391def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
392 "cvtps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000393 [(set VR64:$dst, (int_x86_sse_cvtps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000394 (load addr:$src)))]>;
395def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
396 "cvttps2pi\t{$src, $dst|$dst, $src}",
397 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
398def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
399 "cvttps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000400 [(set VR64:$dst, (int_x86_sse_cvttps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000401 (load addr:$src)))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +0000402let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000403 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000404 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
405 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
406 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
407 VR64:$src2))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000408 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000409 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
410 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000411 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000412 (load addr:$src2)))]>;
413}
414
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000415// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000416def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000417 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000418 [(set GR32:$dst,
419 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000420def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000421 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422 [(set GR32:$dst,
423 (int_x86_sse_cvttss2si(load addr:$src)))]>;
424
Evan Cheng3ea4d672008-03-05 08:19:16 +0000425let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000427 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000428 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000429 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
430 GR32:$src2))]>;
431 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000432 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000433 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
435 (loadi32 addr:$src2)))]>;
436}
437
438// Comparison instructions
Dan Gohmanf221da12009-01-09 02:27:34 +0000439let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000440 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000441 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000442 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000443let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000444 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000445 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, 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}
448
Evan Cheng55687072007-09-14 21:48:26 +0000449let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000450def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000451 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000452 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000453def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000454 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000455 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000456 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000457
458def COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
459 "comiss\t{$src2, $src1|$src1, $src2}", []>;
460def COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
461 "comiss\t{$src2, $src1|$src1, $src2}", []>;
462
Evan Cheng55687072007-09-14 21:48:26 +0000463} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464
465// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +0000466let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000467 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Sean Callanan2c48df22009-12-18 00:01:26 +0000468 (outs VR128:$dst),
469 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000470 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Sean Callanan2c48df22009-12-18 00:01:26 +0000471 [(set VR128:$dst, (int_x86_sse_cmp_ss
472 VR128:$src1,
473 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000474 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Sean Callanan2c48df22009-12-18 00:01:26 +0000475 (outs VR128:$dst),
476 (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000477 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
479 (load addr:$src), imm:$cc))]>;
480}
481
Evan Cheng55687072007-09-14 21:48:26 +0000482let Defs = [EFLAGS] in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000483def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000484 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000485 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000486 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000487def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000488 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000489 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000490 (implicit EFLAGS)]>;
491
Dan Gohmanf221da12009-01-09 02:27:34 +0000492def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000493 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000494 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000495 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000496def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000497 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000498 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000499 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000500} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000502// Aliases of packed SSE1 instructions for scalar use. These all have names
503// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504
505// Alias instructions that map fld0 to pxor for sse.
Dan Gohman51dbce62009-09-21 18:30:38 +0000506let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
507 canFoldAsLoad = 1 in
Chris Lattnercb521fb2010-02-05 21:30:49 +0000508 // FIXME: Set encoding to pseudo!
Chris Lattner8042d5d2010-02-05 21:34:18 +0000509def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins), "",
510 [(set FR32:$dst, fp32imm0)]>,
511 Requires<[HasSSE1]>, TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512
513// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
514// disregarded.
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000515let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000516def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000517 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000518
519// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
520// disregarded.
Evan Cheng8e664712009-11-17 09:51:18 +0000521let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000522def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000523 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000524 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525
526// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +0000527let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528let isCommutable = 1 in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000529 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
530 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000531 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000533 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
534 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000535 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000537 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
538 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000539 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
541}
542
Dan Gohmanf221da12009-01-09 02:27:34 +0000543def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
544 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000545 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000546 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000547 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000548def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
549 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000550 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000552 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000553def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
554 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000555 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000557 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000558
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000559let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000560def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000561 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000562 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000563let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000565 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000566 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000567}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000568}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569
570/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
571///
572/// In addition, we also have a special variant of the scalar form here to
573/// represent the associated intrinsic operation. This form is unlike the
574/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000575/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576///
577/// These three forms can each be reg+reg or reg+mem, so there are a total of
578/// six "instructions".
579///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000580let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000581multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
582 SDNode OpNode, Intrinsic F32Int,
583 bit Commutable = 0> {
584 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000585 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000586 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000587 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
588 let isCommutable = Commutable;
589 }
590
591 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000592 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
593 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000594 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000596
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000598 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
599 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000600 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000601 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
602 let isCommutable = Commutable;
603 }
604
605 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000606 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
607 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000608 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000609 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000610
611 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000612 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
613 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000614 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000615 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000616
617 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000618 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
619 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000620 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621 [(set VR128:$dst, (F32Int VR128:$src1,
622 sse_load_f32:$src2))]>;
623}
624}
625
626// Arithmetic instructions
627defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
628defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
629defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
630defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
631
632/// sse1_fp_binop_rm - Other SSE1 binops
633///
634/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
635/// instructions for a full-vector intrinsic form. Operations that map
636/// onto C operators don't use this form since they just use the plain
637/// vector form instead of having a separate vector intrinsic form.
638///
639/// This provides a total of eight "instructions".
640///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000641let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
643 SDNode OpNode,
644 Intrinsic F32Int,
645 Intrinsic V4F32Int,
646 bit Commutable = 0> {
647
648 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000649 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000650 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
652 let isCommutable = Commutable;
653 }
654
655 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000656 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
657 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000658 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000660
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000662 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
663 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000664 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000665 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
666 let isCommutable = Commutable;
667 }
668
669 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000670 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
671 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000672 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000673 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000674
675 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000676 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
677 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000678 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
680 let isCommutable = Commutable;
681 }
682
683 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000684 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
685 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000686 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687 [(set VR128:$dst, (F32Int VR128:$src1,
688 sse_load_f32:$src2))]>;
689
690 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000691 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
692 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000693 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
695 let isCommutable = Commutable;
696 }
697
698 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000699 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
700 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000701 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000702 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703}
704}
705
706defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
707 int_x86_sse_max_ss, int_x86_sse_max_ps>;
708defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
709 int_x86_sse_min_ss, int_x86_sse_min_ps>;
710
711//===----------------------------------------------------------------------===//
712// SSE packed FP Instructions
713
714// Move Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000715let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000716def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000717 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000718let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000719def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000720 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000721 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722
Evan Chengb783fa32007-07-19 01:14:50 +0000723def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000724 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000725 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000727let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000728def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000729 "movups\t{$src, $dst|$dst, $src}", []>;
Evan Cheng9d7cd4e2009-11-16 21:56:03 +0000730let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000731def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000732 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000733 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000734def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000735 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000736 [(store (v4f32 VR128:$src), addr:$dst)]>;
737
738// Intrinsic forms of MOVUPS load and store
Evan Cheng8e664712009-11-17 09:51:18 +0000739let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000740def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000741 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000742 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000743def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000744 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000745 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746
Evan Cheng3ea4d672008-03-05 08:19:16 +0000747let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000748 let AddedComplexity = 20 in {
749 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000750 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000752 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000753 (movlp VR128:$src1,
754 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000755 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000756 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000757 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000758 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +0000759 (movlhps VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000760 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000762} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763
Evan Chengd743a5f2008-05-10 00:59:18 +0000764
Nate Begeman8e140242010-02-12 01:10:45 +0000765def : Pat<(movlhps VR128:$src1, (bc_v4i32 (v2i64 (X86vzload addr:$src2)))),
766 (MOVHPSrm VR128:$src1, addr:$src2)>;
767
Evan Chengb783fa32007-07-19 01:14:50 +0000768def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000769 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
771 (iPTR 0))), addr:$dst)]>;
772
773// v2f64 extract element 1 is always custom lowered to unpack high to low
774// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000775def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000776 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +0000778 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
779 (undef)), (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780
Evan Cheng3ea4d672008-03-05 08:19:16 +0000781let Constraints = "$src1 = $dst" in {
Evan Cheng13559d62008-09-26 23:41:32 +0000782let AddedComplexity = 20 in {
Evan Cheng7581a822009-05-12 20:17:52 +0000783def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
784 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000785 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +0000787 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788
Evan Cheng7581a822009-05-12 20:17:52 +0000789def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
790 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000791 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000793 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000794} // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000795} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796
Nate Begemanb44aad72009-04-29 22:47:44 +0000797let AddedComplexity = 20 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000798def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Evan Chenga2497eb2008-09-25 20:50:48 +0000799 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begemanb44aad72009-04-29 22:47:44 +0000800def : Pat<(v2i64 (movddup VR128:$src, (undef))),
801 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
802}
Evan Chenga2497eb2008-09-25 20:50:48 +0000803
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804
805
806// Arithmetic
807
808/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
809///
810/// In addition, we also have a special variant of the scalar form here to
811/// represent the associated intrinsic operation. This form is unlike the
812/// plain scalar form, in that it takes an entire vector (instead of a
813/// scalar) and leaves the top elements undefined.
814///
815/// And, we have a special variant form for a full-vector intrinsic form.
816///
817/// These four forms can each have a reg or a mem operand, so there are a
818/// total of eight "instructions".
819///
820multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
821 SDNode OpNode,
822 Intrinsic F32Int,
823 Intrinsic V4F32Int,
824 bit Commutable = 0> {
825 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000826 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 [(set FR32:$dst, (OpNode FR32:$src))]> {
829 let isCommutable = Commutable;
830 }
831
832 // Scalar operation, mem.
Evan Chengd3f27fb2009-12-18 07:40:29 +0000833 def SSm : I<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000834 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Evan Chengd3f27fb2009-12-18 07:40:29 +0000835 [(set FR32:$dst, (OpNode (load addr:$src)))]>, XS,
Evan Chengd53fca12009-12-22 17:47:23 +0000836 Requires<[HasSSE1, OptForSize]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000837
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000839 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000840 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
842 let isCommutable = Commutable;
843 }
844
845 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000846 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000847 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000848 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849
850 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000851 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000852 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853 [(set VR128:$dst, (F32Int VR128:$src))]> {
854 let isCommutable = Commutable;
855 }
856
857 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000858 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000859 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
861
862 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000863 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000864 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
866 let isCommutable = Commutable;
867 }
868
869 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000870 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000871 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000872 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873}
874
875// Square root.
876defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
877 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
878
879// Reciprocal approximations. Note that these typically require refinement
880// in order to obtain suitable precision.
881defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
882 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
883defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
884 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
885
886// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +0000887let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888 let isCommutable = 1 in {
889 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000890 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000891 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892 [(set VR128:$dst, (v2i64
893 (and VR128:$src1, VR128:$src2)))]>;
894 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000895 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000896 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 [(set VR128:$dst, (v2i64
898 (or VR128:$src1, VR128:$src2)))]>;
899 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000900 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000901 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 [(set VR128:$dst, (v2i64
903 (xor VR128:$src1, VR128:$src2)))]>;
904 }
905
906 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000907 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000908 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000909 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
910 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000912 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000913 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000914 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
915 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000917 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000918 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000919 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
920 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000922 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000923 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 [(set VR128:$dst,
925 (v2i64 (and (xor VR128:$src1,
926 (bc_v2i64 (v4i32 immAllOnesV))),
927 VR128:$src2)))]>;
928 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000929 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000930 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000932 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000934 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935}
936
Evan Cheng3ea4d672008-03-05 08:19:16 +0000937let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000938 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begeman061db5f2008-05-12 20:34:32 +0000939 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
940 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
941 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
942 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000943 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begeman061db5f2008-05-12 20:34:32 +0000944 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
945 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
946 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +0000947 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948}
Nate Begeman03605a02008-07-17 16:51:19 +0000949def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
950 (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>;
951def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
952 (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953
954// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +0000955let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000957 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000958 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000959 VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000960 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000962 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000963 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000964 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000965 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000966 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000968 (v4f32 (shufp:$src3
969 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970
971 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000972 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000973 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000974 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000976 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000977 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000978 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000979 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000981 (v4f32 (unpckh VR128:$src1,
982 (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000984 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000985 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000986 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000988 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000989 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000990 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000991 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000993 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000995} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996
997// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000998def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000999 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengd8296b82009-05-28 18:55:28 +00001001def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001002 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
1004
Evan Chengd1d68072008-03-08 00:58:38 +00001005// Prefetch intrinsic.
1006def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
1007 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
1008def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
1009 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
1010def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
1011 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
1012def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
1013 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014
1015// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00001016def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001017 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
1019
1020// Load, store, and memory fence
Evan Cheng68cca152009-05-27 18:38:01 +00001021def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022
1023// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +00001024def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001025 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001026def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028
1029// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00001030// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00001031// load of an all-zeros value if folding it would be beneficial.
Chris Lattnercb521fb2010-02-05 21:30:49 +00001032// FIXME: Change encoding to pseudo!
Daniel Dunbara0e62002009-08-11 22:17:52 +00001033let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
1034 isCodeGenOnly = 1 in
Chris Lattnercb521fb2010-02-05 21:30:49 +00001035def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "",
Chris Lattnere6aa3862007-11-25 00:24:49 +00001036 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037
Evan Chenga15896e2008-03-12 07:02:50 +00001038let Predicates = [HasSSE1] in {
1039 def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
1040 def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1041 def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1042 def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1043 def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
1044}
1045
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046// FR32 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001047let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001048def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001049 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050 [(set VR128:$dst,
1051 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001052def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001053 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 [(set VR128:$dst,
1055 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
1056
1057// FIXME: may not be able to eliminate this movss with coalescing the src and
1058// dest register classes are different. We really want to write this pattern
1059// like this:
1060// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1061// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001062let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001063def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001064 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
1066 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001067def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001068 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001069 [(store (f32 (vector_extract (v4f32 VR128:$src),
1070 (iPTR 0))), addr:$dst)]>;
1071
1072
1073// Move to lower bits of a VR128, leaving upper bits alone.
1074// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001075let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001076let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001078 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001079 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001080
1081 let AddedComplexity = 15 in
1082 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001083 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001084 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001086 (v4f32 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087}
1088
1089// Move to lower bits of a VR128 and zeroing upper bits.
1090// Loading from memory automatically zeroing upper bits.
1091let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00001092def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001093 "movss\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00001094 [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001095 (loadf32 addr:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096
Evan Cheng056afe12008-05-20 18:24:47 +00001097def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
Evan Cheng40ee6e52008-05-08 00:57:18 +00001098 (MOVZSS2PSrm addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001100//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001101// SSE2 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001102//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001105let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001106def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "movsd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001108let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001109def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001110 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001112def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001113 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001114 [(store FR64:$src, addr:$dst)]>;
1115
1116// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001117def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001118 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001120def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001121 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001123def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001124 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001125 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengd3f27fb2009-12-18 07:40:29 +00001126def CVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001127 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Evan Chengd3f27fb2009-12-18 07:40:29 +00001128 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>, XD,
Evan Chengd53fca12009-12-22 17:47:23 +00001129 Requires<[HasSSE2, OptForSize]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001130def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001131 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001132 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001133def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001134 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1136
Sean Callanan3d5824c2009-09-16 01:13:52 +00001137def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1138 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1139def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1140 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1141def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1142 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1143def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1144 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1145def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1146 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1147def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1148 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1149def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1150 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1151def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1152 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1153def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1154 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1155def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1156 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1157
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001159def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001160 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1162 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001163def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001164 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
Evan Chengd53fca12009-12-22 17:47:23 +00001166 Requires<[HasSSE2, OptForSize]>;
Evan Chengd3f27fb2009-12-18 07:40:29 +00001167
1168def : Pat<(extloadf32 addr:$src),
Evan Chengd53fca12009-12-22 17:47:23 +00001169 (CVTSS2SDrr (MOVSSrm addr:$src))>, Requires<[HasSSE2, OptForSpeed]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170
1171// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001172def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001173 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001175def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001176 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1178 (load addr:$src)))]>;
1179
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001180// Match intrinisics which expect MM and XMM operand(s).
1181def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1182 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1183 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1184def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1185 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001186 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001187 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001188def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1189 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1190 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1191def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1192 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001193 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001194 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001195def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1196 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1197 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1198def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1199 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001200 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001201 (load addr:$src)))]>;
1202
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001203// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001204def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001205 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206 [(set GR32:$dst,
1207 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001208def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001209 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1211 (load addr:$src)))]>;
1212
1213// Comparison instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001214let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001215 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001216 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001217 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001218let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001219 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001220 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001221 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222}
1223
Evan Cheng950aac02007-09-25 01:57:46 +00001224let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001225def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001226 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001227 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001228def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001229 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001230 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001231 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001232} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001233
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +00001235let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001236 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00001237 (outs VR128:$dst),
1238 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001239 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001240 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1241 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001242 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Sean Callanan2c48df22009-12-18 00:01:26 +00001243 (outs VR128:$dst),
1244 (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001245 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1247 (load addr:$src), imm:$cc))]>;
1248}
1249
Evan Cheng950aac02007-09-25 01:57:46 +00001250let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001251def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001252 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001253 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1254 (implicit EFLAGS)]>;
1255def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001256 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001257 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1258 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259
Evan Chengb783fa32007-07-19 01:14:50 +00001260def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001261 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001262 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1263 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001264def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001265 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001266 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001267 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001268} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001269
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001270// Aliases of packed SSE2 instructions for scalar use. These all have names
1271// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272
1273// Alias instructions that map fld0 to pxor for sse.
Dan Gohman51dbce62009-09-21 18:30:38 +00001274let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1275 canFoldAsLoad = 1 in
Chris Lattner8042d5d2010-02-05 21:34:18 +00001276def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins), "",
1277 [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278 Requires<[HasSSE2]>, TB, OpSize;
1279
1280// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1281// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001282let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001283def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285
1286// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1287// disregarded.
Evan Cheng8e664712009-11-17 09:51:18 +00001288let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001289def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001290 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001291 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001292
1293// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001294let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295let isCommutable = 1 in {
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001296 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1297 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001300 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1301 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001302 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001303 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001304 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1305 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001306 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1308}
1309
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001310def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1311 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001312 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001314 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001315def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1316 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001317 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001319 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001320def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1321 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001322 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001324 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001326let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001328 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001329 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001330let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001332 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001333 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001335}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336
1337/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1338///
1339/// In addition, we also have a special variant of the scalar form here to
1340/// represent the associated intrinsic operation. This form is unlike the
1341/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001342/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343///
1344/// These three forms can each be reg+reg or reg+mem, so there are a total of
1345/// six "instructions".
1346///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001347let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1349 SDNode OpNode, Intrinsic F64Int,
1350 bit Commutable = 0> {
1351 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001352 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001353 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1355 let isCommutable = Commutable;
1356 }
1357
1358 // Scalar operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001359 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1360 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001361 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001363
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364 // Vector operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001365 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1366 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001367 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1369 let isCommutable = Commutable;
1370 }
1371
1372 // Vector operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001373 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1374 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001375 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf221da12009-01-09 02:27:34 +00001376 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377
1378 // Intrinsic operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001379 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1380 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001381 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001382 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383
1384 // Intrinsic operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001385 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1386 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001387 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001388 [(set VR128:$dst, (F64Int VR128:$src1,
1389 sse_load_f64:$src2))]>;
1390}
1391}
1392
1393// Arithmetic instructions
1394defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1395defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1396defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1397defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1398
1399/// sse2_fp_binop_rm - Other SSE2 binops
1400///
1401/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1402/// instructions for a full-vector intrinsic form. Operations that map
1403/// onto C operators don't use this form since they just use the plain
1404/// vector form instead of having a separate vector intrinsic form.
1405///
1406/// This provides a total of eight "instructions".
1407///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001408let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1410 SDNode OpNode,
1411 Intrinsic F64Int,
1412 Intrinsic V2F64Int,
1413 bit Commutable = 0> {
1414
1415 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001416 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1419 let isCommutable = Commutable;
1420 }
1421
1422 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001423 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1424 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001427
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001429 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1430 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001431 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001432 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1433 let isCommutable = Commutable;
1434 }
1435
1436 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001437 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1438 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001440 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001441
1442 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001443 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1444 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001445 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1447 let isCommutable = Commutable;
1448 }
1449
1450 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001451 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1452 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001453 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001454 [(set VR128:$dst, (F64Int VR128:$src1,
1455 sse_load_f64:$src2))]>;
1456
1457 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001458 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1459 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001460 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1462 let isCommutable = Commutable;
1463 }
1464
1465 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001466 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1467 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001468 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001469 [(set VR128:$dst, (V2F64Int VR128:$src1,
1470 (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471}
1472}
1473
1474defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1475 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1476defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1477 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1478
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001479//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001480// SSE packed FP Instructions
1481
1482// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001483let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001484def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001485 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001486let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001487def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001488 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001489 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001490
Evan Chengb783fa32007-07-19 01:14:50 +00001491def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001492 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001493 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001495let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001496def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001498let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001499def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001500 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001501 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001502def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001504 [(store (v2f64 VR128:$src), addr:$dst)]>;
1505
1506// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001507def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001508 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001509 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001510def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001512 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001513
Evan Cheng3ea4d672008-03-05 08:19:16 +00001514let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001515 let AddedComplexity = 20 in {
1516 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001517 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001519 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001520 (v2f64 (movlp VR128:$src1,
1521 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001523 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001525 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +00001526 (v2f64 (movlhps VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00001527 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001529} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530
Evan Chengb783fa32007-07-19 01:14:50 +00001531def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001532 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533 [(store (f64 (vector_extract (v2f64 VR128:$src),
1534 (iPTR 0))), addr:$dst)]>;
1535
1536// v2f64 extract element 1 is always custom lowered to unpack high to low
1537// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001538def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001539 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +00001541 (v2f64 (unpckh VR128:$src, (undef))),
1542 (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543
1544// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001545def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001546 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001547 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1548 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001549def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001550 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1551 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1552 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001553 TB, Requires<[HasSSE2]>;
1554
1555// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001556def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001557 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1559 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001560def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001561 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1562 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1563 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564 XS, Requires<[HasSSE2]>;
1565
Evan Chengb783fa32007-07-19 01:14:50 +00001566def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001567 "cvtps2dq\t{$src, $dst|$dst, $src}",
1568 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001569def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001570 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001572 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001573// SSE2 packed instructions with XS prefix
Sean Callanan2c48df22009-12-18 00:01:26 +00001574def CVTTPS2DQrr : SSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1575 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1576def CVTTPS2DQrm : SSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1577 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1578
Evan Chengb783fa32007-07-19 01:14:50 +00001579def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "cvttps2dq\t{$src, $dst|$dst, $src}",
Sean Callanan2c48df22009-12-18 00:01:26 +00001581 [(set VR128:$dst,
1582 (int_x86_sse2_cvttps2dq VR128:$src))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001584def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001585 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001586 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001587 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001588 XS, Requires<[HasSSE2]>;
1589
1590// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001591def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001592 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001593 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1594 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001595def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001596 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001597 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001598 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 XD, Requires<[HasSSE2]>;
1600
Evan Chengb783fa32007-07-19 01:14:50 +00001601def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng14c97c32008-03-14 07:46:48 +00001604def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001607 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001608
1609// SSE2 instructions without OpSize prefix
Sean Callanan2c48df22009-12-18 00:01:26 +00001610def CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1611 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1612def CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
1613 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1614
Evan Chengb783fa32007-07-19 01:14:50 +00001615def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001616 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1618 TB, Requires<[HasSSE2]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001619def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001620 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1622 (load addr:$src)))]>,
1623 TB, Requires<[HasSSE2]>;
1624
Sean Callanan2c48df22009-12-18 00:01:26 +00001625def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1626 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1627def CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1628 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1629
1630
Evan Chengb783fa32007-07-19 01:14:50 +00001631def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001632 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001634def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001635 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Cheng00b66ef2008-05-23 00:37:07 +00001637 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001638
1639// Match intrinsics which expect XMM operand(s).
1640// Aliases for intrinsics
Evan Cheng3ea4d672008-03-05 08:19:16 +00001641let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001643 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001644 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1646 GR32:$src2))]>;
1647def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001648 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001649 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1651 (loadi32 addr:$src2)))]>;
1652def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001653 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001654 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001655 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1656 VR128:$src2))]>;
1657def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001658 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001659 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001660 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1661 (load addr:$src2)))]>;
1662def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001663 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1666 VR128:$src2))]>, XS,
1667 Requires<[HasSSE2]>;
1668def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001669 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001670 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001671 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1672 (load addr:$src2)))]>, XS,
1673 Requires<[HasSSE2]>;
1674}
1675
1676// Arithmetic
1677
1678/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1679///
1680/// In addition, we also have a special variant of the scalar form here to
1681/// represent the associated intrinsic operation. This form is unlike the
1682/// plain scalar form, in that it takes an entire vector (instead of a
1683/// scalar) and leaves the top elements undefined.
1684///
1685/// And, we have a special variant form for a full-vector intrinsic form.
1686///
1687/// These four forms can each have a reg or a mem operand, so there are a
1688/// total of eight "instructions".
1689///
1690multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1691 SDNode OpNode,
1692 Intrinsic F64Int,
1693 Intrinsic V2F64Int,
1694 bit Commutable = 0> {
1695 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001696 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698 [(set FR64:$dst, (OpNode FR64:$src))]> {
1699 let isCommutable = Commutable;
1700 }
1701
1702 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001703 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001704 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001706
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001708 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001710 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1711 let isCommutable = Commutable;
1712 }
1713
1714 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001715 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001717 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001718
1719 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001720 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001721 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722 [(set VR128:$dst, (F64Int VR128:$src))]> {
1723 let isCommutable = Commutable;
1724 }
1725
1726 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001727 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001728 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001729 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1730
1731 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001732 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001733 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001734 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1735 let isCommutable = Commutable;
1736 }
1737
1738 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001739 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001741 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742}
1743
1744// Square root.
1745defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1746 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1747
1748// There is no f64 version of the reciprocal approximation instructions.
1749
1750// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +00001751let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752 let isCommutable = 1 in {
1753 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001754 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001755 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001756 [(set VR128:$dst,
1757 (and (bc_v2i64 (v2f64 VR128:$src1)),
1758 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1759 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001760 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 [(set VR128:$dst,
1763 (or (bc_v2i64 (v2f64 VR128:$src1)),
1764 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1765 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001766 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768 [(set VR128:$dst,
1769 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1770 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1771 }
1772
1773 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001774 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001775 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776 [(set VR128:$dst,
1777 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001778 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001780 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001782 [(set VR128:$dst,
1783 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001784 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001785 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001786 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788 [(set VR128:$dst,
1789 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001790 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001791 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001792 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001793 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001794 [(set VR128:$dst,
1795 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1796 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1797 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001798 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001799 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001800 [(set VR128:$dst,
1801 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001802 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803}
1804
Evan Cheng3ea4d672008-03-05 08:19:16 +00001805let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001806 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001807 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1808 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1809 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begeman061db5f2008-05-12 20:34:32 +00001810 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001811 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng14c97c32008-03-14 07:46:48 +00001812 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1813 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1814 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00001815 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816}
Evan Cheng33754092008-08-05 22:19:15 +00001817def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001818 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Cheng33754092008-08-05 22:19:15 +00001819def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001820 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821
1822// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001823let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001824 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001825 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1826 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman543d2142009-04-27 18:41:29 +00001827 [(set VR128:$dst,
1828 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001829 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001830 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001831 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001834 (v2f64 (shufp:$src3
1835 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836
1837 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001838 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001839 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001840 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001841 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001842 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001843 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001844 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001845 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001846 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001847 (v2f64 (unpckh VR128:$src1,
1848 (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001849
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001850 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001851 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001853 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001854 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001855 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001856 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001857 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001858 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001859 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001861} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862
1863
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001864//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865// SSE integer instructions
1866
1867// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001868let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001869def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001870 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001871let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001872def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001874 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001875let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001876def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001878 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001879let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001880def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001881 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001882 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001883 XS, Requires<[HasSSE2]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001884let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001885def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001886 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001887 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 XS, Requires<[HasSSE2]>;
1889
Dan Gohman4a4f1512007-07-18 20:23:34 +00001890// Intrinsic forms of MOVDQU load and store
Dan Gohman5574cc72008-12-03 18:15:48 +00001891let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001892def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001894 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1895 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001896def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001897 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001898 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1899 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900
Evan Cheng88004752008-03-05 08:11:27 +00001901let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902
1903multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1904 bit Commutable = 0> {
Sean Callanan2c48df22009-12-18 00:01:26 +00001905 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1906 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1909 let isCommutable = Commutable;
1910 }
Sean Callanan2c48df22009-12-18 00:01:26 +00001911 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1912 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001913 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001914 [(set VR128:$dst, (IntId VR128:$src1,
Sean Callanan2c48df22009-12-18 00:01:26 +00001915 (bitconvert (memopv2i64
1916 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001917}
1918
Evan Chengf90f8f82008-05-03 00:52:09 +00001919multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1920 string OpcodeStr,
1921 Intrinsic IntId, Intrinsic IntId2> {
Sean Callanan2c48df22009-12-18 00:01:26 +00001922 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1923 (ins VR128:$src1, VR128:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001924 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1925 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001926 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1927 (ins VR128:$src1, i128mem:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001928 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1929 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001930 (bitconvert (memopv2i64 addr:$src2))))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001931 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst),
1932 (ins VR128:$src1, i32i8imm:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001933 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1934 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
1935}
1936
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937/// PDI_binop_rm - Simple SSE2 binary operator.
1938multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1939 ValueType OpVT, bit Commutable = 0> {
Sean Callanan2c48df22009-12-18 00:01:26 +00001940 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1941 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001942 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1944 let isCommutable = Commutable;
1945 }
Sean Callanan2c48df22009-12-18 00:01:26 +00001946 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1947 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001948 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001949 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001950 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001951}
1952
1953/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1954///
1955/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1956/// to collapse (bitconvert VT to VT) into its operand.
1957///
1958multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1959 bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001960 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00001961 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1964 let isCommutable = Commutable;
1965 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001966 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00001967 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001969 [(set VR128:$dst, (OpNode VR128:$src1,
Sean Callanan2c48df22009-12-18 00:01:26 +00001970 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001971}
1972
Evan Cheng3ea4d672008-03-05 08:19:16 +00001973} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001974
1975// 128-bit Integer Arithmetic
1976
1977defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1978defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1979defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1980defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1981
1982defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1983defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1984defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1985defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1986
1987defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1988defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1989defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1990defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1991
1992defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1993defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1994defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1995defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1996
1997defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1998
1999defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
2000defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
2001defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
2002
2003defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
2004
2005defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
2006defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
2007
2008
2009defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
2010defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
2011defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
2012defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling953ad2e2009-05-28 02:04:00 +00002013defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014
2015
Evan Chengf90f8f82008-05-03 00:52:09 +00002016defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
2017 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
2018defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
2019 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
2020defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
2021 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022
Evan Chengf90f8f82008-05-03 00:52:09 +00002023defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
2024 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
2025defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
2026 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begemanc2ca5f62008-05-13 17:52:09 +00002027defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Chengf90f8f82008-05-03 00:52:09 +00002028 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029
Evan Chengf90f8f82008-05-03 00:52:09 +00002030defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
2031 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemand66fc342008-05-13 01:47:52 +00002032defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Chengf90f8f82008-05-03 00:52:09 +00002033 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034
2035// 128-bit logical shifts.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002036let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002037 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002038 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002039 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002040 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00002041 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002042 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043 // PSRADQri doesn't exist in SSE[1-3].
2044}
2045
2046let Predicates = [HasSSE2] in {
2047 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
Evan Cheng06cd2072009-10-28 06:30:34 +00002048 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
Evan Cheng06cd2072009-10-28 06:30:34 +00002050 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Bill Wendling314ee052008-10-02 05:56:52 +00002051 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2052 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2053 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2054 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002056 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Evan Chengdea99362008-05-29 08:22:04 +00002057
2058 // Shift up / down and insert zero's.
2059 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
Evan Cheng06cd2072009-10-28 06:30:34 +00002060 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Evan Chengdea99362008-05-29 08:22:04 +00002061 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
Evan Cheng06cd2072009-10-28 06:30:34 +00002062 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002063}
2064
2065// Logical
2066defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2067defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2068defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2069
Evan Cheng3ea4d672008-03-05 08:19:16 +00002070let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002072 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2075 VR128:$src2)))]>;
2076
2077 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002078 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002080 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00002081 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082}
2083
2084// SSE2 Integer comparison
2085defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2086defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2087defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2088defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2089defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2090defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2091
Nate Begeman03605a02008-07-17 16:51:19 +00002092def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002093 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002094def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002095 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002096def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002097 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002098def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002099 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002100def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002101 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002102def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002103 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2104
Nate Begeman03605a02008-07-17 16:51:19 +00002105def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002106 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002107def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002108 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002109def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002110 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002111def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002112 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002113def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002114 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002115def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002116 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2117
2118
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119// Pack instructions
2120defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2121defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2122defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2123
2124// Shuffle and unpack instructions
Nate Begeman080f8e22009-10-19 02:17:23 +00002125let AddedComplexity = 5 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002127 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002129 [(set VR128:$dst, (v4i32 (pshufd:$src2
2130 VR128:$src1, (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002131def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002132 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002134 [(set VR128:$dst, (v4i32 (pshufd:$src2
Evan Chenge31a26a2009-12-09 21:00:30 +00002135 (bc_v4i32 (memopv2i64 addr:$src1)),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002136 (undef))))]>;
Eric Christopherf3650292009-11-07 08:45:53 +00002137}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138
2139// SSE2 with ImmT == Imm8 and XS prefix.
2140def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002141 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002143 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2144 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002145 XS, Requires<[HasSSE2]>;
2146def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002147 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002148 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002149 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002150 (bc_v8i16 (memopv2i64 addr:$src1)),
2151 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 XS, Requires<[HasSSE2]>;
2153
2154// SSE2 with ImmT == Imm8 and XD prefix.
2155def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman543d2142009-04-27 18:41:29 +00002156 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002158 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2159 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160 XD, Requires<[HasSSE2]>;
2161def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman543d2142009-04-27 18:41:29 +00002162 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002163 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002164 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2165 (bc_v8i16 (memopv2i64 addr:$src1)),
2166 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 XD, Requires<[HasSSE2]>;
2168
2169
Evan Cheng3ea4d672008-03-05 08:19:16 +00002170let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002171 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002172 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002173 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002175 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002176 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002177 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002178 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002180 (unpckl VR128:$src1,
2181 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002182 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002183 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002184 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002185 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002186 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002187 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002188 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002190 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002191 (unpckl VR128:$src1,
2192 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002193 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002194 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002195 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002197 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002198 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002199 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002200 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002201 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002202 (unpckl VR128:$src1,
2203 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002204 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002205 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002206 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002207 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002208 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002209 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002210 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002211 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002213 (v2i64 (unpckl VR128:$src1,
2214 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002215
2216 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002217 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002220 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002221 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002222 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002224 [(set VR128:$dst,
2225 (unpckh VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002226 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002227 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002228 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002229 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002231 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002232 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002233 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002234 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002235 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002236 (unpckh VR128:$src1,
2237 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002238 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002239 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002241 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002242 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002243 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002244 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002247 (unpckh VR128:$src1,
2248 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002249 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002250 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002251 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002253 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002254 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002255 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002258 (v2i64 (unpckh VR128:$src1,
2259 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002260}
2261
2262// Extract / Insert
2263def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002264 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002266 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begemand77e59e2008-02-11 04:19:36 +00002267 imm:$src2))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +00002268let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002270 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002271 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002274 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002275 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002276 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002277 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002278 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002279 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002280 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2281 imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282}
2283
2284// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002285def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002287 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2288
2289// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002290let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002291def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002292 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002293 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294
Evan Cheng430de082009-02-10 22:06:28 +00002295let Uses = [RDI] in
2296def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2297 "maskmovdqu\t{$mask, $src|$src, $mask}",
2298 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2299
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002301def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002302 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002303 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002304def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002305 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002306 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002307def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002308 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002309 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002310 TB, Requires<[HasSSE2]>;
2311
2312// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002313def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002314 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002315 TB, Requires<[HasSSE2]>;
2316
2317// Load, store, and memory fence
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002318def LFENCE : I<0xAE, MRM5r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002319 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002320def MFENCE : I<0xAE, MRM6r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002321 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2322
Andrew Lenharth785610d2008-02-16 01:24:58 +00002323//TODO: custom lower this so as to never even generate the noop
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002324def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002325 (i8 0)), (NOOP)>;
2326def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2327def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002328def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002329 (i8 1)), (MFENCE)>;
2330
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00002332// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00002333// load of an all-ones value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +00002334let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2335 isCodeGenOnly = 1 in
Chris Lattnercb521fb2010-02-05 21:30:49 +00002336 // FIXME: Change encoding to pseudo.
2337 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002338 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002339
2340// FR64 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002341let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002342def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002343 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002344 [(set VR128:$dst,
2345 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002346def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002347 "movsd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002348 [(set VR128:$dst,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2350
Evan Chengb783fa32007-07-19 01:14:50 +00002351def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002353 [(set VR128:$dst,
2354 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002355def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002356 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002357 [(set VR128:$dst,
2358 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2359
Evan Chengb783fa32007-07-19 01:14:50 +00002360def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002361 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002362 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2363
Evan Chengb783fa32007-07-19 01:14:50 +00002364def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002365 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002366 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2367
2368// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002369def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002370 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002371 [(set VR128:$dst,
2372 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2373 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002374def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002375 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002376 [(store (i64 (vector_extract (v2i64 VR128:$src),
2377 (iPTR 0))), addr:$dst)]>;
2378
2379// FIXME: may not be able to eliminate this movss with coalescing the src and
2380// dest register classes are different. We really want to write this pattern
2381// like this:
2382// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2383// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002384let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002385def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002386 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002387 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2388 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002389def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002390 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002391 [(store (f64 (vector_extract (v2f64 VR128:$src),
2392 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002393def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002394 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002395 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2396 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002397def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002398 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002399 [(store (i32 (vector_extract (v4i32 VR128:$src),
2400 (iPTR 0))), addr:$dst)]>;
2401
Evan Chengb783fa32007-07-19 01:14:50 +00002402def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002403 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002405def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002406 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002407 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2408
2409
2410// Move to lower bits of a VR128, leaving upper bits alone.
2411// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002412let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00002413 let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002414 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002415 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002416 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002417
2418 let AddedComplexity = 15 in
2419 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002420 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002421 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002422 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002423 (v2f64 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002424}
2425
2426// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002427def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002428 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002429 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2430
2431// Move to lower bits of a VR128 and zeroing upper bits.
2432// Loading from memory automatically zeroing upper bits.
Evan Chengd743a5f2008-05-10 00:59:18 +00002433let AddedComplexity = 20 in {
2434def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2435 "movsd\t{$src, $dst|$dst, $src}",
2436 [(set VR128:$dst,
2437 (v2f64 (X86vzmovl (v2f64 (scalar_to_vector
2438 (loadf64 addr:$src))))))]>;
Evan Cheng40ee6e52008-05-08 00:57:18 +00002439
Evan Cheng056afe12008-05-20 18:24:47 +00002440def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
2441 (MOVZSD2PDrm addr:$src)>;
2442def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
Evan Chengd743a5f2008-05-10 00:59:18 +00002443 (MOVZSD2PDrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002444def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002445}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002446
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447// movd / movq to XMM register zero-extends
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002448let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002449def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002450 "movd\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002451 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002452 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002453// This is X86-64 only.
2454def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2455 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002456 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002457 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002458}
2459
2460let AddedComplexity = 20 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002461def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002462 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002463 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002464 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002465 (loadi32 addr:$src))))))]>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002466
2467def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2468 (MOVZDI2PDIrm addr:$src)>;
2469def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2470 (MOVZDI2PDIrm addr:$src)>;
Duncan Sands2418bec2008-06-13 19:07:40 +00002471def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2472 (MOVZDI2PDIrm addr:$src)>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002473
Evan Chengb783fa32007-07-19 01:14:50 +00002474def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002475 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002476 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002477 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002478 (loadi64 addr:$src))))))]>, XS,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002479 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002480
Evan Cheng3ad16c42008-05-22 18:56:56 +00002481def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2482 (MOVZQI2PQIrm addr:$src)>;
2483def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2484 (MOVZQI2PQIrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002485def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002486}
Evan Chenge9b9c672008-05-09 21:53:03 +00002487
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002488// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2489// IA32 document. movq xmm1, xmm2 does clear the high bits.
2490let AddedComplexity = 15 in
2491def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2492 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002493 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002494 XS, Requires<[HasSSE2]>;
2495
Evan Cheng056afe12008-05-20 18:24:47 +00002496let AddedComplexity = 20 in {
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002497def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2498 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002499 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng056afe12008-05-20 18:24:47 +00002500 (loadv2i64 addr:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002501 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002502
Evan Cheng056afe12008-05-20 18:24:47 +00002503def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2504 (MOVZPQILo2PQIrm addr:$src)>;
2505}
2506
Sean Callanan2c48df22009-12-18 00:01:26 +00002507// Instructions for the disassembler
2508// xr = XMM register
2509// xm = mem64
2510
2511def MOVQxrxr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2512 "movq\t{$src, $dst|$dst, $src}", []>, XS;
2513
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002514//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002515// SSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002516//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002517
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002518// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002519def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002520 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002521 [(set VR128:$dst, (v4f32 (movshdup
2522 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002523def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002524 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002525 [(set VR128:$dst, (movshdup
2526 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002527
Evan Chengb783fa32007-07-19 01:14:50 +00002528def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002529 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002530 [(set VR128:$dst, (v4f32 (movsldup
2531 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002532def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002533 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002534 [(set VR128:$dst, (movsldup
2535 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002536
Evan Chengb783fa32007-07-19 01:14:50 +00002537def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002538 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002539 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002540def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002541 "movddup\t{$src, $dst|$dst, $src}",
Evan Chenga2497eb2008-09-25 20:50:48 +00002542 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002543 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2544 (undef))))]>;
Evan Chenga2497eb2008-09-25 20:50:48 +00002545
Nate Begeman543d2142009-04-27 18:41:29 +00002546def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2547 (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002548 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002549
2550let AddedComplexity = 5 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002551def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002552 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002553def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2554 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2555def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2556 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2557def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2558 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2559}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002560
2561// Arithmetic
Evan Cheng3ea4d672008-03-05 08:19:16 +00002562let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002563 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002564 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002565 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002566 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2567 VR128:$src2))]>;
2568 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002569 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002570 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002571 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002572 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002573 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002574 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002575 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002576 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2577 VR128:$src2))]>;
2578 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002579 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002580 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002581 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002582 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583}
2584
Evan Chengb783fa32007-07-19 01:14:50 +00002585def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002586 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2588
2589// Horizontal ops
2590class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002591 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002592 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002593 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2594class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002595 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002596 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002597 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002598class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002599 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002600 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002601 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2602class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002603 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002604 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002605 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002606
Evan Cheng3ea4d672008-03-05 08:19:16 +00002607let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002608 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2609 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2610 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2611 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2612 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2613 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2614 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2615 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2616}
2617
2618// Thread synchronization
Bill Wendling6ee76552009-05-28 23:40:46 +00002619def MONITOR : I<0x01, MRM1r, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002620 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Bill Wendling6ee76552009-05-28 23:40:46 +00002621def MWAIT : I<0x01, MRM1r, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002622 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2623
2624// vector_shuffle v1, <undef> <1, 1, 3, 3>
2625let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002626def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002627 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2628let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002629def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002630 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2631
2632// vector_shuffle v1, <undef> <0, 0, 2, 2>
2633let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002634 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002635 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2636let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002637 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002638 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2639
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002640//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002641// SSSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002642//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002643
Bill Wendling98680292007-08-10 06:22:27 +00002644/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002645multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2646 Intrinsic IntId64, Intrinsic IntId128> {
2647 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2648 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2649 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002650
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002651 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2652 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2653 [(set VR64:$dst,
2654 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2655
2656 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2657 (ins VR128:$src),
2658 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2659 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2660 OpSize;
2661
2662 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2663 (ins i128mem:$src),
2664 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2665 [(set VR128:$dst,
2666 (IntId128
2667 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002668}
2669
Bill Wendling98680292007-08-10 06:22:27 +00002670/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002671multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2672 Intrinsic IntId64, Intrinsic IntId128> {
2673 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2674 (ins VR64:$src),
2675 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2676 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002677
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002678 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2679 (ins i64mem:$src),
2680 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2681 [(set VR64:$dst,
2682 (IntId64
2683 (bitconvert (memopv4i16 addr:$src))))]>;
2684
2685 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2686 (ins VR128:$src),
2687 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2688 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2689 OpSize;
2690
2691 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2692 (ins i128mem:$src),
2693 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2694 [(set VR128:$dst,
2695 (IntId128
2696 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002697}
2698
2699/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002700multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2701 Intrinsic IntId64, Intrinsic IntId128> {
2702 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2703 (ins VR64:$src),
2704 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2705 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002706
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002707 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2708 (ins i64mem:$src),
2709 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2710 [(set VR64:$dst,
2711 (IntId64
2712 (bitconvert (memopv2i32 addr:$src))))]>;
2713
2714 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2715 (ins VR128:$src),
2716 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2717 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2718 OpSize;
2719
2720 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2721 (ins i128mem:$src),
2722 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2723 [(set VR128:$dst,
2724 (IntId128
2725 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002726}
2727
2728defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2729 int_x86_ssse3_pabs_b,
2730 int_x86_ssse3_pabs_b_128>;
2731defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2732 int_x86_ssse3_pabs_w,
2733 int_x86_ssse3_pabs_w_128>;
2734defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2735 int_x86_ssse3_pabs_d,
2736 int_x86_ssse3_pabs_d_128>;
2737
2738/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002739let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002740 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2741 Intrinsic IntId64, Intrinsic IntId128,
2742 bit Commutable = 0> {
2743 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2744 (ins VR64:$src1, VR64:$src2),
2745 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2746 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2747 let isCommutable = Commutable;
2748 }
2749 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2750 (ins VR64:$src1, i64mem:$src2),
2751 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2752 [(set VR64:$dst,
2753 (IntId64 VR64:$src1,
2754 (bitconvert (memopv8i8 addr:$src2))))]>;
2755
2756 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2757 (ins VR128:$src1, VR128:$src2),
2758 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2759 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2760 OpSize {
2761 let isCommutable = Commutable;
2762 }
2763 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2764 (ins VR128:$src1, i128mem:$src2),
2765 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2766 [(set VR128:$dst,
2767 (IntId128 VR128:$src1,
2768 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2769 }
2770}
2771
2772/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002773let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002774 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2775 Intrinsic IntId64, Intrinsic IntId128,
2776 bit Commutable = 0> {
2777 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2778 (ins VR64:$src1, VR64:$src2),
2779 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2780 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2781 let isCommutable = Commutable;
2782 }
2783 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2784 (ins VR64:$src1, i64mem:$src2),
2785 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2786 [(set VR64:$dst,
2787 (IntId64 VR64:$src1,
2788 (bitconvert (memopv4i16 addr:$src2))))]>;
2789
2790 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2791 (ins VR128:$src1, VR128:$src2),
2792 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2793 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2794 OpSize {
2795 let isCommutable = Commutable;
2796 }
2797 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2798 (ins VR128:$src1, i128mem:$src2),
2799 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2800 [(set VR128:$dst,
2801 (IntId128 VR128:$src1,
2802 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2803 }
2804}
2805
2806/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002807let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002808 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2809 Intrinsic IntId64, Intrinsic IntId128,
2810 bit Commutable = 0> {
2811 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2812 (ins VR64:$src1, VR64:$src2),
2813 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2814 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2815 let isCommutable = Commutable;
2816 }
2817 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2818 (ins VR64:$src1, i64mem:$src2),
2819 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2820 [(set VR64:$dst,
2821 (IntId64 VR64:$src1,
2822 (bitconvert (memopv2i32 addr:$src2))))]>;
2823
2824 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2825 (ins VR128:$src1, VR128:$src2),
2826 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2827 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2828 OpSize {
2829 let isCommutable = Commutable;
2830 }
2831 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2832 (ins VR128:$src1, i128mem:$src2),
2833 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2834 [(set VR128:$dst,
2835 (IntId128 VR128:$src1,
2836 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2837 }
2838}
2839
2840defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2841 int_x86_ssse3_phadd_w,
Evan Cheng944e4412008-06-16 21:16:24 +00002842 int_x86_ssse3_phadd_w_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002843defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2844 int_x86_ssse3_phadd_d,
Evan Cheng944e4412008-06-16 21:16:24 +00002845 int_x86_ssse3_phadd_d_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002846defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2847 int_x86_ssse3_phadd_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002848 int_x86_ssse3_phadd_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002849defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2850 int_x86_ssse3_phsub_w,
2851 int_x86_ssse3_phsub_w_128>;
2852defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2853 int_x86_ssse3_phsub_d,
2854 int_x86_ssse3_phsub_d_128>;
2855defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2856 int_x86_ssse3_phsub_sw,
2857 int_x86_ssse3_phsub_sw_128>;
2858defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2859 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002860 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002861defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2862 int_x86_ssse3_pmul_hr_sw,
2863 int_x86_ssse3_pmul_hr_sw_128, 1>;
2864defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2865 int_x86_ssse3_pshuf_b,
2866 int_x86_ssse3_pshuf_b_128>;
2867defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2868 int_x86_ssse3_psign_b,
2869 int_x86_ssse3_psign_b_128>;
2870defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2871 int_x86_ssse3_psign_w,
2872 int_x86_ssse3_psign_w_128>;
Evan Chengabfed472009-05-28 18:48:53 +00002873defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling98680292007-08-10 06:22:27 +00002874 int_x86_ssse3_psign_d,
2875 int_x86_ssse3_psign_d_128>;
2876
Evan Cheng3ea4d672008-03-05 08:19:16 +00002877let Constraints = "$src1 = $dst" in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002878 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002879 (ins VR64:$src1, VR64:$src2, i8imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002880 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002881 []>;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002882 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002883 (ins VR64:$src1, i64mem:$src2, i8imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002884 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002885 []>;
Bill Wendling98680292007-08-10 06:22:27 +00002886
Bill Wendling1dc817c2007-08-10 09:00:17 +00002887 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002888 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002889 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002890 []>, OpSize;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002891 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002892 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002893 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002894 []>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002895}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002896
Nate Begeman080f8e22009-10-19 02:17:23 +00002897// palignr patterns.
Sean Callananb02aec52009-11-20 22:28:42 +00002898def : Pat<(int_x86_ssse3_palign_r VR64:$src1, VR64:$src2, (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002899 (PALIGNR64rr VR64:$src1, VR64:$src2, (BYTE_imm imm:$src3))>,
2900 Requires<[HasSSSE3]>;
2901def : Pat<(int_x86_ssse3_palign_r VR64:$src1,
2902 (memop64 addr:$src2),
Sean Callananb02aec52009-11-20 22:28:42 +00002903 (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002904 (PALIGNR64rm VR64:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2905 Requires<[HasSSSE3]>;
2906
Sean Callananb02aec52009-11-20 22:28:42 +00002907def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1, VR128:$src2, (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002908 (PALIGNR128rr VR128:$src1, VR128:$src2, (BYTE_imm imm:$src3))>,
2909 Requires<[HasSSSE3]>;
2910def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1,
2911 (memopv2i64 addr:$src2),
Sean Callananb02aec52009-11-20 22:28:42 +00002912 (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002913 (PALIGNR128rm VR128:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2914 Requires<[HasSSSE3]>;
2915
Nate Begeman080f8e22009-10-19 02:17:23 +00002916let AddedComplexity = 5 in {
2917def : Pat<(v4i32 (palign:$src3 VR128:$src1, VR128:$src2)),
2918 (PALIGNR128rr VR128:$src2, VR128:$src1,
2919 (SHUFFLE_get_palign_imm VR128:$src3))>,
2920 Requires<[HasSSSE3]>;
2921def : Pat<(v4f32 (palign:$src3 VR128:$src1, VR128:$src2)),
2922 (PALIGNR128rr VR128:$src2, VR128:$src1,
2923 (SHUFFLE_get_palign_imm VR128:$src3))>,
2924 Requires<[HasSSSE3]>;
2925def : Pat<(v8i16 (palign:$src3 VR128:$src1, VR128:$src2)),
2926 (PALIGNR128rr VR128:$src2, VR128:$src1,
2927 (SHUFFLE_get_palign_imm VR128:$src3))>,
2928 Requires<[HasSSSE3]>;
2929def : Pat<(v16i8 (palign:$src3 VR128:$src1, VR128:$src2)),
2930 (PALIGNR128rr VR128:$src2, VR128:$src1,
2931 (SHUFFLE_get_palign_imm VR128:$src3))>,
2932 Requires<[HasSSSE3]>;
Eric Christopherf3650292009-11-07 08:45:53 +00002933}
Nate Begeman080f8e22009-10-19 02:17:23 +00002934
Nate Begeman2c87c422009-02-23 08:49:38 +00002935def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2936 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2937def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2938 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2939
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002940//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002941// Non-Instruction Patterns
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002942//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002943
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002944// extload f32 -> f64. This matches load+fextend because we have a hack in
2945// the isel (PreprocessForFPConvert) that can introduce loads after dag
2946// combine.
Chris Lattnerdec9cb52008-01-24 08:07:48 +00002947// Since these loads aren't folded into the fextend, we have to match it
2948// explicitly here.
2949let Predicates = [HasSSE2] in
2950 def : Pat<(fextend (loadf32 addr:$src)),
2951 (CVTSS2SDrm addr:$src)>;
2952
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002953// bit_convert
2954let Predicates = [HasSSE2] in {
2955 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2956 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2957 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2958 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2959 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2960 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2961 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2962 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2963 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2964 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2965 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2966 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2967 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2968 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2969 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2970 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2971 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2972 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2973 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2974 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2975 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2976 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2977 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2978 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2979 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2980 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2981 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2982 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2983 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2984 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2985}
2986
2987// Move scalar to XMM zero-extended
2988// movd to XMM register zero-extends
2989let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002990// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chenge9b9c672008-05-09 21:53:03 +00002991def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002992 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002993def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002994 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>;
Evan Chenge259e872008-05-09 23:37:55 +00002995def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002996 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Evan Cheng7fe0ff02008-07-10 01:08:23 +00002997def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002998 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002999}
3000
3001// Splat v2f64 / v2i64
3002let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003003def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003004 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003005def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003006 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003007def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003008 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003009def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003010 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
3011}
3012
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003013// Special unary SHUFPSrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00003014def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
3015 (SHUFPSrri VR128:$src1, VR128:$src1,
3016 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003017 Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003018let AddedComplexity = 5 in
3019def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
3020 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3021 Requires<[HasSSE2]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00003022// Special unary SHUFPDrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00003023def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003024 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00003025 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3026 Requires<[HasSSE2]>;
3027// Special unary SHUFPDrri case.
3028def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003029 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00003030 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7dc19012007-08-02 21:17:01 +00003031 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003032// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman543d2142009-04-27 18:41:29 +00003033def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
3034 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003035 Requires<[HasSSE2]>;
Evan Cheng13559d62008-09-26 23:41:32 +00003036
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003037// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman543d2142009-04-27 18:41:29 +00003038def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003039 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00003040 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003041 Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003042def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003043 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00003044 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003045 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003046// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman543d2142009-04-27 18:41:29 +00003047def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003048 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00003049 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003050 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003051
3052// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00003053let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003054def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
3055 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003056 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003057def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
3058 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003059 Requires<[OptForSpeed, HasSSE2]>;
3060}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003061let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003062def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003063 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003064def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003065 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003066def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003067 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003068def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003069 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003070}
3071
3072// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00003073let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003074def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
3075 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003076 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003077def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
3078 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003079 Requires<[OptForSpeed, HasSSE2]>;
3080}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003081let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003082def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003083 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003084def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003085 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003086def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003087 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003088def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003089 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003090}
3091
Evan Cheng13559d62008-09-26 23:41:32 +00003092let AddedComplexity = 20 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003093// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begemanb13034d2009-11-07 23:17:15 +00003094def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003095 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
3096
3097// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003098def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003099 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
3100
3101// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003102def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003103 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman543d2142009-04-27 18:41:29 +00003104def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003105 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
3106}
3107
3108let AddedComplexity = 20 in {
3109// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003110def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003111 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003112def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003113 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003114def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003115 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003116def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003117 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003118}
3119
Evan Cheng2b2a7012008-05-23 21:23:16 +00003120// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003121def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003122 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003123def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003124 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003125def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3126 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003127 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003128def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003129 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2b2a7012008-05-23 21:23:16 +00003130
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003131let AddedComplexity = 15 in {
3132// Setting the lowest element in the vector.
Nate Begeman543d2142009-04-27 18:41:29 +00003133def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003134 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003135def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003136 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3137
3138// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
Nate Begeman543d2142009-04-27 18:41:29 +00003139def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003140 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003141def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003142 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3143}
3144
Eli Friedman27d19742009-06-19 07:00:55 +00003145// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3146// fall back to this for SSE1)
3147def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003148 (SHUFPSrri VR128:$src2, VR128:$src1,
Eli Friedman27d19742009-06-19 07:00:55 +00003149 (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>;
3150
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003151// Set lowest element and zero upper elements.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003152let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00003153def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003154 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00003155def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengd09a8a02008-05-08 22:35:02 +00003156 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003157
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003158// Some special case pandn patterns.
3159def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3160 VR128:$src2)),
3161 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3162def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3163 VR128:$src2)),
3164 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3165def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3166 VR128:$src2)),
3167 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3168
3169def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003170 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003171 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3172def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003173 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003174 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3175def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003176 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003177 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3178
Nate Begeman78246ca2007-11-17 03:58:34 +00003179// vector -> vector casts
3180def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3181 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3182def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3183 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedman7fa52ca2008-09-05 23:07:03 +00003184def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3185 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3186def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3187 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman78246ca2007-11-17 03:58:34 +00003188
Evan Cheng51a49b22007-07-20 00:27:43 +00003189// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00003190def : Pat<(alignedloadv4i32 addr:$src),
3191 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3192def : Pat<(loadv4i32 addr:$src),
3193 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00003194def : Pat<(alignedloadv2i64 addr:$src),
3195 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3196def : Pat<(loadv2i64 addr:$src),
3197 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3198
3199def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3200 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3201def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3202 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3203def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3204 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3205def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3206 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3207def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3208 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3209def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3210 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3211def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3212 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3213def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3214 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003215
Nate Begemanb2975562008-02-03 07:18:54 +00003216//===----------------------------------------------------------------------===//
3217// SSE4.1 Instructions
3218//===----------------------------------------------------------------------===//
3219
Dale Johannesena7d2b442008-10-10 23:51:03 +00003220multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begemanb2975562008-02-03 07:18:54 +00003221 string OpcodeStr,
Nate Begemanb2975562008-02-03 07:18:54 +00003222 Intrinsic V4F32Int,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003223 Intrinsic V2F64Int> {
Nate Begemanb2975562008-02-03 07:18:54 +00003224 // Intrinsic operation, reg.
Nate Begemanb2975562008-02-03 07:18:54 +00003225 // Vector intrinsic operation, reg
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003226 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003227 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003228 !strconcat(OpcodeStr,
3229 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003230 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3231 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003232
3233 // Vector intrinsic operation, mem
Evan Chengd3f27fb2009-12-18 07:40:29 +00003234 def PSm_Int : Ii8<opcps, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003235 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003236 !strconcat(OpcodeStr,
3237 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003238 [(set VR128:$dst,
3239 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Evan Chengd3f27fb2009-12-18 07:40:29 +00003240 TA, OpSize,
Evan Chengd53fca12009-12-22 17:47:23 +00003241 Requires<[HasSSE41]>;
Nate Begemanb2975562008-02-03 07:18:54 +00003242
Nate Begemanb2975562008-02-03 07:18:54 +00003243 // Vector intrinsic operation, reg
Evan Cheng78d00612008-03-14 07:39:27 +00003244 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003245 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003246 !strconcat(OpcodeStr,
3247 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003248 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3249 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003250
3251 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003252 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003253 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003254 !strconcat(OpcodeStr,
3255 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003256 [(set VR128:$dst,
3257 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003258 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003259}
3260
Dale Johannesena7d2b442008-10-10 23:51:03 +00003261let Constraints = "$src1 = $dst" in {
3262multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3263 string OpcodeStr,
3264 Intrinsic F32Int,
3265 Intrinsic F64Int> {
3266 // Intrinsic operation, reg.
3267 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003268 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003269 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3270 !strconcat(OpcodeStr,
3271 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003272 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003273 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3274 OpSize;
3275
3276 // Intrinsic operation, mem.
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003277 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3278 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003279 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003280 !strconcat(OpcodeStr,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003281 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003282 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003283 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3284 OpSize;
3285
3286 // Intrinsic operation, reg.
3287 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003288 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003289 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3290 !strconcat(OpcodeStr,
3291 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003292 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003293 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3294 OpSize;
3295
3296 // Intrinsic operation, mem.
3297 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003298 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003299 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3300 !strconcat(OpcodeStr,
3301 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003302 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003303 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3304 OpSize;
3305}
3306}
3307
Nate Begemanb2975562008-02-03 07:18:54 +00003308// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesena7d2b442008-10-10 23:51:03 +00003309defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3310 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3311defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3312 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003313
3314// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3315multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3316 Intrinsic IntId128> {
3317 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3318 (ins VR128:$src),
3319 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3320 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3321 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3322 (ins i128mem:$src),
3323 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3324 [(set VR128:$dst,
3325 (IntId128
3326 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3327}
3328
3329defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3330 int_x86_sse41_phminposuw>;
3331
3332/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003333let Constraints = "$src1 = $dst" in {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003334 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3335 Intrinsic IntId128, bit Commutable = 0> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003336 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3337 (ins VR128:$src1, VR128:$src2),
3338 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3339 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3340 OpSize {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003341 let isCommutable = Commutable;
3342 }
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003343 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3344 (ins VR128:$src1, i128mem:$src2),
3345 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3346 [(set VR128:$dst,
3347 (IntId128 VR128:$src1,
3348 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003349 }
3350}
3351
3352defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3353 int_x86_sse41_pcmpeqq, 1>;
3354defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3355 int_x86_sse41_packusdw, 0>;
3356defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3357 int_x86_sse41_pminsb, 1>;
3358defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3359 int_x86_sse41_pminsd, 1>;
3360defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3361 int_x86_sse41_pminud, 1>;
3362defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3363 int_x86_sse41_pminuw, 1>;
3364defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3365 int_x86_sse41_pmaxsb, 1>;
3366defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3367 int_x86_sse41_pmaxsd, 1>;
3368defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3369 int_x86_sse41_pmaxud, 1>;
3370defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3371 int_x86_sse41_pmaxuw, 1>;
Nate Begeman72d802a2008-02-04 06:00:24 +00003372
Mon P Wang14edb092008-12-18 21:42:19 +00003373defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3374
Nate Begeman03605a02008-07-17 16:51:19 +00003375def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3376 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3377def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3378 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3379
Nate Begeman58057962008-02-09 01:38:08 +00003380/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003381let Constraints = "$src1 = $dst" in {
Dan Gohmane3731f52008-05-23 17:49:40 +00003382 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3383 SDNode OpNode, Intrinsic IntId128,
3384 bit Commutable = 0> {
Nate Begeman58057962008-02-09 01:38:08 +00003385 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3386 (ins VR128:$src1, VR128:$src2),
3387 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmane3731f52008-05-23 17:49:40 +00003388 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3389 VR128:$src2))]>, OpSize {
Nate Begeman58057962008-02-09 01:38:08 +00003390 let isCommutable = Commutable;
3391 }
3392 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3393 (ins VR128:$src1, VR128:$src2),
3394 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3395 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3396 OpSize {
3397 let isCommutable = Commutable;
3398 }
3399 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3400 (ins VR128:$src1, i128mem:$src2),
3401 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3402 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003403 (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003404 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3405 (ins VR128:$src1, i128mem:$src2),
3406 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3407 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003408 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman58057962008-02-09 01:38:08 +00003409 OpSize;
3410 }
3411}
Dan Gohmane3731f52008-05-23 17:49:40 +00003412defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
Nate Begeman58057962008-02-09 01:38:08 +00003413 int_x86_sse41_pmulld, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003414
Evan Cheng78d00612008-03-14 07:39:27 +00003415/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Cheng3ea4d672008-03-05 08:19:16 +00003416let Constraints = "$src1 = $dst" in {
Nate Begeman72d802a2008-02-04 06:00:24 +00003417 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3418 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng78d00612008-03-14 07:39:27 +00003419 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003420 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003421 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003422 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003423 [(set VR128:$dst,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003424 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3425 OpSize {
Nate Begeman72d802a2008-02-04 06:00:24 +00003426 let isCommutable = Commutable;
3427 }
Evan Cheng78d00612008-03-14 07:39:27 +00003428 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003429 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3430 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003431 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003432 [(set VR128:$dst,
3433 (IntId128 VR128:$src1,
3434 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3435 OpSize;
Nate Begeman72d802a2008-02-04 06:00:24 +00003436 }
3437}
3438
3439defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3440 int_x86_sse41_blendps, 0>;
3441defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3442 int_x86_sse41_blendpd, 0>;
3443defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3444 int_x86_sse41_pblendw, 0>;
3445defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3446 int_x86_sse41_dpps, 1>;
3447defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3448 int_x86_sse41_dppd, 1>;
3449defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng81ed9852008-06-16 20:25:59 +00003450 int_x86_sse41_mpsadbw, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003451
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003452
Evan Cheng78d00612008-03-14 07:39:27 +00003453/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003454let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanb4e9a042008-02-10 18:47:57 +00003455 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3456 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3457 (ins VR128:$src1, VR128:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003458 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003459 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3460 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3461 OpSize;
3462
3463 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3464 (ins VR128:$src1, i128mem:$src2),
3465 !strconcat(OpcodeStr,
3466 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3467 [(set VR128:$dst,
3468 (IntId VR128:$src1,
3469 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3470 }
3471}
3472
3473defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3474defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3475defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3476
3477
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003478multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3479 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3480 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3481 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3482
3483 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3484 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003485 [(set VR128:$dst,
3486 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3487 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003488}
3489
3490defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3491defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3492defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3493defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3494defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3495defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3496
Evan Cheng56ec77b2008-09-24 23:27:55 +00003497// Common patterns involving scalar load.
3498def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3499 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3500def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3501 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3502
3503def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3504 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3505def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3506 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3507
3508def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3509 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3510def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3511 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3512
3513def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3514 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3515def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3516 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3517
3518def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3519 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3520def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3521 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3522
3523def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3524 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3525def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3526 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3527
3528
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003529multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3530 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3531 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3532 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3533
3534 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3535 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003536 [(set VR128:$dst,
3537 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3538 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003539}
3540
3541defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3542defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3543defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3544defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3545
Evan Cheng56ec77b2008-09-24 23:27:55 +00003546// Common patterns involving scalar load
3547def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003548 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003549def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003550 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003551
3552def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003553 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003554def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003555 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003556
3557
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003558multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3559 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3560 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3561 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3562
Evan Cheng56ec77b2008-09-24 23:27:55 +00003563 // Expecting a i16 load any extended to i32 value.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003564 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3565 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003566 [(set VR128:$dst, (IntId (bitconvert
3567 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3568 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003569}
3570
3571defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman75a89d62009-06-06 05:55:37 +00003572defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003573
Evan Cheng56ec77b2008-09-24 23:27:55 +00003574// Common patterns involving scalar load
3575def : Pat<(int_x86_sse41_pmovsxbq
3576 (bitconvert (v4i32 (X86vzmovl
3577 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003578 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003579
3580def : Pat<(int_x86_sse41_pmovzxbq
3581 (bitconvert (v4i32 (X86vzmovl
3582 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003583 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003584
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003585
Nate Begemand77e59e2008-02-11 04:19:36 +00003586/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3587multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003588 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003589 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003590 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003591 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003592 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3593 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003594 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003595 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003596 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003597 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003598 []>, OpSize;
3599// FIXME:
3600// There's an AssertZext in the way of writing the store pattern
3601// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003602}
3603
Nate Begemand77e59e2008-02-11 04:19:36 +00003604defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003605
Nate Begemand77e59e2008-02-11 04:19:36 +00003606
3607/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3608multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003609 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemand77e59e2008-02-11 04:19:36 +00003610 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003611 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003612 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3613 []>, OpSize;
3614// FIXME:
3615// There's an AssertZext in the way of writing the store pattern
3616// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3617}
3618
3619defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3620
3621
3622/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3623multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003624 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003625 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003626 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003627 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3628 [(set GR32:$dst,
3629 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003630 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003631 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003632 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003633 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3634 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3635 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003636}
3637
Nate Begemand77e59e2008-02-11 04:19:36 +00003638defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman58057962008-02-09 01:38:08 +00003639
Nate Begemand77e59e2008-02-11 04:19:36 +00003640
Evan Cheng6c249332008-03-24 21:52:23 +00003641/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3642/// destination
Nate Begemand77e59e2008-02-11 04:19:36 +00003643multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003644 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003645 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003646 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003647 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman788db592008-04-16 02:32:24 +00003648 [(set GR32:$dst,
3649 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng6c249332008-03-24 21:52:23 +00003650 OpSize;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003651 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003652 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003653 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003654 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng6c249332008-03-24 21:52:23 +00003655 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003656 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003657}
3658
Nate Begemand77e59e2008-02-11 04:19:36 +00003659defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003660
Dan Gohmana41862a2008-08-08 18:30:21 +00003661// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3662def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3663 imm:$src2))),
3664 addr:$dst),
3665 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3666 Requires<[HasSSE41]>;
3667
Evan Cheng3ea4d672008-03-05 08:19:16 +00003668let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003669 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003670 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003671 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003672 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003673 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003674 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003675 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003676 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003677 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3678 !strconcat(OpcodeStr,
3679 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003680 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003681 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3682 imm:$src3))]>, OpSize;
3683 }
3684}
3685
3686defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3687
Evan Cheng3ea4d672008-03-05 08:19:16 +00003688let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003689 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003690 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003691 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003692 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003693 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003694 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003695 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3696 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003697 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003698 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3699 !strconcat(OpcodeStr,
3700 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003701 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003702 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3703 imm:$src3)))]>, OpSize;
3704 }
3705}
3706
3707defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3708
Eric Christophera0443602009-07-23 02:22:41 +00003709// insertps has a few different modes, there's the first two here below which
3710// are optimized inserts that won't zero arbitrary elements in the destination
3711// vector. The next one matches the intrinsic and could zero arbitrary elements
3712// in the target vector.
Evan Cheng3ea4d672008-03-05 08:19:16 +00003713let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003714 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherefb657e2009-07-24 00:33:09 +00003715 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3716 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003717 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003718 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003719 [(set VR128:$dst,
3720 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
Sean Callanan2c48df22009-12-18 00:01:26 +00003721 OpSize;
Eric Christopherefb657e2009-07-24 00:33:09 +00003722 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003723 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3724 !strconcat(OpcodeStr,
3725 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003726 [(set VR128:$dst,
Eric Christopherefb657e2009-07-24 00:33:09 +00003727 (X86insrtps VR128:$src1,
3728 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begemand77e59e2008-02-11 04:19:36 +00003729 imm:$src3))]>, OpSize;
3730 }
3731}
3732
Evan Chengc2054be2008-03-26 08:11:49 +00003733defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003734
Eric Christopherefb657e2009-07-24 00:33:09 +00003735def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3736 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3737
Eric Christopher95d79262009-07-29 00:28:05 +00003738// ptest instruction we'll lower to this in X86ISelLowering primarily from
3739// the intel intrinsic that corresponds to this.
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003740let Defs = [EFLAGS] in {
3741def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003742 "ptest \t{$src2, $src1|$src1, $src2}",
3743 [(X86ptest VR128:$src1, VR128:$src2),
3744 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003745def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003746 "ptest \t{$src2, $src1|$src1, $src2}",
3747 [(X86ptest VR128:$src1, (load addr:$src2)),
3748 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003749}
3750
3751def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3752 "movntdqa\t{$src, $dst|$dst, $src}",
Kevin Enderbye6b2a5d2010-02-10 00:10:31 +00003753 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>,
3754 OpSize;
Nate Begeman03605a02008-07-17 16:51:19 +00003755
Eric Christopher22a39402009-08-18 22:50:32 +00003756
3757//===----------------------------------------------------------------------===//
3758// SSE4.2 Instructions
3759//===----------------------------------------------------------------------===//
3760
Nate Begeman03605a02008-07-17 16:51:19 +00003761/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3762let Constraints = "$src1 = $dst" in {
3763 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3764 Intrinsic IntId128, bit Commutable = 0> {
3765 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3766 (ins VR128:$src1, VR128:$src2),
3767 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3768 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3769 OpSize {
3770 let isCommutable = Commutable;
3771 }
3772 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3773 (ins VR128:$src1, i128mem:$src2),
3774 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3775 [(set VR128:$dst,
3776 (IntId128 VR128:$src1,
3777 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3778 }
3779}
3780
Nate Begeman235666b2008-07-17 17:04:58 +00003781defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman03605a02008-07-17 16:51:19 +00003782
3783def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3784 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3785def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3786 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003787
3788// crc intrinsic instruction
3789// This set of instructions are only rm, the only difference is the size
3790// of r and m.
3791let Constraints = "$src1 = $dst" in {
Eric Christopher85f187b2009-08-10 21:48:58 +00003792 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003793 (ins GR32:$src1, i8mem:$src2),
3794 "crc32 \t{$src2, $src1|$src1, $src2}",
3795 [(set GR32:$dst,
3796 (int_x86_sse42_crc32_8 GR32:$src1,
3797 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003798 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003799 (ins GR32:$src1, GR8:$src2),
3800 "crc32 \t{$src2, $src1|$src1, $src2}",
3801 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003802 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003803 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003804 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003805 (ins GR32:$src1, i16mem:$src2),
3806 "crc32 \t{$src2, $src1|$src1, $src2}",
3807 [(set GR32:$dst,
3808 (int_x86_sse42_crc32_16 GR32:$src1,
3809 (load addr:$src2)))]>,
3810 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003811 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003812 (ins GR32:$src1, GR16:$src2),
3813 "crc32 \t{$src2, $src1|$src1, $src2}",
3814 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003815 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003816 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003817 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003818 (ins GR32:$src1, i32mem:$src2),
3819 "crc32 \t{$src2, $src1|$src1, $src2}",
3820 [(set GR32:$dst,
3821 (int_x86_sse42_crc32_32 GR32:$src1,
3822 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003823 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003824 (ins GR32:$src1, GR32:$src2),
3825 "crc32 \t{$src2, $src1|$src1, $src2}",
3826 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003827 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003828 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003829 def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003830 (ins GR64:$src1, i64mem:$src2),
3831 "crc32 \t{$src2, $src1|$src1, $src2}",
3832 [(set GR64:$dst,
3833 (int_x86_sse42_crc32_64 GR64:$src1,
3834 (load addr:$src2)))]>,
3835 OpSize, REX_W;
Eric Christopher85f187b2009-08-10 21:48:58 +00003836 def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003837 (ins GR64:$src1, GR64:$src2),
3838 "crc32 \t{$src2, $src1|$src1, $src2}",
3839 [(set GR64:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003840 (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003841 OpSize, REX_W;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003842}
Eric Christopher22a39402009-08-18 22:50:32 +00003843
3844// String/text processing instructions.
Dan Gohman30afe012009-10-29 18:10:34 +00003845let Defs = [EFLAGS], usesCustomInserter = 1 in {
Eric Christopher22a39402009-08-18 22:50:32 +00003846def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003847 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3848 "#PCMPISTRM128rr PSEUDO!",
3849 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
3850 imm:$src3))]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003851def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003852 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3853 "#PCMPISTRM128rm PSEUDO!",
3854 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, (load addr:$src2),
3855 imm:$src3))]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003856}
3857
3858let Defs = [XMM0, EFLAGS] in {
3859def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003860 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3861 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003862def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003863 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3864 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003865}
3866
Sean Callanan2c48df22009-12-18 00:01:26 +00003867let Defs = [EFLAGS], Uses = [EAX, EDX], usesCustomInserter = 1 in {
Eric Christopher22a39402009-08-18 22:50:32 +00003868def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003869 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3870 "#PCMPESTRM128rr PSEUDO!",
3871 [(set VR128:$dst,
3872 (int_x86_sse42_pcmpestrm128
3873 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5))]>, OpSize;
3874
Eric Christopher22a39402009-08-18 22:50:32 +00003875def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003876 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3877 "#PCMPESTRM128rm PSEUDO!",
3878 [(set VR128:$dst, (int_x86_sse42_pcmpestrm128
3879 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5))]>,
3880 OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003881}
3882
3883let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
Sean Callananc5a05b72009-08-20 18:24:27 +00003884def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003885 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3886 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Sean Callananc5a05b72009-08-20 18:24:27 +00003887def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003888 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3889 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003890}
3891
3892let Defs = [ECX, EFLAGS] in {
3893 multiclass SS42AI_pcmpistri<Intrinsic IntId128> {
Sean Callanan2c48df22009-12-18 00:01:26 +00003894 def rr : SS42AI<0x63, MRMSrcReg, (outs),
3895 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3896 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3897 [(set ECX, (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
3898 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003899 def rm : SS42AI<0x63, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003900 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3901 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3902 [(set ECX, (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
3903 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003904 }
3905}
3906
3907defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
3908defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
3909defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
3910defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
3911defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
3912defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
3913
3914let Defs = [ECX, EFLAGS] in {
3915let Uses = [EAX, EDX] in {
3916 multiclass SS42AI_pcmpestri<Intrinsic IntId128> {
3917 def rr : SS42AI<0x61, MRMSrcReg, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003918 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3919 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3920 [(set ECX, (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
3921 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003922 def rm : SS42AI<0x61, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003923 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3924 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3925 [(set ECX,
3926 (IntId128 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5)),
3927 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003928 }
3929}
3930}
3931
3932defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
3933defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
3934defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
3935defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
3936defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
3937defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;