blob: 94b9b5543066f3e771de1c887c574ca57cca6ce8 [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
Evan Chengb783fa32007-07-19 01:14:50 +0000508def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000509 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000510 Requires<[HasSSE1]>, TB, OpSize;
511
512// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
513// disregarded.
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000514let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000515def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000516 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517
518// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
519// disregarded.
Evan Cheng8e664712009-11-17 09:51:18 +0000520let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000521def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000522 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000523 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000524
525// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +0000526let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527let isCommutable = 1 in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000528 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
529 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000530 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000532 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
533 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000534 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000536 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
537 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000538 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
540}
541
Dan Gohmanf221da12009-01-09 02:27:34 +0000542def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
543 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000544 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000546 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000547def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
548 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000549 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000551 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000552def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
553 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000554 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000556 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000557
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000558let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000560 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000561 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000562let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000564 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000565 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000567}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568
569/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
570///
571/// In addition, we also have a special variant of the scalar form here to
572/// represent the associated intrinsic operation. This form is unlike the
573/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000574/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575///
576/// These three forms can each be reg+reg or reg+mem, so there are a total of
577/// six "instructions".
578///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000579let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
581 SDNode OpNode, Intrinsic F32Int,
582 bit Commutable = 0> {
583 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000584 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000585 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
587 let isCommutable = Commutable;
588 }
589
590 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000591 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
592 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000593 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000595
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000597 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
598 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000599 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
601 let isCommutable = Commutable;
602 }
603
604 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000605 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
606 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000607 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000608 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609
610 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000611 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
612 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000613 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000614 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615
616 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000617 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
618 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000619 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000620 [(set VR128:$dst, (F32Int VR128:$src1,
621 sse_load_f32:$src2))]>;
622}
623}
624
625// Arithmetic instructions
626defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
627defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
628defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
629defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
630
631/// sse1_fp_binop_rm - Other SSE1 binops
632///
633/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
634/// instructions for a full-vector intrinsic form. Operations that map
635/// onto C operators don't use this form since they just use the plain
636/// vector form instead of having a separate vector intrinsic form.
637///
638/// This provides a total of eight "instructions".
639///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000640let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
642 SDNode OpNode,
643 Intrinsic F32Int,
644 Intrinsic V4F32Int,
645 bit Commutable = 0> {
646
647 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000648 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000649 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000650 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
651 let isCommutable = Commutable;
652 }
653
654 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000655 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
656 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000657 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000659
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000660 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000661 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
662 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000663 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
665 let isCommutable = Commutable;
666 }
667
668 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000669 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
670 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000671 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000672 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673
674 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000675 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
676 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000677 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000678 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
679 let isCommutable = Commutable;
680 }
681
682 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000683 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
684 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000685 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686 [(set VR128:$dst, (F32Int VR128:$src1,
687 sse_load_f32:$src2))]>;
688
689 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000690 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
691 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000692 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
694 let isCommutable = Commutable;
695 }
696
697 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000698 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
699 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000700 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000701 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702}
703}
704
705defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
706 int_x86_sse_max_ss, int_x86_sse_max_ps>;
707defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
708 int_x86_sse_min_ss, int_x86_sse_min_ps>;
709
710//===----------------------------------------------------------------------===//
711// SSE packed FP Instructions
712
713// Move Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000714let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000715def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000716 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000717let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000718def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000719 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000720 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721
Evan Chengb783fa32007-07-19 01:14:50 +0000722def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000723 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000724 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000726let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000727def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000728 "movups\t{$src, $dst|$dst, $src}", []>;
Evan Cheng9d7cd4e2009-11-16 21:56:03 +0000729let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000730def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000731 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000732 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000733def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000734 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000735 [(store (v4f32 VR128:$src), addr:$dst)]>;
736
737// Intrinsic forms of MOVUPS load and store
Evan Cheng8e664712009-11-17 09:51:18 +0000738let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000739def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000740 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000741 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000742def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000743 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000744 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745
Evan Cheng3ea4d672008-03-05 08:19:16 +0000746let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747 let AddedComplexity = 20 in {
748 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000749 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000750 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000751 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000752 (movlp VR128:$src1,
753 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000755 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000756 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000757 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +0000758 (movlhps VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000759 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000761} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762
Evan Chengd743a5f2008-05-10 00:59:18 +0000763
Evan Chengb783fa32007-07-19 01:14:50 +0000764def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000765 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
767 (iPTR 0))), addr:$dst)]>;
768
769// v2f64 extract element 1 is always custom lowered to unpack high to low
770// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000771def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000772 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +0000774 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
775 (undef)), (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776
Evan Cheng3ea4d672008-03-05 08:19:16 +0000777let Constraints = "$src1 = $dst" in {
Evan Cheng13559d62008-09-26 23:41:32 +0000778let AddedComplexity = 20 in {
Evan Cheng7581a822009-05-12 20:17:52 +0000779def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
780 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000781 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +0000783 (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784
Evan Cheng7581a822009-05-12 20:17:52 +0000785def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
786 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000787 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000789 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000790} // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000791} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792
Nate Begemanb44aad72009-04-29 22:47:44 +0000793let AddedComplexity = 20 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000794def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Evan Chenga2497eb2008-09-25 20:50:48 +0000795 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begemanb44aad72009-04-29 22:47:44 +0000796def : Pat<(v2i64 (movddup VR128:$src, (undef))),
797 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
798}
Evan Chenga2497eb2008-09-25 20:50:48 +0000799
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800
801
802// Arithmetic
803
804/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
805///
806/// In addition, we also have a special variant of the scalar form here to
807/// represent the associated intrinsic operation. This form is unlike the
808/// plain scalar form, in that it takes an entire vector (instead of a
809/// scalar) and leaves the top elements undefined.
810///
811/// And, we have a special variant form for a full-vector intrinsic form.
812///
813/// These four forms can each have a reg or a mem operand, so there are a
814/// total of eight "instructions".
815///
816multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
817 SDNode OpNode,
818 Intrinsic F32Int,
819 Intrinsic V4F32Int,
820 bit Commutable = 0> {
821 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000822 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000823 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000824 [(set FR32:$dst, (OpNode FR32:$src))]> {
825 let isCommutable = Commutable;
826 }
827
828 // Scalar operation, mem.
Evan Chengd3f27fb2009-12-18 07:40:29 +0000829 def SSm : I<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000830 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Evan Chengd3f27fb2009-12-18 07:40:29 +0000831 [(set FR32:$dst, (OpNode (load addr:$src)))]>, XS,
Evan Chengd53fca12009-12-22 17:47:23 +0000832 Requires<[HasSSE1, OptForSize]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000833
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000835 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000836 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
838 let isCommutable = Commutable;
839 }
840
841 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000842 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000843 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000844 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845
846 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000847 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000848 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849 [(set VR128:$dst, (F32Int VR128:$src))]> {
850 let isCommutable = Commutable;
851 }
852
853 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000854 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000855 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
857
858 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000859 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000860 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
862 let isCommutable = Commutable;
863 }
864
865 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000866 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000867 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000868 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869}
870
871// Square root.
872defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
873 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
874
875// Reciprocal approximations. Note that these typically require refinement
876// in order to obtain suitable precision.
877defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
878 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
879defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
880 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
881
882// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +0000883let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 let isCommutable = 1 in {
885 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000886 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000887 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888 [(set VR128:$dst, (v2i64
889 (and VR128:$src1, VR128:$src2)))]>;
890 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000891 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000892 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 [(set VR128:$dst, (v2i64
894 (or VR128:$src1, VR128:$src2)))]>;
895 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000896 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000897 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898 [(set VR128:$dst, (v2i64
899 (xor VR128:$src1, VR128:$src2)))]>;
900 }
901
902 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000903 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000904 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000905 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
906 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000908 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000909 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000910 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
911 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000913 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000914 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000915 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
916 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000918 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000919 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 [(set VR128:$dst,
921 (v2i64 (and (xor VR128:$src1,
922 (bc_v2i64 (v4i32 immAllOnesV))),
923 VR128:$src2)))]>;
924 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000925 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000926 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000928 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000930 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931}
932
Evan Cheng3ea4d672008-03-05 08:19:16 +0000933let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000934 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begeman061db5f2008-05-12 20:34:32 +0000935 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
936 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
937 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
938 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000939 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begeman061db5f2008-05-12 20:34:32 +0000940 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
941 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
942 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +0000943 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944}
Nate Begeman03605a02008-07-17 16:51:19 +0000945def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
946 (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>;
947def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
948 (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949
950// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +0000951let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000953 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000954 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000955 VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000956 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000958 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000959 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000960 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000961 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000964 (v4f32 (shufp:$src3
965 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966
967 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000968 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000969 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000970 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000972 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000973 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000974 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000975 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000977 (v4f32 (unpckh VR128:$src1,
978 (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000980 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000981 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000984 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000985 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000986 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000987 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000989 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000991} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992
993// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000994def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000995 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengd8296b82009-05-28 18:55:28 +0000997def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000998 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
1000
Evan Chengd1d68072008-03-08 00:58:38 +00001001// Prefetch intrinsic.
1002def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
1003 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
1004def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
1005 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
1006def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
1007 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
1008def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
1009 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010
1011// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00001012def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001013 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
1015
1016// Load, store, and memory fence
Evan Cheng68cca152009-05-27 18:38:01 +00001017def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018
1019// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +00001020def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001021 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001022def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001023 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024
1025// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00001026// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00001027// load of an all-zeros value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +00001028let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
1029 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001030def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001031 "xorps\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00001032 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033
Evan Chenga15896e2008-03-12 07:02:50 +00001034let Predicates = [HasSSE1] in {
1035 def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
1036 def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1037 def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1038 def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1039 def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
1040}
1041
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042// FR32 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001043let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001044def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001045 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 [(set VR128:$dst,
1047 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001048def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$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 (loadf32 addr:$src))))]>;
1052
1053// FIXME: may not be able to eliminate this movss with coalescing the src and
1054// dest register classes are different. We really want to write this pattern
1055// like this:
1056// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1057// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001058let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001059def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001060 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
1062 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001063def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001064 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 [(store (f32 (vector_extract (v4f32 VR128:$src),
1066 (iPTR 0))), addr:$dst)]>;
1067
1068
1069// Move to lower bits of a VR128, leaving upper bits alone.
1070// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001071let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001072let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001074 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001075 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076
1077 let AddedComplexity = 15 in
1078 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001079 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001080 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001082 (v4f32 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083}
1084
1085// Move to lower bits of a VR128 and zeroing upper bits.
1086// Loading from memory automatically zeroing upper bits.
1087let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00001088def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001089 "movss\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00001090 [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001091 (loadf32 addr:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092
Evan Cheng056afe12008-05-20 18:24:47 +00001093def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
Evan Cheng40ee6e52008-05-08 00:57:18 +00001094 (MOVZSS2PSrm addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001096//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097// SSE2 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001098//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001101let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001102def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001103 "movsd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001104let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001105def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001106 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001107 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001108def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001109 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110 [(store FR64:$src, addr:$dst)]>;
1111
1112// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001113def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001114 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001116def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001117 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001119def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001120 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengd3f27fb2009-12-18 07:40:29 +00001122def CVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001123 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Evan Chengd3f27fb2009-12-18 07:40:29 +00001124 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>, XD,
Evan Chengd53fca12009-12-22 17:47:23 +00001125 Requires<[HasSSE2, OptForSize]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001126def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001127 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001128 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001129def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001130 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001131 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1132
Sean Callanan3d5824c2009-09-16 01:13:52 +00001133def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1134 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1135def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1136 "cvtpd2dq\t{$src, $dst|$dst, $src}", []>;
1137def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1138 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1139def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1140 "cvtdq2pd\t{$src, $dst|$dst, $src}", []>;
1141def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1142 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1143def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1144 "cvtps2dq\t{$src, $dst|$dst, $src}", []>;
1145def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1146 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1147def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1148 "cvtdq2ps\t{$src, $dst|$dst, $src}", []>;
1149def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
1150 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1151def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
1152 "comisd\t{$src2, $src1|$src1, $src2}", []>;
1153
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001155def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001156 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001157 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1158 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001159def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$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, (extloadf32 addr:$src))]>, XS,
Evan Chengd53fca12009-12-22 17:47:23 +00001162 Requires<[HasSSE2, OptForSize]>;
Evan Chengd3f27fb2009-12-18 07:40:29 +00001163
1164def : Pat<(extloadf32 addr:$src),
Evan Chengd53fca12009-12-22 17:47:23 +00001165 (CVTSS2SDrr (MOVSSrm addr:$src))>, Requires<[HasSSE2, OptForSpeed]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166
1167// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001168def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001169 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001171def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001172 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001173 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1174 (load addr:$src)))]>;
1175
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001176// Match intrinisics which expect MM and XMM operand(s).
1177def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1178 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1179 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1180def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1181 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001182 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001183 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001184def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1185 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1186 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1187def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1188 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001189 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001190 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001191def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1192 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1193 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1194def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1195 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001196 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001197 (load addr:$src)))]>;
1198
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001200def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001201 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202 [(set GR32:$dst,
1203 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001204def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$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, (int_x86_sse2_cvttsd2si
1207 (load addr:$src)))]>;
1208
1209// Comparison instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001210let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001211 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001212 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001213 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001214let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001215 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001216 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001217 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218}
1219
Evan Cheng950aac02007-09-25 01:57:46 +00001220let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001221def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001222 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001223 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001224def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001225 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001226 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001227 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001228} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001229
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +00001231let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001232 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00001233 (outs VR128:$dst),
1234 (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001235 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1237 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001238 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Sean Callanan2c48df22009-12-18 00:01:26 +00001239 (outs VR128:$dst),
1240 (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001241 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1243 (load addr:$src), imm:$cc))]>;
1244}
1245
Evan Cheng950aac02007-09-25 01:57:46 +00001246let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001247def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001248 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001249 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1250 (implicit EFLAGS)]>;
1251def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$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), (load addr:$src2)),
1254 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001255
Evan Chengb783fa32007-07-19 01:14:50 +00001256def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001257 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001258 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1259 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001260def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$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), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001263 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001264} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001265
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001266// Aliases of packed SSE2 instructions for scalar use. These all have names
1267// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001268
1269// Alias instructions that map fld0 to pxor for sse.
Dan Gohman51dbce62009-09-21 18:30:38 +00001270let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1,
1271 canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001272def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001273 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001274 Requires<[HasSSE2]>, TB, OpSize;
1275
1276// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1277// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001278let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001279def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281
1282// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1283// disregarded.
Evan Cheng8e664712009-11-17 09:51:18 +00001284let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001285def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001286 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001287 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288
1289// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001290let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291let isCommutable = 1 in {
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001292 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1293 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001294 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001296 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1297 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001300 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1301 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001302 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001303 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1304}
1305
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001306def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1307 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001308 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001310 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001311def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1312 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001313 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001315 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001316def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1317 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001318 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001320 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001322let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001324 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001325 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001326let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001328 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001329 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001331}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332
1333/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1334///
1335/// In addition, we also have a special variant of the scalar form here to
1336/// represent the associated intrinsic operation. This form is unlike the
1337/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001338/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339///
1340/// These three forms can each be reg+reg or reg+mem, so there are a total of
1341/// six "instructions".
1342///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001343let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001344multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1345 SDNode OpNode, Intrinsic F64Int,
1346 bit Commutable = 0> {
1347 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001348 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001349 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1351 let isCommutable = Commutable;
1352 }
1353
1354 // Scalar operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001355 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1356 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001357 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001358 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001359
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360 // Vector operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001361 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1362 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001363 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1365 let isCommutable = Commutable;
1366 }
1367
1368 // Vector operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001369 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1370 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001371 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf221da12009-01-09 02:27:34 +00001372 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373
1374 // Intrinsic operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001375 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1376 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001377 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001378 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001379
1380 // Intrinsic operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001381 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1382 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001383 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 [(set VR128:$dst, (F64Int VR128:$src1,
1385 sse_load_f64:$src2))]>;
1386}
1387}
1388
1389// Arithmetic instructions
1390defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1391defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1392defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1393defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1394
1395/// sse2_fp_binop_rm - Other SSE2 binops
1396///
1397/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1398/// instructions for a full-vector intrinsic form. Operations that map
1399/// onto C operators don't use this form since they just use the plain
1400/// vector form instead of having a separate vector intrinsic form.
1401///
1402/// This provides a total of eight "instructions".
1403///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001404let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001405multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1406 SDNode OpNode,
1407 Intrinsic F64Int,
1408 Intrinsic V2F64Int,
1409 bit Commutable = 0> {
1410
1411 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001412 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001413 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001414 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1415 let isCommutable = Commutable;
1416 }
1417
1418 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001419 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1420 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001421 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001423
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001424 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001425 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1426 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001427 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1429 let isCommutable = Commutable;
1430 }
1431
1432 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001433 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1434 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001436 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001437
1438 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001439 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1440 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001441 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1443 let isCommutable = Commutable;
1444 }
1445
1446 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001447 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1448 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001449 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001450 [(set VR128:$dst, (F64Int VR128:$src1,
1451 sse_load_f64:$src2))]>;
1452
1453 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001454 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1455 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001456 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001457 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1458 let isCommutable = Commutable;
1459 }
1460
1461 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001462 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1463 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001465 [(set VR128:$dst, (V2F64Int VR128:$src1,
1466 (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467}
1468}
1469
1470defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1471 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1472defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1473 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1474
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001475//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476// SSE packed FP Instructions
1477
1478// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001479let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001480def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001482let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001483def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001485 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486
Evan Chengb783fa32007-07-19 01:14:50 +00001487def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001488 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001489 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001490
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001491let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001492def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001494let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001495def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001497 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001498def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001499 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001500 [(store (v2f64 VR128:$src), addr:$dst)]>;
1501
1502// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001503def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001504 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001505 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001506def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001507 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001508 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001509
Evan Cheng3ea4d672008-03-05 08:19:16 +00001510let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511 let AddedComplexity = 20 in {
1512 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001513 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001515 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001516 (v2f64 (movlp VR128:$src1,
1517 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001518 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001519 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001520 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001521 [(set VR128:$dst,
Nate Begemanb13034d2009-11-07 23:17:15 +00001522 (v2f64 (movlhps VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00001523 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001525} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526
Evan Chengb783fa32007-07-19 01:14:50 +00001527def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001529 [(store (f64 (vector_extract (v2f64 VR128:$src),
1530 (iPTR 0))), addr:$dst)]>;
1531
1532// v2f64 extract element 1 is always custom lowered to unpack high to low
1533// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001534def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001535 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001536 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +00001537 (v2f64 (unpckh VR128:$src, (undef))),
1538 (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001539
1540// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001541def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1544 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001545def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001546 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1547 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1548 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549 TB, Requires<[HasSSE2]>;
1550
1551// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001552def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1555 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001556def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001557 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1558 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1559 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 XS, Requires<[HasSSE2]>;
1561
Evan Chengb783fa32007-07-19 01:14:50 +00001562def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001563 "cvtps2dq\t{$src, $dst|$dst, $src}",
1564 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001565def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001568 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569// SSE2 packed instructions with XS prefix
Sean Callanan2c48df22009-12-18 00:01:26 +00001570def CVTTPS2DQrr : SSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1571 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1572def CVTTPS2DQrm : SSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1573 "cvttps2dq\t{$src, $dst|$dst, $src}", []>;
1574
Evan Chengb783fa32007-07-19 01:14:50 +00001575def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 "cvttps2dq\t{$src, $dst|$dst, $src}",
Sean Callanan2c48df22009-12-18 00:01:26 +00001577 [(set VR128:$dst,
1578 (int_x86_sse2_cvttps2dq VR128:$src))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001579 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001580def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001581 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001582 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001583 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001584 XS, Requires<[HasSSE2]>;
1585
1586// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001587def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001588 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001589 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1590 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001591def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$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
Evan Cheng00b66ef2008-05-23 00:37:07 +00001594 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595 XD, Requires<[HasSSE2]>;
1596
Evan Chengb783fa32007-07-19 01:14:50 +00001597def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001598 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng14c97c32008-03-14 07:46:48 +00001600def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001601 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001602 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001603 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001604
1605// SSE2 instructions without OpSize prefix
Sean Callanan2c48df22009-12-18 00:01:26 +00001606def CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1607 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1608def CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
1609 "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB;
1610
Evan Chengb783fa32007-07-19 01:14:50 +00001611def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001613 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1614 TB, Requires<[HasSSE2]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001615def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$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
1618 (load addr:$src)))]>,
1619 TB, Requires<[HasSSE2]>;
1620
Sean Callanan2c48df22009-12-18 00:01:26 +00001621def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
1622 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1623def CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
1624 "cvtpd2ps\t{$src, $dst|$dst, $src}", []>;
1625
1626
Evan Chengb783fa32007-07-19 01:14:50 +00001627def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001629 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001630def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001631 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Cheng00b66ef2008-05-23 00:37:07 +00001633 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634
1635// Match intrinsics which expect XMM operand(s).
1636// Aliases for intrinsics
Evan Cheng3ea4d672008-03-05 08:19:16 +00001637let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001638def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001639 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001640 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1642 GR32:$src2))]>;
1643def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001644 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001645 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001646 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1647 (loadi32 addr:$src2)))]>;
1648def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001649 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001650 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001651 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1652 VR128:$src2))]>;
1653def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001654 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1657 (load addr:$src2)))]>;
1658def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001659 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001660 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1662 VR128:$src2))]>, XS,
1663 Requires<[HasSSE2]>;
1664def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001665 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001666 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1668 (load addr:$src2)))]>, XS,
1669 Requires<[HasSSE2]>;
1670}
1671
1672// Arithmetic
1673
1674/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1675///
1676/// In addition, we also have a special variant of the scalar form here to
1677/// represent the associated intrinsic operation. This form is unlike the
1678/// plain scalar form, in that it takes an entire vector (instead of a
1679/// scalar) and leaves the top elements undefined.
1680///
1681/// And, we have a special variant form for a full-vector intrinsic form.
1682///
1683/// These four forms can each have a reg or a mem operand, so there are a
1684/// total of eight "instructions".
1685///
1686multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1687 SDNode OpNode,
1688 Intrinsic F64Int,
1689 Intrinsic V2F64Int,
1690 bit Commutable = 0> {
1691 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001692 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001693 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001694 [(set FR64:$dst, (OpNode FR64:$src))]> {
1695 let isCommutable = Commutable;
1696 }
1697
1698 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001699 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001700 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001702
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001704 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001705 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001706 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1707 let isCommutable = Commutable;
1708 }
1709
1710 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001711 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001712 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001713 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001714
1715 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001716 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001717 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001718 [(set VR128:$dst, (F64Int VR128:$src))]> {
1719 let isCommutable = Commutable;
1720 }
1721
1722 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001723 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1726
1727 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001728 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001730 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1731 let isCommutable = Commutable;
1732 }
1733
1734 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001735 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001737 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738}
1739
1740// Square root.
1741defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1742 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1743
1744// There is no f64 version of the reciprocal approximation instructions.
1745
1746// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +00001747let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001748 let isCommutable = 1 in {
1749 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001750 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001751 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752 [(set VR128:$dst,
1753 (and (bc_v2i64 (v2f64 VR128:$src1)),
1754 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1755 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001756 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001757 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758 [(set VR128:$dst,
1759 (or (bc_v2i64 (v2f64 VR128:$src1)),
1760 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1761 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001762 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001763 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001764 [(set VR128:$dst,
1765 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1766 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1767 }
1768
1769 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001770 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001771 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772 [(set VR128:$dst,
1773 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001774 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001776 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778 [(set VR128:$dst,
1779 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001780 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001782 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001784 [(set VR128:$dst,
1785 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001786 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001788 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790 [(set VR128:$dst,
1791 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1792 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1793 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001794 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(set VR128:$dst,
1797 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001798 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799}
1800
Evan Cheng3ea4d672008-03-05 08:19:16 +00001801let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001802 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001803 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1804 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1805 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begeman061db5f2008-05-12 20:34:32 +00001806 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001807 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng14c97c32008-03-14 07:46:48 +00001808 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1809 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1810 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00001811 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812}
Evan Cheng33754092008-08-05 22:19:15 +00001813def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001814 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Cheng33754092008-08-05 22:19:15 +00001815def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001816 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001817
1818// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001819let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001820 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001821 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1822 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman543d2142009-04-27 18:41:29 +00001823 [(set VR128:$dst,
1824 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001825 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001826 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001830 (v2f64 (shufp:$src3
1831 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832
1833 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001834 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001835 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001838 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001839 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001840 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001842 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001843 (v2f64 (unpckh VR128:$src1,
1844 (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001846 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001847 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001848 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001849 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001850 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001851 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001852 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001855 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001856 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001857} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001858
1859
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001860//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001861// SSE integer instructions
1862
1863// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001864let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001865def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001867let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001868def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001869 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001870 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001871let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001872def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001874 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001875let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001876def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001878 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 XS, Requires<[HasSSE2]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001880let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001881def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001882 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001883 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001884 XS, Requires<[HasSSE2]>;
1885
Dan Gohman4a4f1512007-07-18 20:23:34 +00001886// Intrinsic forms of MOVDQU load and store
Dan Gohman5574cc72008-12-03 18:15:48 +00001887let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001888def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001889 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001890 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1891 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001892def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001894 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1895 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001896
Evan Cheng88004752008-03-05 08:11:27 +00001897let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898
1899multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1900 bit Commutable = 0> {
Sean Callanan2c48df22009-12-18 00:01:26 +00001901 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1902 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001904 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1905 let isCommutable = Commutable;
1906 }
Sean Callanan2c48df22009-12-18 00:01:26 +00001907 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1908 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001909 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910 [(set VR128:$dst, (IntId VR128:$src1,
Sean Callanan2c48df22009-12-18 00:01:26 +00001911 (bitconvert (memopv2i64
1912 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913}
1914
Evan Chengf90f8f82008-05-03 00:52:09 +00001915multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1916 string OpcodeStr,
1917 Intrinsic IntId, Intrinsic IntId2> {
Sean Callanan2c48df22009-12-18 00:01:26 +00001918 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1919 (ins VR128:$src1, VR128:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001920 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1921 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001922 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1923 (ins VR128:$src1, i128mem:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001924 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1925 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001926 (bitconvert (memopv2i64 addr:$src2))))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001927 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst),
1928 (ins VR128:$src1, i32i8imm:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001929 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1930 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
1931}
1932
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001933/// PDI_binop_rm - Simple SSE2 binary operator.
1934multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1935 ValueType OpVT, bit Commutable = 0> {
Sean Callanan2c48df22009-12-18 00:01:26 +00001936 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1937 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1940 let isCommutable = Commutable;
1941 }
Sean Callanan2c48df22009-12-18 00:01:26 +00001942 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1943 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001946 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947}
1948
1949/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1950///
1951/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1952/// to collapse (bitconvert VT to VT) into its operand.
1953///
1954multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1955 bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001956 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00001957 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001958 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001959 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1960 let isCommutable = Commutable;
1961 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001962 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00001963 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001964 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001965 [(set VR128:$dst, (OpNode VR128:$src1,
Sean Callanan2c48df22009-12-18 00:01:26 +00001966 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967}
1968
Evan Cheng3ea4d672008-03-05 08:19:16 +00001969} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970
1971// 128-bit Integer Arithmetic
1972
1973defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1974defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1975defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1976defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1977
1978defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1979defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1980defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1981defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1982
1983defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1984defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1985defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1986defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1987
1988defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1989defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1990defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1991defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1992
1993defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1994
1995defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1996defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1997defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1998
1999defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
2000
2001defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
2002defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
2003
2004
2005defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
2006defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
2007defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
2008defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling953ad2e2009-05-28 02:04:00 +00002009defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010
2011
Evan Chengf90f8f82008-05-03 00:52:09 +00002012defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
2013 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
2014defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
2015 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
2016defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
2017 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002018
Evan Chengf90f8f82008-05-03 00:52:09 +00002019defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
2020 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
2021defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
2022 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begemanc2ca5f62008-05-13 17:52:09 +00002023defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Chengf90f8f82008-05-03 00:52:09 +00002024 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025
Evan Chengf90f8f82008-05-03 00:52:09 +00002026defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
2027 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemand66fc342008-05-13 01:47:52 +00002028defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Chengf90f8f82008-05-03 00:52:09 +00002029 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030
2031// 128-bit logical shifts.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002032let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002034 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00002037 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 // PSRADQri doesn't exist in SSE[1-3].
2040}
2041
2042let Predicates = [HasSSE2] in {
2043 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
Evan Cheng06cd2072009-10-28 06:30:34 +00002044 (v2i64 (PSLLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002045 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
Evan Cheng06cd2072009-10-28 06:30:34 +00002046 (v2i64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Bill Wendling314ee052008-10-02 05:56:52 +00002047 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
2048 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
2049 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
2050 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002051 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002052 (v2f64 (PSRLDQri VR128:$src1, (BYTE_imm imm:$src2)))>;
Evan Chengdea99362008-05-29 08:22:04 +00002053
2054 // Shift up / down and insert zero's.
2055 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
Evan Cheng06cd2072009-10-28 06:30:34 +00002056 (v2i64 (PSLLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Evan Chengdea99362008-05-29 08:22:04 +00002057 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
Evan Cheng06cd2072009-10-28 06:30:34 +00002058 (v2i64 (PSRLDQri VR128:$src, (BYTE_imm imm:$amt)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002059}
2060
2061// Logical
2062defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
2063defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
2064defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
2065
Evan Cheng3ea4d672008-03-05 08:19:16 +00002066let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002068 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
2071 VR128:$src2)))]>;
2072
2073 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002074 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002075 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00002077 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078}
2079
2080// SSE2 Integer comparison
2081defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
2082defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2083defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2084defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2085defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2086defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2087
Nate Begeman03605a02008-07-17 16:51:19 +00002088def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002089 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002090def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002091 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002092def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002093 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002094def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002095 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002096def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002097 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002098def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002099 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2100
Nate Begeman03605a02008-07-17 16:51:19 +00002101def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002102 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002103def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002104 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002105def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002106 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002107def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002108 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002109def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002110 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002111def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002112 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2113
2114
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002115// Pack instructions
2116defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2117defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2118defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2119
2120// Shuffle and unpack instructions
Nate Begeman080f8e22009-10-19 02:17:23 +00002121let AddedComplexity = 5 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002122def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002123 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002124 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002125 [(set VR128:$dst, (v4i32 (pshufd:$src2
2126 VR128:$src1, (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002128 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002129 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002130 [(set VR128:$dst, (v4i32 (pshufd:$src2
Evan Chenge31a26a2009-12-09 21:00:30 +00002131 (bc_v4i32 (memopv2i64 addr:$src1)),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002132 (undef))))]>;
Eric Christopherf3650292009-11-07 08:45:53 +00002133}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134
2135// SSE2 with ImmT == Imm8 and XS prefix.
2136def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002137 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002138 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002139 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2140 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141 XS, Requires<[HasSSE2]>;
2142def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002143 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002144 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002145 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002146 (bc_v8i16 (memopv2i64 addr:$src1)),
2147 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 XS, Requires<[HasSSE2]>;
2149
2150// SSE2 with ImmT == Imm8 and XD prefix.
2151def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman543d2142009-04-27 18:41:29 +00002152 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002153 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002154 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2155 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156 XD, Requires<[HasSSE2]>;
2157def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman543d2142009-04-27 18:41:29 +00002158 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002160 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2161 (bc_v8i16 (memopv2i64 addr:$src1)),
2162 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 XD, Requires<[HasSSE2]>;
2164
2165
Evan Cheng3ea4d672008-03-05 08:19:16 +00002166let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002167 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002168 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002169 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002170 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002171 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002172 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002173 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002174 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002176 (unpckl VR128:$src1,
2177 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002178 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002179 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002181 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002182 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002183 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002184 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002187 (unpckl VR128:$src1,
2188 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002189 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002190 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002191 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002193 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002194 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002195 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002197 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002198 (unpckl VR128:$src1,
2199 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002200 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002201 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002202 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002203 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002204 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002205 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002206 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002208 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002209 (v2i64 (unpckl VR128:$src1,
2210 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002211
2212 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002213 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002214 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002215 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002216 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002217 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002218 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002219 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002220 [(set VR128:$dst,
2221 (unpckh VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002222 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002223 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002224 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002227 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002228 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002229 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002232 (unpckh VR128:$src1,
2233 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002234 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002235 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002236 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002237 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002238 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002239 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002240 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002241 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002243 (unpckh VR128:$src1,
2244 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002245 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002246 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002247 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002248 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002249 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002250 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002251 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002253 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002254 (v2i64 (unpckh VR128:$src1,
2255 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002256}
2257
2258// Extract / Insert
2259def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002260 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002262 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begemand77e59e2008-02-11 04:19:36 +00002263 imm:$src2))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +00002264let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002265 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002266 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002268 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002270 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002271 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002272 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002274 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002275 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002276 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2277 imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002278}
2279
2280// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002281def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2284
2285// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002286let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002287def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002289 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290
Evan Cheng430de082009-02-10 22:06:28 +00002291let Uses = [RDI] in
2292def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2293 "maskmovdqu\t{$mask, $src|$src, $mask}",
2294 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2295
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002296// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002297def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002298 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002299 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002300def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002302 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002303def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002304 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002305 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002306 TB, Requires<[HasSSE2]>;
2307
2308// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002309def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002310 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002311 TB, Requires<[HasSSE2]>;
2312
2313// Load, store, and memory fence
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002314def LFENCE : I<0xAE, MRM5r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002315 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002316def MFENCE : I<0xAE, MRM6r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2318
Andrew Lenharth785610d2008-02-16 01:24:58 +00002319//TODO: custom lower this so as to never even generate the noop
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002320def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002321 (i8 0)), (NOOP)>;
2322def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2323def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
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 1)), (MFENCE)>;
2326
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00002328// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00002329// load of an all-ones value if folding it would be beneficial.
Daniel Dunbara0e62002009-08-11 22:17:52 +00002330let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
2331 isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002332 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002334 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002335
2336// FR64 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002337let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002338def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002340 [(set VR128:$dst,
2341 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002342def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002343 "movsd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002344 [(set VR128:$dst,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002345 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2346
Evan Chengb783fa32007-07-19 01:14:50 +00002347def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002348 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349 [(set VR128:$dst,
2350 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002351def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$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 (loadi32 addr:$src))))]>;
2355
Evan Chengb783fa32007-07-19 01:14:50 +00002356def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002358 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2359
Evan Chengb783fa32007-07-19 01:14:50 +00002360def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$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 (loadi32 addr:$src)))]>;
2363
2364// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002365def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002366 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002367 [(set VR128:$dst,
2368 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2369 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002370def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002372 [(store (i64 (vector_extract (v2i64 VR128:$src),
2373 (iPTR 0))), addr:$dst)]>;
2374
2375// FIXME: may not be able to eliminate this movss with coalescing the src and
2376// dest register classes are different. We really want to write this pattern
2377// like this:
2378// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2379// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002380let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002381def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002382 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002383 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2384 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002385def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002386 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002387 [(store (f64 (vector_extract (v2f64 VR128:$src),
2388 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002389def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002390 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002391 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2392 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002393def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002394 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002395 [(store (i32 (vector_extract (v4i32 VR128:$src),
2396 (iPTR 0))), addr:$dst)]>;
2397
Evan Chengb783fa32007-07-19 01:14:50 +00002398def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002399 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002400 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002401def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002402 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002403 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2404
2405
2406// Move to lower bits of a VR128, leaving upper bits alone.
2407// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002408let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00002409 let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002410 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002411 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002412 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002413
2414 let AddedComplexity = 15 in
2415 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002416 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002417 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002419 (v2f64 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002420}
2421
2422// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002423def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002424 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002425 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2426
2427// Move to lower bits of a VR128 and zeroing upper bits.
2428// Loading from memory automatically zeroing upper bits.
Evan Chengd743a5f2008-05-10 00:59:18 +00002429let AddedComplexity = 20 in {
2430def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2431 "movsd\t{$src, $dst|$dst, $src}",
2432 [(set VR128:$dst,
2433 (v2f64 (X86vzmovl (v2f64 (scalar_to_vector
2434 (loadf64 addr:$src))))))]>;
Evan Cheng40ee6e52008-05-08 00:57:18 +00002435
Evan Cheng056afe12008-05-20 18:24:47 +00002436def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
2437 (MOVZSD2PDrm addr:$src)>;
2438def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
Evan Chengd743a5f2008-05-10 00:59:18 +00002439 (MOVZSD2PDrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002440def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002441}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002442
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002443// movd / movq to XMM register zero-extends
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002444let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002445def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "movd\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002447 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002448 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002449// This is X86-64 only.
2450def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2451 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002452 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002453 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002454}
2455
2456let AddedComplexity = 20 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002457def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002458 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002459 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002460 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002461 (loadi32 addr:$src))))))]>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002462
2463def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2464 (MOVZDI2PDIrm addr:$src)>;
2465def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2466 (MOVZDI2PDIrm addr:$src)>;
Duncan Sands2418bec2008-06-13 19:07:40 +00002467def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2468 (MOVZDI2PDIrm addr:$src)>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002469
Evan Chengb783fa32007-07-19 01:14:50 +00002470def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002471 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002472 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002473 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002474 (loadi64 addr:$src))))))]>, XS,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002475 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002476
Evan Cheng3ad16c42008-05-22 18:56:56 +00002477def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2478 (MOVZQI2PQIrm addr:$src)>;
2479def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2480 (MOVZQI2PQIrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002481def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002482}
Evan Chenge9b9c672008-05-09 21:53:03 +00002483
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002484// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2485// IA32 document. movq xmm1, xmm2 does clear the high bits.
2486let AddedComplexity = 15 in
2487def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2488 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002489 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002490 XS, Requires<[HasSSE2]>;
2491
Evan Cheng056afe12008-05-20 18:24:47 +00002492let AddedComplexity = 20 in {
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002493def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2494 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002495 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng056afe12008-05-20 18:24:47 +00002496 (loadv2i64 addr:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002497 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002498
Evan Cheng056afe12008-05-20 18:24:47 +00002499def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2500 (MOVZPQILo2PQIrm addr:$src)>;
2501}
2502
Sean Callanan2c48df22009-12-18 00:01:26 +00002503// Instructions for the disassembler
2504// xr = XMM register
2505// xm = mem64
2506
2507def MOVQxrxr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2508 "movq\t{$src, $dst|$dst, $src}", []>, XS;
2509
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002510//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002511// SSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002512//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002513
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002514// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002515def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002516 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002517 [(set VR128:$dst, (v4f32 (movshdup
2518 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002519def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$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, (movshdup
2522 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002523
Evan Chengb783fa32007-07-19 01:14:50 +00002524def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002525 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002526 [(set VR128:$dst, (v4f32 (movsldup
2527 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002528def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$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, (movsldup
2531 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002532
Evan Chengb783fa32007-07-19 01:14:50 +00002533def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002534 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002535 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002536def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002537 "movddup\t{$src, $dst|$dst, $src}",
Evan Chenga2497eb2008-09-25 20:50:48 +00002538 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002539 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2540 (undef))))]>;
Evan Chenga2497eb2008-09-25 20:50:48 +00002541
Nate Begeman543d2142009-04-27 18:41:29 +00002542def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2543 (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002544 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002545
2546let AddedComplexity = 5 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002547def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002548 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002549def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2550 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2551def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2552 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2553def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2554 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2555}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002556
2557// Arithmetic
Evan Cheng3ea4d672008-03-05 08:19:16 +00002558let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002559 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002560 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002561 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002562 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2563 VR128:$src2))]>;
2564 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002565 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002566 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002567 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002568 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002569 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002570 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002571 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002572 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2573 VR128:$src2))]>;
2574 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002575 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002576 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002577 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002578 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002579}
2580
Evan Chengb783fa32007-07-19 01:14:50 +00002581def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002582 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2584
2585// Horizontal ops
2586class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002587 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2590class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002591 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002592 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002593 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002594class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002595 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002596 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002597 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2598class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002599 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002600 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002601 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602
Evan Cheng3ea4d672008-03-05 08:19:16 +00002603let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002604 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2605 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2606 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2607 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2608 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2609 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2610 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2611 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2612}
2613
2614// Thread synchronization
Bill Wendling6ee76552009-05-28 23:40:46 +00002615def MONITOR : I<0x01, MRM1r, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002616 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Bill Wendling6ee76552009-05-28 23:40:46 +00002617def MWAIT : I<0x01, MRM1r, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002618 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2619
2620// vector_shuffle v1, <undef> <1, 1, 3, 3>
2621let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002622def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002623 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2624let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002625def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002626 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2627
2628// vector_shuffle v1, <undef> <0, 0, 2, 2>
2629let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002630 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002631 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2632let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002633 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002634 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2635
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002636//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002637// SSSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002638//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002639
Bill Wendling98680292007-08-10 06:22:27 +00002640/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002641multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2642 Intrinsic IntId64, Intrinsic IntId128> {
2643 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2644 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2645 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002646
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002647 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2648 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2649 [(set VR64:$dst,
2650 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2651
2652 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2653 (ins VR128:$src),
2654 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2655 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2656 OpSize;
2657
2658 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2659 (ins i128mem:$src),
2660 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2661 [(set VR128:$dst,
2662 (IntId128
2663 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002664}
2665
Bill Wendling98680292007-08-10 06:22:27 +00002666/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002667multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2668 Intrinsic IntId64, Intrinsic IntId128> {
2669 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2670 (ins VR64:$src),
2671 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2672 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002673
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002674 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2675 (ins i64mem:$src),
2676 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2677 [(set VR64:$dst,
2678 (IntId64
2679 (bitconvert (memopv4i16 addr:$src))))]>;
2680
2681 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2682 (ins VR128:$src),
2683 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2684 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2685 OpSize;
2686
2687 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2688 (ins i128mem:$src),
2689 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2690 [(set VR128:$dst,
2691 (IntId128
2692 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002693}
2694
2695/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002696multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2697 Intrinsic IntId64, Intrinsic IntId128> {
2698 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2699 (ins VR64:$src),
2700 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2701 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002702
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002703 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2704 (ins i64mem:$src),
2705 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2706 [(set VR64:$dst,
2707 (IntId64
2708 (bitconvert (memopv2i32 addr:$src))))]>;
2709
2710 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2711 (ins VR128:$src),
2712 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2713 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2714 OpSize;
2715
2716 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2717 (ins i128mem:$src),
2718 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2719 [(set VR128:$dst,
2720 (IntId128
2721 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002722}
2723
2724defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2725 int_x86_ssse3_pabs_b,
2726 int_x86_ssse3_pabs_b_128>;
2727defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2728 int_x86_ssse3_pabs_w,
2729 int_x86_ssse3_pabs_w_128>;
2730defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2731 int_x86_ssse3_pabs_d,
2732 int_x86_ssse3_pabs_d_128>;
2733
2734/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002735let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002736 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2737 Intrinsic IntId64, Intrinsic IntId128,
2738 bit Commutable = 0> {
2739 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2740 (ins VR64:$src1, VR64:$src2),
2741 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2742 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2743 let isCommutable = Commutable;
2744 }
2745 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2746 (ins VR64:$src1, i64mem:$src2),
2747 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2748 [(set VR64:$dst,
2749 (IntId64 VR64:$src1,
2750 (bitconvert (memopv8i8 addr:$src2))))]>;
2751
2752 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2753 (ins VR128:$src1, VR128:$src2),
2754 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2755 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2756 OpSize {
2757 let isCommutable = Commutable;
2758 }
2759 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2760 (ins VR128:$src1, i128mem:$src2),
2761 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2762 [(set VR128:$dst,
2763 (IntId128 VR128:$src1,
2764 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2765 }
2766}
2767
2768/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002769let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002770 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2771 Intrinsic IntId64, Intrinsic IntId128,
2772 bit Commutable = 0> {
2773 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2774 (ins VR64:$src1, VR64:$src2),
2775 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2776 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2777 let isCommutable = Commutable;
2778 }
2779 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2780 (ins VR64:$src1, i64mem:$src2),
2781 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2782 [(set VR64:$dst,
2783 (IntId64 VR64:$src1,
2784 (bitconvert (memopv4i16 addr:$src2))))]>;
2785
2786 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2787 (ins VR128:$src1, VR128:$src2),
2788 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2789 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2790 OpSize {
2791 let isCommutable = Commutable;
2792 }
2793 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2794 (ins VR128:$src1, i128mem:$src2),
2795 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2796 [(set VR128:$dst,
2797 (IntId128 VR128:$src1,
2798 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2799 }
2800}
2801
2802/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002803let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002804 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2805 Intrinsic IntId64, Intrinsic IntId128,
2806 bit Commutable = 0> {
2807 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2808 (ins VR64:$src1, VR64:$src2),
2809 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2810 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2811 let isCommutable = Commutable;
2812 }
2813 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2814 (ins VR64:$src1, i64mem:$src2),
2815 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2816 [(set VR64:$dst,
2817 (IntId64 VR64:$src1,
2818 (bitconvert (memopv2i32 addr:$src2))))]>;
2819
2820 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2821 (ins VR128:$src1, VR128:$src2),
2822 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2823 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2824 OpSize {
2825 let isCommutable = Commutable;
2826 }
2827 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2828 (ins VR128:$src1, i128mem:$src2),
2829 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2830 [(set VR128:$dst,
2831 (IntId128 VR128:$src1,
2832 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2833 }
2834}
2835
2836defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2837 int_x86_ssse3_phadd_w,
Evan Cheng944e4412008-06-16 21:16:24 +00002838 int_x86_ssse3_phadd_w_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002839defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2840 int_x86_ssse3_phadd_d,
Evan Cheng944e4412008-06-16 21:16:24 +00002841 int_x86_ssse3_phadd_d_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002842defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2843 int_x86_ssse3_phadd_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002844 int_x86_ssse3_phadd_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002845defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2846 int_x86_ssse3_phsub_w,
2847 int_x86_ssse3_phsub_w_128>;
2848defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2849 int_x86_ssse3_phsub_d,
2850 int_x86_ssse3_phsub_d_128>;
2851defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2852 int_x86_ssse3_phsub_sw,
2853 int_x86_ssse3_phsub_sw_128>;
2854defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2855 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002856 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002857defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2858 int_x86_ssse3_pmul_hr_sw,
2859 int_x86_ssse3_pmul_hr_sw_128, 1>;
2860defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2861 int_x86_ssse3_pshuf_b,
2862 int_x86_ssse3_pshuf_b_128>;
2863defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2864 int_x86_ssse3_psign_b,
2865 int_x86_ssse3_psign_b_128>;
2866defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2867 int_x86_ssse3_psign_w,
2868 int_x86_ssse3_psign_w_128>;
Evan Chengabfed472009-05-28 18:48:53 +00002869defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling98680292007-08-10 06:22:27 +00002870 int_x86_ssse3_psign_d,
2871 int_x86_ssse3_psign_d_128>;
2872
Evan Cheng3ea4d672008-03-05 08:19:16 +00002873let Constraints = "$src1 = $dst" in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002874 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002875 (ins VR64:$src1, VR64:$src2, i8imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002876 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002877 []>;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002878 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002879 (ins VR64:$src1, i64mem:$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 []>;
Bill Wendling98680292007-08-10 06:22:27 +00002882
Bill Wendling1dc817c2007-08-10 09:00:17 +00002883 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002884 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002885 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng06cd2072009-10-28 06:30:34 +00002886 []>, OpSize;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002887 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Sean Callananb02aec52009-11-20 22:28:42 +00002888 (ins VR128:$src1, i128mem:$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;
Bill Wendling98680292007-08-10 06:22:27 +00002891}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002892
Nate Begeman080f8e22009-10-19 02:17:23 +00002893// palignr patterns.
Sean Callananb02aec52009-11-20 22:28:42 +00002894def : Pat<(int_x86_ssse3_palign_r VR64:$src1, VR64:$src2, (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002895 (PALIGNR64rr VR64:$src1, VR64:$src2, (BYTE_imm imm:$src3))>,
2896 Requires<[HasSSSE3]>;
2897def : Pat<(int_x86_ssse3_palign_r VR64:$src1,
2898 (memop64 addr:$src2),
Sean Callananb02aec52009-11-20 22:28:42 +00002899 (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002900 (PALIGNR64rm VR64:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2901 Requires<[HasSSSE3]>;
2902
Sean Callananb02aec52009-11-20 22:28:42 +00002903def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1, VR128:$src2, (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002904 (PALIGNR128rr VR128:$src1, VR128:$src2, (BYTE_imm imm:$src3))>,
2905 Requires<[HasSSSE3]>;
2906def : Pat<(int_x86_ssse3_palign_r_128 VR128:$src1,
2907 (memopv2i64 addr:$src2),
Sean Callananb02aec52009-11-20 22:28:42 +00002908 (i8 imm:$src3)),
Evan Cheng06cd2072009-10-28 06:30:34 +00002909 (PALIGNR128rm VR128:$src1, addr:$src2, (BYTE_imm imm:$src3))>,
2910 Requires<[HasSSSE3]>;
2911
Nate Begeman080f8e22009-10-19 02:17:23 +00002912let AddedComplexity = 5 in {
2913def : Pat<(v4i32 (palign:$src3 VR128:$src1, VR128:$src2)),
2914 (PALIGNR128rr VR128:$src2, VR128:$src1,
2915 (SHUFFLE_get_palign_imm VR128:$src3))>,
2916 Requires<[HasSSSE3]>;
2917def : Pat<(v4f32 (palign:$src3 VR128:$src1, VR128:$src2)),
2918 (PALIGNR128rr VR128:$src2, VR128:$src1,
2919 (SHUFFLE_get_palign_imm VR128:$src3))>,
2920 Requires<[HasSSSE3]>;
2921def : Pat<(v8i16 (palign:$src3 VR128:$src1, VR128:$src2)),
2922 (PALIGNR128rr VR128:$src2, VR128:$src1,
2923 (SHUFFLE_get_palign_imm VR128:$src3))>,
2924 Requires<[HasSSSE3]>;
2925def : Pat<(v16i8 (palign:$src3 VR128:$src1, VR128:$src2)),
2926 (PALIGNR128rr VR128:$src2, VR128:$src1,
2927 (SHUFFLE_get_palign_imm VR128:$src3))>,
2928 Requires<[HasSSSE3]>;
Eric Christopherf3650292009-11-07 08:45:53 +00002929}
Nate Begeman080f8e22009-10-19 02:17:23 +00002930
Nate Begeman2c87c422009-02-23 08:49:38 +00002931def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2932 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2933def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2934 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2935
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002936//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937// Non-Instruction Patterns
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002938//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002939
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002940// extload f32 -> f64. This matches load+fextend because we have a hack in
2941// the isel (PreprocessForFPConvert) that can introduce loads after dag
2942// combine.
Chris Lattnerdec9cb52008-01-24 08:07:48 +00002943// Since these loads aren't folded into the fextend, we have to match it
2944// explicitly here.
2945let Predicates = [HasSSE2] in
2946 def : Pat<(fextend (loadf32 addr:$src)),
2947 (CVTSS2SDrm addr:$src)>;
2948
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002949// bit_convert
2950let Predicates = [HasSSE2] in {
2951 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2952 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2953 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2954 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2955 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2956 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2957 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2958 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2959 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2960 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2961 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2962 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2963 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2964 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2965 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2966 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2967 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2968 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2969 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2970 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2971 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2972 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2973 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2974 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2975 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2976 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2977 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2978 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2979 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2980 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2981}
2982
2983// Move scalar to XMM zero-extended
2984// movd to XMM register zero-extends
2985let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002986// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chenge9b9c672008-05-09 21:53:03 +00002987def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002988 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002989def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002990 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>;
Evan Chenge259e872008-05-09 23:37:55 +00002991def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002992 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Evan Cheng7fe0ff02008-07-10 01:08:23 +00002993def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002994 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002995}
2996
2997// Splat v2f64 / v2i64
2998let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002999def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003000 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003001def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003002 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003003def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003004 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003005def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003006 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
3007}
3008
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003009// Special unary SHUFPSrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00003010def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
3011 (SHUFPSrri VR128:$src1, VR128:$src1,
3012 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003013 Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003014let AddedComplexity = 5 in
3015def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
3016 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
3017 Requires<[HasSSE2]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00003018// Special unary SHUFPDrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00003019def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003020 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00003021 (SHUFFLE_get_shuf_imm VR128:$src3))>,
3022 Requires<[HasSSE2]>;
3023// Special unary SHUFPDrri case.
3024def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003025 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00003026 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7dc19012007-08-02 21:17:01 +00003027 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003028// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman543d2142009-04-27 18:41:29 +00003029def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
3030 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003031 Requires<[HasSSE2]>;
Evan Cheng13559d62008-09-26 23:41:32 +00003032
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003033// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman543d2142009-04-27 18:41:29 +00003034def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003035 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00003036 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003037 Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003038def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003039 (SHUFPSrmi VR128:$src1, addr:$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]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003042// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman543d2142009-04-27 18:41:29 +00003043def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003044 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00003045 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003046 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003047
3048// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00003049let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003050def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
3051 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003052 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003053def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
3054 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003055 Requires<[OptForSpeed, HasSSE2]>;
3056}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003057let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003058def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003059 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003060def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003061 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003062def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003063 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003064def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003065 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003066}
3067
3068// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00003069let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003070def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
3071 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003072 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003073def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
3074 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00003075 Requires<[OptForSpeed, HasSSE2]>;
3076}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003077let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00003078def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003079 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003080def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003081 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003082def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003083 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003084def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00003085 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003086}
3087
Evan Cheng13559d62008-09-26 23:41:32 +00003088let AddedComplexity = 20 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003089// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begemanb13034d2009-11-07 23:17:15 +00003090def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003091 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
3092
3093// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003094def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003095 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
3096
3097// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003098def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003099 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman543d2142009-04-27 18:41:29 +00003100def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003101 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
3102}
3103
3104let AddedComplexity = 20 in {
3105// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003106def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003107 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003108def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003110def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003111 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003112def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003113 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003114}
3115
Evan Cheng2b2a7012008-05-23 21:23:16 +00003116// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
Nate Begeman543d2142009-04-27 18:41:29 +00003117def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003118 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003119def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003120 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003121def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3122 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003123 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003124def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003125 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Evan Cheng2b2a7012008-05-23 21:23:16 +00003126
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003127let AddedComplexity = 15 in {
3128// Setting the lowest element in the vector.
Nate Begeman543d2142009-04-27 18:41:29 +00003129def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003130 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003131def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003132 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3133
3134// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
Nate Begeman543d2142009-04-27 18:41:29 +00003135def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003136 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003137def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003138 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3139}
3140
Eli Friedman27d19742009-06-19 07:00:55 +00003141// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3142// fall back to this for SSE1)
3143def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003144 (SHUFPSrri VR128:$src2, VR128:$src1,
Eli Friedman27d19742009-06-19 07:00:55 +00003145 (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>;
3146
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003147// Set lowest element and zero upper elements.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003148let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00003149def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003150 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00003151def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengd09a8a02008-05-08 22:35:02 +00003152 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003153
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003154// Some special case pandn patterns.
3155def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3156 VR128:$src2)),
3157 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3158def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3159 VR128:$src2)),
3160 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3161def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3162 VR128:$src2)),
3163 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3164
3165def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003166 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003167 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3168def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003169 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003170 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3171def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003172 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003173 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3174
Nate Begeman78246ca2007-11-17 03:58:34 +00003175// vector -> vector casts
3176def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3177 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3178def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3179 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedman7fa52ca2008-09-05 23:07:03 +00003180def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3181 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3182def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3183 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman78246ca2007-11-17 03:58:34 +00003184
Evan Cheng51a49b22007-07-20 00:27:43 +00003185// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00003186def : Pat<(alignedloadv4i32 addr:$src),
3187 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3188def : Pat<(loadv4i32 addr:$src),
3189 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00003190def : Pat<(alignedloadv2i64 addr:$src),
3191 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3192def : Pat<(loadv2i64 addr:$src),
3193 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3194
3195def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3196 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3197def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3198 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3199def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3200 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3201def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3202 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3203def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3204 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3205def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3206 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3207def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3208 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3209def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3210 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003211
Nate Begemanb2975562008-02-03 07:18:54 +00003212//===----------------------------------------------------------------------===//
3213// SSE4.1 Instructions
3214//===----------------------------------------------------------------------===//
3215
Dale Johannesena7d2b442008-10-10 23:51:03 +00003216multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begemanb2975562008-02-03 07:18:54 +00003217 string OpcodeStr,
Nate Begemanb2975562008-02-03 07:18:54 +00003218 Intrinsic V4F32Int,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003219 Intrinsic V2F64Int> {
Nate Begemanb2975562008-02-03 07:18:54 +00003220 // Intrinsic operation, reg.
Nate Begemanb2975562008-02-03 07:18:54 +00003221 // Vector intrinsic operation, reg
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003222 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003223 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003224 !strconcat(OpcodeStr,
3225 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003226 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3227 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003228
3229 // Vector intrinsic operation, mem
Evan Chengd3f27fb2009-12-18 07:40:29 +00003230 def PSm_Int : Ii8<opcps, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003231 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003232 !strconcat(OpcodeStr,
3233 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003234 [(set VR128:$dst,
3235 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Evan Chengd3f27fb2009-12-18 07:40:29 +00003236 TA, OpSize,
Evan Chengd53fca12009-12-22 17:47:23 +00003237 Requires<[HasSSE41]>;
Nate Begemanb2975562008-02-03 07:18:54 +00003238
Nate Begemanb2975562008-02-03 07:18:54 +00003239 // Vector intrinsic operation, reg
Evan Cheng78d00612008-03-14 07:39:27 +00003240 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003241 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003242 !strconcat(OpcodeStr,
3243 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003244 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3245 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003246
3247 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003248 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003249 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003250 !strconcat(OpcodeStr,
3251 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003252 [(set VR128:$dst,
3253 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003254 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003255}
3256
Dale Johannesena7d2b442008-10-10 23:51:03 +00003257let Constraints = "$src1 = $dst" in {
3258multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3259 string OpcodeStr,
3260 Intrinsic F32Int,
3261 Intrinsic F64Int> {
3262 // Intrinsic operation, reg.
3263 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003264 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003265 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3266 !strconcat(OpcodeStr,
3267 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003268 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003269 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3270 OpSize;
3271
3272 // Intrinsic operation, mem.
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003273 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3274 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003275 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003276 !strconcat(OpcodeStr,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003277 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003278 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003279 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3280 OpSize;
3281
3282 // Intrinsic operation, reg.
3283 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003284 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003285 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3286 !strconcat(OpcodeStr,
3287 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003288 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003289 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3290 OpSize;
3291
3292 // Intrinsic operation, mem.
3293 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003294 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003295 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3296 !strconcat(OpcodeStr,
3297 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003298 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003299 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3300 OpSize;
3301}
3302}
3303
Nate Begemanb2975562008-02-03 07:18:54 +00003304// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesena7d2b442008-10-10 23:51:03 +00003305defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3306 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3307defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3308 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003309
3310// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3311multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3312 Intrinsic IntId128> {
3313 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3314 (ins VR128:$src),
3315 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3316 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3317 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3318 (ins i128mem:$src),
3319 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3320 [(set VR128:$dst,
3321 (IntId128
3322 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3323}
3324
3325defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3326 int_x86_sse41_phminposuw>;
3327
3328/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003329let Constraints = "$src1 = $dst" in {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003330 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3331 Intrinsic IntId128, bit Commutable = 0> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003332 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3333 (ins VR128:$src1, VR128:$src2),
3334 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3335 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3336 OpSize {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003337 let isCommutable = Commutable;
3338 }
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003339 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3340 (ins VR128:$src1, i128mem:$src2),
3341 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3342 [(set VR128:$dst,
3343 (IntId128 VR128:$src1,
3344 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003345 }
3346}
3347
3348defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3349 int_x86_sse41_pcmpeqq, 1>;
3350defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3351 int_x86_sse41_packusdw, 0>;
3352defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3353 int_x86_sse41_pminsb, 1>;
3354defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3355 int_x86_sse41_pminsd, 1>;
3356defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3357 int_x86_sse41_pminud, 1>;
3358defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3359 int_x86_sse41_pminuw, 1>;
3360defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3361 int_x86_sse41_pmaxsb, 1>;
3362defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3363 int_x86_sse41_pmaxsd, 1>;
3364defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3365 int_x86_sse41_pmaxud, 1>;
3366defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3367 int_x86_sse41_pmaxuw, 1>;
Nate Begeman72d802a2008-02-04 06:00:24 +00003368
Mon P Wang14edb092008-12-18 21:42:19 +00003369defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3370
Nate Begeman03605a02008-07-17 16:51:19 +00003371def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3372 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3373def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3374 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3375
Nate Begeman58057962008-02-09 01:38:08 +00003376/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003377let Constraints = "$src1 = $dst" in {
Dan Gohmane3731f52008-05-23 17:49:40 +00003378 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3379 SDNode OpNode, Intrinsic IntId128,
3380 bit Commutable = 0> {
Nate Begeman58057962008-02-09 01:38:08 +00003381 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3382 (ins VR128:$src1, VR128:$src2),
3383 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmane3731f52008-05-23 17:49:40 +00003384 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3385 VR128:$src2))]>, OpSize {
Nate Begeman58057962008-02-09 01:38:08 +00003386 let isCommutable = Commutable;
3387 }
3388 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3389 (ins VR128:$src1, VR128:$src2),
3390 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3391 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3392 OpSize {
3393 let isCommutable = Commutable;
3394 }
3395 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3396 (ins VR128:$src1, i128mem:$src2),
3397 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3398 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003399 (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003400 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3401 (ins VR128:$src1, i128mem:$src2),
3402 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3403 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003404 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman58057962008-02-09 01:38:08 +00003405 OpSize;
3406 }
3407}
Dan Gohmane3731f52008-05-23 17:49:40 +00003408defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
Nate Begeman58057962008-02-09 01:38:08 +00003409 int_x86_sse41_pmulld, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003410
Evan Cheng78d00612008-03-14 07:39:27 +00003411/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Cheng3ea4d672008-03-05 08:19:16 +00003412let Constraints = "$src1 = $dst" in {
Nate Begeman72d802a2008-02-04 06:00:24 +00003413 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3414 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng78d00612008-03-14 07:39:27 +00003415 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003416 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003417 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003418 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003419 [(set VR128:$dst,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003420 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3421 OpSize {
Nate Begeman72d802a2008-02-04 06:00:24 +00003422 let isCommutable = Commutable;
3423 }
Evan Cheng78d00612008-03-14 07:39:27 +00003424 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003425 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3426 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003427 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003428 [(set VR128:$dst,
3429 (IntId128 VR128:$src1,
3430 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3431 OpSize;
Nate Begeman72d802a2008-02-04 06:00:24 +00003432 }
3433}
3434
3435defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3436 int_x86_sse41_blendps, 0>;
3437defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3438 int_x86_sse41_blendpd, 0>;
3439defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3440 int_x86_sse41_pblendw, 0>;
3441defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3442 int_x86_sse41_dpps, 1>;
3443defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3444 int_x86_sse41_dppd, 1>;
3445defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng81ed9852008-06-16 20:25:59 +00003446 int_x86_sse41_mpsadbw, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003447
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003448
Evan Cheng78d00612008-03-14 07:39:27 +00003449/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003450let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanb4e9a042008-02-10 18:47:57 +00003451 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3452 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3453 (ins VR128:$src1, VR128:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003454 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003455 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3456 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3457 OpSize;
3458
3459 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3460 (ins VR128:$src1, i128mem:$src2),
3461 !strconcat(OpcodeStr,
3462 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3463 [(set VR128:$dst,
3464 (IntId VR128:$src1,
3465 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3466 }
3467}
3468
3469defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3470defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3471defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3472
3473
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003474multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3475 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3476 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3477 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3478
3479 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3480 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003481 [(set VR128:$dst,
3482 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3483 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003484}
3485
3486defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3487defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3488defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3489defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3490defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3491defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3492
Evan Cheng56ec77b2008-09-24 23:27:55 +00003493// Common patterns involving scalar load.
3494def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3495 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3496def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3497 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3498
3499def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3500 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3501def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3502 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3503
3504def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3505 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3506def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3507 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3508
3509def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3510 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3511def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3512 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3513
3514def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3515 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3516def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3517 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3518
3519def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3520 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3521def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3522 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3523
3524
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003525multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3526 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3527 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3528 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3529
3530 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3531 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003532 [(set VR128:$dst,
3533 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3534 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003535}
3536
3537defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3538defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3539defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3540defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3541
Evan Cheng56ec77b2008-09-24 23:27:55 +00003542// Common patterns involving scalar load
3543def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003544 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003545def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003546 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003547
3548def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003549 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003550def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003551 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003552
3553
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003554multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3555 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3556 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3557 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3558
Evan Cheng56ec77b2008-09-24 23:27:55 +00003559 // Expecting a i16 load any extended to i32 value.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003560 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3561 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003562 [(set VR128:$dst, (IntId (bitconvert
3563 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3564 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003565}
3566
3567defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman75a89d62009-06-06 05:55:37 +00003568defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003569
Evan Cheng56ec77b2008-09-24 23:27:55 +00003570// Common patterns involving scalar load
3571def : Pat<(int_x86_sse41_pmovsxbq
3572 (bitconvert (v4i32 (X86vzmovl
3573 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003574 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003575
3576def : Pat<(int_x86_sse41_pmovzxbq
3577 (bitconvert (v4i32 (X86vzmovl
3578 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003579 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003580
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003581
Nate Begemand77e59e2008-02-11 04:19:36 +00003582/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3583multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003584 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003585 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003586 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003587 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003588 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3589 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003590 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003591 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003592 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003593 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003594 []>, OpSize;
3595// FIXME:
3596// There's an AssertZext in the way of writing the store pattern
3597// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003598}
3599
Nate Begemand77e59e2008-02-11 04:19:36 +00003600defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003601
Nate Begemand77e59e2008-02-11 04:19:36 +00003602
3603/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3604multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003605 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemand77e59e2008-02-11 04:19:36 +00003606 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003607 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003608 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3609 []>, OpSize;
3610// FIXME:
3611// There's an AssertZext in the way of writing the store pattern
3612// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3613}
3614
3615defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3616
3617
3618/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3619multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003620 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003621 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003622 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003623 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3624 [(set GR32:$dst,
3625 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003626 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003627 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003628 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003629 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3630 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3631 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003632}
3633
Nate Begemand77e59e2008-02-11 04:19:36 +00003634defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman58057962008-02-09 01:38:08 +00003635
Nate Begemand77e59e2008-02-11 04:19:36 +00003636
Evan Cheng6c249332008-03-24 21:52:23 +00003637/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3638/// destination
Nate Begemand77e59e2008-02-11 04:19:36 +00003639multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003640 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003641 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003642 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003643 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman788db592008-04-16 02:32:24 +00003644 [(set GR32:$dst,
3645 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng6c249332008-03-24 21:52:23 +00003646 OpSize;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003647 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003648 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003649 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003650 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng6c249332008-03-24 21:52:23 +00003651 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003652 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003653}
3654
Nate Begemand77e59e2008-02-11 04:19:36 +00003655defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003656
Dan Gohmana41862a2008-08-08 18:30:21 +00003657// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3658def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3659 imm:$src2))),
3660 addr:$dst),
3661 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3662 Requires<[HasSSE41]>;
3663
Evan Cheng3ea4d672008-03-05 08:19:16 +00003664let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003665 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003666 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003667 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003668 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003669 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003670 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003671 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003672 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003673 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3674 !strconcat(OpcodeStr,
3675 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003676 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003677 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3678 imm:$src3))]>, OpSize;
3679 }
3680}
3681
3682defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3683
Evan Cheng3ea4d672008-03-05 08:19:16 +00003684let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003685 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003686 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003687 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003688 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003689 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003690 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003691 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3692 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003693 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003694 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3695 !strconcat(OpcodeStr,
3696 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003697 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003698 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3699 imm:$src3)))]>, OpSize;
3700 }
3701}
3702
3703defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3704
Eric Christophera0443602009-07-23 02:22:41 +00003705// insertps has a few different modes, there's the first two here below which
3706// are optimized inserts that won't zero arbitrary elements in the destination
3707// vector. The next one matches the intrinsic and could zero arbitrary elements
3708// in the target vector.
Evan Cheng3ea4d672008-03-05 08:19:16 +00003709let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003710 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherefb657e2009-07-24 00:33:09 +00003711 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3712 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003713 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003714 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003715 [(set VR128:$dst,
3716 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
Sean Callanan2c48df22009-12-18 00:01:26 +00003717 OpSize;
Eric Christopherefb657e2009-07-24 00:33:09 +00003718 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003719 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3720 !strconcat(OpcodeStr,
3721 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003722 [(set VR128:$dst,
Eric Christopherefb657e2009-07-24 00:33:09 +00003723 (X86insrtps VR128:$src1,
3724 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begemand77e59e2008-02-11 04:19:36 +00003725 imm:$src3))]>, OpSize;
3726 }
3727}
3728
Evan Chengc2054be2008-03-26 08:11:49 +00003729defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003730
Eric Christopherefb657e2009-07-24 00:33:09 +00003731def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3732 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3733
Eric Christopher95d79262009-07-29 00:28:05 +00003734// ptest instruction we'll lower to this in X86ISelLowering primarily from
3735// the intel intrinsic that corresponds to this.
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003736let Defs = [EFLAGS] in {
3737def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003738 "ptest \t{$src2, $src1|$src1, $src2}",
3739 [(X86ptest VR128:$src1, VR128:$src2),
3740 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003741def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003742 "ptest \t{$src2, $src1|$src1, $src2}",
3743 [(X86ptest VR128:$src1, (load addr:$src2)),
3744 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003745}
3746
3747def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3748 "movntdqa\t{$src, $dst|$dst, $src}",
3749 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>;
Nate Begeman03605a02008-07-17 16:51:19 +00003750
Eric Christopher22a39402009-08-18 22:50:32 +00003751
3752//===----------------------------------------------------------------------===//
3753// SSE4.2 Instructions
3754//===----------------------------------------------------------------------===//
3755
Nate Begeman03605a02008-07-17 16:51:19 +00003756/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3757let Constraints = "$src1 = $dst" in {
3758 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3759 Intrinsic IntId128, bit Commutable = 0> {
3760 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3761 (ins VR128:$src1, VR128:$src2),
3762 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3763 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3764 OpSize {
3765 let isCommutable = Commutable;
3766 }
3767 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3768 (ins VR128:$src1, i128mem:$src2),
3769 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3770 [(set VR128:$dst,
3771 (IntId128 VR128:$src1,
3772 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3773 }
3774}
3775
Nate Begeman235666b2008-07-17 17:04:58 +00003776defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman03605a02008-07-17 16:51:19 +00003777
3778def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3779 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3780def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3781 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003782
3783// crc intrinsic instruction
3784// This set of instructions are only rm, the only difference is the size
3785// of r and m.
3786let Constraints = "$src1 = $dst" in {
Eric Christopher85f187b2009-08-10 21:48:58 +00003787 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003788 (ins GR32:$src1, i8mem:$src2),
3789 "crc32 \t{$src2, $src1|$src1, $src2}",
3790 [(set GR32:$dst,
3791 (int_x86_sse42_crc32_8 GR32:$src1,
3792 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003793 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003794 (ins GR32:$src1, GR8:$src2),
3795 "crc32 \t{$src2, $src1|$src1, $src2}",
3796 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003797 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003798 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003799 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003800 (ins GR32:$src1, i16mem:$src2),
3801 "crc32 \t{$src2, $src1|$src1, $src2}",
3802 [(set GR32:$dst,
3803 (int_x86_sse42_crc32_16 GR32:$src1,
3804 (load addr:$src2)))]>,
3805 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003806 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003807 (ins GR32:$src1, GR16:$src2),
3808 "crc32 \t{$src2, $src1|$src1, $src2}",
3809 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003810 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003811 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003812 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003813 (ins GR32:$src1, i32mem:$src2),
3814 "crc32 \t{$src2, $src1|$src1, $src2}",
3815 [(set GR32:$dst,
3816 (int_x86_sse42_crc32_32 GR32:$src1,
3817 (load addr:$src2)))]>, OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003818 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003819 (ins GR32:$src1, GR32:$src2),
3820 "crc32 \t{$src2, $src1|$src1, $src2}",
3821 [(set GR32:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003822 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003823 OpSize;
Eric Christopher85f187b2009-08-10 21:48:58 +00003824 def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003825 (ins GR64:$src1, i64mem:$src2),
3826 "crc32 \t{$src2, $src1|$src1, $src2}",
3827 [(set GR64:$dst,
3828 (int_x86_sse42_crc32_64 GR64:$src1,
3829 (load addr:$src2)))]>,
3830 OpSize, REX_W;
Eric Christopher85f187b2009-08-10 21:48:58 +00003831 def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
Eric Christopherb5f948c2009-08-08 21:55:08 +00003832 (ins GR64:$src1, GR64:$src2),
3833 "crc32 \t{$src2, $src1|$src1, $src2}",
3834 [(set GR64:$dst,
Eric Christopher85f187b2009-08-10 21:48:58 +00003835 (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>,
Eric Christopherb5f948c2009-08-08 21:55:08 +00003836 OpSize, REX_W;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003837}
Eric Christopher22a39402009-08-18 22:50:32 +00003838
3839// String/text processing instructions.
Dan Gohman30afe012009-10-29 18:10:34 +00003840let Defs = [EFLAGS], usesCustomInserter = 1 in {
Eric Christopher22a39402009-08-18 22:50:32 +00003841def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003842 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3843 "#PCMPISTRM128rr PSEUDO!",
3844 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2,
3845 imm:$src3))]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003846def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003847 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3848 "#PCMPISTRM128rm PSEUDO!",
3849 [(set VR128:$dst, (int_x86_sse42_pcmpistrm128 VR128:$src1, (load addr:$src2),
3850 imm:$src3))]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003851}
3852
3853let Defs = [XMM0, EFLAGS] in {
3854def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003855 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3856 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003857def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003858 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3859 "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003860}
3861
Sean Callanan2c48df22009-12-18 00:01:26 +00003862let Defs = [EFLAGS], Uses = [EAX, EDX], usesCustomInserter = 1 in {
Eric Christopher22a39402009-08-18 22:50:32 +00003863def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003864 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3865 "#PCMPESTRM128rr PSEUDO!",
3866 [(set VR128:$dst,
3867 (int_x86_sse42_pcmpestrm128
3868 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5))]>, OpSize;
3869
Eric Christopher22a39402009-08-18 22:50:32 +00003870def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst),
Sean Callanan2c48df22009-12-18 00:01:26 +00003871 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3872 "#PCMPESTRM128rm PSEUDO!",
3873 [(set VR128:$dst, (int_x86_sse42_pcmpestrm128
3874 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5))]>,
3875 OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003876}
3877
3878let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in {
Sean Callananc5a05b72009-08-20 18:24:27 +00003879def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003880 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3881 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Sean Callananc5a05b72009-08-20 18:24:27 +00003882def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003883 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3884 "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", []>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003885}
3886
3887let Defs = [ECX, EFLAGS] in {
3888 multiclass SS42AI_pcmpistri<Intrinsic IntId128> {
Sean Callanan2c48df22009-12-18 00:01:26 +00003889 def rr : SS42AI<0x63, MRMSrcReg, (outs),
3890 (ins VR128:$src1, VR128:$src2, i8imm:$src3),
3891 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3892 [(set ECX, (IntId128 VR128:$src1, VR128:$src2, imm:$src3)),
3893 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003894 def rm : SS42AI<0x63, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003895 (ins VR128:$src1, i128mem:$src2, i8imm:$src3),
3896 "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}",
3897 [(set ECX, (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)),
3898 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003899 }
3900}
3901
3902defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>;
3903defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>;
3904defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>;
3905defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>;
3906defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>;
3907defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>;
3908
3909let Defs = [ECX, EFLAGS] in {
3910let Uses = [EAX, EDX] in {
3911 multiclass SS42AI_pcmpestri<Intrinsic IntId128> {
3912 def rr : SS42AI<0x61, MRMSrcReg, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003913 (ins VR128:$src1, VR128:$src3, i8imm:$src5),
3914 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3915 [(set ECX, (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)),
3916 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003917 def rm : SS42AI<0x61, MRMSrcMem, (outs),
Sean Callanan2c48df22009-12-18 00:01:26 +00003918 (ins VR128:$src1, i128mem:$src3, i8imm:$src5),
3919 "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}",
3920 [(set ECX,
3921 (IntId128 VR128:$src1, EAX, (load addr:$src3), EDX, imm:$src5)),
3922 (implicit EFLAGS)]>, OpSize;
Eric Christopher22a39402009-08-18 22:50:32 +00003923 }
3924}
3925}
3926
3927defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>;
3928defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>;
3929defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>;
3930defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>;
3931defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>;
3932defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>;