blob: fefdba096ab1ec5b506ae7fcc340b45189857f4d [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 Christopher95d79262009-07-29 00:28:05 +000072def SDTX86CmpPTest : SDTypeProfile<0, 2, [SDTCisVT<0, v4f32>, SDTCisVT<1, v4f32>]>;
73def X86ptest : SDNode<"X86ISD::PTEST", SDTX86CmpPTest>;
74
Dan Gohmanf17a25c2007-07-18 16:29:46 +000075//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076// SSE Complex Patterns
77//===----------------------------------------------------------------------===//
78
79// These are 'extloads' from a scalar to the low element of a vector, zeroing
80// the top elements. These are used for the SSE 'ss' and 'sd' instruction
81// forms.
Rafael Espindolabca99f72009-04-08 21:14:34 +000082def sse_load_f32 : ComplexPattern<v4f32, 5, "SelectScalarSSELoad", [],
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000083 [SDNPHasChain, SDNPMayLoad]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +000084def sse_load_f64 : ComplexPattern<v2f64, 5, "SelectScalarSSELoad", [],
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000085 [SDNPHasChain, SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086
87def ssmem : Operand<v4f32> {
88 let PrintMethod = "printf32mem";
Dan Gohmanfe606822009-07-30 01:56:29 +000089 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000090}
91def sdmem : Operand<v2f64> {
92 let PrintMethod = "printf64mem";
Dan Gohmanfe606822009-07-30 01:56:29 +000093 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000094}
95
96//===----------------------------------------------------------------------===//
97// SSE pattern fragments
98//===----------------------------------------------------------------------===//
99
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000100def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
101def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
102def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
103def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
104
Dan Gohman11821702007-07-27 17:16:43 +0000105// Like 'store', but always requires vector alignment.
Dan Gohman4a4f1512007-07-18 20:23:34 +0000106def alignedstore : PatFrag<(ops node:$val, node:$ptr),
Dan Gohman2a174122008-10-15 06:50:19 +0000107 (store node:$val, node:$ptr), [{
108 return cast<StoreSDNode>(N)->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000109}]>;
110
Dan Gohman11821702007-07-27 17:16:43 +0000111// Like 'load', but always requires vector alignment.
Dan Gohman2a174122008-10-15 06:50:19 +0000112def alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
113 return cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000114}]>;
115
Dan Gohman11821702007-07-27 17:16:43 +0000116def alignedloadfsf32 : PatFrag<(ops node:$ptr), (f32 (alignedload node:$ptr))>;
117def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000118def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>;
119def alignedloadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (alignedload node:$ptr))>;
120def alignedloadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (alignedload node:$ptr))>;
121def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>;
122
123// Like 'load', but uses special alignment checks suitable for use in
124// memory operands in most SSE instructions, which are required to
125// be naturally aligned on some targets but not on others.
126// FIXME: Actually implement support for targets that don't require the
127// alignment. This probably wants a subtarget predicate.
Dan Gohman2a174122008-10-15 06:50:19 +0000128def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{
129 return cast<LoadSDNode>(N)->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000130}]>;
131
Dan Gohman11821702007-07-27 17:16:43 +0000132def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
133def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000134def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
135def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
136def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
137def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +0000138def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000139
Bill Wendling3b15d722007-08-11 09:52:53 +0000140// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
141// 16-byte boundary.
Nate Begeman9a58b8a2008-02-09 23:46:37 +0000142// FIXME: 8 byte alignment for mmx reads is not required
Dan Gohman61efc5a2008-10-16 00:03:00 +0000143def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Dan Gohman2a174122008-10-15 06:50:19 +0000144 return cast<LoadSDNode>(N)->getAlignment() >= 8;
Bill Wendling3b15d722007-08-11 09:52:53 +0000145}]>;
146
147def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
Bill Wendling3b15d722007-08-11 09:52:53 +0000148def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
149def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
150def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
151
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
153def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
154def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
155def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
156def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
157def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
158
Evan Cheng56ec77b2008-09-24 23:27:55 +0000159def vzmovl_v2i64 : PatFrag<(ops node:$src),
160 (bitconvert (v2i64 (X86vzmovl
161 (v2i64 (scalar_to_vector (loadi64 node:$src))))))>;
162def vzmovl_v4i32 : PatFrag<(ops node:$src),
163 (bitconvert (v4i32 (X86vzmovl
164 (v4i32 (scalar_to_vector (loadi32 node:$src))))))>;
165
166def vzload_v2i64 : PatFrag<(ops node:$src),
167 (bitconvert (v2i64 (X86vzload node:$src)))>;
168
169
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000170def fp32imm0 : PatLeaf<(f32 fpimm), [{
171 return N->isExactlyValue(+0.0);
172}]>;
173
174def PSxLDQ_imm : SDNodeXForm<imm, [{
175 // Transformation function: imm >> 3
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000176 return getI32Imm(N->getZExtValue() >> 3);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177}]>;
178
179// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
180// SHUFP* etc. imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000181def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182 return getI8Imm(X86::getShuffleSHUFImmediate(N));
183}]>;
184
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000185// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186// PSHUFHW imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000187def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000188 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
189}]>;
190
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000191// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192// PSHUFLW imm.
Nate Begeman543d2142009-04-27 18:41:29 +0000193def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000194 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
195}]>;
196
Nate Begeman543d2142009-04-27 18:41:29 +0000197def splat_lo : PatFrag<(ops node:$lhs, node:$rhs),
198 (vector_shuffle node:$lhs, node:$rhs), [{
199 ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
200 return SVOp->isSplat() && SVOp->getSplatIndex() == 0;
201}]>;
202
203def movddup : PatFrag<(ops node:$lhs, node:$rhs),
204 (vector_shuffle node:$lhs, node:$rhs), [{
205 return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N));
206}]>;
207
208def movhlps : PatFrag<(ops node:$lhs, node:$rhs),
209 (vector_shuffle node:$lhs, node:$rhs), [{
210 return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N));
211}]>;
212
213def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs),
214 (vector_shuffle node:$lhs, node:$rhs), [{
215 return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
216}]>;
217
218def movhp : PatFrag<(ops node:$lhs, node:$rhs),
219 (vector_shuffle node:$lhs, node:$rhs), [{
220 return X86::isMOVHPMask(cast<ShuffleVectorSDNode>(N));
221}]>;
222
223def movlp : PatFrag<(ops node:$lhs, node:$rhs),
224 (vector_shuffle node:$lhs, node:$rhs), [{
225 return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N));
226}]>;
227
228def movl : PatFrag<(ops node:$lhs, node:$rhs),
229 (vector_shuffle node:$lhs, node:$rhs), [{
230 return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N));
231}]>;
232
233def movshdup : PatFrag<(ops node:$lhs, node:$rhs),
234 (vector_shuffle node:$lhs, node:$rhs), [{
235 return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N));
236}]>;
237
238def movsldup : PatFrag<(ops node:$lhs, node:$rhs),
239 (vector_shuffle node:$lhs, node:$rhs), [{
240 return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N));
241}]>;
242
243def unpckl : PatFrag<(ops node:$lhs, node:$rhs),
244 (vector_shuffle node:$lhs, node:$rhs), [{
245 return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N));
246}]>;
247
248def unpckh : PatFrag<(ops node:$lhs, node:$rhs),
249 (vector_shuffle node:$lhs, node:$rhs), [{
250 return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N));
251}]>;
252
253def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs),
254 (vector_shuffle node:$lhs, node:$rhs), [{
255 return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
256}]>;
257
258def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs),
259 (vector_shuffle node:$lhs, node:$rhs), [{
260 return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N));
261}]>;
262
263def pshufd : PatFrag<(ops node:$lhs, node:$rhs),
264 (vector_shuffle node:$lhs, node:$rhs), [{
265 return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266}], SHUFFLE_get_shuf_imm>;
267
Nate Begeman543d2142009-04-27 18:41:29 +0000268def shufp : PatFrag<(ops node:$lhs, node:$rhs),
269 (vector_shuffle node:$lhs, node:$rhs), [{
270 return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271}], SHUFFLE_get_shuf_imm>;
272
Nate Begeman543d2142009-04-27 18:41:29 +0000273def pshufhw : PatFrag<(ops node:$lhs, node:$rhs),
274 (vector_shuffle node:$lhs, node:$rhs), [{
275 return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276}], SHUFFLE_get_pshufhw_imm>;
277
Nate Begeman543d2142009-04-27 18:41:29 +0000278def pshuflw : PatFrag<(ops node:$lhs, node:$rhs),
279 (vector_shuffle node:$lhs, node:$rhs), [{
280 return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000281}], SHUFFLE_get_pshuflw_imm>;
282
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000283//===----------------------------------------------------------------------===//
284// SSE scalar FP Instructions
285//===----------------------------------------------------------------------===//
286
287// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
288// scheduler into a branch sequence.
Evan Cheng950aac02007-09-25 01:57:46 +0000289// These are expanded by the scheduler.
290let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291 def CMOV_FR32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000292 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000293 "#CMOV_FR32 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000294 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
295 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000296 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000297 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298 "#CMOV_FR64 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000299 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
300 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000301 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000302 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000303 "#CMOV_V4F32 PSEUDO!",
304 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000305 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
306 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307 def CMOV_V2F64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000308 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309 "#CMOV_V2F64 PSEUDO!",
310 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000311 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
312 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 def CMOV_V2I64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000314 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315 "#CMOV_V2I64 PSEUDO!",
316 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000317 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng950aac02007-09-25 01:57:46 +0000318 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319}
320
321//===----------------------------------------------------------------------===//
322// SSE1 Instructions
323//===----------------------------------------------------------------------===//
324
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000326let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000327def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000328 "movss\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000329let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000330def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000331 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000332 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000333def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000334 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335 [(store FR32:$src, addr:$dst)]>;
336
337// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000338def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000339 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000341def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000342 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000343 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000344def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000345 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000347def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000348 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
350
351// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000352def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000353 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000355def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000356 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357 [(set GR32:$dst, (int_x86_sse_cvtss2si
358 (load addr:$src)))]>;
359
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000360// Match intrinisics which expect MM and XMM operand(s).
361def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
362 "cvtps2pi\t{$src, $dst|$dst, $src}",
363 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
364def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
365 "cvtps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000366 [(set VR64:$dst, (int_x86_sse_cvtps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000367 (load addr:$src)))]>;
368def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
369 "cvttps2pi\t{$src, $dst|$dst, $src}",
370 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
371def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
372 "cvttps2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000373 [(set VR64:$dst, (int_x86_sse_cvttps2pi
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000374 (load addr:$src)))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +0000375let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000376 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000377 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
378 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
379 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
380 VR64:$src2))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000381 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000382 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
383 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000384 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000385 (load addr:$src2)))]>;
386}
387
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000389def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000390 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391 [(set GR32:$dst,
392 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000393def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000394 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000395 [(set GR32:$dst,
396 (int_x86_sse_cvttss2si(load addr:$src)))]>;
397
Evan Cheng3ea4d672008-03-05 08:19:16 +0000398let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000400 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000401 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000402 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
403 GR32:$src2))]>;
404 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000405 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000406 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
408 (loadi32 addr:$src2)))]>;
409}
410
411// Comparison instructions
Dan Gohmanf221da12009-01-09 02:27:34 +0000412let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000413 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000414 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000415 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000416let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000417 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000418 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000419 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420}
421
Evan Cheng55687072007-09-14 21:48:26 +0000422let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000423def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000424 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000425 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000426def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000427 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000428 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000429 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000430} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431
432// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +0000433let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000434 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
435 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
436 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000437 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000438 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000439 VR128:$src, imm:$cc))]>;
440 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
441 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src,
442 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000443 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
445 (load addr:$src), imm:$cc))]>;
446}
447
Evan Cheng55687072007-09-14 21:48:26 +0000448let Defs = [EFLAGS] in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000449def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000450 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000451 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000452 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000453def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000454 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000455 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000456 (implicit EFLAGS)]>;
457
Dan Gohmanf221da12009-01-09 02:27:34 +0000458def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000459 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000460 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000461 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000462def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000463 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000464 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000465 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000466} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000468// Aliases of packed SSE1 instructions for scalar use. These all have names
469// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470
471// Alias instructions that map fld0 to pxor for sse.
Evan Chengbf81b9b2008-08-28 07:52:25 +0000472let isReMaterializable = 1, isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000473def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000474 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000475 Requires<[HasSSE1]>, TB, OpSize;
476
477// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
478// disregarded.
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000479let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000480def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000481 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000482
483// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
484// disregarded.
Dan Gohman5574cc72008-12-03 18:15:48 +0000485let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000486def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000487 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000488 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489
490// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +0000491let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492let isCommutable = 1 in {
Dan Gohmanf221da12009-01-09 02:27:34 +0000493 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst),
494 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000495 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000496 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000497 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst),
498 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000499 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000501 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst),
502 (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000503 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
505}
506
Dan Gohmanf221da12009-01-09 02:27:34 +0000507def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst),
508 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000509 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000510 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000511 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000512def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst),
513 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000514 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000516 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000517def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst),
518 (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000519 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000521 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf221da12009-01-09 02:27:34 +0000522
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000523let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000524def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000525 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000526 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000527let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000529 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000530 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000532}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000533
534/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
535///
536/// In addition, we also have a special variant of the scalar form here to
537/// represent the associated intrinsic operation. This form is unlike the
538/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000539/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540///
541/// These three forms can each be reg+reg or reg+mem, so there are a total of
542/// six "instructions".
543///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000544let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
546 SDNode OpNode, Intrinsic F32Int,
547 bit Commutable = 0> {
548 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000549 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000550 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
552 let isCommutable = Commutable;
553 }
554
555 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000556 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
557 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000558 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000560
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000562 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
563 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000564 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
566 let isCommutable = Commutable;
567 }
568
569 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000570 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
571 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000572 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000573 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000574
575 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000576 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
577 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000578 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +0000579 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580
581 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000582 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
583 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000584 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000585 [(set VR128:$dst, (F32Int VR128:$src1,
586 sse_load_f32:$src2))]>;
587}
588}
589
590// Arithmetic instructions
591defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
592defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
593defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
594defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
595
596/// sse1_fp_binop_rm - Other SSE1 binops
597///
598/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
599/// instructions for a full-vector intrinsic form. Operations that map
600/// onto C operators don't use this form since they just use the plain
601/// vector form instead of having a separate vector intrinsic form.
602///
603/// This provides a total of eight "instructions".
604///
Evan Cheng3ea4d672008-03-05 08:19:16 +0000605let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000606multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
607 SDNode OpNode,
608 Intrinsic F32Int,
609 Intrinsic V4F32Int,
610 bit Commutable = 0> {
611
612 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000613 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000614 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
616 let isCommutable = Commutable;
617 }
618
619 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000620 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
621 (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000622 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000624
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000626 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst),
627 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000628 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000629 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
630 let isCommutable = Commutable;
631 }
632
633 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000634 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst),
635 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000636 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000637 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000638
639 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000640 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst),
641 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000642 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000643 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
644 let isCommutable = Commutable;
645 }
646
647 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000648 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst),
649 (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000650 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651 [(set VR128:$dst, (F32Int VR128:$src1,
652 sse_load_f32:$src2))]>;
653
654 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000655 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst),
656 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000657 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
659 let isCommutable = Commutable;
660 }
661
662 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +0000663 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst),
664 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000665 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000666 [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000667}
668}
669
670defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
671 int_x86_sse_max_ss, int_x86_sse_max_ps>;
672defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
673 int_x86_sse_min_ss, int_x86_sse_min_ps>;
674
675//===----------------------------------------------------------------------===//
676// SSE packed FP Instructions
677
678// Move Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000679let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000680def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000681 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000682let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000683def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000684 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000685 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686
Evan Chengb783fa32007-07-19 01:14:50 +0000687def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000688 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000689 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000691let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000692def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000693 "movups\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +0000694let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000695def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000696 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000697 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000698def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000699 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000700 [(store (v4f32 VR128:$src), addr:$dst)]>;
701
702// Intrinsic forms of MOVUPS load and store
Dan Gohman5574cc72008-12-03 18:15:48 +0000703let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000704def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000705 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000706 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000707def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000709 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710
Evan Cheng3ea4d672008-03-05 08:19:16 +0000711let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712 let AddedComplexity = 20 in {
713 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000714 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000715 "movlps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000716 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000717 (movlp VR128:$src1,
718 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000720 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000721 "movhps\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000722 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000723 (movhp VR128:$src1,
724 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000726} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727
Evan Chengd743a5f2008-05-10 00:59:18 +0000728
Evan Chengb783fa32007-07-19 01:14:50 +0000729def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000730 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
732 (iPTR 0))), addr:$dst)]>;
733
734// v2f64 extract element 1 is always custom lowered to unpack high to low
735// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000736def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000737 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000738 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +0000739 (unpckh (bc_v2f64 (v4f32 VR128:$src)),
740 (undef)), (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741
Evan Cheng3ea4d672008-03-05 08:19:16 +0000742let Constraints = "$src1 = $dst" in {
Evan Cheng13559d62008-09-26 23:41:32 +0000743let AddedComplexity = 20 in {
Evan Cheng7581a822009-05-12 20:17:52 +0000744def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst),
745 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000746 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000748 (v4f32 (movhp VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749
Evan Cheng7581a822009-05-12 20:17:52 +0000750def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst),
751 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000752 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000754 (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000755} // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000756} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757
Nate Begemanb44aad72009-04-29 22:47:44 +0000758let AddedComplexity = 20 in {
Nate Begeman543d2142009-04-27 18:41:29 +0000759def : Pat<(v4f32 (movddup VR128:$src, (undef))),
Evan Chenga2497eb2008-09-25 20:50:48 +0000760 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begemanb44aad72009-04-29 22:47:44 +0000761def : Pat<(v2i64 (movddup VR128:$src, (undef))),
762 (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
763}
Evan Chenga2497eb2008-09-25 20:50:48 +0000764
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765
766
767// Arithmetic
768
769/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
770///
771/// In addition, we also have a special variant of the scalar form here to
772/// represent the associated intrinsic operation. This form is unlike the
773/// plain scalar form, in that it takes an entire vector (instead of a
774/// scalar) and leaves the top elements undefined.
775///
776/// And, we have a special variant form for a full-vector intrinsic form.
777///
778/// These four forms can each have a reg or a mem operand, so there are a
779/// total of eight "instructions".
780///
781multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
782 SDNode OpNode,
783 Intrinsic F32Int,
784 Intrinsic V4F32Int,
785 bit Commutable = 0> {
786 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000787 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000788 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789 [(set FR32:$dst, (OpNode FR32:$src))]> {
790 let isCommutable = Commutable;
791 }
792
793 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000794 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000795 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000797
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000799 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000800 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
802 let isCommutable = Commutable;
803 }
804
805 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000806 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000807 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000808 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809
810 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000811 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000812 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813 [(set VR128:$dst, (F32Int VR128:$src))]> {
814 let isCommutable = Commutable;
815 }
816
817 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000818 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000819 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
821
822 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000823 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000824 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
826 let isCommutable = Commutable;
827 }
828
829 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000830 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000831 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +0000832 [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833}
834
835// Square root.
836defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
837 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
838
839// Reciprocal approximations. Note that these typically require refinement
840// in order to obtain suitable precision.
841defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
842 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
843defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
844 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
845
846// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +0000847let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 let isCommutable = 1 in {
849 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000850 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000851 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 [(set VR128:$dst, (v2i64
853 (and VR128:$src1, VR128:$src2)))]>;
854 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000855 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000856 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 [(set VR128:$dst, (v2i64
858 (or VR128:$src1, VR128:$src2)))]>;
859 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000860 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set VR128:$dst, (v2i64
863 (xor VR128:$src1, VR128:$src2)))]>;
864 }
865
866 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000867 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000868 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000869 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
870 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000872 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000873 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000874 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
875 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000877 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000878 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000879 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
880 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000882 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000883 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 [(set VR128:$dst,
885 (v2i64 (and (xor VR128:$src1,
886 (bc_v2i64 (v4i32 immAllOnesV))),
887 VR128:$src2)))]>;
888 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000889 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000890 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000892 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000894 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895}
896
Evan Cheng3ea4d672008-03-05 08:19:16 +0000897let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000898 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Nate Begeman061db5f2008-05-12 20:34:32 +0000899 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
900 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
901 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
902 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000903 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Nate Begeman061db5f2008-05-12 20:34:32 +0000904 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
905 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
906 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +0000907 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908}
Nate Begeman03605a02008-07-17 16:51:19 +0000909def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)),
910 (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>;
911def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)),
912 (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913
914// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +0000915let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000917 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000918 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000919 VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000920 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000922 (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000923 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000924 (outs VR128:$dst), (ins VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +0000925 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000926 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000928 (v4f32 (shufp:$src3
929 VR128:$src1, (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930
931 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000932 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000933 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000934 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000936 (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000937 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000938 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000939 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000941 (v4f32 (unpckh VR128:$src1,
942 (memopv4f32 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000944 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000945 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000946 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000948 (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +0000949 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000950 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000951 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +0000953 (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +0000955} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956
957// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000958def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000959 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengd8296b82009-05-28 18:55:28 +0000961def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
964
Evan Chengd1d68072008-03-08 00:58:38 +0000965// Prefetch intrinsic.
966def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src),
967 "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>;
968def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src),
969 "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>;
970def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src),
971 "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>;
972def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src),
973 "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974
975// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000976def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000977 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
979
980// Load, store, and memory fence
Evan Cheng68cca152009-05-27 18:38:01 +0000981def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982
983// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000984def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000985 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000986def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000987 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988
989// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +0000990// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +0000991// load of an all-zeros value if folding it would be beneficial.
Dan Gohman5574cc72008-12-03 18:15:48 +0000992let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000993def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000994 "xorps\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000995 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996
Evan Chenga15896e2008-03-12 07:02:50 +0000997let Predicates = [HasSSE1] in {
998 def : Pat<(v2i64 immAllZerosV), (V_SET0)>;
999 def : Pat<(v8i16 immAllZerosV), (V_SET0)>;
1000 def : Pat<(v16i8 immAllZerosV), (V_SET0)>;
1001 def : Pat<(v2f64 immAllZerosV), (V_SET0)>;
1002 def : Pat<(v4f32 immAllZerosV), (V_SET0)>;
1003}
1004
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005// FR32 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001006let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001007def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001008 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 [(set VR128:$dst,
1010 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001011def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001012 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 [(set VR128:$dst,
1014 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
1015
1016// FIXME: may not be able to eliminate this movss with coalescing the src and
1017// dest register classes are different. We really want to write this pattern
1018// like this:
1019// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
1020// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001021let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001022def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001023 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
1025 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001026def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 [(store (f32 (vector_extract (v4f32 VR128:$src),
1029 (iPTR 0))), addr:$dst)]>;
1030
1031
1032// Move to lower bits of a VR128, leaving upper bits alone.
1033// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001034let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001035let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001037 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001038 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039
1040 let AddedComplexity = 15 in
1041 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001042 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001043 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001045 (v4f32 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046}
1047
1048// Move to lower bits of a VR128 and zeroing upper bits.
1049// Loading from memory automatically zeroing upper bits.
1050let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00001051def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001052 "movss\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00001053 [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001054 (loadf32 addr:$src))))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055
Evan Cheng056afe12008-05-20 18:24:47 +00001056def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))),
Evan Cheng40ee6e52008-05-08 00:57:18 +00001057 (MOVZSS2PSrm addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001059//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060// SSE2 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001061//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001064let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001065def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001066 "movsd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001067let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001068def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001069 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001071def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001072 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073 [(store FR64:$src, addr:$dst)]>;
1074
1075// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001076def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001077 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001079def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001080 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001082def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001083 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001084 [(set FR32:$dst, (fround FR64:$src))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001085def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001086 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001088def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001089 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001091def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001092 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1094
1095// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001096def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001097 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1099 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001100def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1103 Requires<[HasSSE2]>;
1104
1105// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001106def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001109def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001110 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1112 (load addr:$src)))]>;
1113
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001114// Match intrinisics which expect MM and XMM operand(s).
1115def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1116 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1117 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1118def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1119 "cvtpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001120 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001121 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001122def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1123 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1124 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1125def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1126 "cvttpd2pi\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001127 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
Evan Cheng00b66ef2008-05-23 00:37:07 +00001128 (memop addr:$src)))]>;
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001129def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1130 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1131 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1132def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1133 "cvtpi2pd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001134 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001135 (load addr:$src)))]>;
1136
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001138def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001139 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 [(set GR32:$dst,
1141 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001142def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001143 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001144 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1145 (load addr:$src)))]>;
1146
1147// Comparison instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001148let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001149 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001150 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001151 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001152let mayLoad = 1 in
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001153 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001154 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001155 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156}
1157
Evan Cheng950aac02007-09-25 01:57:46 +00001158let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001159def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001160 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001161 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001162def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001163 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001164 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001165 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001166} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001167
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168// Aliases to match intrinsics which expect XMM operand(s).
Evan Cheng3ea4d672008-03-05 08:19:16 +00001169let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001170 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
1171 (outs VR128:$dst), (ins VR128:$src1, VR128:$src,
1172 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001173 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1175 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001176 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
1177 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src,
1178 SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001179 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001180 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1181 (load addr:$src), imm:$cc))]>;
1182}
1183
Evan Cheng950aac02007-09-25 01:57:46 +00001184let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001185def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001186 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001187 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1188 (implicit EFLAGS)]>;
1189def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001190 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001191 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1192 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193
Evan Chengb783fa32007-07-19 01:14:50 +00001194def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001195 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001196 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1197 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001198def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001199 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001200 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001201 (implicit EFLAGS)]>;
Dan Gohmanf221da12009-01-09 02:27:34 +00001202} // Defs = [EFLAGS]
Evan Cheng950aac02007-09-25 01:57:46 +00001203
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001204// Aliases of packed SSE2 instructions for scalar use. These all have names
1205// that start with 'Fs'.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206
1207// Alias instructions that map fld0 to pxor for sse.
Evan Chengbf81b9b2008-08-28 07:52:25 +00001208let isReMaterializable = 1, isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001209def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001210 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 Requires<[HasSSE2]>, TB, OpSize;
1212
1213// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1214// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001215let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001216def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001217 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218
1219// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1220// disregarded.
Dan Gohman5574cc72008-12-03 18:15:48 +00001221let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001222def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001223 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001224 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225
1226// Alias bitwise logical operations using SSE logical ops on packed FP values.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001227let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228let isCommutable = 1 in {
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001229 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst),
1230 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001231 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001232 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001233 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst),
1234 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001235 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001237 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst),
1238 (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001239 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001240 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1241}
1242
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001243def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst),
1244 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001245 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001247 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001248def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst),
1249 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001250 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001251 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001252 (memopfsf64 addr:$src2)))]>;
Evan Cheng0e3e01d2008-05-02 07:53:32 +00001253def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst),
1254 (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001255 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001257 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001259let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001261 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001263let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001265 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001266 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001268}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269
1270/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1271///
1272/// In addition, we also have a special variant of the scalar form here to
1273/// represent the associated intrinsic operation. This form is unlike the
1274/// plain scalar form, in that it takes an entire vector (instead of a scalar)
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001275/// and leaves the top elements unmodified (therefore these cannot be commuted).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276///
1277/// These three forms can each be reg+reg or reg+mem, so there are a total of
1278/// six "instructions".
1279///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001280let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1282 SDNode OpNode, Intrinsic F64Int,
1283 bit Commutable = 0> {
1284 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001285 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001286 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1288 let isCommutable = Commutable;
1289 }
1290
1291 // Scalar operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001292 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1293 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001294 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001296
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297 // Vector operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001298 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1299 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001300 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1302 let isCommutable = Commutable;
1303 }
1304
1305 // Vector operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001306 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1307 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001308 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf221da12009-01-09 02:27:34 +00001309 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001310
1311 // Intrinsic operation, reg+reg.
Dan Gohmanf221da12009-01-09 02:27:34 +00001312 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1313 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001314 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng5d5dbbc2009-02-26 03:12:02 +00001315 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316
1317 // Intrinsic operation, reg+mem.
Dan Gohmanf221da12009-01-09 02:27:34 +00001318 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1319 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001320 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321 [(set VR128:$dst, (F64Int VR128:$src1,
1322 sse_load_f64:$src2))]>;
1323}
1324}
1325
1326// Arithmetic instructions
1327defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1328defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1329defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1330defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1331
1332/// sse2_fp_binop_rm - Other SSE2 binops
1333///
1334/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1335/// instructions for a full-vector intrinsic form. Operations that map
1336/// onto C operators don't use this form since they just use the plain
1337/// vector form instead of having a separate vector intrinsic form.
1338///
1339/// This provides a total of eight "instructions".
1340///
Evan Cheng3ea4d672008-03-05 08:19:16 +00001341let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1343 SDNode OpNode,
1344 Intrinsic F64Int,
1345 Intrinsic V2F64Int,
1346 bit Commutable = 0> {
1347
1348 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001349 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001350 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1352 let isCommutable = Commutable;
1353 }
1354
1355 // Scalar operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001356 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
1357 (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001358 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001360
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361 // Vector operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001362 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1363 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001364 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1366 let isCommutable = Commutable;
1367 }
1368
1369 // Vector operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001370 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1371 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001372 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001373 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374
1375 // Intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001376 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst),
1377 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001378 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001379 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1380 let isCommutable = Commutable;
1381 }
1382
1383 // Intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001384 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst),
1385 (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001386 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387 [(set VR128:$dst, (F64Int VR128:$src1,
1388 sse_load_f64:$src2))]>;
1389
1390 // Vector intrinsic operation, reg+reg.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001391 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1392 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001393 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001394 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1395 let isCommutable = Commutable;
1396 }
1397
1398 // Vector intrinsic operation, reg+mem.
Evan Cheng00b66ef2008-05-23 00:37:07 +00001399 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1400 (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001401 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001402 [(set VR128:$dst, (V2F64Int VR128:$src1,
1403 (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404}
1405}
1406
1407defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1408 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1409defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1410 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1411
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001412//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413// SSE packed FP Instructions
1414
1415// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001416let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001417def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001418 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001419let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001420def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001421 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001422 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001423
Evan Chengb783fa32007-07-19 01:14:50 +00001424def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001426 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001427
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001428let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001429def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001430 "movupd\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001431let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001432def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001433 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001434 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001435def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001436 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001437 [(store (v2f64 VR128:$src), addr:$dst)]>;
1438
1439// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001440def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001441 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001442 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001443def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001444 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001445 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446
Evan Cheng3ea4d672008-03-05 08:19:16 +00001447let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001448 let AddedComplexity = 20 in {
1449 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001450 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001451 "movlpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001452 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001453 (v2f64 (movlp VR128:$src1,
1454 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001456 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001457 "movhpd\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001458 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001459 (v2f64 (movhp VR128:$src1,
1460 (scalar_to_vector (loadf64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001462} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463
Evan Chengb783fa32007-07-19 01:14:50 +00001464def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001465 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001466 [(store (f64 (vector_extract (v2f64 VR128:$src),
1467 (iPTR 0))), addr:$dst)]>;
1468
1469// v2f64 extract element 1 is always custom lowered to unpack high to low
1470// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001471def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001472 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473 [(store (f64 (vector_extract
Nate Begeman543d2142009-04-27 18:41:29 +00001474 (v2f64 (unpckh VR128:$src, (undef))),
1475 (iPTR 0))), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476
1477// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001478def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001480 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1481 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001482def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001483 "cvtdq2ps\t{$src, $dst|$dst, $src}",
1484 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
1485 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486 TB, Requires<[HasSSE2]>;
1487
1488// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001489def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001490 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001491 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1492 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001493def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001494 "cvtdq2pd\t{$src, $dst|$dst, $src}",
1495 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
1496 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001497 XS, Requires<[HasSSE2]>;
1498
Evan Chengb783fa32007-07-19 01:14:50 +00001499def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Evan Cheng14c97c32008-03-14 07:46:48 +00001500 "cvtps2dq\t{$src, $dst|$dst, $src}",
1501 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001502def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001505 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001506// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001507def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001508 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001509 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1510 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001511def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001512 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001513 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001514 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001515 XS, Requires<[HasSSE2]>;
1516
1517// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001518def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001520 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1521 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001522def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001523 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001525 (memop addr:$src)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526 XD, Requires<[HasSSE2]>;
1527
Evan Chengb783fa32007-07-19 01:14:50 +00001528def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001529 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Cheng14c97c32008-03-14 07:46:48 +00001531def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001532 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
Evan Cheng00b66ef2008-05-23 00:37:07 +00001534 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001535
1536// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001537def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001538 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001539 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1540 TB, Requires<[HasSSE2]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001541def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1544 (load addr:$src)))]>,
1545 TB, Requires<[HasSSE2]>;
1546
Evan Chengb783fa32007-07-19 01:14:50 +00001547def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Mon P Wangaa3f2662008-05-28 00:42:27 +00001550def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
Evan Cheng00b66ef2008-05-23 00:37:07 +00001553 (memop addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554
1555// Match intrinsics which expect XMM operand(s).
1556// Aliases for intrinsics
Evan Cheng3ea4d672008-03-05 08:19:16 +00001557let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001559 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001560 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1562 GR32:$src2))]>;
1563def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001564 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001565 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001566 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1567 (loadi32 addr:$src2)))]>;
1568def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001569 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001570 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1572 VR128:$src2))]>;
1573def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001574 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001576 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1577 (load addr:$src2)))]>;
1578def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001579 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1582 VR128:$src2))]>, XS,
1583 Requires<[HasSSE2]>;
1584def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001585 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001587 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1588 (load addr:$src2)))]>, XS,
1589 Requires<[HasSSE2]>;
1590}
1591
1592// Arithmetic
1593
1594/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1595///
1596/// In addition, we also have a special variant of the scalar form here to
1597/// represent the associated intrinsic operation. This form is unlike the
1598/// plain scalar form, in that it takes an entire vector (instead of a
1599/// scalar) and leaves the top elements undefined.
1600///
1601/// And, we have a special variant form for a full-vector intrinsic form.
1602///
1603/// These four forms can each have a reg or a mem operand, so there are a
1604/// total of eight "instructions".
1605///
1606multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1607 SDNode OpNode,
1608 Intrinsic F64Int,
1609 Intrinsic V2F64Int,
1610 bit Commutable = 0> {
1611 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001612 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614 [(set FR64:$dst, (OpNode FR64:$src))]> {
1615 let isCommutable = Commutable;
1616 }
1617
1618 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001619 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001620 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001622
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001624 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001625 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1627 let isCommutable = Commutable;
1628 }
1629
1630 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001631 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001632 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001633 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634
1635 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001636 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001637 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001638 [(set VR128:$dst, (F64Int VR128:$src))]> {
1639 let isCommutable = Commutable;
1640 }
1641
1642 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001643 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001644 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1646
1647 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001648 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001649 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1651 let isCommutable = Commutable;
1652 }
1653
1654 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001655 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001656 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00001657 [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001658}
1659
1660// Square root.
1661defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1662 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1663
1664// There is no f64 version of the reciprocal approximation instructions.
1665
1666// Logical
Evan Cheng3ea4d672008-03-05 08:19:16 +00001667let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001668 let isCommutable = 1 in {
1669 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001670 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672 [(set VR128:$dst,
1673 (and (bc_v2i64 (v2f64 VR128:$src1)),
1674 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1675 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001676 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678 [(set VR128:$dst,
1679 (or (bc_v2i64 (v2f64 VR128:$src1)),
1680 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1681 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001682 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684 [(set VR128:$dst,
1685 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1686 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1687 }
1688
1689 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001690 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001691 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 [(set VR128:$dst,
1693 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001694 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001695 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001696 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698 [(set VR128:$dst,
1699 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001700 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001702 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001704 [(set VR128:$dst,
1705 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001706 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001708 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001710 [(set VR128:$dst,
1711 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1712 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1713 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001714 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001715 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716 [(set VR128:$dst,
1717 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001718 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001719}
1720
Evan Cheng3ea4d672008-03-05 08:19:16 +00001721let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001722 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001723 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
1724 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1725 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Nate Begeman061db5f2008-05-12 20:34:32 +00001726 VR128:$src, imm:$cc))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001727 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Cheng14c97c32008-03-14 07:46:48 +00001728 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
1729 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
1730 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00001731 (memop addr:$src), imm:$cc))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732}
Evan Cheng33754092008-08-05 22:19:15 +00001733def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001734 (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>;
Evan Cheng33754092008-08-05 22:19:15 +00001735def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)),
Nate Begeman03605a02008-07-17 16:51:19 +00001736 (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737
1738// Shuffle and unpack instructions
Evan Cheng3ea4d672008-03-05 08:19:16 +00001739let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001740 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Cheng14c97c32008-03-14 07:46:48 +00001741 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
1742 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begeman543d2142009-04-27 18:41:29 +00001743 [(set VR128:$dst,
1744 (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001745 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001746 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001749 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001750 (v2f64 (shufp:$src3
1751 VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752
1753 let AddedComplexity = 10 in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001754 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001755 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001758 (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001759 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001760 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001763 (v2f64 (unpckh VR128:$src1,
1764 (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001765
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001766 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001767 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001769 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001770 (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001771 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001772 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00001775 (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776 } // AddedComplexity
Evan Cheng3ea4d672008-03-05 08:19:16 +00001777} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778
1779
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001780//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781// SSE integer instructions
1782
1783// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001784let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001785def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "movdqa\t{$src, $dst|$dst, $src}", []>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001787let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001788def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001790 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001791let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001792def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001793 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001794 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Dan Gohman5574cc72008-12-03 18:15:48 +00001795let canFoldAsLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001796def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001798 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799 XS, Requires<[HasSSE2]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001800let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001801def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001802 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001803 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001804 XS, Requires<[HasSSE2]>;
1805
Dan Gohman4a4f1512007-07-18 20:23:34 +00001806// Intrinsic forms of MOVDQU load and store
Dan Gohman5574cc72008-12-03 18:15:48 +00001807let canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001808def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001810 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1811 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001812def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001814 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1815 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816
Evan Cheng88004752008-03-05 08:11:27 +00001817let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818
1819multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1820 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001821 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1824 let isCommutable = Commutable;
1825 }
Evan Chengb783fa32007-07-19 01:14:50 +00001826 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001827 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001828 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001829 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830}
1831
Evan Chengf90f8f82008-05-03 00:52:09 +00001832multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1833 string OpcodeStr,
1834 Intrinsic IntId, Intrinsic IntId2> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001835 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1836 VR128:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001837 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1838 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001839 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1840 i128mem:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001841 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1842 [(set VR128:$dst, (IntId VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001843 (bitconvert (memopv2i64 addr:$src2))))]>;
1844 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1,
1845 i32i8imm:$src2),
Evan Chengf90f8f82008-05-03 00:52:09 +00001846 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
1847 [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>;
1848}
1849
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001850/// PDI_binop_rm - Simple SSE2 binary operator.
1851multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1852 ValueType OpVT, bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001853 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1,
1854 VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001855 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001856 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1857 let isCommutable = Commutable;
1858 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001859 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1,
1860 i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001863 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864}
1865
1866/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1867///
1868/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1869/// to collapse (bitconvert VT to VT) into its operand.
1870///
1871multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1872 bit Commutable = 0> {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001873 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst),
1874 (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1877 let isCommutable = Commutable;
1878 }
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001879 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst),
1880 (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001881 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00001882 [(set VR128:$dst, (OpNode VR128:$src1,
1883 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001884}
1885
Evan Cheng3ea4d672008-03-05 08:19:16 +00001886} // Constraints = "$src1 = $dst"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001887
1888// 128-bit Integer Arithmetic
1889
1890defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1891defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1892defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1893defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1894
1895defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1896defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1897defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1898defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1899
1900defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1901defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1902defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1903defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1904
1905defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1906defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1907defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1908defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1909
1910defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1911
1912defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1913defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1914defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1915
1916defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1917
1918defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1919defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1920
1921
1922defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1923defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1924defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1925defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
Bill Wendling953ad2e2009-05-28 02:04:00 +00001926defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927
1928
Evan Chengf90f8f82008-05-03 00:52:09 +00001929defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
1930 int_x86_sse2_psll_w, int_x86_sse2_pslli_w>;
1931defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
1932 int_x86_sse2_psll_d, int_x86_sse2_pslli_d>;
1933defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
1934 int_x86_sse2_psll_q, int_x86_sse2_pslli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001935
Evan Chengf90f8f82008-05-03 00:52:09 +00001936defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
1937 int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>;
1938defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
1939 int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>;
Nate Begemanc2ca5f62008-05-13 17:52:09 +00001940defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
Evan Chengf90f8f82008-05-03 00:52:09 +00001941 int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942
Evan Chengf90f8f82008-05-03 00:52:09 +00001943defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
1944 int_x86_sse2_psra_w, int_x86_sse2_psrai_w>;
Nate Begemand66fc342008-05-13 01:47:52 +00001945defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
Evan Chengf90f8f82008-05-03 00:52:09 +00001946 int_x86_sse2_psra_d, int_x86_sse2_psrai_d>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947
1948// 128-bit logical shifts.
Evan Cheng3ea4d672008-03-05 08:19:16 +00001949let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001951 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001953 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001954 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 // PSRADQri doesn't exist in SSE[1-3].
1957}
1958
1959let Predicates = [HasSSE2] in {
1960 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1961 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1962 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1963 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
Bill Wendling314ee052008-10-02 05:56:52 +00001964 def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2),
1965 (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>;
1966 def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2),
1967 (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1969 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
Evan Chengdea99362008-05-29 08:22:04 +00001970
1971 // Shift up / down and insert zero's.
1972 def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))),
1973 (v2i64 (PSLLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
1974 def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))),
1975 (v2i64 (PSRLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976}
1977
1978// Logical
1979defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1980defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1981defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1982
Evan Cheng3ea4d672008-03-05 08:19:16 +00001983let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001985 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001986 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001987 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1988 VR128:$src2)))]>;
1989
1990 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001991 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001992 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00001994 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001995}
1996
1997// SSE2 Integer comparison
1998defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1999defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
2000defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
2001defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
2002defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
2003defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
2004
Nate Begeman03605a02008-07-17 16:51:19 +00002005def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002006 (PCMPEQBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002007def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002008 (PCMPEQBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002009def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002010 (PCMPEQWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002011def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002012 (PCMPEQWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002013def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002014 (PCMPEQDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002015def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002016 (PCMPEQDrm VR128:$src1, addr:$src2)>;
2017
Nate Begeman03605a02008-07-17 16:51:19 +00002018def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002019 (PCMPGTBrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002020def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002021 (PCMPGTBrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002022def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002023 (PCMPGTWrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002024def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002025 (PCMPGTWrm VR128:$src1, addr:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002026def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002027 (PCMPGTDrr VR128:$src1, VR128:$src2)>;
Nate Begeman03605a02008-07-17 16:51:19 +00002028def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))),
Nate Begeman78ca4f92008-05-12 23:09:43 +00002029 (PCMPGTDrm VR128:$src1, addr:$src2)>;
2030
2031
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002032// Pack instructions
2033defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
2034defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
2035defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
2036
2037// Shuffle and unpack instructions
2038def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002039 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002041 [(set VR128:$dst, (v4i32 (pshufd:$src2
2042 VR128:$src1, (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002044 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002046 [(set VR128:$dst, (v4i32 (pshufd:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002047 (bc_v4i32(memopv2i64 addr:$src1)),
2048 (undef))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049
2050// SSE2 with ImmT == Imm8 and XS prefix.
2051def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002052 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002053 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002054 [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1,
2055 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002056 XS, Requires<[HasSSE2]>;
2057def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002058 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002059 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002060 [(set VR128:$dst, (v8i16 (pshufhw:$src2
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002061 (bc_v8i16 (memopv2i64 addr:$src1)),
2062 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002063 XS, Requires<[HasSSE2]>;
2064
2065// SSE2 with ImmT == Imm8 and XD prefix.
2066def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Nate Begeman543d2142009-04-27 18:41:29 +00002067 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002068 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002069 [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1,
2070 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 XD, Requires<[HasSSE2]>;
2072def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Nate Begeman543d2142009-04-27 18:41:29 +00002073 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Nate Begeman543d2142009-04-27 18:41:29 +00002075 [(set VR128:$dst, (v8i16 (pshuflw:$src2
2076 (bc_v8i16 (memopv2i64 addr:$src1)),
2077 (undef))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078 XD, Requires<[HasSSE2]>;
2079
2080
Evan Cheng3ea4d672008-03-05 08:19:16 +00002081let Constraints = "$src1 = $dst" in {
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002082 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002083 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002086 (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002087 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002088 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002089 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002090 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002091 (unpckl VR128:$src1,
2092 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002093 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002094 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002095 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002097 (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002098 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002099 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002100 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002101 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002102 (unpckl VR128:$src1,
2103 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002104 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002105 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002106 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002108 (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002109 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002110 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002113 (unpckl VR128:$src1,
2114 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002115 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002116 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002117 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002119 (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002120 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002121 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002124 (v2i64 (unpckl VR128:$src1,
2125 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002126
2127 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002128 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002129 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002131 (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002132 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002133 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002134 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002135 [(set VR128:$dst,
2136 (unpckh VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002137 (bc_v16i8 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002138 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002139 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002142 (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002143 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002144 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002146 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002147 (unpckh VR128:$src1,
2148 (bc_v8i16 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002149 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002150 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002153 (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002154 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002155 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002156 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002157 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002158 (unpckh VR128:$src1,
2159 (bc_v4i32 (memopv2i64 addr:$src2))))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002160 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002161 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002162 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002164 (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002165 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002166 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002169 (v2i64 (unpckh VR128:$src1,
2170 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171}
2172
2173// Extract / Insert
2174def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002175 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002176 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002177 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begemand77e59e2008-02-11 04:19:36 +00002178 imm:$src2))]>;
Evan Cheng3ea4d672008-03-05 08:19:16 +00002179let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002180 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002181 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002183 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002185 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002187 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002190 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002191 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2192 imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193}
2194
2195// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002196def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002197 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2199
2200// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002201let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002202def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002204 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205
Evan Cheng430de082009-02-10 22:06:28 +00002206let Uses = [RDI] in
2207def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
2208 "maskmovdqu\t{$mask, $src|$src, $mask}",
2209 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>;
2210
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002212def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002215def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002216 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002218def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002219 "movnti\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002220 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002221 TB, Requires<[HasSSE2]>;
2222
2223// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002224def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 TB, Requires<[HasSSE2]>;
2227
2228// Load, store, and memory fence
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002229def LFENCE : I<0xAE, MRM5r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Cheng5d0d34e2008-10-17 17:14:20 +00002231def MFENCE : I<0xAE, MRM6r, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002232 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2233
Andrew Lenharth785610d2008-02-16 01:24:58 +00002234//TODO: custom lower this so as to never even generate the noop
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002235def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002236 (i8 0)), (NOOP)>;
2237def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2238def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002239def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
Andrew Lenharth785610d2008-02-16 01:24:58 +00002240 (i8 1)), (MFENCE)>;
2241
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohman5574cc72008-12-03 18:15:48 +00002243// We set canFoldAsLoad because this can be converted to a constant-pool
Dan Gohman37eb6c82008-12-03 05:21:24 +00002244// load of an all-ones value if folding it would be beneficial.
Dan Gohman5574cc72008-12-03 18:15:48 +00002245let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002246 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002247 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002248 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002249
2250// FR64 to 128-bit vector conversion.
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002251let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002252def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002253 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254 [(set VR128:$dst,
2255 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002256def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "movsd\t{$src, $dst|$dst, $src}",
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002258 [(set VR128:$dst,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2260
Evan Chengb783fa32007-07-19 01:14:50 +00002261def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002262 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263 [(set VR128:$dst,
2264 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002265def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002266 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267 [(set VR128:$dst,
2268 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2269
Evan Chengb783fa32007-07-19 01:14:50 +00002270def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002271 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002272 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2273
Evan Chengb783fa32007-07-19 01:14:50 +00002274def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002275 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002276 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2277
2278// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002279def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002280 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002281 [(set VR128:$dst,
2282 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2283 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002284def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002286 [(store (i64 (vector_extract (v2i64 VR128:$src),
2287 (iPTR 0))), addr:$dst)]>;
2288
2289// FIXME: may not be able to eliminate this movss with coalescing the src and
2290// dest register classes are different. We really want to write this pattern
2291// like this:
2292// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2293// (f32 FR32:$src)>;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002294let isAsCheapAsAMove = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002295def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002296 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002297 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2298 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002299def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002300 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002301 [(store (f64 (vector_extract (v2f64 VR128:$src),
2302 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002303def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002304 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002305 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2306 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002307def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002308 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002309 [(store (i32 (vector_extract (v4i32 VR128:$src),
2310 (iPTR 0))), addr:$dst)]>;
2311
Evan Chengb783fa32007-07-19 01:14:50 +00002312def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002313 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002314 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002315def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2318
2319
2320// Move to lower bits of a VR128, leaving upper bits alone.
2321// Three operand (but two address) aliases.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002322let Constraints = "$src1 = $dst" in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00002323 let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002324 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002325 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327
2328 let AddedComplexity = 15 in
2329 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002330 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002331 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002332 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002333 (v2f64 (movl VR128:$src1, VR128:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002334}
2335
2336// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002337def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002338 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002339 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2340
2341// Move to lower bits of a VR128 and zeroing upper bits.
2342// Loading from memory automatically zeroing upper bits.
Evan Chengd743a5f2008-05-10 00:59:18 +00002343let AddedComplexity = 20 in {
2344def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
2345 "movsd\t{$src, $dst|$dst, $src}",
2346 [(set VR128:$dst,
2347 (v2f64 (X86vzmovl (v2f64 (scalar_to_vector
2348 (loadf64 addr:$src))))))]>;
Evan Cheng40ee6e52008-05-08 00:57:18 +00002349
Evan Cheng056afe12008-05-20 18:24:47 +00002350def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))),
2351 (MOVZSD2PDrm addr:$src)>;
2352def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))),
Evan Chengd743a5f2008-05-10 00:59:18 +00002353 (MOVZSD2PDrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002354def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002355}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002357// movd / movq to XMM register zero-extends
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002358let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002359def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002360 "movd\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002361 [(set VR128:$dst, (v4i32 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002362 (v4i32 (scalar_to_vector GR32:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002363// This is X86-64 only.
2364def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2365 "mov{d|q}\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002366 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng40ee6e52008-05-08 00:57:18 +00002367 (v2i64 (scalar_to_vector GR64:$src)))))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002368}
2369
2370let AddedComplexity = 20 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002371def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002372 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002373 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002374 (v4i32 (X86vzmovl (v4i32 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002375 (loadi32 addr:$src))))))]>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002376
2377def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))),
2378 (MOVZDI2PDIrm addr:$src)>;
2379def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))),
2380 (MOVZDI2PDIrm addr:$src)>;
Duncan Sands2418bec2008-06-13 19:07:40 +00002381def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))),
2382 (MOVZDI2PDIrm addr:$src)>;
Evan Cheng3ad16c42008-05-22 18:56:56 +00002383
Evan Chengb783fa32007-07-19 01:14:50 +00002384def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002385 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002386 [(set VR128:$dst,
Evan Chenge9b9c672008-05-09 21:53:03 +00002387 (v2i64 (X86vzmovl (v2i64 (scalar_to_vector
Evan Cheng40ee6e52008-05-08 00:57:18 +00002388 (loadi64 addr:$src))))))]>, XS,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002389 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002390
Evan Cheng3ad16c42008-05-22 18:56:56 +00002391def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))),
2392 (MOVZQI2PQIrm addr:$src)>;
2393def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))),
2394 (MOVZQI2PQIrm addr:$src)>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002395def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>;
Evan Chengd743a5f2008-05-10 00:59:18 +00002396}
Evan Chenge9b9c672008-05-09 21:53:03 +00002397
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002398// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2399// IA32 document. movq xmm1, xmm2 does clear the high bits.
2400let AddedComplexity = 15 in
2401def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2402 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002403 [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002404 XS, Requires<[HasSSE2]>;
2405
Evan Cheng056afe12008-05-20 18:24:47 +00002406let AddedComplexity = 20 in {
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002407def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2408 "movq\t{$src, $dst|$dst, $src}",
Evan Chenge9b9c672008-05-09 21:53:03 +00002409 [(set VR128:$dst, (v2i64 (X86vzmovl
Evan Cheng056afe12008-05-20 18:24:47 +00002410 (loadv2i64 addr:$src))))]>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002411 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002412
Evan Cheng056afe12008-05-20 18:24:47 +00002413def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))),
2414 (MOVZPQILo2PQIrm addr:$src)>;
2415}
2416
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002417//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418// SSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002419//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002420
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002421// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002422def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002423 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002424 [(set VR128:$dst, (v4f32 (movshdup
2425 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002426def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002427 "movshdup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002428 [(set VR128:$dst, (movshdup
2429 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002430
Evan Chengb783fa32007-07-19 01:14:50 +00002431def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002432 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002433 [(set VR128:$dst, (v4f32 (movsldup
2434 VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002435def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002436 "movsldup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002437 [(set VR128:$dst, (movsldup
2438 (memopv4f32 addr:$src), (undef)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002439
Evan Chengb783fa32007-07-19 01:14:50 +00002440def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002441 "movddup\t{$src, $dst|$dst, $src}",
Nate Begeman543d2142009-04-27 18:41:29 +00002442 [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002443def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002444 "movddup\t{$src, $dst|$dst, $src}",
Evan Chenga2497eb2008-09-25 20:50:48 +00002445 [(set VR128:$dst,
Nate Begeman543d2142009-04-27 18:41:29 +00002446 (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)),
2447 (undef))))]>;
Evan Chenga2497eb2008-09-25 20:50:48 +00002448
Nate Begeman543d2142009-04-27 18:41:29 +00002449def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))),
2450 (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002451 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002452
2453let AddedComplexity = 5 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002454def : Pat<(movddup (memopv2f64 addr:$src), (undef)),
Evan Chenga2497eb2008-09-25 20:50:48 +00002455 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
Nate Begemanb44aad72009-04-29 22:47:44 +00002456def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)),
2457 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2458def : Pat<(movddup (memopv2i64 addr:$src), (undef)),
2459 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2460def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)),
2461 (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>;
2462}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002463
2464// Arithmetic
Evan Cheng3ea4d672008-03-05 08:19:16 +00002465let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002466 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002467 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002468 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002469 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2470 VR128:$src2))]>;
2471 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002472 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002473 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002474 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002475 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002476 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002477 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002478 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002479 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2480 VR128:$src2))]>;
2481 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002482 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002483 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002484 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
Evan Cheng00b66ef2008-05-23 00:37:07 +00002485 (memop addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002486}
2487
Evan Chengb783fa32007-07-19 01:14:50 +00002488def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002489 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002490 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2491
2492// Horizontal ops
2493class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002494 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002495 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002496 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2497class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002498 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002499 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002500 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002501class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002502 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002503 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2505class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002506 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002507 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00002508 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002509
Evan Cheng3ea4d672008-03-05 08:19:16 +00002510let Constraints = "$src1 = $dst" in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002511 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2512 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2513 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2514 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2515 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2516 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2517 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2518 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2519}
2520
2521// Thread synchronization
Bill Wendling6ee76552009-05-28 23:40:46 +00002522def MONITOR : I<0x01, MRM1r, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002523 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Bill Wendling6ee76552009-05-28 23:40:46 +00002524def MWAIT : I<0x01, MRM1r, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002525 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2526
2527// vector_shuffle v1, <undef> <1, 1, 3, 3>
2528let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002529def : Pat<(v4i32 (movshdup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002530 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2531let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002532def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002533 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2534
2535// vector_shuffle v1, <undef> <0, 0, 2, 2>
2536let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00002537 def : Pat<(v4i32 (movsldup VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002538 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2539let AddedComplexity = 20 in
Nate Begeman543d2142009-04-27 18:41:29 +00002540 def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002541 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2542
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002543//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002544// SSSE3 Instructions
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002545//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002546
Bill Wendling98680292007-08-10 06:22:27 +00002547/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002548multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2549 Intrinsic IntId64, Intrinsic IntId128> {
2550 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2551 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2552 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002553
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002554 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2555 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2556 [(set VR64:$dst,
2557 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2558
2559 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2560 (ins VR128:$src),
2561 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2562 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2563 OpSize;
2564
2565 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2566 (ins i128mem:$src),
2567 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2568 [(set VR128:$dst,
2569 (IntId128
2570 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002571}
2572
Bill Wendling98680292007-08-10 06:22:27 +00002573/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002574multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2575 Intrinsic IntId64, Intrinsic IntId128> {
2576 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2577 (ins VR64:$src),
2578 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2579 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002580
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002581 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2582 (ins i64mem:$src),
2583 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2584 [(set VR64:$dst,
2585 (IntId64
2586 (bitconvert (memopv4i16 addr:$src))))]>;
2587
2588 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2589 (ins VR128:$src),
2590 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2591 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2592 OpSize;
2593
2594 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2595 (ins i128mem:$src),
2596 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2597 [(set VR128:$dst,
2598 (IntId128
2599 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002600}
2601
2602/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002603multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2604 Intrinsic IntId64, Intrinsic IntId128> {
2605 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2606 (ins VR64:$src),
2607 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2608 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002609
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002610 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2611 (ins i64mem:$src),
2612 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2613 [(set VR64:$dst,
2614 (IntId64
2615 (bitconvert (memopv2i32 addr:$src))))]>;
2616
2617 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2618 (ins VR128:$src),
2619 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2620 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2621 OpSize;
2622
2623 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2624 (ins i128mem:$src),
2625 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2626 [(set VR128:$dst,
2627 (IntId128
2628 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002629}
2630
2631defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2632 int_x86_ssse3_pabs_b,
2633 int_x86_ssse3_pabs_b_128>;
2634defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2635 int_x86_ssse3_pabs_w,
2636 int_x86_ssse3_pabs_w_128>;
2637defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2638 int_x86_ssse3_pabs_d,
2639 int_x86_ssse3_pabs_d_128>;
2640
2641/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002642let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002643 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2644 Intrinsic IntId64, Intrinsic IntId128,
2645 bit Commutable = 0> {
2646 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2647 (ins VR64:$src1, VR64:$src2),
2648 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2649 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2650 let isCommutable = Commutable;
2651 }
2652 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2653 (ins VR64:$src1, i64mem:$src2),
2654 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2655 [(set VR64:$dst,
2656 (IntId64 VR64:$src1,
2657 (bitconvert (memopv8i8 addr:$src2))))]>;
2658
2659 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2660 (ins VR128:$src1, VR128:$src2),
2661 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2662 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2663 OpSize {
2664 let isCommutable = Commutable;
2665 }
2666 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2667 (ins VR128:$src1, i128mem:$src2),
2668 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2669 [(set VR128:$dst,
2670 (IntId128 VR128:$src1,
2671 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2672 }
2673}
2674
2675/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002676let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002677 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2678 Intrinsic IntId64, Intrinsic IntId128,
2679 bit Commutable = 0> {
2680 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2681 (ins VR64:$src1, VR64:$src2),
2682 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2683 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2684 let isCommutable = Commutable;
2685 }
2686 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2687 (ins VR64:$src1, i64mem:$src2),
2688 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2689 [(set VR64:$dst,
2690 (IntId64 VR64:$src1,
2691 (bitconvert (memopv4i16 addr:$src2))))]>;
2692
2693 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2694 (ins VR128:$src1, VR128:$src2),
2695 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2696 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2697 OpSize {
2698 let isCommutable = Commutable;
2699 }
2700 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2701 (ins VR128:$src1, i128mem:$src2),
2702 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2703 [(set VR128:$dst,
2704 (IntId128 VR128:$src1,
2705 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2706 }
2707}
2708
2709/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
Evan Cheng3ea4d672008-03-05 08:19:16 +00002710let Constraints = "$src1 = $dst" in {
Bill Wendling98680292007-08-10 06:22:27 +00002711 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2712 Intrinsic IntId64, Intrinsic IntId128,
2713 bit Commutable = 0> {
2714 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2715 (ins VR64:$src1, VR64:$src2),
2716 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2717 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2718 let isCommutable = Commutable;
2719 }
2720 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2721 (ins VR64:$src1, i64mem:$src2),
2722 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2723 [(set VR64:$dst,
2724 (IntId64 VR64:$src1,
2725 (bitconvert (memopv2i32 addr:$src2))))]>;
2726
2727 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2728 (ins VR128:$src1, VR128:$src2),
2729 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2730 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2731 OpSize {
2732 let isCommutable = Commutable;
2733 }
2734 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2735 (ins VR128:$src1, i128mem:$src2),
2736 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2737 [(set VR128:$dst,
2738 (IntId128 VR128:$src1,
2739 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2740 }
2741}
2742
2743defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2744 int_x86_ssse3_phadd_w,
Evan Cheng944e4412008-06-16 21:16:24 +00002745 int_x86_ssse3_phadd_w_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002746defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2747 int_x86_ssse3_phadd_d,
Evan Cheng944e4412008-06-16 21:16:24 +00002748 int_x86_ssse3_phadd_d_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002749defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2750 int_x86_ssse3_phadd_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002751 int_x86_ssse3_phadd_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002752defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2753 int_x86_ssse3_phsub_w,
2754 int_x86_ssse3_phsub_w_128>;
2755defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2756 int_x86_ssse3_phsub_d,
2757 int_x86_ssse3_phsub_d_128>;
2758defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2759 int_x86_ssse3_phsub_sw,
2760 int_x86_ssse3_phsub_sw_128>;
2761defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2762 int_x86_ssse3_pmadd_ub_sw,
Evan Cheng944e4412008-06-16 21:16:24 +00002763 int_x86_ssse3_pmadd_ub_sw_128>;
Bill Wendling98680292007-08-10 06:22:27 +00002764defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2765 int_x86_ssse3_pmul_hr_sw,
2766 int_x86_ssse3_pmul_hr_sw_128, 1>;
2767defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2768 int_x86_ssse3_pshuf_b,
2769 int_x86_ssse3_pshuf_b_128>;
2770defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2771 int_x86_ssse3_psign_b,
2772 int_x86_ssse3_psign_b_128>;
2773defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2774 int_x86_ssse3_psign_w,
2775 int_x86_ssse3_psign_w_128>;
Evan Chengabfed472009-05-28 18:48:53 +00002776defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd",
Bill Wendling98680292007-08-10 06:22:27 +00002777 int_x86_ssse3_psign_d,
2778 int_x86_ssse3_psign_d_128>;
2779
Evan Cheng3ea4d672008-03-05 08:19:16 +00002780let Constraints = "$src1 = $dst" in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002781 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2782 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002783 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002784 [(set VR64:$dst,
2785 (int_x86_ssse3_palign_r
2786 VR64:$src1, VR64:$src2,
2787 imm:$src3))]>;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002788 def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
Bill Wendling1dc817c2007-08-10 09:00:17 +00002789 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002790 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002791 [(set VR64:$dst,
2792 (int_x86_ssse3_palign_r
2793 VR64:$src1,
2794 (bitconvert (memopv2i32 addr:$src2)),
2795 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002796
Bill Wendling1dc817c2007-08-10 09:00:17 +00002797 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2798 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002799 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002800 [(set VR128:$dst,
2801 (int_x86_ssse3_palign_r_128
2802 VR128:$src1, VR128:$src2,
2803 imm:$src3))]>, OpSize;
Dan Gohmanbcb9d462008-05-28 01:50:19 +00002804 def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst),
Bill Wendling1dc817c2007-08-10 09:00:17 +00002805 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002806 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002807 [(set VR128:$dst,
2808 (int_x86_ssse3_palign_r_128
2809 VR128:$src1,
2810 (bitconvert (memopv4i32 addr:$src2)),
2811 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002812}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002813
Nate Begeman2c87c422009-02-23 08:49:38 +00002814def : Pat<(X86pshufb VR128:$src, VR128:$mask),
2815 (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>;
2816def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))),
2817 (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>;
2818
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002819//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002820// Non-Instruction Patterns
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002821//===---------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002822
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002823// extload f32 -> f64. This matches load+fextend because we have a hack in
2824// the isel (PreprocessForFPConvert) that can introduce loads after dag
2825// combine.
Chris Lattnerdec9cb52008-01-24 08:07:48 +00002826// Since these loads aren't folded into the fextend, we have to match it
2827// explicitly here.
2828let Predicates = [HasSSE2] in
2829 def : Pat<(fextend (loadf32 addr:$src)),
2830 (CVTSS2SDrm addr:$src)>;
2831
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002832// bit_convert
2833let Predicates = [HasSSE2] in {
2834 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2835 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2836 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2837 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2838 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2839 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2840 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2841 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2842 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2843 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2844 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2845 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2846 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2847 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2848 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2849 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2850 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2851 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2852 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2853 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2854 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2855 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2856 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2857 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2858 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2859 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2860 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2861 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2862 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2863 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2864}
2865
2866// Move scalar to XMM zero-extended
2867// movd to XMM register zero-extends
2868let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002869// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Evan Chenge9b9c672008-05-09 21:53:03 +00002870def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002871 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00002872def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002873 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>;
Evan Chenge259e872008-05-09 23:37:55 +00002874def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002875 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Evan Cheng7fe0ff02008-07-10 01:08:23 +00002876def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))),
Anders Carlssonfd7e4502008-10-07 16:14:11 +00002877 (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002878}
2879
2880// Splat v2f64 / v2i64
2881let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002882def : Pat<(splat_lo (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002884def : Pat<(unpckh (v2f64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002885 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002886def : Pat<(splat_lo (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002887 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002888def : Pat<(unpckh (v2i64 VR128:$src), (undef)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002889 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2890}
2891
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002892// Special unary SHUFPSrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00002893def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))),
2894 (SHUFPSrri VR128:$src1, VR128:$src1,
2895 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002896 Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002897let AddedComplexity = 5 in
2898def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))),
2899 (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
2900 Requires<[HasSSE2]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002901// Special unary SHUFPDrri case.
Nate Begeman543d2142009-04-27 18:41:29 +00002902def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002903 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002904 (SHUFFLE_get_shuf_imm VR128:$src3))>,
2905 Requires<[HasSSE2]>;
2906// Special unary SHUFPDrri case.
2907def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002908 (SHUFPDrri VR128:$src1, VR128:$src1,
Nate Begeman543d2142009-04-27 18:41:29 +00002909 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohman7dc19012007-08-02 21:17:01 +00002910 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Nate Begeman543d2142009-04-27 18:41:29 +00002912def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)),
2913 (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002914 Requires<[HasSSE2]>;
Evan Cheng13559d62008-09-26 23:41:32 +00002915
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002916// Special binary v4i32 shuffle cases with SHUFPS.
Nate Begeman543d2142009-04-27 18:41:29 +00002917def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002918 (SHUFPSrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002919 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002920 Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002921def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002922 (SHUFPSrmi VR128:$src1, addr:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002923 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002924 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002925// Special binary v2i64 shuffle cases using SHUFPDrri.
Nate Begeman543d2142009-04-27 18:41:29 +00002926def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00002927 (SHUFPDrri VR128:$src1, VR128:$src2,
Nate Begeman543d2142009-04-27 18:41:29 +00002928 (SHUFFLE_get_shuf_imm VR128:$src3))>,
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002929 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002930
2931// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00002932let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002933def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))),
2934 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002935 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002936def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))),
2937 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002938 Requires<[OptForSpeed, HasSSE2]>;
2939}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002940let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002941def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002942 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002943def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002944 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002945def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002946 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002947def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002948 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002949}
2950
2951// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
Evan Cheng13559d62008-09-26 23:41:32 +00002952let AddedComplexity = 15 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002953def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))),
2954 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002955 Requires<[OptForSpeed, HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002956def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))),
2957 (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>,
Evan Cheng13559d62008-09-26 23:41:32 +00002958 Requires<[OptForSpeed, HasSSE2]>;
2959}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002960let AddedComplexity = 10 in {
Nate Begeman543d2142009-04-27 18:41:29 +00002961def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002962 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002963def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002964 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002965def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002966 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002967def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))),
Evan Cheng09d45072008-09-26 21:26:30 +00002968 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002969}
2970
Evan Cheng13559d62008-09-26 23:41:32 +00002971let AddedComplexity = 20 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002972// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
Nate Begeman543d2142009-04-27 18:41:29 +00002973def : Pat<(v4i32 (movhp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002974 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2975
2976// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00002977def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002978 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2979
2980// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
Nate Begeman543d2142009-04-27 18:41:29 +00002981def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002982 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
Nate Begeman543d2142009-04-27 18:41:29 +00002983def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002984 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2985}
2986
2987let AddedComplexity = 20 in {
2988// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2989// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Nate Begeman543d2142009-04-27 18:41:29 +00002990def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002991 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002992def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002993 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002994def : Pat<(v4f32 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002995 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00002996def : Pat<(v2f64 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002997 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2998
Nate Begeman543d2142009-04-27 18:41:29 +00002999def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003000 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003001def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003002 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003003def : Pat<(v4i32 (movhp VR128:$src1, (load addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003004 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003005def : Pat<(v2i64 (movhp VR128:$src1, (load addr:$src2))),
Evan Cheng1ff2ea52008-05-23 18:00:18 +00003006 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003007}
3008
Evan Cheng2b2a7012008-05-23 21:23:16 +00003009// (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS
3010// (store (vector_shuffle (load addr), v2, <0, 1, 4, 5>), addr) using MOVHPS
Nate Begeman543d2142009-04-27 18:41:29 +00003011def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003012 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003013def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003014 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003015def : Pat<(store (v4f32 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003016 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003017def : Pat<(store (v2f64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003018 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3019
Nate Begeman543d2142009-04-27 18:41:29 +00003020def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3021 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003022 (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003023def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003024 (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003025def : Pat<(store (v4i32 (movhp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)),
3026 addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003027 (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003028def : Pat<(store (v2i64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1),
Evan Cheng2b2a7012008-05-23 21:23:16 +00003029 (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3030
3031
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003032let AddedComplexity = 15 in {
3033// Setting the lowest element in the vector.
Nate Begeman543d2142009-04-27 18:41:29 +00003034def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003035 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003036def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003037 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3038
3039// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
Nate Begeman543d2142009-04-27 18:41:29 +00003040def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003041 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
Nate Begeman543d2142009-04-27 18:41:29 +00003042def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003043 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3044}
3045
Eli Friedman27d19742009-06-19 07:00:55 +00003046// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but
3047// fall back to this for SSE1)
3048def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003049 (SHUFPSrri VR128:$src2, VR128:$src1,
Eli Friedman27d19742009-06-19 07:00:55 +00003050 (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>;
3051
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003052// Set lowest element and zero upper elements.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003053let AddedComplexity = 15 in
Nate Begeman543d2142009-04-27 18:41:29 +00003054def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)),
Evan Cheng15e8f5a2007-12-15 03:00:47 +00003055 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Evan Chenge9b9c672008-05-09 21:53:03 +00003056def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))),
Evan Chengd09a8a02008-05-08 22:35:02 +00003057 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003058
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003059// Some special case pandn patterns.
3060def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
3061 VR128:$src2)),
3062 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3063def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3064 VR128:$src2)),
3065 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3066def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3067 VR128:$src2)),
3068 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3069
3070def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003071 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003072 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3073def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003074 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003075 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3076def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003077 (memop addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003078 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3079
Nate Begeman78246ca2007-11-17 03:58:34 +00003080// vector -> vector casts
3081def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3082 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3083def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3084 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
Eli Friedman7fa52ca2008-09-05 23:07:03 +00003085def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))),
3086 (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>;
3087def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))),
3088 (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>;
Nate Begeman78246ca2007-11-17 03:58:34 +00003089
Evan Cheng51a49b22007-07-20 00:27:43 +00003090// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00003091def : Pat<(alignedloadv4i32 addr:$src),
3092 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3093def : Pat<(loadv4i32 addr:$src),
3094 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00003095def : Pat<(alignedloadv2i64 addr:$src),
3096 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3097def : Pat<(loadv2i64 addr:$src),
3098 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3099
3100def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3101 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3102def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3103 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3104def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3105 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3106def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3107 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3108def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3109 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3110def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3111 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3112def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3113 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3114def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3115 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003116
Nate Begemanb2975562008-02-03 07:18:54 +00003117//===----------------------------------------------------------------------===//
3118// SSE4.1 Instructions
3119//===----------------------------------------------------------------------===//
3120
Dale Johannesena7d2b442008-10-10 23:51:03 +00003121multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd,
Nate Begemanb2975562008-02-03 07:18:54 +00003122 string OpcodeStr,
Nate Begemanb2975562008-02-03 07:18:54 +00003123 Intrinsic V4F32Int,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003124 Intrinsic V2F64Int> {
Nate Begemanb2975562008-02-03 07:18:54 +00003125 // Intrinsic operation, reg.
Nate Begemanb2975562008-02-03 07:18:54 +00003126 // Vector intrinsic operation, reg
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003127 def PSr_Int : SS4AIi8<opcps, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003128 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003129 !strconcat(OpcodeStr,
3130 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003131 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3132 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003133
3134 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003135 def PSm_Int : SS4AIi8<opcps, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003136 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003137 !strconcat(OpcodeStr,
3138 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003139 [(set VR128:$dst,
3140 (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003141 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003142
Nate Begemanb2975562008-02-03 07:18:54 +00003143 // Vector intrinsic operation, reg
Evan Cheng78d00612008-03-14 07:39:27 +00003144 def PDr_Int : SS4AIi8<opcpd, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003145 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003146 !strconcat(OpcodeStr,
3147 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003148 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3149 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003150
3151 // Vector intrinsic operation, mem
Evan Cheng78d00612008-03-14 07:39:27 +00003152 def PDm_Int : SS4AIi8<opcpd, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003153 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003154 !strconcat(OpcodeStr,
3155 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng00b66ef2008-05-23 00:37:07 +00003156 [(set VR128:$dst,
3157 (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003158 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003159}
3160
Dale Johannesena7d2b442008-10-10 23:51:03 +00003161let Constraints = "$src1 = $dst" in {
3162multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd,
3163 string OpcodeStr,
3164 Intrinsic F32Int,
3165 Intrinsic F64Int> {
3166 // Intrinsic operation, reg.
3167 def SSr_Int : SS4AIi8<opcss, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003168 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003169 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3170 !strconcat(OpcodeStr,
3171 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003172 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003173 (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3174 OpSize;
3175
3176 // Intrinsic operation, mem.
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003177 def SSm_Int : SS4AIi8<opcss, MRMSrcMem,
3178 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003179 (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003180 !strconcat(OpcodeStr,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003181 "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003182 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003183 (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>,
3184 OpSize;
3185
3186 // Intrinsic operation, reg.
3187 def SDr_Int : SS4AIi8<opcsd, MRMSrcReg,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003188 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003189 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3190 !strconcat(OpcodeStr,
3191 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003192 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003193 (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>,
3194 OpSize;
3195
3196 // Intrinsic operation, mem.
3197 def SDm_Int : SS4AIi8<opcsd, MRMSrcMem,
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003198 (outs VR128:$dst),
Dale Johannesena7d2b442008-10-10 23:51:03 +00003199 (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3),
3200 !strconcat(OpcodeStr,
3201 "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003202 [(set VR128:$dst,
Dale Johannesena7d2b442008-10-10 23:51:03 +00003203 (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>,
3204 OpSize;
3205}
3206}
3207
Nate Begemanb2975562008-02-03 07:18:54 +00003208// FP round - roundss, roundps, roundsd, roundpd
Dale Johannesena7d2b442008-10-10 23:51:03 +00003209defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round",
3210 int_x86_sse41_round_ps, int_x86_sse41_round_pd>;
3211defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round",
3212 int_x86_sse41_round_ss, int_x86_sse41_round_sd>;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003213
3214// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3215multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3216 Intrinsic IntId128> {
3217 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3218 (ins VR128:$src),
3219 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3220 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3221 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3222 (ins i128mem:$src),
3223 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3224 [(set VR128:$dst,
3225 (IntId128
3226 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3227}
3228
3229defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3230 int_x86_sse41_phminposuw>;
3231
3232/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003233let Constraints = "$src1 = $dst" in {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003234 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3235 Intrinsic IntId128, bit Commutable = 0> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003236 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3237 (ins VR128:$src1, VR128:$src2),
3238 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3239 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3240 OpSize {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003241 let isCommutable = Commutable;
3242 }
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003243 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3244 (ins VR128:$src1, i128mem:$src2),
3245 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3246 [(set VR128:$dst,
3247 (IntId128 VR128:$src1,
3248 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003249 }
3250}
3251
3252defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3253 int_x86_sse41_pcmpeqq, 1>;
3254defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3255 int_x86_sse41_packusdw, 0>;
3256defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3257 int_x86_sse41_pminsb, 1>;
3258defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3259 int_x86_sse41_pminsd, 1>;
3260defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3261 int_x86_sse41_pminud, 1>;
3262defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3263 int_x86_sse41_pminuw, 1>;
3264defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3265 int_x86_sse41_pmaxsb, 1>;
3266defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3267 int_x86_sse41_pmaxsd, 1>;
3268defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3269 int_x86_sse41_pmaxud, 1>;
3270defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3271 int_x86_sse41_pmaxuw, 1>;
Nate Begeman72d802a2008-02-04 06:00:24 +00003272
Mon P Wang14edb092008-12-18 21:42:19 +00003273defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>;
3274
Nate Begeman03605a02008-07-17 16:51:19 +00003275def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)),
3276 (PCMPEQQrr VR128:$src1, VR128:$src2)>;
3277def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))),
3278 (PCMPEQQrm VR128:$src1, addr:$src2)>;
3279
Nate Begeman58057962008-02-09 01:38:08 +00003280/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003281let Constraints = "$src1 = $dst" in {
Dan Gohmane3731f52008-05-23 17:49:40 +00003282 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT,
3283 SDNode OpNode, Intrinsic IntId128,
3284 bit Commutable = 0> {
Nate Begeman58057962008-02-09 01:38:08 +00003285 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3286 (ins VR128:$src1, VR128:$src2),
3287 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmane3731f52008-05-23 17:49:40 +00003288 [(set VR128:$dst, (OpNode (OpVT VR128:$src1),
3289 VR128:$src2))]>, OpSize {
Nate Begeman58057962008-02-09 01:38:08 +00003290 let isCommutable = Commutable;
3291 }
3292 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3293 (ins VR128:$src1, VR128:$src2),
3294 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3295 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3296 OpSize {
3297 let isCommutable = Commutable;
3298 }
3299 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3300 (ins VR128:$src1, i128mem:$src2),
3301 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3302 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003303 (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003304 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3305 (ins VR128:$src1, i128mem:$src2),
3306 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3307 [(set VR128:$dst,
Evan Cheng00b66ef2008-05-23 00:37:07 +00003308 (IntId128 VR128:$src1, (memop addr:$src2)))]>,
Nate Begeman58057962008-02-09 01:38:08 +00003309 OpSize;
3310 }
3311}
Dan Gohmane3731f52008-05-23 17:49:40 +00003312defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
Nate Begeman58057962008-02-09 01:38:08 +00003313 int_x86_sse41_pmulld, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003314
Evan Cheng78d00612008-03-14 07:39:27 +00003315/// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
Evan Cheng3ea4d672008-03-05 08:19:16 +00003316let Constraints = "$src1 = $dst" in {
Nate Begeman72d802a2008-02-04 06:00:24 +00003317 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3318 Intrinsic IntId128, bit Commutable = 0> {
Evan Cheng78d00612008-03-14 07:39:27 +00003319 def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003320 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003321 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003322 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003323 [(set VR128:$dst,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003324 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3325 OpSize {
Nate Begeman72d802a2008-02-04 06:00:24 +00003326 let isCommutable = Commutable;
3327 }
Evan Cheng78d00612008-03-14 07:39:27 +00003328 def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003329 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3330 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003331 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003332 [(set VR128:$dst,
3333 (IntId128 VR128:$src1,
3334 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3335 OpSize;
Nate Begeman72d802a2008-02-04 06:00:24 +00003336 }
3337}
3338
3339defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3340 int_x86_sse41_blendps, 0>;
3341defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3342 int_x86_sse41_blendpd, 0>;
3343defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3344 int_x86_sse41_pblendw, 0>;
3345defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3346 int_x86_sse41_dpps, 1>;
3347defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3348 int_x86_sse41_dppd, 1>;
3349defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
Evan Cheng81ed9852008-06-16 20:25:59 +00003350 int_x86_sse41_mpsadbw, 1>;
Nate Begeman58057962008-02-09 01:38:08 +00003351
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003352
Evan Cheng78d00612008-03-14 07:39:27 +00003353/// SS41I_ternary_int - SSE 4.1 ternary operator
Evan Cheng3ea4d672008-03-05 08:19:16 +00003354let Uses = [XMM0], Constraints = "$src1 = $dst" in {
Nate Begemanb4e9a042008-02-10 18:47:57 +00003355 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3356 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3357 (ins VR128:$src1, VR128:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003358 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003359 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3360 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3361 OpSize;
3362
3363 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3364 (ins VR128:$src1, i128mem:$src2),
3365 !strconcat(OpcodeStr,
3366 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3367 [(set VR128:$dst,
3368 (IntId VR128:$src1,
3369 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3370 }
3371}
3372
3373defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3374defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3375defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3376
3377
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003378multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3379 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3380 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3381 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3382
3383 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3384 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003385 [(set VR128:$dst,
3386 (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>,
3387 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003388}
3389
3390defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3391defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3392defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3393defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3394defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3395defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3396
Evan Cheng56ec77b2008-09-24 23:27:55 +00003397// Common patterns involving scalar load.
3398def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)),
3399 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3400def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)),
3401 (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>;
3402
3403def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)),
3404 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3405def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)),
3406 (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>;
3407
3408def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)),
3409 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3410def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)),
3411 (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>;
3412
3413def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)),
3414 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3415def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)),
3416 (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>;
3417
3418def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)),
3419 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3420def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)),
3421 (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>;
3422
3423def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)),
3424 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3425def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)),
3426 (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>;
3427
3428
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003429multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3430 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3431 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3432 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3433
3434 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3435 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003436 [(set VR128:$dst,
3437 (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>,
3438 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003439}
3440
3441defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3442defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3443defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3444defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3445
Evan Cheng56ec77b2008-09-24 23:27:55 +00003446// Common patterns involving scalar load
3447def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003448 (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003449def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003450 (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003451
3452def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003453 (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003454def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003455 (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003456
3457
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003458multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3459 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3460 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3461 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3462
Evan Cheng56ec77b2008-09-24 23:27:55 +00003463 // Expecting a i16 load any extended to i32 value.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003464 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3465 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
Evan Cheng56ec77b2008-09-24 23:27:55 +00003466 [(set VR128:$dst, (IntId (bitconvert
3467 (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>,
3468 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003469}
3470
3471defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
Eli Friedman75a89d62009-06-06 05:55:37 +00003472defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003473
Evan Cheng56ec77b2008-09-24 23:27:55 +00003474// Common patterns involving scalar load
3475def : Pat<(int_x86_sse41_pmovsxbq
3476 (bitconvert (v4i32 (X86vzmovl
3477 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003478 (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003479
3480def : Pat<(int_x86_sse41_pmovzxbq
3481 (bitconvert (v4i32 (X86vzmovl
3482 (v4i32 (scalar_to_vector (loadi32 addr:$src))))))),
Evan Cheng00a3ec52008-09-25 00:49:51 +00003483 (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>;
Evan Cheng56ec77b2008-09-24 23:27:55 +00003484
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003485
Nate Begemand77e59e2008-02-11 04:19:36 +00003486/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3487multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003488 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003489 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003490 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003491 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003492 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3493 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003494 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003495 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003496 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003497 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003498 []>, OpSize;
3499// FIXME:
3500// There's an AssertZext in the way of writing the store pattern
3501// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003502}
3503
Nate Begemand77e59e2008-02-11 04:19:36 +00003504defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003505
Nate Begemand77e59e2008-02-11 04:19:36 +00003506
3507/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3508multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003509 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begemand77e59e2008-02-11 04:19:36 +00003510 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003511 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003512 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3513 []>, OpSize;
3514// FIXME:
3515// There's an AssertZext in the way of writing the store pattern
3516// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3517}
3518
3519defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3520
3521
3522/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3523multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003524 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003525 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003526 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003527 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3528 [(set GR32:$dst,
3529 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003530 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003531 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003532 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003533 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3534 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3535 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003536}
3537
Nate Begemand77e59e2008-02-11 04:19:36 +00003538defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman58057962008-02-09 01:38:08 +00003539
Nate Begemand77e59e2008-02-11 04:19:36 +00003540
Evan Cheng6c249332008-03-24 21:52:23 +00003541/// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory
3542/// destination
Nate Begemand77e59e2008-02-11 04:19:36 +00003543multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Evan Chengc2054be2008-03-26 08:11:49 +00003544 def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003545 (ins VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003546 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003547 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Dan Gohman788db592008-04-16 02:32:24 +00003548 [(set GR32:$dst,
3549 (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>,
Evan Cheng6c249332008-03-24 21:52:23 +00003550 OpSize;
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003551 def mr : SS4AIi8<opc, MRMDestMem, (outs),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003552 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003553 !strconcat(OpcodeStr,
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003554 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Evan Cheng6c249332008-03-24 21:52:23 +00003555 [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003556 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003557}
3558
Nate Begemand77e59e2008-02-11 04:19:36 +00003559defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003560
Dan Gohmana41862a2008-08-08 18:30:21 +00003561// Also match an EXTRACTPS store when the store is done as f32 instead of i32.
3562def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)),
3563 imm:$src2))),
3564 addr:$dst),
3565 (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>,
3566 Requires<[HasSSE41]>;
3567
Evan Cheng3ea4d672008-03-05 08:19:16 +00003568let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003569 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003570 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003571 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003572 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003573 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003574 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003575 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003576 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003577 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3578 !strconcat(OpcodeStr,
3579 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003580 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003581 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3582 imm:$src3))]>, OpSize;
3583 }
3584}
3585
3586defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3587
Evan Cheng3ea4d672008-03-05 08:19:16 +00003588let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003589 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
Evan Cheng78d00612008-03-14 07:39:27 +00003590 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003591 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003592 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003593 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003594 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003595 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3596 OpSize;
Evan Cheng78d00612008-03-14 07:39:27 +00003597 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003598 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3599 !strconcat(OpcodeStr,
3600 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003601 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00003602 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3603 imm:$src3)))]>, OpSize;
3604 }
3605}
3606
3607defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3608
Eric Christophera0443602009-07-23 02:22:41 +00003609// insertps has a few different modes, there's the first two here below which
3610// are optimized inserts that won't zero arbitrary elements in the destination
3611// vector. The next one matches the intrinsic and could zero arbitrary elements
3612// in the target vector.
Evan Cheng3ea4d672008-03-05 08:19:16 +00003613let Constraints = "$src1 = $dst" in {
Nate Begemand77e59e2008-02-11 04:19:36 +00003614 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
Eric Christopherefb657e2009-07-24 00:33:09 +00003615 def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst),
3616 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003617 !strconcat(OpcodeStr,
Nate Begemand77e59e2008-02-11 04:19:36 +00003618 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003619 [(set VR128:$dst,
3620 (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>,
3621 OpSize;
Eric Christopherefb657e2009-07-24 00:33:09 +00003622 def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst),
Nate Begemand77e59e2008-02-11 04:19:36 +00003623 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3624 !strconcat(OpcodeStr,
3625 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Eric Christopher7f2d4f42009-07-31 20:07:27 +00003626 [(set VR128:$dst,
Eric Christopherefb657e2009-07-24 00:33:09 +00003627 (X86insrtps VR128:$src1,
3628 (v4f32 (scalar_to_vector (loadf32 addr:$src2))),
Nate Begemand77e59e2008-02-11 04:19:36 +00003629 imm:$src3))]>, OpSize;
3630 }
3631}
3632
Evan Chengc2054be2008-03-26 08:11:49 +00003633defm INSERTPS : SS41I_insertf32<0x21, "insertps">;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003634
Eric Christopherefb657e2009-07-24 00:33:09 +00003635def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3),
3636 (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>;
3637
Eric Christopher95d79262009-07-29 00:28:05 +00003638// ptest instruction we'll lower to this in X86ISelLowering primarily from
3639// the intel intrinsic that corresponds to this.
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003640let Defs = [EFLAGS] in {
3641def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003642 "ptest \t{$src2, $src1|$src1, $src2}",
3643 [(X86ptest VR128:$src1, VR128:$src2),
3644 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003645def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2),
Eric Christopher95d79262009-07-29 00:28:05 +00003646 "ptest \t{$src2, $src1|$src1, $src2}",
3647 [(X86ptest VR128:$src1, (load addr:$src2)),
3648 (implicit EFLAGS)]>, OpSize;
Nate Begeman0dd3cb52008-03-16 21:14:46 +00003649}
3650
3651def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
3652 "movntdqa\t{$src, $dst|$dst, $src}",
3653 [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>;
Nate Begeman03605a02008-07-17 16:51:19 +00003654
3655/// SS42I_binop_rm_int - Simple SSE 4.2 binary operator
3656let Constraints = "$src1 = $dst" in {
3657 multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr,
3658 Intrinsic IntId128, bit Commutable = 0> {
3659 def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst),
3660 (ins VR128:$src1, VR128:$src2),
3661 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3662 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3663 OpSize {
3664 let isCommutable = Commutable;
3665 }
3666 def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst),
3667 (ins VR128:$src1, i128mem:$src2),
3668 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3669 [(set VR128:$dst,
3670 (IntId128 VR128:$src1,
3671 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
3672 }
3673}
3674
Nate Begeman235666b2008-07-17 17:04:58 +00003675defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>;
Nate Begeman03605a02008-07-17 16:51:19 +00003676
3677def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)),
3678 (PCMPGTQrr VR128:$src1, VR128:$src2)>;
3679def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))),
3680 (PCMPGTQrm VR128:$src1, addr:$src2)>;
Eric Christopherb5f948c2009-08-08 21:55:08 +00003681
3682// crc intrinsic instruction
3683// This set of instructions are only rm, the only difference is the size
3684// of r and m.
3685let Constraints = "$src1 = $dst" in {
3686 def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst),
3687 (ins GR32:$src1, i8mem:$src2),
3688 "crc32 \t{$src2, $src1|$src1, $src2}",
3689 [(set GR32:$dst,
3690 (int_x86_sse42_crc32_8 GR32:$src1,
3691 (load addr:$src2)))]>, OpSize;
3692 def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst),
3693 (ins GR32:$src1, GR8:$src2),
3694 "crc32 \t{$src2, $src1|$src1, $src2}",
3695 [(set GR32:$dst,
3696 (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
3697 OpSize;
3698 def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
3699 (ins GR32:$src1, i16mem:$src2),
3700 "crc32 \t{$src2, $src1|$src1, $src2}",
3701 [(set GR32:$dst,
3702 (int_x86_sse42_crc32_16 GR32:$src1,
3703 (load addr:$src2)))]>,
3704 OpSize;
3705 def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
3706 (ins GR32:$src1, GR16:$src2),
3707 "crc32 \t{$src2, $src1|$src1, $src2}",
3708 [(set GR32:$dst,
3709 (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>,
3710 OpSize;
3711 def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst),
3712 (ins GR32:$src1, i32mem:$src2),
3713 "crc32 \t{$src2, $src1|$src1, $src2}",
3714 [(set GR32:$dst,
3715 (int_x86_sse42_crc32_32 GR32:$src1,
3716 (load addr:$src2)))]>, OpSize;
3717 def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst),
3718 (ins GR32:$src1, GR32:$src2),
3719 "crc32 \t{$src2, $src1|$src1, $src2}",
3720 [(set GR32:$dst,
3721 (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>,
3722 OpSize;
3723 def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst),
3724 (ins GR64:$src1, i64mem:$src2),
3725 "crc32 \t{$src2, $src1|$src1, $src2}",
3726 [(set GR64:$dst,
3727 (int_x86_sse42_crc32_64 GR64:$src1,
3728 (load addr:$src2)))]>,
3729 OpSize, REX_W;
3730 def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst),
3731 (ins GR64:$src1, GR64:$src2),
3732 "crc32 \t{$src2, $src1|$src1, $src2}",
3733 [(set GR64:$dst,
3734 (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>,
3735 OpSize, REX_W;
3736
3737 // TODO: These correspond to int_x86_sse42_crc32_8 but with a 64-bit src
3738 // and dest, figure it out.
3739 //def CRC64m8 : SS42FI<0xF1, MRMSrcMem, (outs GR64:$dst),
3740 // (ins GR32:$src1, i8mem:$src2),
3741 // "crc32 \t{$src2, $src1|$src1, $src2}",
3742 // [(set GR64:$dst,
3743 // (int_x86_sse42_crc32_8 GR64:$src1,
3744 // (load addr:$src2)))]>,
3745 // OpSize, REX_W;
3746 //def CRC64r8 : SS42FI<0xF1, MRMSrcReg, (outs GR64:$dst),
3747 // (ins GR64:$src1, GR8:$src2),
3748 // "crc32 \t{$src2, $src1|$src1, $src2}",
3749 // [(set GR64:$dst,
3750 // (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>,
3751 // OpSize, REX_W;
3752}