blob: 46f70da83d25e20c0e2dc1142896a2016203344e [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//====- X86InstrSSE.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// 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.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
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> ]>;
23
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024def X86fmin : SDNode<"X86ISD::FMIN", SDTFPBinOp>;
25def X86fmax : SDNode<"X86ISD::FMAX", SDTFPBinOp>;
26def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
27 [SDNPCommutative, SDNPAssociative]>;
28def X86for : SDNode<"X86ISD::FOR", SDTFPBinOp,
29 [SDNPCommutative, SDNPAssociative]>;
30def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
31 [SDNPCommutative, SDNPAssociative]>;
32def X86frsqrt : SDNode<"X86ISD::FRSQRT", SDTFPUnaryOp>;
33def X86frcp : SDNode<"X86ISD::FRCP", SDTFPUnaryOp>;
34def X86fsrl : SDNode<"X86ISD::FSRL", SDTX86FPShiftOp>;
Evan Chengf37bf452007-10-01 18:12:48 +000035def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest>;
Evan Cheng621216e2007-09-29 00:00:36 +000036def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest>;
Nate Begemand77e59e2008-02-11 04:19:36 +000037def X86pextrb : SDNode<"X86ISD::PEXTRB",
38 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
39def X86pextrw : SDNode<"X86ISD::PEXTRW",
40 SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>;
41def X86pinsrb : SDNode<"X86ISD::PINSRB",
42 SDTypeProfile<1, 3, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>,
43 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
44def X86pinsrw : SDNode<"X86ISD::PINSRW",
45 SDTypeProfile<1, 3, [SDTCisVT<0, v8i16>, SDTCisSameAs<0,1>,
46 SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>;
47def X86insrtps : SDNode<"X86ISD::INSERTPS",
48 SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, SDTCisSameAs<0,1>,
49 SDTCisVT<2, f32>, SDTCisPtrTy<3>]>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000050
51//===----------------------------------------------------------------------===//
52// SSE 'Special' Instructions
53//===----------------------------------------------------------------------===//
54
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000055let isImplicitDef = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +000056def IMPLICIT_DEF_VR128 : I<0, Pseudo, (outs VR128:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057 "#IMPLICIT_DEF $dst",
58 [(set VR128:$dst, (v4f32 (undef)))]>,
59 Requires<[HasSSE1]>;
Evan Chengb783fa32007-07-19 01:14:50 +000060def IMPLICIT_DEF_FR32 : I<0, Pseudo, (outs FR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061 "#IMPLICIT_DEF $dst",
Dale Johannesene0e0fd02007-09-23 14:52:20 +000062 [(set FR32:$dst, (undef))]>, Requires<[HasSSE1]>;
Evan Chengb783fa32007-07-19 01:14:50 +000063def IMPLICIT_DEF_FR64 : I<0, Pseudo, (outs FR64:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064 "#IMPLICIT_DEF $dst",
65 [(set FR64:$dst, (undef))]>, Requires<[HasSSE2]>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000066}
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067
68//===----------------------------------------------------------------------===//
69// SSE Complex Patterns
70//===----------------------------------------------------------------------===//
71
72// These are 'extloads' from a scalar to the low element of a vector, zeroing
73// the top elements. These are used for the SSE 'ss' and 'sd' instruction
74// forms.
75def sse_load_f32 : ComplexPattern<v4f32, 4, "SelectScalarSSELoad", [],
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000076 [SDNPHasChain, SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000077def sse_load_f64 : ComplexPattern<v2f64, 4, "SelectScalarSSELoad", [],
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000078 [SDNPHasChain, SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079
80def ssmem : Operand<v4f32> {
81 let PrintMethod = "printf32mem";
82 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
83}
84def sdmem : Operand<v2f64> {
85 let PrintMethod = "printf64mem";
86 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
87}
88
89//===----------------------------------------------------------------------===//
90// SSE pattern fragments
91//===----------------------------------------------------------------------===//
92
Dan Gohmanf17a25c2007-07-18 16:29:46 +000093def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
94def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
95def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
96def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
97
Dan Gohman11821702007-07-27 17:16:43 +000098// Like 'store', but always requires vector alignment.
Dan Gohman4a4f1512007-07-18 20:23:34 +000099def alignedstore : PatFrag<(ops node:$val, node:$ptr),
100 (st node:$val, node:$ptr), [{
101 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
102 return !ST->isTruncatingStore() &&
103 ST->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +0000104 ST->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000105 return false;
106}]>;
107
Dan Gohman11821702007-07-27 17:16:43 +0000108// Like 'load', but always requires vector alignment.
Dan Gohman4a4f1512007-07-18 20:23:34 +0000109def alignedload : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
110 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
111 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
112 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +0000113 LD->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000114 return false;
115}]>;
116
Dan Gohman11821702007-07-27 17:16:43 +0000117def alignedloadfsf32 : PatFrag<(ops node:$ptr), (f32 (alignedload node:$ptr))>;
118def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000119def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>;
120def alignedloadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (alignedload node:$ptr))>;
121def alignedloadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (alignedload node:$ptr))>;
122def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>;
123
124// Like 'load', but uses special alignment checks suitable for use in
125// memory operands in most SSE instructions, which are required to
126// be naturally aligned on some targets but not on others.
127// FIXME: Actually implement support for targets that don't require the
128// alignment. This probably wants a subtarget predicate.
129def memop : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
130 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
131 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
132 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +0000133 LD->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000134 return false;
135}]>;
136
Dan Gohman11821702007-07-27 17:16:43 +0000137def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
138def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000139def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
140def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
141def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
142def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
Nate Begeman9a58b8a2008-02-09 23:46:37 +0000143def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000144
Bill Wendling3b15d722007-08-11 09:52:53 +0000145// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
146// 16-byte boundary.
Nate Begeman9a58b8a2008-02-09 23:46:37 +0000147// FIXME: 8 byte alignment for mmx reads is not required
Bill Wendling3b15d722007-08-11 09:52:53 +0000148def memop64 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
149 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
150 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
151 LD->getAddressingMode() == ISD::UNINDEXED &&
152 LD->getAlignment() >= 8;
153 return false;
154}]>;
155
156def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
Bill Wendling3b15d722007-08-11 09:52:53 +0000157def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
158def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
159def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
160
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000161def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
162def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
163def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
164def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
165def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
166def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
167
168def fp32imm0 : PatLeaf<(f32 fpimm), [{
169 return N->isExactlyValue(+0.0);
170}]>;
171
172def PSxLDQ_imm : SDNodeXForm<imm, [{
173 // Transformation function: imm >> 3
174 return getI32Imm(N->getValue() >> 3);
175}]>;
176
177// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
178// SHUFP* etc. imm.
179def SHUFFLE_get_shuf_imm : SDNodeXForm<build_vector, [{
180 return getI8Imm(X86::getShuffleSHUFImmediate(N));
181}]>;
182
183// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
184// PSHUFHW imm.
185def SHUFFLE_get_pshufhw_imm : SDNodeXForm<build_vector, [{
186 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
187}]>;
188
189// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
190// PSHUFLW imm.
191def SHUFFLE_get_pshuflw_imm : SDNodeXForm<build_vector, [{
192 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
193}]>;
194
195def SSE_splat_mask : PatLeaf<(build_vector), [{
196 return X86::isSplatMask(N);
197}], SHUFFLE_get_shuf_imm>;
198
199def SSE_splat_lo_mask : PatLeaf<(build_vector), [{
200 return X86::isSplatLoMask(N);
201}]>;
202
203def MOVHLPS_shuffle_mask : PatLeaf<(build_vector), [{
204 return X86::isMOVHLPSMask(N);
205}]>;
206
207def MOVHLPS_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
208 return X86::isMOVHLPS_v_undef_Mask(N);
209}]>;
210
211def MOVHP_shuffle_mask : PatLeaf<(build_vector), [{
212 return X86::isMOVHPMask(N);
213}]>;
214
215def MOVLP_shuffle_mask : PatLeaf<(build_vector), [{
216 return X86::isMOVLPMask(N);
217}]>;
218
219def MOVL_shuffle_mask : PatLeaf<(build_vector), [{
220 return X86::isMOVLMask(N);
221}]>;
222
223def MOVSHDUP_shuffle_mask : PatLeaf<(build_vector), [{
224 return X86::isMOVSHDUPMask(N);
225}]>;
226
227def MOVSLDUP_shuffle_mask : PatLeaf<(build_vector), [{
228 return X86::isMOVSLDUPMask(N);
229}]>;
230
231def UNPCKL_shuffle_mask : PatLeaf<(build_vector), [{
232 return X86::isUNPCKLMask(N);
233}]>;
234
235def UNPCKH_shuffle_mask : PatLeaf<(build_vector), [{
236 return X86::isUNPCKHMask(N);
237}]>;
238
239def UNPCKL_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
240 return X86::isUNPCKL_v_undef_Mask(N);
241}]>;
242
243def UNPCKH_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
244 return X86::isUNPCKH_v_undef_Mask(N);
245}]>;
246
247def PSHUFD_shuffle_mask : PatLeaf<(build_vector), [{
248 return X86::isPSHUFDMask(N);
249}], SHUFFLE_get_shuf_imm>;
250
251def PSHUFHW_shuffle_mask : PatLeaf<(build_vector), [{
252 return X86::isPSHUFHWMask(N);
253}], SHUFFLE_get_pshufhw_imm>;
254
255def PSHUFLW_shuffle_mask : PatLeaf<(build_vector), [{
256 return X86::isPSHUFLWMask(N);
257}], SHUFFLE_get_pshuflw_imm>;
258
259def SHUFP_unary_shuffle_mask : PatLeaf<(build_vector), [{
260 return X86::isPSHUFDMask(N);
261}], SHUFFLE_get_shuf_imm>;
262
263def SHUFP_shuffle_mask : PatLeaf<(build_vector), [{
264 return X86::isSHUFPMask(N);
265}], SHUFFLE_get_shuf_imm>;
266
267def PSHUFD_binary_shuffle_mask : PatLeaf<(build_vector), [{
268 return X86::isSHUFPMask(N);
269}], SHUFFLE_get_shuf_imm>;
270
271//===----------------------------------------------------------------------===//
272// SSE scalar FP Instructions
273//===----------------------------------------------------------------------===//
274
275// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
276// scheduler into a branch sequence.
Evan Cheng950aac02007-09-25 01:57:46 +0000277// These are expanded by the scheduler.
278let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000279 def CMOV_FR32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000280 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000281 "#CMOV_FR32 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000282 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
283 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000285 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000286 "#CMOV_FR64 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000287 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
288 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000289 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000290 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291 "#CMOV_V4F32 PSEUDO!",
292 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000293 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
294 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295 def CMOV_V2F64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000296 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000297 "#CMOV_V2F64 PSEUDO!",
298 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000299 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
300 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000301 def CMOV_V2I64 : 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_V2I64 PSEUDO!",
304 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000305 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng950aac02007-09-25 01:57:46 +0000306 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307}
308
309//===----------------------------------------------------------------------===//
310// SSE1 Instructions
311//===----------------------------------------------------------------------===//
312
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000314let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000315def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000316 "movss\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +0000317let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000318def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000319 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000321def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000322 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323 [(store FR32:$src, addr:$dst)]>;
324
325// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000326def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000327 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000329def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000330 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000332def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000333 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000335def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000336 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
338
339// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000340def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000341 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000342 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000343def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000344 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345 [(set GR32:$dst, (int_x86_sse_cvtss2si
346 (load addr:$src)))]>;
347
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000348// Match intrinisics which expect MM and XMM operand(s).
349def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
350 "cvtps2pi\t{$src, $dst|$dst, $src}",
351 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
352def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
353 "cvtps2pi\t{$src, $dst|$dst, $src}",
354 [(set VR64:$dst, (int_x86_sse_cvtps2pi
355 (load addr:$src)))]>;
356def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
357 "cvttps2pi\t{$src, $dst|$dst, $src}",
358 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
359def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
360 "cvttps2pi\t{$src, $dst|$dst, $src}",
361 [(set VR64:$dst, (int_x86_sse_cvttps2pi
362 (load addr:$src)))]>;
363let isTwoAddress = 1 in {
364 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
365 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
366 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
367 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
368 VR64:$src2))]>;
369 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
370 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
371 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
372 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
373 (load addr:$src2)))]>;
374}
375
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000377def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000378 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000379 [(set GR32:$dst,
380 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000381def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000382 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383 [(set GR32:$dst,
384 (int_x86_sse_cvttss2si(load addr:$src)))]>;
385
386let isTwoAddress = 1 in {
387 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000388 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000389 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
391 GR32:$src2))]>;
392 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000393 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000394 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000395 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
396 (loadi32 addr:$src2)))]>;
397}
398
399// Comparison instructions
400let isTwoAddress = 1 in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000401let neverHasSideEffects = 1 in
Chris Lattnera9f545f2007-12-16 20:12:41 +0000402 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000403 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000404 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000405let neverHasSideEffects = 1, mayLoad = 1 in
Chris Lattnera9f545f2007-12-16 20:12:41 +0000406 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000407 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000408 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409}
410
Evan Cheng55687072007-09-14 21:48:26 +0000411let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000412def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000413 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000414 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000415def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000416 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000417 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000418 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000419} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420
421// Aliases to match intrinsics which expect XMM operand(s).
422let isTwoAddress = 1 in {
Chris Lattnera9f545f2007-12-16 20:12:41 +0000423 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000424 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000425 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
427 VR128:$src, imm:$cc))]>;
Chris Lattnera9f545f2007-12-16 20:12:41 +0000428 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000429 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000430 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
432 (load addr:$src), imm:$cc))]>;
433}
434
Evan Cheng55687072007-09-14 21:48:26 +0000435let Defs = [EFLAGS] in {
Evan Cheng621216e2007-09-29 00:00:36 +0000436def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000437 (ins VR128:$src1, VR128:$src2),
438 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000439 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000440 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000441def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000442 (ins VR128:$src1, f128mem:$src2),
443 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000444 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000445 (implicit EFLAGS)]>;
446
Evan Cheng621216e2007-09-29 00:00:36 +0000447def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000448 (ins VR128:$src1, VR128:$src2),
449 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000450 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000451 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000452def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000453 (ins VR128:$src1, f128mem:$src2),
454 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000455 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000456 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000457} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458
459// Aliases of packed SSE1 instructions for scalar use. These all have names that
460// start with 'Fs'.
461
462// Alias instructions that map fld0 to pxor for sse.
Chris Lattner17dab4a2008-01-10 05:45:39 +0000463let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000464def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000465 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000466 Requires<[HasSSE1]>, TB, OpSize;
467
468// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
469// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000470let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000471def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000472 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473
474// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
475// disregarded.
Chris Lattner1a1932c2008-01-06 23:38:27 +0000476let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000477def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000478 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000479 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000480
481// Alias bitwise logical operations using SSE logical ops on packed FP values.
482let isTwoAddress = 1 in {
483let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000484 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000485 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000486 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000487 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000488 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000490 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000491 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
493}
494
Evan Chengb783fa32007-07-19 01:14:50 +0000495def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000496 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000497 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000498 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000499def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000500 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000502 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000503def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000504 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000505 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000506 (memopfsf32 addr:$src2)))]>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000507let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000509 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000510 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000511
512let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000513def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000514 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000515 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000517}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000518
519/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
520///
521/// In addition, we also have a special variant of the scalar form here to
522/// represent the associated intrinsic operation. This form is unlike the
523/// plain scalar form, in that it takes an entire vector (instead of a scalar)
524/// and leaves the top elements undefined.
525///
526/// These three forms can each be reg+reg or reg+mem, so there are a total of
527/// six "instructions".
528///
529let isTwoAddress = 1 in {
530multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
531 SDNode OpNode, Intrinsic F32Int,
532 bit Commutable = 0> {
533 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000534 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000535 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
537 let isCommutable = Commutable;
538 }
539
540 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000541 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000542 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
544
545 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000546 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000547 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
549 let isCommutable = Commutable;
550 }
551
552 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000553 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000554 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000555 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556
557 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000558 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000559 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000560 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
561 let isCommutable = Commutable;
562 }
563
564 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000565 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000566 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000567 [(set VR128:$dst, (F32Int VR128:$src1,
568 sse_load_f32:$src2))]>;
569}
570}
571
572// Arithmetic instructions
573defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
574defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
575defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
576defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
577
578/// sse1_fp_binop_rm - Other SSE1 binops
579///
580/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
581/// instructions for a full-vector intrinsic form. Operations that map
582/// onto C operators don't use this form since they just use the plain
583/// vector form instead of having a separate vector intrinsic form.
584///
585/// This provides a total of eight "instructions".
586///
587let isTwoAddress = 1 in {
588multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
589 SDNode OpNode,
590 Intrinsic F32Int,
591 Intrinsic V4F32Int,
592 bit Commutable = 0> {
593
594 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000595 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000596 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
598 let isCommutable = Commutable;
599 }
600
601 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000602 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000603 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000604 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
605
606 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000607 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000608 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
610 let isCommutable = Commutable;
611 }
612
613 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000614 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000615 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000616 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000617
618 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000619 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000620 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
622 let isCommutable = Commutable;
623 }
624
625 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000626 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000627 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000628 [(set VR128:$dst, (F32Int VR128:$src1,
629 sse_load_f32:$src2))]>;
630
631 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000632 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000633 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000634 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
635 let isCommutable = Commutable;
636 }
637
638 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +0000639 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000640 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641 [(set VR128:$dst, (V4F32Int VR128:$src1, (load addr:$src2)))]>;
642}
643}
644
645defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
646 int_x86_sse_max_ss, int_x86_sse_max_ps>;
647defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
648 int_x86_sse_min_ss, int_x86_sse_min_ps>;
649
650//===----------------------------------------------------------------------===//
651// SSE packed FP Instructions
652
653// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000654let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000655def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000656 "movaps\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +0000657let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000658def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000659 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000660 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661
Evan Chengb783fa32007-07-19 01:14:50 +0000662def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000663 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000664 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000665
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000666let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000667def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000668 "movups\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +0000669let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000670def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000671 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000672 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000673def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000674 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000675 [(store (v4f32 VR128:$src), addr:$dst)]>;
676
677// Intrinsic forms of MOVUPS load and store
Chris Lattner1a1932c2008-01-06 23:38:27 +0000678let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000679def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000680 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000681 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000682def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000683 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000684 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000685
686let isTwoAddress = 1 in {
687 let AddedComplexity = 20 in {
688 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000689 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000690 "movlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 [(set VR128:$dst,
692 (v4f32 (vector_shuffle VR128:$src1,
693 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
694 MOVLP_shuffle_mask)))]>;
695 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000696 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000697 "movhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698 [(set VR128:$dst,
699 (v4f32 (vector_shuffle VR128:$src1,
700 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
701 MOVHP_shuffle_mask)))]>;
702 } // AddedComplexity
703} // isTwoAddress
704
Evan Chengb783fa32007-07-19 01:14:50 +0000705def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000706 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000707 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
708 (iPTR 0))), addr:$dst)]>;
709
710// v2f64 extract element 1 is always custom lowered to unpack high to low
711// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000712def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000713 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714 [(store (f64 (vector_extract
715 (v2f64 (vector_shuffle
716 (bc_v2f64 (v4f32 VR128:$src)), (undef),
717 UNPCKH_shuffle_mask)), (iPTR 0))),
718 addr:$dst)]>;
719
720let isTwoAddress = 1 in {
721let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000722def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000723 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000724 [(set VR128:$dst,
725 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
726 MOVHP_shuffle_mask)))]>;
727
Evan Chengb783fa32007-07-19 01:14:50 +0000728def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000729 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730 [(set VR128:$dst,
731 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
732 MOVHLPS_shuffle_mask)))]>;
733} // AddedComplexity
734} // isTwoAddress
735
736
737
738// Arithmetic
739
740/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
741///
742/// In addition, we also have a special variant of the scalar form here to
743/// represent the associated intrinsic operation. This form is unlike the
744/// plain scalar form, in that it takes an entire vector (instead of a
745/// scalar) and leaves the top elements undefined.
746///
747/// And, we have a special variant form for a full-vector intrinsic form.
748///
749/// These four forms can each have a reg or a mem operand, so there are a
750/// total of eight "instructions".
751///
752multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
753 SDNode OpNode,
754 Intrinsic F32Int,
755 Intrinsic V4F32Int,
756 bit Commutable = 0> {
757 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000758 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000759 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760 [(set FR32:$dst, (OpNode FR32:$src))]> {
761 let isCommutable = Commutable;
762 }
763
764 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000765 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000766 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
768
769 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000770 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000771 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
773 let isCommutable = Commutable;
774 }
775
776 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000777 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000778 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000779 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780
781 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000782 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000783 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784 [(set VR128:$dst, (F32Int VR128:$src))]> {
785 let isCommutable = Commutable;
786 }
787
788 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000789 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000790 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
792
793 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000794 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000795 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
797 let isCommutable = Commutable;
798 }
799
800 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000801 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000802 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803 [(set VR128:$dst, (V4F32Int (load addr:$src)))]>;
804}
805
806// Square root.
807defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
808 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
809
810// Reciprocal approximations. Note that these typically require refinement
811// in order to obtain suitable precision.
812defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
813 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
814defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
815 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
816
817// Logical
818let isTwoAddress = 1 in {
819 let isCommutable = 1 in {
820 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000821 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000822 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 [(set VR128:$dst, (v2i64
824 (and VR128:$src1, VR128:$src2)))]>;
825 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000826 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 [(set VR128:$dst, (v2i64
829 (or VR128:$src1, VR128:$src2)))]>;
830 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000831 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000832 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833 [(set VR128:$dst, (v2i64
834 (xor VR128:$src1, VR128:$src2)))]>;
835 }
836
837 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000838 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000839 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000840 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
841 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000843 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000845 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
846 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000848 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000849 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000850 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
851 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000853 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000854 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 [(set VR128:$dst,
856 (v2i64 (and (xor VR128:$src1,
857 (bc_v2i64 (v4i32 immAllOnesV))),
858 VR128:$src2)))]>;
859 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000860 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000863 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000865 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866}
867
868let isTwoAddress = 1 in {
869 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000870 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000871 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
873 VR128:$src, imm:$cc))]>;
874 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000875 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000876 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
878 (load addr:$src), imm:$cc))]>;
879}
880
881// Shuffle and unpack instructions
882let isTwoAddress = 1 in {
883 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
884 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000885 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 VR128:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000887 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888 [(set VR128:$dst,
889 (v4f32 (vector_shuffle
890 VR128:$src1, VR128:$src2,
891 SHUFP_shuffle_mask:$src3)))]>;
892 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000893 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894 f128mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000895 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896 [(set VR128:$dst,
897 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000898 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899 SHUFP_shuffle_mask:$src3)))]>;
900
901 let AddedComplexity = 10 in {
902 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000903 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000904 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 [(set VR128:$dst,
906 (v4f32 (vector_shuffle
907 VR128:$src1, VR128:$src2,
908 UNPCKH_shuffle_mask)))]>;
909 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000910 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000911 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912 [(set VR128:$dst,
913 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000914 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 UNPCKH_shuffle_mask)))]>;
916
917 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000918 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000919 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 [(set VR128:$dst,
921 (v4f32 (vector_shuffle
922 VR128:$src1, VR128:$src2,
923 UNPCKL_shuffle_mask)))]>;
924 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000925 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000926 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 [(set VR128:$dst,
928 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000929 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 UNPCKL_shuffle_mask)))]>;
931 } // AddedComplexity
932} // isTwoAddress
933
934// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000935def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000936 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000938def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000939 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
941
942// Prefetching loads.
943// TODO: no intrinsics for these?
Dan Gohman91888f02007-07-31 20:11:57 +0000944def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), "prefetcht0\t$src", []>;
945def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src), "prefetcht1\t$src", []>;
946def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src), "prefetcht2\t$src", []>;
947def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src), "prefetchnta\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948
949// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000950def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000951 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
953
954// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +0000955def SFENCE : PSI<0xAE, MRM7m, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956
957// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000958def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000959 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000960def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000961 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962
963// Alias instructions that map zero vector to pxor / xorp* for sse.
Chris Lattner17dab4a2008-01-10 05:45:39 +0000964let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000965def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000966 "xorps\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000967 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968
969// FR32 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +0000970def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000971 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972 [(set VR128:$dst,
973 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000974def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000975 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 [(set VR128:$dst,
977 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
978
979// FIXME: may not be able to eliminate this movss with coalescing the src and
980// dest register classes are different. We really want to write this pattern
981// like this:
982// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
983// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +0000984def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000985 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
987 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000988def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000989 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990 [(store (f32 (vector_extract (v4f32 VR128:$src),
991 (iPTR 0))), addr:$dst)]>;
992
993
994// Move to lower bits of a VR128, leaving upper bits alone.
995// Three operand (but two address) aliases.
996let isTwoAddress = 1 in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +0000997let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000999 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001000 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001
1002 let AddedComplexity = 15 in
1003 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001004 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001005 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006 [(set VR128:$dst,
1007 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
1008 MOVL_shuffle_mask)))]>;
1009}
1010
1011// Move to lower bits of a VR128 and zeroing upper bits.
1012// Loading from memory automatically zeroing upper bits.
1013let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00001014def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001015 "movss\t{$src, $dst|$dst, $src}",
Chris Lattnere6aa3862007-11-25 00:24:49 +00001016 [(set VR128:$dst, (v4f32 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017 (v4f32 (scalar_to_vector (loadf32 addr:$src))),
1018 MOVL_shuffle_mask)))]>;
1019
1020
1021//===----------------------------------------------------------------------===//
1022// SSE2 Instructions
1023//===----------------------------------------------------------------------===//
1024
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001026let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001027def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "movsd\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001029let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001030def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001031 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001033def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001034 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035 [(store FR64:$src, addr:$dst)]>;
1036
1037// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001038def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001039 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001041def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001042 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001044def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001045 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001047def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001048 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001050def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001051 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001053def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001054 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1056
1057// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001058def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001059 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1061 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001062def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001063 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1065 Requires<[HasSSE2]>;
1066
1067// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001068def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001069 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001071def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001072 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1074 (load addr:$src)))]>;
1075
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001076// Match intrinisics which expect MM and XMM operand(s).
1077def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1078 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1079 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1080def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1081 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1082 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
1083 (load addr:$src)))]>;
1084def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1085 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1086 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1087def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1088 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1089 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
1090 (load addr:$src)))]>;
1091def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1092 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1093 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1094def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1095 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1096 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
1097 (load addr:$src)))]>;
1098
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001100def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 [(set GR32:$dst,
1103 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001104def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001105 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1107 (load addr:$src)))]>;
1108
1109// Comparison instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001110let isTwoAddress = 1, neverHasSideEffects = 1 in {
Evan Cheng653c7ac2007-12-20 19:57:09 +00001111 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001112 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001113 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001114let mayLoad = 1 in
Evan Cheng653c7ac2007-12-20 19:57:09 +00001115 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001116 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001117 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118}
1119
Evan Cheng950aac02007-09-25 01:57:46 +00001120let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001121def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001122 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001123 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001124def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001125 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001126 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001127 (implicit EFLAGS)]>;
1128}
1129
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130// Aliases to match intrinsics which expect XMM operand(s).
1131let isTwoAddress = 1 in {
Evan Cheng653c7ac2007-12-20 19:57:09 +00001132 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001133 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001134 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1136 VR128:$src, imm:$cc))]>;
Evan Cheng653c7ac2007-12-20 19:57:09 +00001137 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001138 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001139 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1141 (load addr:$src), imm:$cc))]>;
1142}
1143
Evan Cheng950aac02007-09-25 01:57:46 +00001144let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001145def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001146 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001147 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1148 (implicit EFLAGS)]>;
1149def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001150 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001151 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1152 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153
Evan Chengb783fa32007-07-19 01:14:50 +00001154def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001155 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001156 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1157 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001158def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001159 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001160 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001161 (implicit EFLAGS)]>;
1162} // Defs = EFLAGS]
1163
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164// Aliases of packed SSE2 instructions for scalar use. These all have names that
1165// start with 'Fs'.
1166
1167// Alias instructions that map fld0 to pxor for sse.
Chris Lattner17dab4a2008-01-10 05:45:39 +00001168let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001169def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001170 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001171 Requires<[HasSSE2]>, TB, OpSize;
1172
1173// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1174// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001175let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001176def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001177 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001178
1179// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1180// disregarded.
Chris Lattner1a1932c2008-01-06 23:38:27 +00001181let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001182def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001183 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001184 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185
1186// Alias bitwise logical operations using SSE logical ops on packed FP values.
1187let isTwoAddress = 1 in {
1188let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001189 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001190 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001191 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001192 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001193 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001195 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001196 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1198}
1199
Evan Chengb783fa32007-07-19 01:14:50 +00001200def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001201 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001203 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001204def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001205 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001207 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001208def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001209 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001211 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001213let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001214def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001215 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001216 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001217let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001219 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001220 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001221}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001222}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223
1224/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1225///
1226/// In addition, we also have a special variant of the scalar form here to
1227/// represent the associated intrinsic operation. This form is unlike the
1228/// plain scalar form, in that it takes an entire vector (instead of a scalar)
1229/// and leaves the top elements undefined.
1230///
1231/// These three forms can each be reg+reg or reg+mem, so there are a total of
1232/// six "instructions".
1233///
1234let isTwoAddress = 1 in {
1235multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1236 SDNode OpNode, Intrinsic F64Int,
1237 bit Commutable = 0> {
1238 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001239 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001240 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1242 let isCommutable = Commutable;
1243 }
1244
1245 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001246 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001247 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1249
1250 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001251 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001252 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1254 let isCommutable = Commutable;
1255 }
1256
1257 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001258 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001259 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001260 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261
1262 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001263 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001264 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1266 let isCommutable = Commutable;
1267 }
1268
1269 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001270 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001271 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 [(set VR128:$dst, (F64Int VR128:$src1,
1273 sse_load_f64:$src2))]>;
1274}
1275}
1276
1277// Arithmetic instructions
1278defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1279defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1280defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1281defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1282
1283/// sse2_fp_binop_rm - Other SSE2 binops
1284///
1285/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1286/// instructions for a full-vector intrinsic form. Operations that map
1287/// onto C operators don't use this form since they just use the plain
1288/// vector form instead of having a separate vector intrinsic form.
1289///
1290/// This provides a total of eight "instructions".
1291///
1292let isTwoAddress = 1 in {
1293multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1294 SDNode OpNode,
1295 Intrinsic F64Int,
1296 Intrinsic V2F64Int,
1297 bit Commutable = 0> {
1298
1299 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001300 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001301 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1303 let isCommutable = Commutable;
1304 }
1305
1306 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001307 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001308 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1310
1311 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001312 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001313 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1315 let isCommutable = Commutable;
1316 }
1317
1318 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001319 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001320 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001321 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322
1323 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001324 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001325 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1327 let isCommutable = Commutable;
1328 }
1329
1330 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001331 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001332 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333 [(set VR128:$dst, (F64Int VR128:$src1,
1334 sse_load_f64:$src2))]>;
1335
1336 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001337 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001338 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1340 let isCommutable = Commutable;
1341 }
1342
1343 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +00001344 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001345 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(set VR128:$dst, (V2F64Int VR128:$src1, (load addr:$src2)))]>;
1347}
1348}
1349
1350defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1351 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1352defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1353 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1354
1355//===----------------------------------------------------------------------===//
1356// SSE packed FP Instructions
1357
1358// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001359let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001360def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001361 "movapd\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001362let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001363def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001364 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001365 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366
Evan Chengb783fa32007-07-19 01:14:50 +00001367def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001368 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001369 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001370
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001371let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001372def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001373 "movupd\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001374let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001375def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001376 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001377 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001378def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001379 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001380 [(store (v2f64 VR128:$src), addr:$dst)]>;
1381
1382// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001383def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001384 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001385 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001386def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001387 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001388 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389
1390let isTwoAddress = 1 in {
1391 let AddedComplexity = 20 in {
1392 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001393 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001394 "movlpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395 [(set VR128:$dst,
1396 (v2f64 (vector_shuffle VR128:$src1,
1397 (scalar_to_vector (loadf64 addr:$src2)),
1398 MOVLP_shuffle_mask)))]>;
1399 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001400 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001401 "movhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001402 [(set VR128:$dst,
1403 (v2f64 (vector_shuffle VR128:$src1,
1404 (scalar_to_vector (loadf64 addr:$src2)),
1405 MOVHP_shuffle_mask)))]>;
1406 } // AddedComplexity
1407} // isTwoAddress
1408
Evan Chengb783fa32007-07-19 01:14:50 +00001409def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001410 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411 [(store (f64 (vector_extract (v2f64 VR128:$src),
1412 (iPTR 0))), addr:$dst)]>;
1413
1414// v2f64 extract element 1 is always custom lowered to unpack high to low
1415// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001416def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418 [(store (f64 (vector_extract
1419 (v2f64 (vector_shuffle VR128:$src, (undef),
1420 UNPCKH_shuffle_mask)), (iPTR 0))),
1421 addr:$dst)]>;
1422
1423// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001424def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1427 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001428def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001429 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001430 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
Dan Gohman4a4f1512007-07-18 20:23:34 +00001431 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001432 TB, Requires<[HasSSE2]>;
1433
1434// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001435def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001436 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001437 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1438 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001439def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001440 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001441 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
Dan Gohman4a4f1512007-07-18 20:23:34 +00001442 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443 XS, Requires<[HasSSE2]>;
1444
Evan Chengb783fa32007-07-19 01:14:50 +00001445def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001446 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001448def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001449 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001450 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1451 (load addr:$src)))]>;
1452// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001453def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001454 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1456 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001457def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001459 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1460 (load addr:$src)))]>,
1461 XS, Requires<[HasSSE2]>;
1462
1463// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001464def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001465 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001466 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1467 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001468def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001470 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1471 (load addr:$src)))]>,
1472 XD, Requires<[HasSSE2]>;
1473
Evan Chengb783fa32007-07-19 01:14:50 +00001474def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001477def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001478 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001479 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1480 (load addr:$src)))]>;
1481
1482// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001483def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001485 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1486 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001487def Int_CVTPS2PDrm : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001488 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1490 (load addr:$src)))]>,
1491 TB, Requires<[HasSSE2]>;
1492
Evan Chengb783fa32007-07-19 01:14:50 +00001493def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001494 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001495 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001496def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001498 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1499 (load addr:$src)))]>;
1500
1501// Match intrinsics which expect XMM operand(s).
1502// Aliases for intrinsics
1503let isTwoAddress = 1 in {
1504def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001505 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001507 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1508 GR32:$src2))]>;
1509def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001510 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001512 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1513 (loadi32 addr:$src2)))]>;
1514def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001515 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1518 VR128:$src2))]>;
1519def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001520 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001521 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1523 (load addr:$src2)))]>;
1524def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001525 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001526 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001527 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1528 VR128:$src2))]>, XS,
1529 Requires<[HasSSE2]>;
1530def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001531 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001532 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1534 (load addr:$src2)))]>, XS,
1535 Requires<[HasSSE2]>;
1536}
1537
1538// Arithmetic
1539
1540/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1541///
1542/// In addition, we also have a special variant of the scalar form here to
1543/// represent the associated intrinsic operation. This form is unlike the
1544/// plain scalar form, in that it takes an entire vector (instead of a
1545/// scalar) and leaves the top elements undefined.
1546///
1547/// And, we have a special variant form for a full-vector intrinsic form.
1548///
1549/// These four forms can each have a reg or a mem operand, so there are a
1550/// total of eight "instructions".
1551///
1552multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1553 SDNode OpNode,
1554 Intrinsic F64Int,
1555 Intrinsic V2F64Int,
1556 bit Commutable = 0> {
1557 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001558 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 [(set FR64:$dst, (OpNode FR64:$src))]> {
1561 let isCommutable = Commutable;
1562 }
1563
1564 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001565 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1568
1569 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001570 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1573 let isCommutable = Commutable;
1574 }
1575
1576 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001577 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001578 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001579 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001580
1581 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001582 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001583 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001584 [(set VR128:$dst, (F64Int VR128:$src))]> {
1585 let isCommutable = Commutable;
1586 }
1587
1588 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001589 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001590 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1592
1593 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001594 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001595 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001596 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1597 let isCommutable = Commutable;
1598 }
1599
1600 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001601 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603 [(set VR128:$dst, (V2F64Int (load addr:$src)))]>;
1604}
1605
1606// Square root.
1607defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1608 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1609
1610// There is no f64 version of the reciprocal approximation instructions.
1611
1612// Logical
1613let isTwoAddress = 1 in {
1614 let isCommutable = 1 in {
1615 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001616 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001617 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001618 [(set VR128:$dst,
1619 (and (bc_v2i64 (v2f64 VR128:$src1)),
1620 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1621 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001622 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001624 [(set VR128:$dst,
1625 (or (bc_v2i64 (v2f64 VR128:$src1)),
1626 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1627 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001628 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001629 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001630 [(set VR128:$dst,
1631 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1632 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1633 }
1634
1635 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001636 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001637 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001638 [(set VR128:$dst,
1639 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001640 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001642 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001643 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644 [(set VR128:$dst,
1645 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001646 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001647 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001648 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001649 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 [(set VR128:$dst,
1651 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001652 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001654 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 [(set VR128:$dst,
1657 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1658 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1659 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001660 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001661 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001662 [(set VR128:$dst,
1663 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001664 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665}
1666
1667let isTwoAddress = 1 in {
1668 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001669 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001670 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001671 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1672 VR128:$src, imm:$cc))]>;
1673 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001674 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001675 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001676 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1677 (load addr:$src), imm:$cc))]>;
1678}
1679
1680// Shuffle and unpack instructions
1681let isTwoAddress = 1 in {
1682 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001683 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685 [(set VR128:$dst, (v2f64 (vector_shuffle
1686 VR128:$src1, VR128:$src2,
1687 SHUFP_shuffle_mask:$src3)))]>;
1688 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001689 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001690 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001691 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 [(set VR128:$dst,
1693 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001694 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001695 SHUFP_shuffle_mask:$src3)))]>;
1696
1697 let AddedComplexity = 10 in {
1698 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001699 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001700 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701 [(set VR128:$dst,
1702 (v2f64 (vector_shuffle
1703 VR128:$src1, VR128:$src2,
1704 UNPCKH_shuffle_mask)))]>;
1705 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001706 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001707 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001708 [(set VR128:$dst,
1709 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001710 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 UNPCKH_shuffle_mask)))]>;
1712
1713 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001714 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001715 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716 [(set VR128:$dst,
1717 (v2f64 (vector_shuffle
1718 VR128:$src1, VR128:$src2,
1719 UNPCKL_shuffle_mask)))]>;
1720 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001721 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001722 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001723 [(set VR128:$dst,
1724 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001725 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001726 UNPCKL_shuffle_mask)))]>;
1727 } // AddedComplexity
1728} // isTwoAddress
1729
1730
1731//===----------------------------------------------------------------------===//
1732// SSE integer instructions
1733
1734// Move Instructions
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001735let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001736def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001737 "movdqa\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001738let isSimpleLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001739def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001741 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001742let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001743def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001744 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001745 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001746let isSimpleLoad = 1, mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001747def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001749 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001750 XS, Requires<[HasSSE2]>;
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001751let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001752def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001753 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001754 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755 XS, Requires<[HasSSE2]>;
1756
Dan Gohman4a4f1512007-07-18 20:23:34 +00001757// Intrinsic forms of MOVDQU load and store
Chris Lattner1a1932c2008-01-06 23:38:27 +00001758let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001759def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001760 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001761 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1762 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001763def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001765 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1766 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001767
1768let isTwoAddress = 1 in {
1769
1770multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1771 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001772 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1775 let isCommutable = Commutable;
1776 }
Evan Chengb783fa32007-07-19 01:14:50 +00001777 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001780 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781}
1782
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783/// PDI_binop_rm - Simple SSE2 binary operator.
1784multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1785 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001786 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1789 let isCommutable = Commutable;
1790 }
Evan Chengb783fa32007-07-19 01:14:50 +00001791 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001794 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795}
1796
1797/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1798///
1799/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1800/// to collapse (bitconvert VT to VT) into its operand.
1801///
1802multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1803 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001804 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001805 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1807 let isCommutable = Commutable;
1808 }
Evan Chengb783fa32007-07-19 01:14:50 +00001809 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001811 [(set VR128:$dst, (OpNode VR128:$src1,(memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812}
1813
1814} // isTwoAddress
1815
1816// 128-bit Integer Arithmetic
1817
1818defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1819defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1820defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1821defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1822
1823defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1824defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1825defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1826defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1827
1828defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1829defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1830defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1831defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1832
1833defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1834defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1835defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1836defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1837
1838defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1839
1840defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1841defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1842defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1843
1844defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1845
1846defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1847defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1848
1849
1850defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1851defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1852defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1853defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1854defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>;
1855
1856
Evan Chengd1045a62008-02-18 23:04:32 +00001857defm PSLLW : PDI_binop_rm_int<0xF1, "psllw", int_x86_sse2_psll_w>;
1858defm PSLLD : PDI_binop_rm_int<0xF2, "pslld", int_x86_sse2_psll_d>;
1859defm PSLLQ : PDI_binop_rm_int<0xF3, "psllq", int_x86_sse2_psll_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860
Evan Chengd1045a62008-02-18 23:04:32 +00001861defm PSRLW : PDI_binop_rm_int<0xD1, "psrlw", int_x86_sse2_psrl_w>;
1862defm PSRLD : PDI_binop_rm_int<0xD2, "psrld", int_x86_sse2_psrl_d>;
1863defm PSRLQ : PDI_binop_rm_int<0xD3, "psrlq", int_x86_sse2_psrl_q>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864
Evan Chengd1045a62008-02-18 23:04:32 +00001865defm PSRAW : PDI_binop_rm_int<0xE1, "psraw", int_x86_sse2_psra_w>;
1866defm PSRAD : PDI_binop_rm_int<0xE2, "psrad", int_x86_sse2_psra_d>;
1867
1868// Some immediate variants need to match a bit_convert.
1869def PSLLWri : PDIi8<0x71, MRM6r, (outs VR128:$dst),
1870 (ins VR128:$src1, i32i8imm:$src2),
1871 "psllw\t{$src2, $dst|$dst, $src2}",
1872 [(set VR128:$dst, (int_x86_sse2_psll_w VR128:$src1,
1873 (bc_v8i16 (v4i32 (scalar_to_vector (i32 imm:$src2))))))]>;
1874def PSLLDri : PDIi8<0x72, MRM6r, (outs VR128:$dst),
1875 (ins VR128:$src1, i32i8imm:$src2),
1876 "pslld\t{$src2, $dst|$dst, $src2}",
1877 [(set VR128:$dst, (int_x86_sse2_psll_d VR128:$src1,
1878 (scalar_to_vector (i32 imm:$src2))))]>;
1879def PSLLQri : PDIi8<0x73, MRM6r, (outs VR128:$dst),
1880 (ins VR128:$src1, i32i8imm:$src2),
1881 "psllq\t{$src2, $dst|$dst, $src2}",
1882 [(set VR128:$dst, (int_x86_sse2_psll_q VR128:$src1,
1883 (bc_v2i64 (v4i32 (scalar_to_vector (i32 imm:$src2))))))]>;
1884
1885def PSRLWri : PDIi8<0x71, MRM2r, (outs VR128:$dst),
1886 (ins VR128:$src1, i32i8imm:$src2),
1887 "psrlw\t{$src2, $dst|$dst, $src2}",
1888 [(set VR128:$dst, (int_x86_sse2_psrl_w VR128:$src1,
1889 (bc_v8i16 (v4i32 (scalar_to_vector (i32 imm:$src2))))))]>;
1890def PSRLDri : PDIi8<0x72, MRM2r, (outs VR128:$dst),
1891 (ins VR128:$src1, i32i8imm:$src2),
1892 "psrld\t{$src2, $dst|$dst, $src2}",
1893 [(set VR128:$dst, (int_x86_sse2_psrl_d VR128:$src1,
1894 (scalar_to_vector (i32 imm:$src2))))]>;
1895def PSRLQri : PDIi8<0x73, MRM2r, (outs VR128:$dst),
1896 (ins VR128:$src1, i32i8imm:$src2),
1897 "psrlq\t{$src2, $dst|$dst, $src2}",
1898 [(set VR128:$dst, (int_x86_sse2_psrl_q VR128:$src1,
1899 (bc_v2i64 (v4i32 (scalar_to_vector (i32 imm:$src2))))))]>;
1900
1901def PSRAWri : PDIi8<0x71, MRM4r, (outs VR128:$dst),
1902 (ins VR128:$src1, i32i8imm:$src2),
1903 "psraw\t{$src2, $dst|$dst, $src2}",
1904 [(set VR128:$dst, (int_x86_sse2_psra_w VR128:$src1,
1905 (bc_v8i16 (v4i32 (scalar_to_vector (i32 imm:$src2))))))]>;
1906def PSRADri : PDIi8<0x72, MRM4r, (outs VR128:$dst),
1907 (ins VR128:$src1, i32i8imm:$src2),
1908 "psrad\t{$src2, $dst|$dst, $src2}",
1909 [(set VR128:$dst, (int_x86_sse2_psra_d VR128:$src1,
1910 (scalar_to_vector (i32 imm:$src2))))]>;
1911
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001912// PSRAQ doesn't exist in SSE[1-3].
1913
1914// 128-bit logical shifts.
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00001915let isTwoAddress = 1, neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001917 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001919 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001920 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001921 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922 // PSRADQri doesn't exist in SSE[1-3].
1923}
1924
1925let Predicates = [HasSSE2] in {
1926 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1927 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1928 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1929 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1930 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1931 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1932}
1933
1934// Logical
1935defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1936defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1937defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1938
1939let isTwoAddress = 1 in {
1940 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001941 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001942 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1944 VR128:$src2)))]>;
1945
1946 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001947 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001948 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001949 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00001950 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001951}
1952
1953// SSE2 Integer comparison
1954defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1955defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
1956defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
1957defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
1958defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
1959defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
1960
1961// Pack instructions
1962defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
1963defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
1964defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
1965
1966// Shuffle and unpack instructions
1967def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001968 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970 [(set VR128:$dst, (v4i32 (vector_shuffle
1971 VR128:$src1, (undef),
1972 PSHUFD_shuffle_mask:$src2)))]>;
1973def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001974 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(set VR128:$dst, (v4i32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001977 (bc_v4i32(memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978 (undef),
1979 PSHUFD_shuffle_mask:$src2)))]>;
1980
1981// SSE2 with ImmT == Imm8 and XS prefix.
1982def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001983 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001984 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985 [(set VR128:$dst, (v8i16 (vector_shuffle
1986 VR128:$src1, (undef),
1987 PSHUFHW_shuffle_mask:$src2)))]>,
1988 XS, Requires<[HasSSE2]>;
1989def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001990 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001991 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001993 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994 (undef),
1995 PSHUFHW_shuffle_mask:$src2)))]>,
1996 XS, Requires<[HasSSE2]>;
1997
1998// SSE2 with ImmT == Imm8 and XD prefix.
1999def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002000 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002 [(set VR128:$dst, (v8i16 (vector_shuffle
2003 VR128:$src1, (undef),
2004 PSHUFLW_shuffle_mask:$src2)))]>,
2005 XD, Requires<[HasSSE2]>;
2006def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002007 (outs VR128:$dst), (ins i128mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002010 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011 (undef),
2012 PSHUFLW_shuffle_mask:$src2)))]>,
2013 XD, Requires<[HasSSE2]>;
2014
2015
2016let isTwoAddress = 1 in {
2017 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002018 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002019 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020 [(set VR128:$dst,
2021 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
2022 UNPCKL_shuffle_mask)))]>;
2023 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002024 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002025 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002026 [(set VR128:$dst,
2027 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002028 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029 UNPCKL_shuffle_mask)))]>;
2030 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002031 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002032 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033 [(set VR128:$dst,
2034 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
2035 UNPCKL_shuffle_mask)))]>;
2036 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002037 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 [(set VR128:$dst,
2040 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002041 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042 UNPCKL_shuffle_mask)))]>;
2043 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002044 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(set VR128:$dst,
2047 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2048 UNPCKL_shuffle_mask)))]>;
2049 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002050 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002052 [(set VR128:$dst,
2053 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002054 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055 UNPCKL_shuffle_mask)))]>;
2056 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002057 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002058 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002059 [(set VR128:$dst,
2060 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2061 UNPCKL_shuffle_mask)))]>;
2062 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002063 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(set VR128:$dst,
2066 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002067 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002068 UNPCKL_shuffle_mask)))]>;
2069
2070 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002071 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002072 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002073 [(set VR128:$dst,
2074 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
2075 UNPCKH_shuffle_mask)))]>;
2076 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002077 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079 [(set VR128:$dst,
2080 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002081 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082 UNPCKH_shuffle_mask)))]>;
2083 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002084 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002086 [(set VR128:$dst,
2087 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
2088 UNPCKH_shuffle_mask)))]>;
2089 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002090 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092 [(set VR128:$dst,
2093 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002094 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002095 UNPCKH_shuffle_mask)))]>;
2096 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002097 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002098 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002099 [(set VR128:$dst,
2100 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2101 UNPCKH_shuffle_mask)))]>;
2102 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002103 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002104 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002105 [(set VR128:$dst,
2106 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002107 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002108 UNPCKH_shuffle_mask)))]>;
2109 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002110 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(set VR128:$dst,
2113 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2114 UNPCKH_shuffle_mask)))]>;
2115 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002116 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002117 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118 [(set VR128:$dst,
2119 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002120 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121 UNPCKH_shuffle_mask)))]>;
2122}
2123
2124// Extract / Insert
2125def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002126 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002127 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
Nate Begemand77e59e2008-02-11 04:19:36 +00002129 imm:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130let isTwoAddress = 1 in {
2131 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002132 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002134 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002135 [(set VR128:$dst,
Nate Begemand77e59e2008-02-11 04:19:36 +00002136 (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002138 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Nate Begemand77e59e2008-02-11 04:19:36 +00002141 [(set VR128:$dst,
2142 (X86pinsrw VR128:$src1, (extloadi16 addr:$src2),
2143 imm:$src3))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144}
2145
2146// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002147def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002148 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2150
2151// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002152let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002153def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002155 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156
2157// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002158def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002161def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002162 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002164def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002165 "movnti\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002166 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2167 TB, Requires<[HasSSE2]>;
2168
2169// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002170def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172 TB, Requires<[HasSSE2]>;
2173
2174// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +00002175def LFENCE : I<0xAE, MRM5m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002176 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002177def MFENCE : I<0xAE, MRM6m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002178 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2179
Andrew Lenharth785610d2008-02-16 01:24:58 +00002180//TODO: custom lower this so as to never even generate the noop
2181def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
2182 (i8 0)), (NOOP)>;
2183def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>;
2184def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>;
2185def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss),
2186 (i8 1)), (MFENCE)>;
2187
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188// Alias instructions that map zero vector to pxor / xorp* for sse.
Chris Lattner17dab4a2008-01-10 05:45:39 +00002189let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002190 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002191 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002192 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193
2194// FR64 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +00002195def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002197 [(set VR128:$dst,
2198 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002199def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002200 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002201 [(set VR128:$dst,
2202 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2203
Evan Chengb783fa32007-07-19 01:14:50 +00002204def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 [(set VR128:$dst,
2207 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002208def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210 [(set VR128:$dst,
2211 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2212
Evan Chengb783fa32007-07-19 01:14:50 +00002213def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002214 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002215 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2216
Evan Chengb783fa32007-07-19 01:14:50 +00002217def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2220
2221// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002222def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002224 [(set VR128:$dst,
2225 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2226 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002227def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229 [(store (i64 (vector_extract (v2i64 VR128:$src),
2230 (iPTR 0))), addr:$dst)]>;
2231
2232// FIXME: may not be able to eliminate this movss with coalescing the src and
2233// dest register classes are different. We really want to write this pattern
2234// like this:
2235// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2236// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +00002237def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002238 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002239 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2240 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002241def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002242 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002243 [(store (f64 (vector_extract (v2f64 VR128:$src),
2244 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002245def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2248 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002249def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002250 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251 [(store (i32 (vector_extract (v4i32 VR128:$src),
2252 (iPTR 0))), addr:$dst)]>;
2253
Evan Chengb783fa32007-07-19 01:14:50 +00002254def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002255 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002256 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002257def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002258 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2260
2261
2262// Move to lower bits of a VR128, leaving upper bits alone.
2263// Three operand (but two address) aliases.
2264let isTwoAddress = 1 in {
Chris Lattnerd1a9eb62008-01-11 06:59:07 +00002265 let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002266 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002267 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002268 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269
2270 let AddedComplexity = 15 in
2271 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002272 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002274 [(set VR128:$dst,
2275 (v2f64 (vector_shuffle VR128:$src1, VR128:$src2,
2276 MOVL_shuffle_mask)))]>;
2277}
2278
2279// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002280def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2283
2284// Move to lower bits of a VR128 and zeroing upper bits.
2285// Loading from memory automatically zeroing upper bits.
2286let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002287 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289 [(set VR128:$dst,
Chris Lattnere6aa3862007-11-25 00:24:49 +00002290 (v2f64 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291 (v2f64 (scalar_to_vector
2292 (loadf64 addr:$src))),
2293 MOVL_shuffle_mask)))]>;
2294
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295// movd / movq to XMM register zero-extends
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002296let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002297def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002298 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002299 [(set VR128:$dst,
2300 (v4i32 (vector_shuffle immAllZerosV,
2301 (v4i32 (scalar_to_vector GR32:$src)),
2302 MOVL_shuffle_mask)))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002303// This is X86-64 only.
2304def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2305 "mov{d|q}\t{$src, $dst|$dst, $src}",
2306 [(set VR128:$dst,
2307 (v2i64 (vector_shuffle immAllZerosV_bc,
2308 (v2i64 (scalar_to_vector GR64:$src)),
2309 MOVL_shuffle_mask)))]>;
2310}
2311
2312let AddedComplexity = 20 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002313def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002314 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002315 [(set VR128:$dst,
2316 (v4i32 (vector_shuffle immAllZerosV,
2317 (v4i32 (scalar_to_vector (loadi32 addr:$src))),
2318 MOVL_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002319def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002320 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002321 [(set VR128:$dst,
2322 (v2i64 (vector_shuffle immAllZerosV_bc,
2323 (v2i64 (scalar_to_vector (loadi64 addr:$src))),
2324 MOVL_shuffle_mask)))]>, XS,
2325 Requires<[HasSSE2]>;
2326}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002328// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2329// IA32 document. movq xmm1, xmm2 does clear the high bits.
2330let AddedComplexity = 15 in
2331def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2332 "movq\t{$src, $dst|$dst, $src}",
2333 [(set VR128:$dst, (v2i64 (vector_shuffle immAllZerosV_bc,
2334 VR128:$src,
2335 MOVL_shuffle_mask)))]>,
2336 XS, Requires<[HasSSE2]>;
2337
2338let AddedComplexity = 20 in
2339def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2340 "movq\t{$src, $dst|$dst, $src}",
2341 [(set VR128:$dst, (v2i64 (vector_shuffle immAllZerosV_bc,
2342 (memopv2i64 addr:$src),
2343 MOVL_shuffle_mask)))]>,
2344 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002345
2346//===----------------------------------------------------------------------===//
2347// SSE3 Instructions
2348//===----------------------------------------------------------------------===//
2349
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002350// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002351def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002353 [(set VR128:$dst, (v4f32 (vector_shuffle
2354 VR128:$src, (undef),
2355 MOVSHDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002356def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002358 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002359 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002360 MOVSHDUP_shuffle_mask)))]>;
2361
Evan Chengb783fa32007-07-19 01:14:50 +00002362def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002363 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002364 [(set VR128:$dst, (v4f32 (vector_shuffle
2365 VR128:$src, (undef),
2366 MOVSLDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002367def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002368 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002369 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002370 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002371 MOVSLDUP_shuffle_mask)))]>;
2372
Evan Chengb783fa32007-07-19 01:14:50 +00002373def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002374 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002375 [(set VR128:$dst, (v2f64 (vector_shuffle
2376 VR128:$src, (undef),
2377 SSE_splat_lo_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002378def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002379 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002380 [(set VR128:$dst,
2381 (v2f64 (vector_shuffle
2382 (scalar_to_vector (loadf64 addr:$src)),
2383 (undef),
2384 SSE_splat_lo_mask)))]>;
2385
2386// Arithmetic
2387let isTwoAddress = 1 in {
2388 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002389 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002390 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002391 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2392 VR128:$src2))]>;
2393 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002394 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002395 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002396 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2397 (load addr:$src2)))]>;
2398 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002399 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002400 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002401 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2402 VR128:$src2))]>;
2403 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002404 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002405 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002406 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2407 (load addr:$src2)))]>;
2408}
2409
Evan Chengb783fa32007-07-19 01:14:50 +00002410def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002411 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002412 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2413
2414// Horizontal ops
2415class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002416 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002417 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2419class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002420 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002421 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002422 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (load addr:$src2))))]>;
2423class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002424 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002425 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002426 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2427class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002428 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002429 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002430 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (load addr:$src2))))]>;
2431
2432let isTwoAddress = 1 in {
2433 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2434 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2435 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2436 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2437 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2438 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2439 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2440 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2441}
2442
2443// Thread synchronization
Evan Chengb783fa32007-07-19 01:14:50 +00002444def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002445 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002446def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2448
2449// vector_shuffle v1, <undef> <1, 1, 3, 3>
2450let AddedComplexity = 15 in
2451def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2452 MOVSHDUP_shuffle_mask)),
2453 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2454let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002455def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002456 MOVSHDUP_shuffle_mask)),
2457 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2458
2459// vector_shuffle v1, <undef> <0, 0, 2, 2>
2460let AddedComplexity = 15 in
2461 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2462 MOVSLDUP_shuffle_mask)),
2463 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2464let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002465 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002466 MOVSLDUP_shuffle_mask)),
2467 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2468
2469//===----------------------------------------------------------------------===//
2470// SSSE3 Instructions
2471//===----------------------------------------------------------------------===//
2472
Bill Wendling98680292007-08-10 06:22:27 +00002473/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002474multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2475 Intrinsic IntId64, Intrinsic IntId128> {
2476 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2477 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2478 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002479
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002480 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2481 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2482 [(set VR64:$dst,
2483 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2484
2485 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2486 (ins VR128:$src),
2487 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2488 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2489 OpSize;
2490
2491 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2492 (ins i128mem:$src),
2493 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2494 [(set VR128:$dst,
2495 (IntId128
2496 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002497}
2498
Bill Wendling98680292007-08-10 06:22:27 +00002499/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002500multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2501 Intrinsic IntId64, Intrinsic IntId128> {
2502 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2503 (ins VR64:$src),
2504 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2505 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002506
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002507 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2508 (ins i64mem:$src),
2509 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2510 [(set VR64:$dst,
2511 (IntId64
2512 (bitconvert (memopv4i16 addr:$src))))]>;
2513
2514 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2515 (ins VR128:$src),
2516 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2517 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2518 OpSize;
2519
2520 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2521 (ins i128mem:$src),
2522 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2523 [(set VR128:$dst,
2524 (IntId128
2525 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002526}
2527
2528/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002529multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2530 Intrinsic IntId64, Intrinsic IntId128> {
2531 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2532 (ins VR64:$src),
2533 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2534 [(set VR64:$dst, (IntId64 VR64:$src))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002535
Nate Begeman9a58b8a2008-02-09 23:46:37 +00002536 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2537 (ins i64mem:$src),
2538 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2539 [(set VR64:$dst,
2540 (IntId64
2541 (bitconvert (memopv2i32 addr:$src))))]>;
2542
2543 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2544 (ins VR128:$src),
2545 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2546 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2547 OpSize;
2548
2549 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2550 (ins i128mem:$src),
2551 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2552 [(set VR128:$dst,
2553 (IntId128
2554 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002555}
2556
2557defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2558 int_x86_ssse3_pabs_b,
2559 int_x86_ssse3_pabs_b_128>;
2560defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2561 int_x86_ssse3_pabs_w,
2562 int_x86_ssse3_pabs_w_128>;
2563defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2564 int_x86_ssse3_pabs_d,
2565 int_x86_ssse3_pabs_d_128>;
2566
2567/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2568let isTwoAddress = 1 in {
2569 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2570 Intrinsic IntId64, Intrinsic IntId128,
2571 bit Commutable = 0> {
2572 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2573 (ins VR64:$src1, VR64:$src2),
2574 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2575 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2576 let isCommutable = Commutable;
2577 }
2578 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2579 (ins VR64:$src1, i64mem:$src2),
2580 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2581 [(set VR64:$dst,
2582 (IntId64 VR64:$src1,
2583 (bitconvert (memopv8i8 addr:$src2))))]>;
2584
2585 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2586 (ins VR128:$src1, VR128:$src2),
2587 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2588 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2589 OpSize {
2590 let isCommutable = Commutable;
2591 }
2592 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2593 (ins VR128:$src1, i128mem:$src2),
2594 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2595 [(set VR128:$dst,
2596 (IntId128 VR128:$src1,
2597 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2598 }
2599}
2600
2601/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2602let isTwoAddress = 1 in {
2603 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2604 Intrinsic IntId64, Intrinsic IntId128,
2605 bit Commutable = 0> {
2606 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2607 (ins VR64:$src1, VR64:$src2),
2608 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2609 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2610 let isCommutable = Commutable;
2611 }
2612 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2613 (ins VR64:$src1, i64mem:$src2),
2614 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2615 [(set VR64:$dst,
2616 (IntId64 VR64:$src1,
2617 (bitconvert (memopv4i16 addr:$src2))))]>;
2618
2619 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2620 (ins VR128:$src1, VR128:$src2),
2621 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2622 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2623 OpSize {
2624 let isCommutable = Commutable;
2625 }
2626 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2627 (ins VR128:$src1, i128mem:$src2),
2628 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2629 [(set VR128:$dst,
2630 (IntId128 VR128:$src1,
2631 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2632 }
2633}
2634
2635/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2636let isTwoAddress = 1 in {
2637 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2638 Intrinsic IntId64, Intrinsic IntId128,
2639 bit Commutable = 0> {
2640 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2641 (ins VR64:$src1, VR64:$src2),
2642 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2643 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2644 let isCommutable = Commutable;
2645 }
2646 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2647 (ins VR64:$src1, i64mem:$src2),
2648 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2649 [(set VR64:$dst,
2650 (IntId64 VR64:$src1,
2651 (bitconvert (memopv2i32 addr:$src2))))]>;
2652
2653 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2654 (ins VR128:$src1, VR128:$src2),
2655 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2656 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2657 OpSize {
2658 let isCommutable = Commutable;
2659 }
2660 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2661 (ins VR128:$src1, i128mem:$src2),
2662 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2663 [(set VR128:$dst,
2664 (IntId128 VR128:$src1,
2665 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2666 }
2667}
2668
2669defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2670 int_x86_ssse3_phadd_w,
2671 int_x86_ssse3_phadd_w_128, 1>;
2672defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2673 int_x86_ssse3_phadd_d,
2674 int_x86_ssse3_phadd_d_128, 1>;
2675defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2676 int_x86_ssse3_phadd_sw,
2677 int_x86_ssse3_phadd_sw_128, 1>;
2678defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2679 int_x86_ssse3_phsub_w,
2680 int_x86_ssse3_phsub_w_128>;
2681defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2682 int_x86_ssse3_phsub_d,
2683 int_x86_ssse3_phsub_d_128>;
2684defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2685 int_x86_ssse3_phsub_sw,
2686 int_x86_ssse3_phsub_sw_128>;
2687defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2688 int_x86_ssse3_pmadd_ub_sw,
2689 int_x86_ssse3_pmadd_ub_sw_128, 1>;
2690defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2691 int_x86_ssse3_pmul_hr_sw,
2692 int_x86_ssse3_pmul_hr_sw_128, 1>;
2693defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2694 int_x86_ssse3_pshuf_b,
2695 int_x86_ssse3_pshuf_b_128>;
2696defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2697 int_x86_ssse3_psign_b,
2698 int_x86_ssse3_psign_b_128>;
2699defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2700 int_x86_ssse3_psign_w,
2701 int_x86_ssse3_psign_w_128>;
2702defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2703 int_x86_ssse3_psign_d,
2704 int_x86_ssse3_psign_d_128>;
2705
2706let isTwoAddress = 1 in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002707 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2708 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002709 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002710 [(set VR64:$dst,
2711 (int_x86_ssse3_palign_r
2712 VR64:$src1, VR64:$src2,
2713 imm:$src3))]>;
2714 def PALIGNR64rm : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2715 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002716 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002717 [(set VR64:$dst,
2718 (int_x86_ssse3_palign_r
2719 VR64:$src1,
2720 (bitconvert (memopv2i32 addr:$src2)),
2721 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002722
Bill Wendling1dc817c2007-08-10 09:00:17 +00002723 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2724 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002725 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002726 [(set VR128:$dst,
2727 (int_x86_ssse3_palign_r_128
2728 VR128:$src1, VR128:$src2,
2729 imm:$src3))]>, OpSize;
2730 def PALIGNR128rm : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2731 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002732 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002733 [(set VR128:$dst,
2734 (int_x86_ssse3_palign_r_128
2735 VR128:$src1,
2736 (bitconvert (memopv4i32 addr:$src2)),
2737 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002738}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002739
2740//===----------------------------------------------------------------------===//
2741// Non-Instruction Patterns
2742//===----------------------------------------------------------------------===//
2743
2744// 128-bit vector undef's.
Bill Wendling1dc817c2007-08-10 09:00:17 +00002745def : Pat<(v4f32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002746def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2747def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2748def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2749def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2750def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2751
Chris Lattnerdec9cb52008-01-24 08:07:48 +00002752// extload f32 -> f64. This matches load+fextend because we have a hack in
2753// the isel (PreprocessForFPConvert) that can introduce loads after dag combine.
2754// Since these loads aren't folded into the fextend, we have to match it
2755// explicitly here.
2756let Predicates = [HasSSE2] in
2757 def : Pat<(fextend (loadf32 addr:$src)),
2758 (CVTSS2SDrm addr:$src)>;
2759
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002760// bit_convert
2761let Predicates = [HasSSE2] in {
2762 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2763 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2764 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2765 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2766 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2767 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2768 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2769 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2770 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2771 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2772 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2773 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2774 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2775 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2776 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2777 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2778 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2779 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2780 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2781 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2782 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2783 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2784 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2785 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2786 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2787 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2788 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2789 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2790 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2791 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2792}
2793
2794// Move scalar to XMM zero-extended
2795// movd to XMM register zero-extends
2796let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002797// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Chris Lattnere6aa3862007-11-25 00:24:49 +00002798def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002799 (v2f64 (scalar_to_vector FR64:$src)), MOVL_shuffle_mask)),
2800 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Chris Lattnere6aa3862007-11-25 00:24:49 +00002801def : Pat<(v4f32 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002802 (v4f32 (scalar_to_vector FR32:$src)), MOVL_shuffle_mask)),
2803 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>;
2804}
2805
2806// Splat v2f64 / v2i64
2807let AddedComplexity = 10 in {
2808def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2809 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2810def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2811 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2812def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2813 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2814def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2815 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2816}
2817
2818// Splat v4f32
2819def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SSE_splat_mask:$sm),
2820 (SHUFPSrri VR128:$src, VR128:$src, SSE_splat_mask:$sm)>,
2821 Requires<[HasSSE1]>;
2822
2823// Special unary SHUFPSrri case.
2824// FIXME: when we want non two-address code, then we should use PSHUFD?
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002825def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2826 SHUFP_unary_shuffle_mask:$sm)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002827 (SHUFPSrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2828 Requires<[HasSSE1]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002829// Special unary SHUFPDrri case.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002830def : Pat<(v2f64 (vector_shuffle VR128:$src1, (undef),
2831 SHUFP_unary_shuffle_mask:$sm)),
Dan Gohman7dc19012007-08-02 21:17:01 +00002832 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2833 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002834// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Dan Gohman4a4f1512007-07-18 20:23:34 +00002835def : Pat<(vector_shuffle (memopv4f32 addr:$src1), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002836 SHUFP_unary_shuffle_mask:$sm),
2837 (PSHUFDmi addr:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2838 Requires<[HasSSE2]>;
2839// Special binary v4i32 shuffle cases with SHUFPS.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002840def : Pat<(v4i32 (vector_shuffle VR128:$src1, (v4i32 VR128:$src2),
2841 PSHUFD_binary_shuffle_mask:$sm)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002842 (SHUFPSrri VR128:$src1, VR128:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2843 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002844def : Pat<(v4i32 (vector_shuffle VR128:$src1,
2845 (bc_v4i32 (memopv2i64 addr:$src2)), PSHUFD_binary_shuffle_mask:$sm)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002846 (SHUFPSrmi VR128:$src1, addr:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2847 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002848// Special binary v2i64 shuffle cases using SHUFPDrri.
2849def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2850 SHUFP_shuffle_mask:$sm)),
2851 (SHUFPDrri VR128:$src1, VR128:$src2, SHUFP_shuffle_mask:$sm)>,
2852 Requires<[HasSSE2]>;
2853// Special unary SHUFPDrri case.
2854def : Pat<(v2i64 (vector_shuffle VR128:$src1, (undef),
2855 SHUFP_unary_shuffle_mask:$sm)),
2856 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2857 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002858
2859// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2860let AddedComplexity = 10 in {
2861def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2862 UNPCKL_v_undef_shuffle_mask)),
2863 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2864def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2865 UNPCKL_v_undef_shuffle_mask)),
2866 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2867def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2868 UNPCKL_v_undef_shuffle_mask)),
2869 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2870def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2871 UNPCKL_v_undef_shuffle_mask)),
2872 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2873}
2874
2875// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2876let AddedComplexity = 10 in {
2877def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2878 UNPCKH_v_undef_shuffle_mask)),
2879 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2880def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2881 UNPCKH_v_undef_shuffle_mask)),
2882 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2883def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2884 UNPCKH_v_undef_shuffle_mask)),
2885 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2886def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2887 UNPCKH_v_undef_shuffle_mask)),
2888 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2889}
2890
2891let AddedComplexity = 15 in {
2892// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2893def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2894 MOVHP_shuffle_mask)),
2895 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2896
2897// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2898def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2899 MOVHLPS_shuffle_mask)),
2900 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2901
2902// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2903def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2904 MOVHLPS_v_undef_shuffle_mask)),
2905 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2906def : Pat<(v4i32 (vector_shuffle VR128:$src1, (undef),
2907 MOVHLPS_v_undef_shuffle_mask)),
2908 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2909}
2910
2911let AddedComplexity = 20 in {
2912// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2913// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Dan Gohman4a4f1512007-07-18 20:23:34 +00002914def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002915 MOVLP_shuffle_mask)),
2916 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002917def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002918 MOVLP_shuffle_mask)),
2919 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002920def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002921 MOVHP_shuffle_mask)),
2922 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002923def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002924 MOVHP_shuffle_mask)),
2925 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2926
Dan Gohman4a4f1512007-07-18 20:23:34 +00002927def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002928 MOVLP_shuffle_mask)),
2929 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002930def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002931 MOVLP_shuffle_mask)),
2932 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002933def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002934 MOVHP_shuffle_mask)),
2935 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002936def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937 MOVLP_shuffle_mask)),
2938 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2939}
2940
2941let AddedComplexity = 15 in {
2942// Setting the lowest element in the vector.
2943def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2944 MOVL_shuffle_mask)),
2945 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2946def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2947 MOVL_shuffle_mask)),
2948 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2949
2950// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
2951def : Pat<(v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
2952 MOVLP_shuffle_mask)),
2953 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2954def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2955 MOVLP_shuffle_mask)),
2956 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2957}
2958
2959// Set lowest element and zero upper elements.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002960let AddedComplexity = 15 in
2961def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc, VR128:$src,
2962 MOVL_shuffle_mask)),
2963 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
2964
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002965
2966// FIXME: Temporary workaround since 2-wide shuffle is broken.
2967def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
2968 (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2969def : Pat<(int_x86_sse2_loadh_pd VR128:$src1, addr:$src2),
2970 (v2f64 (MOVHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2971def : Pat<(int_x86_sse2_loadl_pd VR128:$src1, addr:$src2),
2972 (v2f64 (MOVLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2973def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
2974 (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
2975 Requires<[HasSSE2]>;
2976def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (load addr:$src2), imm:$src3),
2977 (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
2978 Requires<[HasSSE2]>;
2979def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
2980 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2981def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (load addr:$src2)),
2982 (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2983def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
2984 (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2985def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (load addr:$src2)),
2986 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2987def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2),
2988 (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2989def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (load addr:$src2)),
2990 (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2991def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2),
2992 (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2993def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (load addr:$src2)),
2994 (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2995
2996// Some special case pandn patterns.
2997def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2998 VR128:$src2)),
2999 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3000def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
3001 VR128:$src2)),
3002 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3003def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
3004 VR128:$src2)),
3005 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
3006
3007def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00003008 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003009 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3010def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00003011 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003012 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3013def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00003014 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003015 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
3016
Nate Begeman78246ca2007-11-17 03:58:34 +00003017// vector -> vector casts
3018def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
3019 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
3020def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
3021 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
3022
Evan Cheng51a49b22007-07-20 00:27:43 +00003023// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00003024def : Pat<(alignedloadv4i32 addr:$src),
3025 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
3026def : Pat<(loadv4i32 addr:$src),
3027 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00003028def : Pat<(alignedloadv2i64 addr:$src),
3029 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3030def : Pat<(loadv2i64 addr:$src),
3031 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3032
3033def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3034 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3035def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3036 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3037def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3038 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3039def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3040 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3041def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3042 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3043def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3044 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3045def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3046 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3047def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3048 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Nate Begemanb2975562008-02-03 07:18:54 +00003049
3050//===----------------------------------------------------------------------===//
3051// SSE4.1 Instructions
3052//===----------------------------------------------------------------------===//
3053
Nate Begemanb2975562008-02-03 07:18:54 +00003054multiclass sse41_fp_unop_rm<bits<8> opcss, bits<8> opcps,
3055 bits<8> opcsd, bits<8> opcpd,
3056 string OpcodeStr,
3057 Intrinsic F32Int,
3058 Intrinsic V4F32Int,
3059 Intrinsic F64Int,
Nate Begemaneb3f5432008-02-04 05:34:34 +00003060 Intrinsic V2F64Int> {
Nate Begemanb2975562008-02-03 07:18:54 +00003061 // Intrinsic operation, reg.
Nate Begemaneb3f5432008-02-04 05:34:34 +00003062 def SSr_Int : SS4AI<opcss, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003063 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003064 !strconcat(OpcodeStr,
3065 "ss\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003066 [(set VR128:$dst, (F32Int VR128:$src1, imm:$src2))]>,
3067 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003068
3069 // Intrinsic operation, mem.
Nate Begemaneb3f5432008-02-04 05:34:34 +00003070 def SSm_Int : SS4AI<opcss, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003071 (outs VR128:$dst), (ins ssmem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003072 !strconcat(OpcodeStr,
3073 "ss\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003074 [(set VR128:$dst, (F32Int sse_load_f32:$src1, imm:$src2))]>,
3075 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003076
3077 // Vector intrinsic operation, reg
Nate Begemaneb3f5432008-02-04 05:34:34 +00003078 def PSr_Int : SS4AI<opcps, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003079 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003080 !strconcat(OpcodeStr,
3081 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003082 [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>,
3083 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003084
3085 // Vector intrinsic operation, mem
Nate Begemaneb3f5432008-02-04 05:34:34 +00003086 def PSm_Int : SS4AI<opcps, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003087 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003088 !strconcat(OpcodeStr,
3089 "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003090 [(set VR128:$dst, (V4F32Int (load addr:$src1),imm:$src2))]>,
3091 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003092
3093 // Intrinsic operation, reg.
Nate Begemaneb3f5432008-02-04 05:34:34 +00003094 def SDr_Int : SS4AI<opcsd, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003095 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003096 !strconcat(OpcodeStr,
3097 "sd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003098 [(set VR128:$dst, (F64Int VR128:$src1, imm:$src2))]>,
3099 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003100
3101 // Intrinsic operation, mem.
Nate Begemaneb3f5432008-02-04 05:34:34 +00003102 def SDm_Int : SS4AI<opcsd, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003103 (outs VR128:$dst), (ins sdmem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003104 !strconcat(OpcodeStr,
3105 "sd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003106 [(set VR128:$dst, (F64Int sse_load_f64:$src1, imm:$src2))]>,
3107 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003108
3109 // Vector intrinsic operation, reg
Nate Begemaneb3f5432008-02-04 05:34:34 +00003110 def PDr_Int : SS4AI<opcpd, MRMSrcReg,
Nate Begeman72d802a2008-02-04 06:00:24 +00003111 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003112 !strconcat(OpcodeStr,
3113 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003114 [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>,
3115 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003116
3117 // Vector intrinsic operation, mem
Nate Begemaneb3f5432008-02-04 05:34:34 +00003118 def PDm_Int : SS4AI<opcpd, MRMSrcMem,
Nate Begeman72d802a2008-02-04 06:00:24 +00003119 (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2),
Nate Begemanb2975562008-02-03 07:18:54 +00003120 !strconcat(OpcodeStr,
3121 "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemaneb3f5432008-02-04 05:34:34 +00003122 [(set VR128:$dst, (V2F64Int (load addr:$src1),imm:$src2))]>,
3123 OpSize;
Nate Begemanb2975562008-02-03 07:18:54 +00003124}
3125
3126// FP round - roundss, roundps, roundsd, roundpd
3127defm ROUND : sse41_fp_unop_rm<0x0A, 0x08, 0x0B, 0x09, "round",
3128 int_x86_sse41_round_ss, int_x86_sse41_round_ps,
3129 int_x86_sse41_round_sd, int_x86_sse41_round_pd>;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003130
3131// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
3132multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
3133 Intrinsic IntId128> {
3134 def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3135 (ins VR128:$src),
3136 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3137 [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize;
3138 def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3139 (ins i128mem:$src),
3140 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3141 [(set VR128:$dst,
3142 (IntId128
3143 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
3144}
3145
3146defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw",
3147 int_x86_sse41_phminposuw>;
3148
3149/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
3150let isTwoAddress = 1 in {
3151 multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr,
3152 Intrinsic IntId128, bit Commutable = 0> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003153 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3154 (ins VR128:$src1, VR128:$src2),
3155 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3156 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3157 OpSize {
Nate Begemaneb3f5432008-02-04 05:34:34 +00003158 let isCommutable = Commutable;
3159 }
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003160 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3161 (ins VR128:$src1, i128mem:$src2),
3162 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3163 [(set VR128:$dst,
3164 (IntId128 VR128:$src1,
3165 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003166 }
3167}
3168
3169defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq",
3170 int_x86_sse41_pcmpeqq, 1>;
3171defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw",
3172 int_x86_sse41_packusdw, 0>;
3173defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb",
3174 int_x86_sse41_pminsb, 1>;
3175defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd",
3176 int_x86_sse41_pminsd, 1>;
3177defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud",
3178 int_x86_sse41_pminud, 1>;
3179defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw",
3180 int_x86_sse41_pminuw, 1>;
3181defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb",
3182 int_x86_sse41_pmaxsb, 1>;
3183defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd",
3184 int_x86_sse41_pmaxsd, 1>;
3185defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud",
3186 int_x86_sse41_pmaxud, 1>;
3187defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw",
3188 int_x86_sse41_pmaxuw, 1>;
Nate Begemaneb3f5432008-02-04 05:34:34 +00003189defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq",
3190 int_x86_sse41_pmuldq, 1>;
Nate Begeman72d802a2008-02-04 06:00:24 +00003191
Nate Begeman58057962008-02-09 01:38:08 +00003192
3193/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator
3194let isTwoAddress = 1 in {
3195 multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, SDNode OpNode,
3196 Intrinsic IntId128, bit Commutable = 0> {
3197 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3198 (ins VR128:$src1, VR128:$src2),
3199 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3200 [(set VR128:$dst, (OpNode (v4i32 VR128:$src1),
3201 VR128:$src2))]>, OpSize {
3202 let isCommutable = Commutable;
3203 }
3204 def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3205 (ins VR128:$src1, VR128:$src2),
3206 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3207 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
3208 OpSize {
3209 let isCommutable = Commutable;
3210 }
3211 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3212 (ins VR128:$src1, i128mem:$src2),
3213 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3214 [(set VR128:$dst,
3215 (OpNode VR128:$src1, (memopv4i32 addr:$src2)))]>, OpSize;
3216 def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3217 (ins VR128:$src1, i128mem:$src2),
3218 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
3219 [(set VR128:$dst,
3220 (IntId128 VR128:$src1, (memopv4i32 addr:$src2)))]>,
3221 OpSize;
3222 }
3223}
3224defm PMULLD : SS41I_binop_patint<0x40, "pmulld", mul,
3225 int_x86_sse41_pmulld, 1>;
3226
3227
Nate Begeman72d802a2008-02-04 06:00:24 +00003228/// SS41I_binop_rmi_int - SSE 4.1 binary operator with immediate
3229let isTwoAddress = 1 in {
3230 multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr,
3231 Intrinsic IntId128, bit Commutable = 0> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003232 def rri : SS4AI<opc, MRMSrcReg, (outs VR128:$dst),
3233 (ins VR128:$src1, VR128:$src2, i32i8imm:$src3),
3234 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003235 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003236 [(set VR128:$dst,
3237 (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>,
3238 OpSize {
Nate Begeman72d802a2008-02-04 06:00:24 +00003239 let isCommutable = Commutable;
3240 }
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003241 def rmi : SS4AI<opc, MRMSrcMem, (outs VR128:$dst),
3242 (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3),
3243 !strconcat(OpcodeStr,
Nate Begemanb4e9a042008-02-10 18:47:57 +00003244 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003245 [(set VR128:$dst,
3246 (IntId128 VR128:$src1,
3247 (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>,
3248 OpSize;
Nate Begeman72d802a2008-02-04 06:00:24 +00003249 }
3250}
3251
3252defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps",
3253 int_x86_sse41_blendps, 0>;
3254defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd",
3255 int_x86_sse41_blendpd, 0>;
3256defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw",
3257 int_x86_sse41_pblendw, 0>;
3258defm DPPS : SS41I_binop_rmi_int<0x40, "dpps",
3259 int_x86_sse41_dpps, 1>;
3260defm DPPD : SS41I_binop_rmi_int<0x41, "dppd",
3261 int_x86_sse41_dppd, 1>;
3262defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw",
3263 int_x86_sse41_mpsadbw, 0>;
Nate Begeman58057962008-02-09 01:38:08 +00003264
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003265
Nate Begemanb4e9a042008-02-10 18:47:57 +00003266/// SS41I_binop_rmi_int - SSE 4.1 binary operator with immediate
Nate Begemand77e59e2008-02-11 04:19:36 +00003267let Uses = [XMM0], isTwoAddress = 1 in {
Nate Begemanb4e9a042008-02-10 18:47:57 +00003268 multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3269 def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst),
3270 (ins VR128:$src1, VR128:$src2),
3271 !strconcat(OpcodeStr,
3272 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3273 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>,
3274 OpSize;
3275
3276 def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst),
3277 (ins VR128:$src1, i128mem:$src2),
3278 !strconcat(OpcodeStr,
3279 "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"),
3280 [(set VR128:$dst,
3281 (IntId VR128:$src1,
3282 (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize;
3283 }
3284}
3285
3286defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>;
3287defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>;
3288defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>;
3289
3290
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003291multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3292 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3293 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3294 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3295
3296 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
3297 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3298 [(set VR128:$dst,
3299 (IntId (bitconvert (v4i32 (load addr:$src)))))]>, OpSize;
3300}
3301
3302defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>;
3303defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>;
3304defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>;
3305defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>;
3306defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>;
3307defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>;
3308
3309multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3310 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3311 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3312 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3313
3314 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
3315 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3316 [(set VR128:$dst,
3317 (IntId (bitconvert (v4i32 (load addr:$src)))))]>, OpSize;
3318}
3319
3320defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>;
3321defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>;
3322defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>;
3323defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>;
3324
3325multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> {
3326 def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
3327 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3328 [(set VR128:$dst, (IntId VR128:$src))]>, OpSize;
3329
3330 def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src),
3331 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
3332 [(set VR128:$dst,
3333 (IntId (bitconvert (v4i32 (load addr:$src)))))]>, OpSize;
3334}
3335
3336defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>;
3337defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovsxbq", int_x86_sse41_pmovzxbq>;
3338
3339
Nate Begemand77e59e2008-02-11 04:19:36 +00003340/// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem
3341multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003342 def rr : SS4AI<opc, MRMSrcReg, (outs GR32:$dst),
3343 (ins VR128:$src1, i32i8imm:$src2),
3344 !strconcat(OpcodeStr,
3345 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003346 [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>,
3347 OpSize;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003348 def mr : SS4AI<opc, MRMDestMem, (outs),
3349 (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2),
3350 !strconcat(OpcodeStr,
3351 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
Nate Begemand77e59e2008-02-11 04:19:36 +00003352 []>, OpSize;
3353// FIXME:
3354// There's an AssertZext in the way of writing the store pattern
3355// (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003356}
3357
Nate Begemand77e59e2008-02-11 04:19:36 +00003358defm PEXTRB : SS41I_extract8<0x14, "pextrb">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003359
Nate Begemand77e59e2008-02-11 04:19:36 +00003360
3361/// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination
3362multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> {
3363 def mr : SS4AI<opc, MRMDestMem, (outs),
3364 (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2),
3365 !strconcat(OpcodeStr,
3366 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3367 []>, OpSize;
3368// FIXME:
3369// There's an AssertZext in the way of writing the store pattern
3370// (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst)
3371}
3372
3373defm PEXTRW : SS41I_extract16<0x15, "pextrw">;
3374
3375
3376/// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination
3377multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003378 def rr : SS4AI<opc, MRMSrcReg, (outs GR32:$dst),
3379 (ins VR128:$src1, i32i8imm:$src2),
3380 !strconcat(OpcodeStr,
3381 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3382 [(set GR32:$dst,
3383 (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize;
3384 def mr : SS4AI<opc, MRMDestMem, (outs),
3385 (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2),
3386 !strconcat(OpcodeStr,
3387 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3388 [(store (extractelt (v4i32 VR128:$src1), imm:$src2),
3389 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003390}
3391
Nate Begemand77e59e2008-02-11 04:19:36 +00003392defm PEXTRD : SS41I_extract32<0x16, "pextrd">;
Nate Begeman58057962008-02-09 01:38:08 +00003393
Nate Begemand77e59e2008-02-11 04:19:36 +00003394
3395/// SS41I_extractf32 - SSE 4.1 extract 32 bits to fp reg or memory destination
3396multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> {
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003397 def rr : SS4AI<opc, MRMSrcReg, (outs FR32:$dst),
3398 (ins VR128:$src1, i32i8imm:$src2),
3399 !strconcat(OpcodeStr,
3400 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3401 [(set FR32:$dst,
3402 (extractelt (v4f32 VR128:$src1), imm:$src2))]>, OpSize;
3403 def mr : SS4AI<opc, MRMDestMem, (outs),
3404 (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2),
3405 !strconcat(OpcodeStr,
3406 "\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
3407 [(store (extractelt (v4f32 VR128:$src1), imm:$src2),
3408 addr:$dst)]>, OpSize;
Nate Begeman58057962008-02-09 01:38:08 +00003409}
3410
Nate Begemand77e59e2008-02-11 04:19:36 +00003411defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">;
Nate Begeman9a58b8a2008-02-09 23:46:37 +00003412
Nate Begemand77e59e2008-02-11 04:19:36 +00003413let isTwoAddress = 1 in {
3414 multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> {
3415 def rr : SS4AI<opc, MRMSrcReg, (outs VR128:$dst),
3416 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
3417 !strconcat(OpcodeStr,
3418 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3419 [(set VR128:$dst,
3420 (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize;
3421 def rm : SS4AI<opc, MRMSrcMem, (outs VR128:$dst),
3422 (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3),
3423 !strconcat(OpcodeStr,
3424 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3425 [(set VR128:$dst,
3426 (X86pinsrb VR128:$src1, (extloadi8 addr:$src2),
3427 imm:$src3))]>, OpSize;
3428 }
3429}
3430
3431defm PINSRB : SS41I_insert8<0x20, "pinsrb">;
3432
3433let isTwoAddress = 1 in {
3434 multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> {
3435 def rr : SS4AI<opc, MRMSrcReg, (outs VR128:$dst),
3436 (ins VR128:$src1, GR32:$src2, i32i8imm:$src3),
3437 !strconcat(OpcodeStr,
3438 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3439 [(set VR128:$dst,
3440 (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>,
3441 OpSize;
3442 def rm : SS4AI<opc, MRMSrcMem, (outs VR128:$dst),
3443 (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3),
3444 !strconcat(OpcodeStr,
3445 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3446 [(set VR128:$dst,
3447 (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2),
3448 imm:$src3)))]>, OpSize;
3449 }
3450}
3451
3452defm PINSRD : SS41I_insert32<0x22, "pinsrd">;
3453
3454let isTwoAddress = 1 in {
3455 multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> {
3456 def rr : SS4AI<opc, MRMSrcReg, (outs VR128:$dst),
3457 (ins VR128:$src1, FR32:$src2, i32i8imm:$src3),
3458 !strconcat(OpcodeStr,
3459 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3460 [(set VR128:$dst,
3461 (X86insrtps VR128:$src1, FR32:$src2, imm:$src3))]>, OpSize;
3462 def rm : SS4AI<opc, MRMSrcMem, (outs VR128:$dst),
3463 (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3),
3464 !strconcat(OpcodeStr,
3465 "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
3466 [(set VR128:$dst,
3467 (X86insrtps VR128:$src1, (loadf32 addr:$src2),
3468 imm:$src3))]>, OpSize;
3469 }
3470}
3471
3472defm INSERTPS : SS41I_insertf32<0x31, "insertps">;