blob: c38594c3bdaa27c4de72df238145ed497d399872 [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>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037def X86s2vec : SDNode<"X86ISD::S2VEC", SDTypeProfile<1, 1, []>, []>;
38def X86pextrw : SDNode<"X86ISD::PEXTRW", SDTypeProfile<1, 2, []>, []>;
39def X86pinsrw : SDNode<"X86ISD::PINSRW", SDTypeProfile<1, 3, []>, []>;
40
41//===----------------------------------------------------------------------===//
42// SSE 'Special' Instructions
43//===----------------------------------------------------------------------===//
44
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000045let isImplicitDef = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +000046def IMPLICIT_DEF_VR128 : I<0, Pseudo, (outs VR128:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000047 "#IMPLICIT_DEF $dst",
48 [(set VR128:$dst, (v4f32 (undef)))]>,
49 Requires<[HasSSE1]>;
Evan Chengb783fa32007-07-19 01:14:50 +000050def IMPLICIT_DEF_FR32 : I<0, Pseudo, (outs FR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000051 "#IMPLICIT_DEF $dst",
Dale Johannesene0e0fd02007-09-23 14:52:20 +000052 [(set FR32:$dst, (undef))]>, Requires<[HasSSE1]>;
Evan Chengb783fa32007-07-19 01:14:50 +000053def IMPLICIT_DEF_FR64 : I<0, Pseudo, (outs FR64:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000054 "#IMPLICIT_DEF $dst",
55 [(set FR64:$dst, (undef))]>, Requires<[HasSSE2]>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000056}
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057
58//===----------------------------------------------------------------------===//
59// SSE Complex Patterns
60//===----------------------------------------------------------------------===//
61
62// These are 'extloads' from a scalar to the low element of a vector, zeroing
63// the top elements. These are used for the SSE 'ss' and 'sd' instruction
64// forms.
65def sse_load_f32 : ComplexPattern<v4f32, 4, "SelectScalarSSELoad", [],
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000066 [SDNPHasChain, SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067def sse_load_f64 : ComplexPattern<v2f64, 4, "SelectScalarSSELoad", [],
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000068 [SDNPHasChain, SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069
70def ssmem : Operand<v4f32> {
71 let PrintMethod = "printf32mem";
72 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
73}
74def sdmem : Operand<v2f64> {
75 let PrintMethod = "printf64mem";
76 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
77}
78
79//===----------------------------------------------------------------------===//
80// SSE pattern fragments
81//===----------------------------------------------------------------------===//
82
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
84def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
85def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
86def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
87
Dan Gohman11821702007-07-27 17:16:43 +000088// Like 'store', but always requires vector alignment.
Dan Gohman4a4f1512007-07-18 20:23:34 +000089def alignedstore : PatFrag<(ops node:$val, node:$ptr),
90 (st node:$val, node:$ptr), [{
91 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
92 return !ST->isTruncatingStore() &&
93 ST->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +000094 ST->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +000095 return false;
96}]>;
97
Dan Gohman11821702007-07-27 17:16:43 +000098// Like 'load', but always requires vector alignment.
Dan Gohman4a4f1512007-07-18 20:23:34 +000099def alignedload : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
100 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
101 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
102 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +0000103 LD->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000104 return false;
105}]>;
106
Dan Gohman11821702007-07-27 17:16:43 +0000107def alignedloadfsf32 : PatFrag<(ops node:$ptr), (f32 (alignedload node:$ptr))>;
108def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000109def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>;
110def alignedloadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (alignedload node:$ptr))>;
111def alignedloadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (alignedload node:$ptr))>;
112def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>;
113
114// Like 'load', but uses special alignment checks suitable for use in
115// memory operands in most SSE instructions, which are required to
116// be naturally aligned on some targets but not on others.
117// FIXME: Actually implement support for targets that don't require the
118// alignment. This probably wants a subtarget predicate.
119def memop : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
120 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
121 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
122 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +0000123 LD->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000124 return false;
125}]>;
126
Dan Gohman11821702007-07-27 17:16:43 +0000127def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
128def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000129def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
130def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
131def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
132def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
133
Bill Wendling3b15d722007-08-11 09:52:53 +0000134// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
135// 16-byte boundary.
136def memop64 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
137 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
138 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
139 LD->getAddressingMode() == ISD::UNINDEXED &&
140 LD->getAlignment() >= 8;
141 return false;
142}]>;
143
144def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
145def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop64 node:$ptr))>;
146def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
147def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
148def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
149
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000150def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
151def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
152def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
153def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
154def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
155def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
156
157def fp32imm0 : PatLeaf<(f32 fpimm), [{
158 return N->isExactlyValue(+0.0);
159}]>;
160
161def PSxLDQ_imm : SDNodeXForm<imm, [{
162 // Transformation function: imm >> 3
163 return getI32Imm(N->getValue() >> 3);
164}]>;
165
166// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
167// SHUFP* etc. imm.
168def SHUFFLE_get_shuf_imm : SDNodeXForm<build_vector, [{
169 return getI8Imm(X86::getShuffleSHUFImmediate(N));
170}]>;
171
172// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
173// PSHUFHW imm.
174def SHUFFLE_get_pshufhw_imm : SDNodeXForm<build_vector, [{
175 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
176}]>;
177
178// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
179// PSHUFLW imm.
180def SHUFFLE_get_pshuflw_imm : SDNodeXForm<build_vector, [{
181 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
182}]>;
183
184def SSE_splat_mask : PatLeaf<(build_vector), [{
185 return X86::isSplatMask(N);
186}], SHUFFLE_get_shuf_imm>;
187
188def SSE_splat_lo_mask : PatLeaf<(build_vector), [{
189 return X86::isSplatLoMask(N);
190}]>;
191
192def MOVHLPS_shuffle_mask : PatLeaf<(build_vector), [{
193 return X86::isMOVHLPSMask(N);
194}]>;
195
196def MOVHLPS_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
197 return X86::isMOVHLPS_v_undef_Mask(N);
198}]>;
199
200def MOVHP_shuffle_mask : PatLeaf<(build_vector), [{
201 return X86::isMOVHPMask(N);
202}]>;
203
204def MOVLP_shuffle_mask : PatLeaf<(build_vector), [{
205 return X86::isMOVLPMask(N);
206}]>;
207
208def MOVL_shuffle_mask : PatLeaf<(build_vector), [{
209 return X86::isMOVLMask(N);
210}]>;
211
212def MOVSHDUP_shuffle_mask : PatLeaf<(build_vector), [{
213 return X86::isMOVSHDUPMask(N);
214}]>;
215
216def MOVSLDUP_shuffle_mask : PatLeaf<(build_vector), [{
217 return X86::isMOVSLDUPMask(N);
218}]>;
219
220def UNPCKL_shuffle_mask : PatLeaf<(build_vector), [{
221 return X86::isUNPCKLMask(N);
222}]>;
223
224def UNPCKH_shuffle_mask : PatLeaf<(build_vector), [{
225 return X86::isUNPCKHMask(N);
226}]>;
227
228def UNPCKL_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
229 return X86::isUNPCKL_v_undef_Mask(N);
230}]>;
231
232def UNPCKH_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
233 return X86::isUNPCKH_v_undef_Mask(N);
234}]>;
235
236def PSHUFD_shuffle_mask : PatLeaf<(build_vector), [{
237 return X86::isPSHUFDMask(N);
238}], SHUFFLE_get_shuf_imm>;
239
240def PSHUFHW_shuffle_mask : PatLeaf<(build_vector), [{
241 return X86::isPSHUFHWMask(N);
242}], SHUFFLE_get_pshufhw_imm>;
243
244def PSHUFLW_shuffle_mask : PatLeaf<(build_vector), [{
245 return X86::isPSHUFLWMask(N);
246}], SHUFFLE_get_pshuflw_imm>;
247
248def SHUFP_unary_shuffle_mask : PatLeaf<(build_vector), [{
249 return X86::isPSHUFDMask(N);
250}], SHUFFLE_get_shuf_imm>;
251
252def SHUFP_shuffle_mask : PatLeaf<(build_vector), [{
253 return X86::isSHUFPMask(N);
254}], SHUFFLE_get_shuf_imm>;
255
256def PSHUFD_binary_shuffle_mask : PatLeaf<(build_vector), [{
257 return X86::isSHUFPMask(N);
258}], SHUFFLE_get_shuf_imm>;
259
260//===----------------------------------------------------------------------===//
261// SSE scalar FP Instructions
262//===----------------------------------------------------------------------===//
263
264// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
265// scheduler into a branch sequence.
Evan Cheng950aac02007-09-25 01:57:46 +0000266// These are expanded by the scheduler.
267let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268 def CMOV_FR32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000269 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000270 "#CMOV_FR32 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000271 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
272 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000274 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275 "#CMOV_FR64 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000276 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
277 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000279 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280 "#CMOV_V4F32 PSEUDO!",
281 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000282 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
283 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284 def CMOV_V2F64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000285 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000286 "#CMOV_V2F64 PSEUDO!",
287 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000288 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
289 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290 def CMOV_V2I64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000291 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000292 "#CMOV_V2I64 PSEUDO!",
293 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000294 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng950aac02007-09-25 01:57:46 +0000295 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000296}
297
298//===----------------------------------------------------------------------===//
299// SSE1 Instructions
300//===----------------------------------------------------------------------===//
301
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000303def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000304 "movss\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +0000305let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000306def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000307 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000308 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000309def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000310 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311 [(store FR32:$src, addr:$dst)]>;
312
313// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000314def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000315 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000317def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000318 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000320def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000321 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000323def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000324 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
326
327// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000328def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000329 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000330 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000331def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000332 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 [(set GR32:$dst, (int_x86_sse_cvtss2si
334 (load addr:$src)))]>;
335
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000336// Match intrinisics which expect MM and XMM operand(s).
337def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
338 "cvtps2pi\t{$src, $dst|$dst, $src}",
339 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
340def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
341 "cvtps2pi\t{$src, $dst|$dst, $src}",
342 [(set VR64:$dst, (int_x86_sse_cvtps2pi
343 (load addr:$src)))]>;
344def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
345 "cvttps2pi\t{$src, $dst|$dst, $src}",
346 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
347def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
348 "cvttps2pi\t{$src, $dst|$dst, $src}",
349 [(set VR64:$dst, (int_x86_sse_cvttps2pi
350 (load addr:$src)))]>;
351let isTwoAddress = 1 in {
352 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
353 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
354 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
355 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
356 VR64:$src2))]>;
357 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
358 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
359 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
360 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
361 (load addr:$src2)))]>;
362}
363
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000365def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000366 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000367 [(set GR32:$dst,
368 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000369def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000370 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371 [(set GR32:$dst,
372 (int_x86_sse_cvttss2si(load addr:$src)))]>;
373
374let isTwoAddress = 1 in {
375 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000376 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000377 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000378 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
379 GR32:$src2))]>;
380 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000381 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000382 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
384 (loadi32 addr:$src2)))]>;
385}
386
387// Comparison instructions
388let isTwoAddress = 1 in {
Chris Lattnera9f545f2007-12-16 20:12:41 +0000389 def CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000390 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000391 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Chris Lattnera9f545f2007-12-16 20:12:41 +0000392 def CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000393 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000394 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000395}
396
Evan Cheng55687072007-09-14 21:48:26 +0000397let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000398def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000399 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000400 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000401def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000402 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000403 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000404 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000405} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406
407// Aliases to match intrinsics which expect XMM operand(s).
408let isTwoAddress = 1 in {
Chris Lattnera9f545f2007-12-16 20:12:41 +0000409 def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000410 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000411 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
413 VR128:$src, imm:$cc))]>;
Chris Lattnera9f545f2007-12-16 20:12:41 +0000414 def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000415 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000416 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
418 (load addr:$src), imm:$cc))]>;
419}
420
Evan Cheng55687072007-09-14 21:48:26 +0000421let Defs = [EFLAGS] in {
Evan Cheng621216e2007-09-29 00:00:36 +0000422def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000423 (ins VR128:$src1, VR128:$src2),
424 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000425 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000426 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000427def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000428 (ins VR128:$src1, f128mem:$src2),
429 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000430 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000431 (implicit EFLAGS)]>;
432
Evan Cheng621216e2007-09-29 00:00:36 +0000433def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000434 (ins VR128:$src1, VR128:$src2),
435 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000436 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000437 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000438def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000439 (ins VR128:$src1, f128mem:$src2),
440 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000441 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000442 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000443} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444
445// Aliases of packed SSE1 instructions for scalar use. These all have names that
446// start with 'Fs'.
447
448// Alias instructions that map fld0 to pxor for sse.
Chris Lattner17dab4a2008-01-10 05:45:39 +0000449let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000450def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000451 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452 Requires<[HasSSE1]>, TB, OpSize;
453
454// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
455// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000456let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000457def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000458 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000459
460// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
461// disregarded.
Chris Lattner1a1932c2008-01-06 23:38:27 +0000462let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000463def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000464 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000465 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000466
467// Alias bitwise logical operations using SSE logical ops on packed FP values.
468let isTwoAddress = 1 in {
469let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000470 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000471 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000472 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000473 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000474 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000475 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000476 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000477 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
479}
480
Evan Chengb783fa32007-07-19 01:14:50 +0000481def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000482 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000484 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000485def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000486 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000488 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000489def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000490 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000492 (memopfsf32 addr:$src2)))]>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000493let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000495 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000496 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000497
498let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000500 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000501 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000503}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504
505/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
506///
507/// In addition, we also have a special variant of the scalar form here to
508/// represent the associated intrinsic operation. This form is unlike the
509/// plain scalar form, in that it takes an entire vector (instead of a scalar)
510/// and leaves the top elements undefined.
511///
512/// These three forms can each be reg+reg or reg+mem, so there are a total of
513/// six "instructions".
514///
515let isTwoAddress = 1 in {
516multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
517 SDNode OpNode, Intrinsic F32Int,
518 bit Commutable = 0> {
519 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000520 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000521 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
523 let isCommutable = Commutable;
524 }
525
526 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000527 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000528 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
530
531 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000532 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000533 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
535 let isCommutable = Commutable;
536 }
537
538 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000539 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000540 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000541 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542
543 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000544 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000545 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000546 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
547 let isCommutable = Commutable;
548 }
549
550 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000551 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000552 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000553 [(set VR128:$dst, (F32Int VR128:$src1,
554 sse_load_f32:$src2))]>;
555}
556}
557
558// Arithmetic instructions
559defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
560defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
561defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
562defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
563
564/// sse1_fp_binop_rm - Other SSE1 binops
565///
566/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
567/// instructions for a full-vector intrinsic form. Operations that map
568/// onto C operators don't use this form since they just use the plain
569/// vector form instead of having a separate vector intrinsic form.
570///
571/// This provides a total of eight "instructions".
572///
573let isTwoAddress = 1 in {
574multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
575 SDNode OpNode,
576 Intrinsic F32Int,
577 Intrinsic V4F32Int,
578 bit Commutable = 0> {
579
580 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000581 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000582 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000583 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
584 let isCommutable = Commutable;
585 }
586
587 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000588 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000589 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
591
592 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000593 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000594 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
596 let isCommutable = Commutable;
597 }
598
599 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000600 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000601 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000602 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603
604 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000605 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000606 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
608 let isCommutable = Commutable;
609 }
610
611 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000612 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000613 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614 [(set VR128:$dst, (F32Int VR128:$src1,
615 sse_load_f32:$src2))]>;
616
617 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000618 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000619 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000620 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
621 let isCommutable = Commutable;
622 }
623
624 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +0000625 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000626 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 [(set VR128:$dst, (V4F32Int VR128:$src1, (load addr:$src2)))]>;
628}
629}
630
631defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
632 int_x86_sse_max_ss, int_x86_sse_max_ps>;
633defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
634 int_x86_sse_min_ss, int_x86_sse_min_ps>;
635
636//===----------------------------------------------------------------------===//
637// SSE packed FP Instructions
638
639// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000640let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000641def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000642 "movaps\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +0000643let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000644def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000645 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000646 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000647
Evan Chengb783fa32007-07-19 01:14:50 +0000648def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000649 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000650 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651
Evan Chengb783fa32007-07-19 01:14:50 +0000652def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000653 "movups\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +0000654let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000655def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000656 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000657 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000658def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000659 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000660 [(store (v4f32 VR128:$src), addr:$dst)]>;
661
662// Intrinsic forms of MOVUPS load and store
Chris Lattner1a1932c2008-01-06 23:38:27 +0000663let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000664def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000665 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000666 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000667def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000668 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000669 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670
671let isTwoAddress = 1 in {
672 let AddedComplexity = 20 in {
673 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000674 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000675 "movlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 [(set VR128:$dst,
677 (v4f32 (vector_shuffle VR128:$src1,
678 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
679 MOVLP_shuffle_mask)))]>;
680 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000681 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000682 "movhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683 [(set VR128:$dst,
684 (v4f32 (vector_shuffle VR128:$src1,
685 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
686 MOVHP_shuffle_mask)))]>;
687 } // AddedComplexity
688} // isTwoAddress
689
Evan Chengb783fa32007-07-19 01:14:50 +0000690def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000691 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
693 (iPTR 0))), addr:$dst)]>;
694
695// v2f64 extract element 1 is always custom lowered to unpack high to low
696// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000697def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000698 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000699 [(store (f64 (vector_extract
700 (v2f64 (vector_shuffle
701 (bc_v2f64 (v4f32 VR128:$src)), (undef),
702 UNPCKH_shuffle_mask)), (iPTR 0))),
703 addr:$dst)]>;
704
705let isTwoAddress = 1 in {
706let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000707def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 [(set VR128:$dst,
710 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
711 MOVHP_shuffle_mask)))]>;
712
Evan Chengb783fa32007-07-19 01:14:50 +0000713def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000714 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715 [(set VR128:$dst,
716 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
717 MOVHLPS_shuffle_mask)))]>;
718} // AddedComplexity
719} // isTwoAddress
720
721
722
723// Arithmetic
724
725/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
726///
727/// In addition, we also have a special variant of the scalar form here to
728/// represent the associated intrinsic operation. This form is unlike the
729/// plain scalar form, in that it takes an entire vector (instead of a
730/// scalar) and leaves the top elements undefined.
731///
732/// And, we have a special variant form for a full-vector intrinsic form.
733///
734/// These four forms can each have a reg or a mem operand, so there are a
735/// total of eight "instructions".
736///
737multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
738 SDNode OpNode,
739 Intrinsic F32Int,
740 Intrinsic V4F32Int,
741 bit Commutable = 0> {
742 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000743 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000744 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745 [(set FR32:$dst, (OpNode FR32:$src))]> {
746 let isCommutable = Commutable;
747 }
748
749 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000750 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
753
754 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000755 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000756 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
758 let isCommutable = Commutable;
759 }
760
761 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000762 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000763 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000764 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765
766 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000767 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000768 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769 [(set VR128:$dst, (F32Int VR128:$src))]> {
770 let isCommutable = Commutable;
771 }
772
773 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000774 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000775 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
777
778 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000779 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000780 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000781 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
782 let isCommutable = Commutable;
783 }
784
785 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000786 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000787 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 [(set VR128:$dst, (V4F32Int (load addr:$src)))]>;
789}
790
791// Square root.
792defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
793 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
794
795// Reciprocal approximations. Note that these typically require refinement
796// in order to obtain suitable precision.
797defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
798 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
799defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
800 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
801
802// Logical
803let isTwoAddress = 1 in {
804 let isCommutable = 1 in {
805 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000806 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000807 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808 [(set VR128:$dst, (v2i64
809 (and VR128:$src1, VR128:$src2)))]>;
810 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000811 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000812 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813 [(set VR128:$dst, (v2i64
814 (or VR128:$src1, VR128:$src2)))]>;
815 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000816 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000817 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818 [(set VR128:$dst, (v2i64
819 (xor VR128:$src1, VR128:$src2)))]>;
820 }
821
822 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000823 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000824 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000825 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
826 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000828 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000829 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000830 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
831 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000833 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000834 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000835 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
836 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000838 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000839 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 [(set VR128:$dst,
841 (v2i64 (and (xor VR128:$src1,
842 (bc_v2i64 (v4i32 immAllOnesV))),
843 VR128:$src2)))]>;
844 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000845 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000846 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000848 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000850 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851}
852
853let isTwoAddress = 1 in {
854 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000855 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000856 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
858 VR128:$src, imm:$cc))]>;
859 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000860 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
863 (load addr:$src), imm:$cc))]>;
864}
865
866// Shuffle and unpack instructions
867let isTwoAddress = 1 in {
868 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
869 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000870 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871 VR128:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000872 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873 [(set VR128:$dst,
874 (v4f32 (vector_shuffle
875 VR128:$src1, VR128:$src2,
876 SHUFP_shuffle_mask:$src3)))]>;
877 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000878 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879 f128mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000880 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881 [(set VR128:$dst,
882 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000883 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 SHUFP_shuffle_mask:$src3)))]>;
885
886 let AddedComplexity = 10 in {
887 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000888 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000889 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890 [(set VR128:$dst,
891 (v4f32 (vector_shuffle
892 VR128:$src1, VR128:$src2,
893 UNPCKH_shuffle_mask)))]>;
894 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000895 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000896 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 [(set VR128:$dst,
898 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000899 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 UNPCKH_shuffle_mask)))]>;
901
902 def UNPCKLPSrr : PSI<0x14, 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 "unpcklps\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 UNPCKL_shuffle_mask)))]>;
909 def UNPCKLPSrm : PSI<0x14, 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 "unpcklps\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 UNPCKL_shuffle_mask)))]>;
916 } // AddedComplexity
917} // isTwoAddress
918
919// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000920def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000921 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000923def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000924 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
926
927// Prefetching loads.
928// TODO: no intrinsics for these?
Dan Gohman91888f02007-07-31 20:11:57 +0000929def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), "prefetcht0\t$src", []>;
930def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src), "prefetcht1\t$src", []>;
931def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src), "prefetcht2\t$src", []>;
932def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src), "prefetchnta\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933
934// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000935def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000936 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
938
939// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +0000940def SFENCE : PSI<0xAE, MRM7m, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941
942// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000943def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000944 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000945def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000946 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947
948// Alias instructions that map zero vector to pxor / xorp* for sse.
Chris Lattner17dab4a2008-01-10 05:45:39 +0000949let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000950def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000951 "xorps\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000952 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953
954// FR32 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +0000955def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000956 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 [(set VR128:$dst,
958 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000959def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000960 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 [(set VR128:$dst,
962 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
963
964// FIXME: may not be able to eliminate this movss with coalescing the src and
965// dest register classes are different. We really want to write this pattern
966// like this:
967// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
968// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +0000969def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000970 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
972 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000973def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000974 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 [(store (f32 (vector_extract (v4f32 VR128:$src),
976 (iPTR 0))), addr:$dst)]>;
977
978
979// Move to lower bits of a VR128, leaving upper bits alone.
980// Three operand (but two address) aliases.
981let isTwoAddress = 1 in {
982 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000983 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000984 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985
986 let AddedComplexity = 15 in
987 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000988 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000989 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990 [(set VR128:$dst,
991 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
992 MOVL_shuffle_mask)))]>;
993}
994
995// Move to lower bits of a VR128 and zeroing upper bits.
996// Loading from memory automatically zeroing upper bits.
997let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +0000998def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000999 "movss\t{$src, $dst|$dst, $src}",
Chris Lattnere6aa3862007-11-25 00:24:49 +00001000 [(set VR128:$dst, (v4f32 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 (v4f32 (scalar_to_vector (loadf32 addr:$src))),
1002 MOVL_shuffle_mask)))]>;
1003
1004
1005//===----------------------------------------------------------------------===//
1006// SSE2 Instructions
1007//===----------------------------------------------------------------------===//
1008
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001010def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001011 "movsd\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001012let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001013def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001014 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001016def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001017 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 [(store FR64:$src, addr:$dst)]>;
1019
1020// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001021def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001022 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001024def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001025 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001027def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001030def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001031 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001033def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001034 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001036def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001037 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001038 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1039
1040// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001041def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001042 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1044 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001045def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001046 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1048 Requires<[HasSSE2]>;
1049
1050// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001051def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001052 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001054def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001055 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1057 (load addr:$src)))]>;
1058
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001059// Match intrinisics which expect MM and XMM operand(s).
1060def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1061 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1062 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1063def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1064 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1065 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
1066 (load addr:$src)))]>;
1067def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1068 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1069 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1070def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1071 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1072 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
1073 (load addr:$src)))]>;
1074def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1075 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1076 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1077def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1078 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1079 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
1080 (load addr:$src)))]>;
1081
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001083def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001084 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 [(set GR32:$dst,
1086 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001087def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001088 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1090 (load addr:$src)))]>;
1091
1092// Comparison instructions
1093let isTwoAddress = 1 in {
Evan Cheng653c7ac2007-12-20 19:57:09 +00001094 def CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001095 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001096 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng653c7ac2007-12-20 19:57:09 +00001097 def CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001098 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001099 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100}
1101
Evan Cheng950aac02007-09-25 01:57:46 +00001102let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001103def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001104 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001105 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001106def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001108 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001109 (implicit EFLAGS)]>;
1110}
1111
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112// Aliases to match intrinsics which expect XMM operand(s).
1113let isTwoAddress = 1 in {
Evan Cheng653c7ac2007-12-20 19:57:09 +00001114 def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001115 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001116 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1118 VR128:$src, imm:$cc))]>;
Evan Cheng653c7ac2007-12-20 19:57:09 +00001119 def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001120 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001121 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1123 (load addr:$src), imm:$cc))]>;
1124}
1125
Evan Cheng950aac02007-09-25 01:57:46 +00001126let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001127def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001128 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001129 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1130 (implicit EFLAGS)]>;
1131def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001132 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001133 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1134 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135
Evan Chengb783fa32007-07-19 01:14:50 +00001136def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001137 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001138 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1139 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001140def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001141 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001142 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001143 (implicit EFLAGS)]>;
1144} // Defs = EFLAGS]
1145
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146// Aliases of packed SSE2 instructions for scalar use. These all have names that
1147// start with 'Fs'.
1148
1149// Alias instructions that map fld0 to pxor for sse.
Chris Lattner17dab4a2008-01-10 05:45:39 +00001150let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001151def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001152 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153 Requires<[HasSSE2]>, TB, OpSize;
1154
1155// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1156// disregarded.
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001157let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001158def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001159 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160
1161// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1162// disregarded.
Chris Lattner1a1932c2008-01-06 23:38:27 +00001163let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001164def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001165 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001166 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001167
1168// Alias bitwise logical operations using SSE logical ops on packed FP values.
1169let isTwoAddress = 1 in {
1170let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001171 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001172 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001173 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001174 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001175 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001177 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001178 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1180}
1181
Evan Chengb783fa32007-07-19 01:14:50 +00001182def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001183 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001185 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001186def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001187 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001189 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001190def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001191 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001192 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001193 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001195let neverHasSideEffects = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001196def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001197 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001198 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001199let mayLoad = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001201 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001202 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001203}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001204}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205
1206/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1207///
1208/// In addition, we also have a special variant of the scalar form here to
1209/// represent the associated intrinsic operation. This form is unlike the
1210/// plain scalar form, in that it takes an entire vector (instead of a scalar)
1211/// and leaves the top elements undefined.
1212///
1213/// These three forms can each be reg+reg or reg+mem, so there are a total of
1214/// six "instructions".
1215///
1216let isTwoAddress = 1 in {
1217multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1218 SDNode OpNode, Intrinsic F64Int,
1219 bit Commutable = 0> {
1220 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001221 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001222 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1224 let isCommutable = Commutable;
1225 }
1226
1227 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001228 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001229 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1231
1232 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001233 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001234 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1236 let isCommutable = Commutable;
1237 }
1238
1239 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001240 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001241 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001242 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243
1244 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001245 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001246 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1248 let isCommutable = Commutable;
1249 }
1250
1251 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001252 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001253 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254 [(set VR128:$dst, (F64Int VR128:$src1,
1255 sse_load_f64:$src2))]>;
1256}
1257}
1258
1259// Arithmetic instructions
1260defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1261defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1262defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1263defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1264
1265/// sse2_fp_binop_rm - Other SSE2 binops
1266///
1267/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1268/// instructions for a full-vector intrinsic form. Operations that map
1269/// onto C operators don't use this form since they just use the plain
1270/// vector form instead of having a separate vector intrinsic form.
1271///
1272/// This provides a total of eight "instructions".
1273///
1274let isTwoAddress = 1 in {
1275multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1276 SDNode OpNode,
1277 Intrinsic F64Int,
1278 Intrinsic V2F64Int,
1279 bit Commutable = 0> {
1280
1281 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001282 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001283 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1285 let isCommutable = Commutable;
1286 }
1287
1288 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001289 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001290 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1292
1293 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001294 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001295 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1297 let isCommutable = Commutable;
1298 }
1299
1300 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001301 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001302 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001303 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304
1305 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001306 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001307 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1309 let isCommutable = Commutable;
1310 }
1311
1312 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001313 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001314 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001315 [(set VR128:$dst, (F64Int VR128:$src1,
1316 sse_load_f64:$src2))]>;
1317
1318 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001319 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001320 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1322 let isCommutable = Commutable;
1323 }
1324
1325 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +00001326 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001327 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001328 [(set VR128:$dst, (V2F64Int VR128:$src1, (load addr:$src2)))]>;
1329}
1330}
1331
1332defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1333 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1334defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1335 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1336
1337//===----------------------------------------------------------------------===//
1338// SSE packed FP Instructions
1339
1340// Move Instructions
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001341let neverHasSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001342def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001343 "movapd\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001344let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001345def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001346 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001347 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348
Evan Chengb783fa32007-07-19 01:14:50 +00001349def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001350 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001351 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352
Evan Chengb783fa32007-07-19 01:14:50 +00001353def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001354 "movupd\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001355let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001356def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001357 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001358 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001359def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001360 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001361 [(store (v2f64 VR128:$src), addr:$dst)]>;
1362
1363// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001364def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001365 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001366 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001367def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001368 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001369 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001370
1371let isTwoAddress = 1 in {
1372 let AddedComplexity = 20 in {
1373 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001374 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001375 "movlpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376 [(set VR128:$dst,
1377 (v2f64 (vector_shuffle VR128:$src1,
1378 (scalar_to_vector (loadf64 addr:$src2)),
1379 MOVLP_shuffle_mask)))]>;
1380 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001381 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001382 "movhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383 [(set VR128:$dst,
1384 (v2f64 (vector_shuffle VR128:$src1,
1385 (scalar_to_vector (loadf64 addr:$src2)),
1386 MOVHP_shuffle_mask)))]>;
1387 } // AddedComplexity
1388} // isTwoAddress
1389
Evan Chengb783fa32007-07-19 01:14:50 +00001390def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001391 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001392 [(store (f64 (vector_extract (v2f64 VR128:$src),
1393 (iPTR 0))), addr:$dst)]>;
1394
1395// v2f64 extract element 1 is always custom lowered to unpack high to low
1396// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001397def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001398 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399 [(store (f64 (vector_extract
1400 (v2f64 (vector_shuffle VR128:$src, (undef),
1401 UNPCKH_shuffle_mask)), (iPTR 0))),
1402 addr:$dst)]>;
1403
1404// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001405def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001406 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001407 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1408 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001409def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001410 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
Dan Gohman4a4f1512007-07-18 20:23:34 +00001412 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413 TB, Requires<[HasSSE2]>;
1414
1415// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001416def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1419 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001420def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001421 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
Dan Gohman4a4f1512007-07-18 20:23:34 +00001423 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001424 XS, Requires<[HasSSE2]>;
1425
Evan Chengb783fa32007-07-19 01:14:50 +00001426def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001427 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001429def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001430 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001431 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1432 (load addr:$src)))]>;
1433// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001434def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1437 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001438def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1441 (load addr:$src)))]>,
1442 XS, Requires<[HasSSE2]>;
1443
1444// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001445def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001446 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1448 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001449def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1452 (load addr:$src)))]>,
1453 XD, Requires<[HasSSE2]>;
1454
Evan Chengb783fa32007-07-19 01:14:50 +00001455def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001456 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001457 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001458def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001459 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001460 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1461 (load addr:$src)))]>;
1462
1463// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001464def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001465 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001466 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1467 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001468def Int_CVTPS2PDrm : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001470 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1471 (load addr:$src)))]>,
1472 TB, Requires<[HasSSE2]>;
1473
Evan Chengb783fa32007-07-19 01:14:50 +00001474def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001477def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001478 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001479 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1480 (load addr:$src)))]>;
1481
1482// Match intrinsics which expect XMM operand(s).
1483// Aliases for intrinsics
1484let isTwoAddress = 1 in {
1485def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001486 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001487 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001488 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1489 GR32:$src2))]>;
1490def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001491 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001492 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001493 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1494 (loadi32 addr:$src2)))]>;
1495def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001496 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001498 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1499 VR128:$src2))]>;
1500def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001501 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001502 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001503 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1504 (load addr:$src2)))]>;
1505def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001506 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001507 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001508 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1509 VR128:$src2))]>, XS,
1510 Requires<[HasSSE2]>;
1511def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001512 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001513 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001514 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1515 (load addr:$src2)))]>, XS,
1516 Requires<[HasSSE2]>;
1517}
1518
1519// Arithmetic
1520
1521/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1522///
1523/// In addition, we also have a special variant of the scalar form here to
1524/// represent the associated intrinsic operation. This form is unlike the
1525/// plain scalar form, in that it takes an entire vector (instead of a
1526/// scalar) and leaves the top elements undefined.
1527///
1528/// And, we have a special variant form for a full-vector intrinsic form.
1529///
1530/// These four forms can each have a reg or a mem operand, so there are a
1531/// total of eight "instructions".
1532///
1533multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1534 SDNode OpNode,
1535 Intrinsic F64Int,
1536 Intrinsic V2F64Int,
1537 bit Commutable = 0> {
1538 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001539 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001540 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001541 [(set FR64:$dst, (OpNode FR64:$src))]> {
1542 let isCommutable = Commutable;
1543 }
1544
1545 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001546 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1549
1550 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001551 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001552 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001553 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1554 let isCommutable = Commutable;
1555 }
1556
1557 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001558 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001560 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561
1562 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001563 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001564 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 [(set VR128:$dst, (F64Int VR128:$src))]> {
1566 let isCommutable = Commutable;
1567 }
1568
1569 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001570 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1573
1574 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001575 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001577 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1578 let isCommutable = Commutable;
1579 }
1580
1581 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001582 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001583 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001584 [(set VR128:$dst, (V2F64Int (load addr:$src)))]>;
1585}
1586
1587// Square root.
1588defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1589 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1590
1591// There is no f64 version of the reciprocal approximation instructions.
1592
1593// Logical
1594let isTwoAddress = 1 in {
1595 let isCommutable = 1 in {
1596 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001597 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001598 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 [(set VR128:$dst,
1600 (and (bc_v2i64 (v2f64 VR128:$src1)),
1601 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1602 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001603 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001604 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001605 [(set VR128:$dst,
1606 (or (bc_v2i64 (v2f64 VR128:$src1)),
1607 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1608 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001609 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001610 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001611 [(set VR128:$dst,
1612 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1613 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1614 }
1615
1616 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001617 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001618 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001619 [(set VR128:$dst,
1620 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001621 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001622 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001623 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001624 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625 [(set VR128:$dst,
1626 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001627 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001628 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001629 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631 [(set VR128:$dst,
1632 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001633 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001635 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001637 [(set VR128:$dst,
1638 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1639 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1640 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001641 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001642 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001643 [(set VR128:$dst,
1644 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001645 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001646}
1647
1648let isTwoAddress = 1 in {
1649 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001650 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001651 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1653 VR128:$src, imm:$cc))]>;
1654 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001655 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001656 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001657 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1658 (load addr:$src), imm:$cc))]>;
1659}
1660
1661// Shuffle and unpack instructions
1662let isTwoAddress = 1 in {
1663 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001664 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001665 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666 [(set VR128:$dst, (v2f64 (vector_shuffle
1667 VR128:$src1, VR128:$src2,
1668 SHUFP_shuffle_mask:$src3)))]>;
1669 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001670 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001671 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001672 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001673 [(set VR128:$dst,
1674 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001675 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001676 SHUFP_shuffle_mask:$src3)))]>;
1677
1678 let AddedComplexity = 10 in {
1679 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001680 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001681 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001682 [(set VR128:$dst,
1683 (v2f64 (vector_shuffle
1684 VR128:$src1, VR128:$src2,
1685 UNPCKH_shuffle_mask)))]>;
1686 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001687 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001688 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689 [(set VR128:$dst,
1690 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001691 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 UNPCKH_shuffle_mask)))]>;
1693
1694 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001695 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001696 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697 [(set VR128:$dst,
1698 (v2f64 (vector_shuffle
1699 VR128:$src1, VR128:$src2,
1700 UNPCKL_shuffle_mask)))]>;
1701 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001702 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001704 [(set VR128:$dst,
1705 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001706 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 UNPCKL_shuffle_mask)))]>;
1708 } // AddedComplexity
1709} // isTwoAddress
1710
1711
1712//===----------------------------------------------------------------------===//
1713// SSE integer instructions
1714
1715// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001716def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001717 "movdqa\t{$src, $dst|$dst, $src}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001718let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001719def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001721 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001722def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001723 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001724 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001725let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001726def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001727 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001728 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001729 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001730def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001731 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001732 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733 XS, Requires<[HasSSE2]>;
1734
Dan Gohman4a4f1512007-07-18 20:23:34 +00001735// Intrinsic forms of MOVDQU load and store
Chris Lattner1a1932c2008-01-06 23:38:27 +00001736let isSimpleLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001737def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001738 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001739 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1740 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001741def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001743 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1744 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001745
1746let isTwoAddress = 1 in {
1747
1748multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1749 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001750 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001751 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1753 let isCommutable = Commutable;
1754 }
Evan Chengb783fa32007-07-19 01:14:50 +00001755 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001758 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001759}
1760
1761multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1762 string OpcodeStr, Intrinsic IntId> {
Evan Chengb783fa32007-07-19 01:14:50 +00001763 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001765 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001766 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001769 (bitconvert (memopv2i64 addr:$src2))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001770 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001771 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772 [(set VR128:$dst, (IntId VR128:$src1,
1773 (scalar_to_vector (i32 imm:$src2))))]>;
1774}
1775
1776
1777/// PDI_binop_rm - Simple SSE2 binary operator.
1778multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1779 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001780 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001782 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1783 let isCommutable = Commutable;
1784 }
Evan Chengb783fa32007-07-19 01:14:50 +00001785 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001788 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001789}
1790
1791/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1792///
1793/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1794/// to collapse (bitconvert VT to VT) into its operand.
1795///
1796multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1797 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001798 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001799 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001800 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1801 let isCommutable = Commutable;
1802 }
Evan Chengb783fa32007-07-19 01:14:50 +00001803 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001805 [(set VR128:$dst, (OpNode VR128:$src1,(memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806}
1807
1808} // isTwoAddress
1809
1810// 128-bit Integer Arithmetic
1811
1812defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1813defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1814defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1815defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1816
1817defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1818defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1819defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1820defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1821
1822defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1823defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1824defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1825defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1826
1827defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1828defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1829defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1830defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1831
1832defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1833
1834defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1835defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1836defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1837
1838defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1839
1840defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1841defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1842
1843
1844defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1845defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1846defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1847defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1848defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>;
1849
1850
1851defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", int_x86_sse2_psll_w>;
1852defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", int_x86_sse2_psll_d>;
1853defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", int_x86_sse2_psll_q>;
1854
1855defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", int_x86_sse2_psrl_w>;
1856defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", int_x86_sse2_psrl_d>;
1857defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq", int_x86_sse2_psrl_q>;
1858
1859defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", int_x86_sse2_psra_w>;
1860defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad", int_x86_sse2_psra_d>;
1861// PSRAQ doesn't exist in SSE[1-3].
1862
1863// 128-bit logical shifts.
1864let isTwoAddress = 1 in {
1865 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001866 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001868 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001869 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001870 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871 // PSRADQri doesn't exist in SSE[1-3].
1872}
1873
1874let Predicates = [HasSSE2] in {
1875 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1876 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1877 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1878 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1879 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1880 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1881}
1882
1883// Logical
1884defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1885defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1886defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1887
1888let isTwoAddress = 1 in {
1889 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001890 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001892 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1893 VR128:$src2)))]>;
1894
1895 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001896 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001897 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00001899 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900}
1901
1902// SSE2 Integer comparison
1903defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1904defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
1905defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
1906defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
1907defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
1908defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
1909
1910// Pack instructions
1911defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
1912defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
1913defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
1914
1915// Shuffle and unpack instructions
1916def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001917 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001919 [(set VR128:$dst, (v4i32 (vector_shuffle
1920 VR128:$src1, (undef),
1921 PSHUFD_shuffle_mask:$src2)))]>;
1922def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001923 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001925 [(set VR128:$dst, (v4i32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001926 (bc_v4i32(memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927 (undef),
1928 PSHUFD_shuffle_mask:$src2)))]>;
1929
1930// SSE2 with ImmT == Imm8 and XS prefix.
1931def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001932 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001934 [(set VR128:$dst, (v8i16 (vector_shuffle
1935 VR128:$src1, (undef),
1936 PSHUFHW_shuffle_mask:$src2)))]>,
1937 XS, Requires<[HasSSE2]>;
1938def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001939 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001942 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 (undef),
1944 PSHUFHW_shuffle_mask:$src2)))]>,
1945 XS, Requires<[HasSSE2]>;
1946
1947// SSE2 with ImmT == Imm8 and XD prefix.
1948def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001949 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001950 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001951 [(set VR128:$dst, (v8i16 (vector_shuffle
1952 VR128:$src1, (undef),
1953 PSHUFLW_shuffle_mask:$src2)))]>,
1954 XD, Requires<[HasSSE2]>;
1955def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001956 (outs VR128:$dst), (ins i128mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001959 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 (undef),
1961 PSHUFLW_shuffle_mask:$src2)))]>,
1962 XD, Requires<[HasSSE2]>;
1963
1964
1965let isTwoAddress = 1 in {
1966 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001967 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 [(set VR128:$dst,
1970 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1971 UNPCKL_shuffle_mask)))]>;
1972 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001973 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001974 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 [(set VR128:$dst,
1976 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001977 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978 UNPCKL_shuffle_mask)))]>;
1979 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001980 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001981 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001982 [(set VR128:$dst,
1983 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1984 UNPCKL_shuffle_mask)))]>;
1985 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001986 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001987 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001988 [(set VR128:$dst,
1989 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001990 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991 UNPCKL_shuffle_mask)))]>;
1992 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001993 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001994 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001995 [(set VR128:$dst,
1996 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1997 UNPCKL_shuffle_mask)))]>;
1998 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001999 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(set VR128:$dst,
2002 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002003 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002004 UNPCKL_shuffle_mask)))]>;
2005 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002006 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002007 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002008 [(set VR128:$dst,
2009 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2010 UNPCKL_shuffle_mask)))]>;
2011 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002012 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(set VR128:$dst,
2015 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002016 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017 UNPCKL_shuffle_mask)))]>;
2018
2019 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002020 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002021 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022 [(set VR128:$dst,
2023 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
2024 UNPCKH_shuffle_mask)))]>;
2025 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002026 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 [(set VR128:$dst,
2029 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002030 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002031 UNPCKH_shuffle_mask)))]>;
2032 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002033 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002034 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035 [(set VR128:$dst,
2036 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
2037 UNPCKH_shuffle_mask)))]>;
2038 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002039 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 [(set VR128:$dst,
2042 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002043 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044 UNPCKH_shuffle_mask)))]>;
2045 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002046 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002048 [(set VR128:$dst,
2049 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2050 UNPCKH_shuffle_mask)))]>;
2051 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002052 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002053 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002054 [(set VR128:$dst,
2055 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002056 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 UNPCKH_shuffle_mask)))]>;
2058 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002059 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061 [(set VR128:$dst,
2062 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2063 UNPCKH_shuffle_mask)))]>;
2064 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002065 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(set VR128:$dst,
2068 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002069 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 UNPCKH_shuffle_mask)))]>;
2071}
2072
2073// Extract / Insert
2074def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002075 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
2078 (iPTR imm:$src2)))]>;
2079let isTwoAddress = 1 in {
2080 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002081 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(set VR128:$dst,
2085 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
2086 GR32:$src2, (iPTR imm:$src3))))]>;
2087 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002088 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002090 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002091 [(set VR128:$dst,
2092 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
2093 (i32 (anyext (loadi16 addr:$src2))),
2094 (iPTR imm:$src3))))]>;
2095}
2096
2097// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002098def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002099 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002100 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2101
2102// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002103let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002104def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002105 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002106 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107
2108// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002109def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002110 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002111 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002112def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002113 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002114 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002115def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002116 "movnti\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2118 TB, Requires<[HasSSE2]>;
2119
2120// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002121def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123 TB, Requires<[HasSSE2]>;
2124
2125// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +00002126def LFENCE : I<0xAE, MRM5m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002128def MFENCE : I<0xAE, MRM6m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2130
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002131// Alias instructions that map zero vector to pxor / xorp* for sse.
Chris Lattner17dab4a2008-01-10 05:45:39 +00002132let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002133 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002134 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002135 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136
2137// FR64 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +00002138def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002139 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002140 [(set VR128:$dst,
2141 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002142def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002143 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144 [(set VR128:$dst,
2145 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2146
Evan Chengb783fa32007-07-19 01:14:50 +00002147def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002148 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149 [(set VR128:$dst,
2150 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002151def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(set VR128:$dst,
2154 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2155
Evan Chengb783fa32007-07-19 01:14:50 +00002156def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2159
Evan Chengb783fa32007-07-19 01:14:50 +00002160def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002161 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002162 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2163
2164// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002165def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 [(set VR128:$dst,
2168 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2169 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002170def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172 [(store (i64 (vector_extract (v2i64 VR128:$src),
2173 (iPTR 0))), addr:$dst)]>;
2174
2175// FIXME: may not be able to eliminate this movss with coalescing the src and
2176// dest register classes are different. We really want to write this pattern
2177// like this:
2178// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2179// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +00002180def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002181 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2183 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002184def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 [(store (f64 (vector_extract (v2f64 VR128:$src),
2187 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002188def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002190 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2191 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002192def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194 [(store (i32 (vector_extract (v4i32 VR128:$src),
2195 (iPTR 0))), addr:$dst)]>;
2196
Evan Chengb783fa32007-07-19 01:14:50 +00002197def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002198 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002199 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002200def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2203
2204
2205// Move to lower bits of a VR128, leaving upper bits alone.
2206// Three operand (but two address) aliases.
2207let isTwoAddress = 1 in {
2208 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002209 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002210 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211
2212 let AddedComplexity = 15 in
2213 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002214 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002215 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002216 [(set VR128:$dst,
2217 (v2f64 (vector_shuffle VR128:$src1, VR128:$src2,
2218 MOVL_shuffle_mask)))]>;
2219}
2220
2221// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002222def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002224 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2225
2226// Move to lower bits of a VR128 and zeroing upper bits.
2227// Loading from memory automatically zeroing upper bits.
2228let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002229 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231 [(set VR128:$dst,
Chris Lattnere6aa3862007-11-25 00:24:49 +00002232 (v2f64 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002233 (v2f64 (scalar_to_vector
2234 (loadf64 addr:$src))),
2235 MOVL_shuffle_mask)))]>;
2236
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002237// movd / movq to XMM register zero-extends
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002238let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002239def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002241 [(set VR128:$dst,
2242 (v4i32 (vector_shuffle immAllZerosV,
2243 (v4i32 (scalar_to_vector GR32:$src)),
2244 MOVL_shuffle_mask)))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002245// This is X86-64 only.
2246def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2247 "mov{d|q}\t{$src, $dst|$dst, $src}",
2248 [(set VR128:$dst,
2249 (v2i64 (vector_shuffle immAllZerosV_bc,
2250 (v2i64 (scalar_to_vector GR64:$src)),
2251 MOVL_shuffle_mask)))]>;
2252}
2253
2254let AddedComplexity = 20 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002255def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257 [(set VR128:$dst,
2258 (v4i32 (vector_shuffle immAllZerosV,
2259 (v4i32 (scalar_to_vector (loadi32 addr:$src))),
2260 MOVL_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002261def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002262 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002263 [(set VR128:$dst,
2264 (v2i64 (vector_shuffle immAllZerosV_bc,
2265 (v2i64 (scalar_to_vector (loadi64 addr:$src))),
2266 MOVL_shuffle_mask)))]>, XS,
2267 Requires<[HasSSE2]>;
2268}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002270// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2271// IA32 document. movq xmm1, xmm2 does clear the high bits.
2272let AddedComplexity = 15 in
2273def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2274 "movq\t{$src, $dst|$dst, $src}",
2275 [(set VR128:$dst, (v2i64 (vector_shuffle immAllZerosV_bc,
2276 VR128:$src,
2277 MOVL_shuffle_mask)))]>,
2278 XS, Requires<[HasSSE2]>;
2279
2280let AddedComplexity = 20 in
2281def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2282 "movq\t{$src, $dst|$dst, $src}",
2283 [(set VR128:$dst, (v2i64 (vector_shuffle immAllZerosV_bc,
2284 (memopv2i64 addr:$src),
2285 MOVL_shuffle_mask)))]>,
2286 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002287
2288//===----------------------------------------------------------------------===//
2289// SSE3 Instructions
2290//===----------------------------------------------------------------------===//
2291
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002292// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002293def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295 [(set VR128:$dst, (v4f32 (vector_shuffle
2296 VR128:$src, (undef),
2297 MOVSHDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002298def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002299 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002301 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002302 MOVSHDUP_shuffle_mask)))]>;
2303
Evan Chengb783fa32007-07-19 01:14:50 +00002304def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002305 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002306 [(set VR128:$dst, (v4f32 (vector_shuffle
2307 VR128:$src, (undef),
2308 MOVSLDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002309def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002310 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002311 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002312 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002313 MOVSLDUP_shuffle_mask)))]>;
2314
Evan Chengb783fa32007-07-19 01:14:50 +00002315def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317 [(set VR128:$dst, (v2f64 (vector_shuffle
2318 VR128:$src, (undef),
2319 SSE_splat_lo_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002320def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322 [(set VR128:$dst,
2323 (v2f64 (vector_shuffle
2324 (scalar_to_vector (loadf64 addr:$src)),
2325 (undef),
2326 SSE_splat_lo_mask)))]>;
2327
2328// Arithmetic
2329let isTwoAddress = 1 in {
2330 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002331 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002332 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002333 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2334 VR128:$src2))]>;
2335 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002336 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002337 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002338 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2339 (load addr:$src2)))]>;
2340 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002341 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002342 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002343 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2344 VR128:$src2))]>;
2345 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002346 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002347 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002348 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2349 (load addr:$src2)))]>;
2350}
2351
Evan Chengb783fa32007-07-19 01:14:50 +00002352def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002353 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002354 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2355
2356// Horizontal ops
2357class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002358 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002359 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002360 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2361class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002362 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002363 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002364 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (load addr:$src2))))]>;
2365class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002366 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002367 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002368 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2369class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002370 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002372 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (load addr:$src2))))]>;
2373
2374let isTwoAddress = 1 in {
2375 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2376 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2377 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2378 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2379 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2380 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2381 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2382 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2383}
2384
2385// Thread synchronization
Evan Chengb783fa32007-07-19 01:14:50 +00002386def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002387 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002388def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002389 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2390
2391// vector_shuffle v1, <undef> <1, 1, 3, 3>
2392let AddedComplexity = 15 in
2393def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2394 MOVSHDUP_shuffle_mask)),
2395 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2396let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002397def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398 MOVSHDUP_shuffle_mask)),
2399 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2400
2401// vector_shuffle v1, <undef> <0, 0, 2, 2>
2402let AddedComplexity = 15 in
2403 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2404 MOVSLDUP_shuffle_mask)),
2405 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2406let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002407 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002408 MOVSLDUP_shuffle_mask)),
2409 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2410
2411//===----------------------------------------------------------------------===//
2412// SSSE3 Instructions
2413//===----------------------------------------------------------------------===//
2414
Bill Wendling3b15d722007-08-11 09:52:53 +00002415// SSSE3 Instruction Templates:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002416//
Bill Wendling98680292007-08-10 06:22:27 +00002417// SS38I - SSSE3 instructions with T8 prefix.
2418// SS3AI - SSSE3 instructions with TA prefix.
Bill Wendling3b15d722007-08-11 09:52:53 +00002419//
2420// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
2421// uses the MMX registers. We put those instructions here because they better
2422// fit into the SSSE3 instruction category rather than the MMX category.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002423
Evan Chengb783fa32007-07-19 01:14:50 +00002424class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
2425 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002426 : I<o, F, outs, ins, asm, pattern>, T8, Requires<[HasSSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002427class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
2428 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002429 : I<o, F, outs, ins, asm, pattern>, TA, Requires<[HasSSSE3]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002430
Bill Wendling98680292007-08-10 06:22:27 +00002431/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002432let isTwoAddress = 1 in {
Bill Wendling98680292007-08-10 06:22:27 +00002433 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2434 Intrinsic IntId64, Intrinsic IntId128,
2435 bit Commutable = 0> {
2436 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2437 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2438 [(set VR64:$dst, (IntId64 VR64:$src))]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002439 let isCommutable = Commutable;
2440 }
Bill Wendling98680292007-08-10 06:22:27 +00002441 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2442 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2443 [(set VR64:$dst,
2444 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2445
2446 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2447 (ins VR128:$src),
2448 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2449 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2450 OpSize {
2451 let isCommutable = Commutable;
2452 }
2453 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2454 (ins i128mem:$src),
2455 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2456 [(set VR128:$dst,
2457 (IntId128
2458 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002459 }
2460}
2461
Bill Wendling98680292007-08-10 06:22:27 +00002462/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2463let isTwoAddress = 1 in {
2464 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2465 Intrinsic IntId64, Intrinsic IntId128,
2466 bit Commutable = 0> {
2467 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2468 (ins VR64:$src),
2469 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2470 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2471 let isCommutable = Commutable;
2472 }
2473 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2474 (ins i64mem:$src),
2475 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2476 [(set VR64:$dst,
2477 (IntId64
2478 (bitconvert (memopv4i16 addr:$src))))]>;
2479
2480 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2481 (ins VR128:$src),
2482 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2483 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2484 OpSize {
2485 let isCommutable = Commutable;
2486 }
2487 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2488 (ins i128mem:$src),
2489 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2490 [(set VR128:$dst,
2491 (IntId128
2492 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2493 }
2494}
2495
2496/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2497let isTwoAddress = 1 in {
2498 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2499 Intrinsic IntId64, Intrinsic IntId128,
2500 bit Commutable = 0> {
2501 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2502 (ins VR64:$src),
2503 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2504 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2505 let isCommutable = Commutable;
2506 }
2507 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 (memopv2i32 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 let isCommutable = Commutable;
2520 }
2521 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2522 (ins i128mem:$src),
2523 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2524 [(set VR128:$dst,
2525 (IntId128
2526 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2527 }
2528}
2529
2530defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2531 int_x86_ssse3_pabs_b,
2532 int_x86_ssse3_pabs_b_128>;
2533defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2534 int_x86_ssse3_pabs_w,
2535 int_x86_ssse3_pabs_w_128>;
2536defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2537 int_x86_ssse3_pabs_d,
2538 int_x86_ssse3_pabs_d_128>;
2539
2540/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2541let isTwoAddress = 1 in {
2542 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2543 Intrinsic IntId64, Intrinsic IntId128,
2544 bit Commutable = 0> {
2545 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2546 (ins VR64:$src1, VR64:$src2),
2547 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2548 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2549 let isCommutable = Commutable;
2550 }
2551 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2552 (ins VR64:$src1, i64mem:$src2),
2553 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2554 [(set VR64:$dst,
2555 (IntId64 VR64:$src1,
2556 (bitconvert (memopv8i8 addr:$src2))))]>;
2557
2558 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2559 (ins VR128:$src1, VR128:$src2),
2560 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2561 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2562 OpSize {
2563 let isCommutable = Commutable;
2564 }
2565 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2566 (ins VR128:$src1, i128mem:$src2),
2567 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2568 [(set VR128:$dst,
2569 (IntId128 VR128:$src1,
2570 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2571 }
2572}
2573
2574/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2575let isTwoAddress = 1 in {
2576 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2577 Intrinsic IntId64, Intrinsic IntId128,
2578 bit Commutable = 0> {
2579 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2580 (ins VR64:$src1, VR64:$src2),
2581 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2582 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2583 let isCommutable = Commutable;
2584 }
2585 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2586 (ins VR64:$src1, i64mem:$src2),
2587 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2588 [(set VR64:$dst,
2589 (IntId64 VR64:$src1,
2590 (bitconvert (memopv4i16 addr:$src2))))]>;
2591
2592 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2593 (ins VR128:$src1, VR128:$src2),
2594 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2595 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2596 OpSize {
2597 let isCommutable = Commutable;
2598 }
2599 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2600 (ins VR128:$src1, i128mem:$src2),
2601 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2602 [(set VR128:$dst,
2603 (IntId128 VR128:$src1,
2604 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2605 }
2606}
2607
2608/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2609let isTwoAddress = 1 in {
2610 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2611 Intrinsic IntId64, Intrinsic IntId128,
2612 bit Commutable = 0> {
2613 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2614 (ins VR64:$src1, VR64:$src2),
2615 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2616 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2617 let isCommutable = Commutable;
2618 }
2619 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2620 (ins VR64:$src1, i64mem:$src2),
2621 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2622 [(set VR64:$dst,
2623 (IntId64 VR64:$src1,
2624 (bitconvert (memopv2i32 addr:$src2))))]>;
2625
2626 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2627 (ins VR128:$src1, VR128:$src2),
2628 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2629 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2630 OpSize {
2631 let isCommutable = Commutable;
2632 }
2633 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2634 (ins VR128:$src1, i128mem:$src2),
2635 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2636 [(set VR128:$dst,
2637 (IntId128 VR128:$src1,
2638 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2639 }
2640}
2641
2642defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2643 int_x86_ssse3_phadd_w,
2644 int_x86_ssse3_phadd_w_128, 1>;
2645defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2646 int_x86_ssse3_phadd_d,
2647 int_x86_ssse3_phadd_d_128, 1>;
2648defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2649 int_x86_ssse3_phadd_sw,
2650 int_x86_ssse3_phadd_sw_128, 1>;
2651defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2652 int_x86_ssse3_phsub_w,
2653 int_x86_ssse3_phsub_w_128>;
2654defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2655 int_x86_ssse3_phsub_d,
2656 int_x86_ssse3_phsub_d_128>;
2657defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2658 int_x86_ssse3_phsub_sw,
2659 int_x86_ssse3_phsub_sw_128>;
2660defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2661 int_x86_ssse3_pmadd_ub_sw,
2662 int_x86_ssse3_pmadd_ub_sw_128, 1>;
2663defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2664 int_x86_ssse3_pmul_hr_sw,
2665 int_x86_ssse3_pmul_hr_sw_128, 1>;
2666defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2667 int_x86_ssse3_pshuf_b,
2668 int_x86_ssse3_pshuf_b_128>;
2669defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2670 int_x86_ssse3_psign_b,
2671 int_x86_ssse3_psign_b_128>;
2672defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2673 int_x86_ssse3_psign_w,
2674 int_x86_ssse3_psign_w_128>;
2675defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2676 int_x86_ssse3_psign_d,
2677 int_x86_ssse3_psign_d_128>;
2678
2679let isTwoAddress = 1 in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002680 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2681 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002682 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002683 [(set VR64:$dst,
2684 (int_x86_ssse3_palign_r
2685 VR64:$src1, VR64:$src2,
2686 imm:$src3))]>;
2687 def PALIGNR64rm : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2688 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002689 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002690 [(set VR64:$dst,
2691 (int_x86_ssse3_palign_r
2692 VR64:$src1,
2693 (bitconvert (memopv2i32 addr:$src2)),
2694 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002695
Bill Wendling1dc817c2007-08-10 09:00:17 +00002696 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2697 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002698 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002699 [(set VR128:$dst,
2700 (int_x86_ssse3_palign_r_128
2701 VR128:$src1, VR128:$src2,
2702 imm:$src3))]>, OpSize;
2703 def PALIGNR128rm : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2704 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002705 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002706 [(set VR128:$dst,
2707 (int_x86_ssse3_palign_r_128
2708 VR128:$src1,
2709 (bitconvert (memopv4i32 addr:$src2)),
2710 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002711}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002712
2713//===----------------------------------------------------------------------===//
2714// Non-Instruction Patterns
2715//===----------------------------------------------------------------------===//
2716
2717// 128-bit vector undef's.
Bill Wendling1dc817c2007-08-10 09:00:17 +00002718def : Pat<(v4f32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002719def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2720def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2721def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2722def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2723def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2724
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002725// Scalar to v8i16 / v16i8. The source may be a GR32, but only the lower 8 or
2726// 16-bits matter.
2727def : Pat<(v8i16 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2728 Requires<[HasSSE2]>;
2729def : Pat<(v16i8 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2730 Requires<[HasSSE2]>;
2731
2732// bit_convert
2733let Predicates = [HasSSE2] in {
2734 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2735 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2736 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2737 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2738 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2739 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2740 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2741 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2742 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2743 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2744 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2745 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2746 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2747 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2748 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2749 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2750 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2751 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2752 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2753 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2754 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2755 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2756 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2757 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2758 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2759 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2760 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2761 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2762 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2763 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2764}
2765
2766// Move scalar to XMM zero-extended
2767// movd to XMM register zero-extends
2768let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002769// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Chris Lattnere6aa3862007-11-25 00:24:49 +00002770def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002771 (v2f64 (scalar_to_vector FR64:$src)), MOVL_shuffle_mask)),
2772 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Chris Lattnere6aa3862007-11-25 00:24:49 +00002773def : Pat<(v4f32 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002774 (v4f32 (scalar_to_vector FR32:$src)), MOVL_shuffle_mask)),
2775 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>;
2776}
2777
2778// Splat v2f64 / v2i64
2779let AddedComplexity = 10 in {
2780def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2781 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2782def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2783 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2784def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2785 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2786def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2787 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2788}
2789
2790// Splat v4f32
2791def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SSE_splat_mask:$sm),
2792 (SHUFPSrri VR128:$src, VR128:$src, SSE_splat_mask:$sm)>,
2793 Requires<[HasSSE1]>;
2794
2795// Special unary SHUFPSrri case.
2796// FIXME: when we want non two-address code, then we should use PSHUFD?
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002797def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2798 SHUFP_unary_shuffle_mask:$sm)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002799 (SHUFPSrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2800 Requires<[HasSSE1]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002801// Special unary SHUFPDrri case.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002802def : Pat<(v2f64 (vector_shuffle VR128:$src1, (undef),
2803 SHUFP_unary_shuffle_mask:$sm)),
Dan Gohman7dc19012007-08-02 21:17:01 +00002804 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2805 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002806// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Dan Gohman4a4f1512007-07-18 20:23:34 +00002807def : Pat<(vector_shuffle (memopv4f32 addr:$src1), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002808 SHUFP_unary_shuffle_mask:$sm),
2809 (PSHUFDmi addr:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2810 Requires<[HasSSE2]>;
2811// Special binary v4i32 shuffle cases with SHUFPS.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002812def : Pat<(v4i32 (vector_shuffle VR128:$src1, (v4i32 VR128:$src2),
2813 PSHUFD_binary_shuffle_mask:$sm)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002814 (SHUFPSrri VR128:$src1, VR128:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2815 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002816def : Pat<(v4i32 (vector_shuffle VR128:$src1,
2817 (bc_v4i32 (memopv2i64 addr:$src2)), PSHUFD_binary_shuffle_mask:$sm)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002818 (SHUFPSrmi VR128:$src1, addr:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2819 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002820// Special binary v2i64 shuffle cases using SHUFPDrri.
2821def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2822 SHUFP_shuffle_mask:$sm)),
2823 (SHUFPDrri VR128:$src1, VR128:$src2, SHUFP_shuffle_mask:$sm)>,
2824 Requires<[HasSSE2]>;
2825// Special unary SHUFPDrri case.
2826def : Pat<(v2i64 (vector_shuffle VR128:$src1, (undef),
2827 SHUFP_unary_shuffle_mask:$sm)),
2828 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2829 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002830
2831// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2832let AddedComplexity = 10 in {
2833def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2834 UNPCKL_v_undef_shuffle_mask)),
2835 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2836def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2837 UNPCKL_v_undef_shuffle_mask)),
2838 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2839def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2840 UNPCKL_v_undef_shuffle_mask)),
2841 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2842def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2843 UNPCKL_v_undef_shuffle_mask)),
2844 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2845}
2846
2847// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2848let AddedComplexity = 10 in {
2849def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2850 UNPCKH_v_undef_shuffle_mask)),
2851 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2852def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2853 UNPCKH_v_undef_shuffle_mask)),
2854 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2855def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2856 UNPCKH_v_undef_shuffle_mask)),
2857 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2858def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2859 UNPCKH_v_undef_shuffle_mask)),
2860 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2861}
2862
2863let AddedComplexity = 15 in {
2864// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2865def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2866 MOVHP_shuffle_mask)),
2867 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2868
2869// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2870def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2871 MOVHLPS_shuffle_mask)),
2872 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2873
2874// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2875def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2876 MOVHLPS_v_undef_shuffle_mask)),
2877 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2878def : Pat<(v4i32 (vector_shuffle VR128:$src1, (undef),
2879 MOVHLPS_v_undef_shuffle_mask)),
2880 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2881}
2882
2883let AddedComplexity = 20 in {
2884// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2885// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Dan Gohman4a4f1512007-07-18 20:23:34 +00002886def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002887 MOVLP_shuffle_mask)),
2888 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002889def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002890 MOVLP_shuffle_mask)),
2891 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002892def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002893 MOVHP_shuffle_mask)),
2894 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002895def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002896 MOVHP_shuffle_mask)),
2897 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2898
Dan Gohman4a4f1512007-07-18 20:23:34 +00002899def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002900 MOVLP_shuffle_mask)),
2901 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002902def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002903 MOVLP_shuffle_mask)),
2904 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002905def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002906 MOVHP_shuffle_mask)),
2907 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002908def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002909 MOVLP_shuffle_mask)),
2910 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2911}
2912
2913let AddedComplexity = 15 in {
2914// Setting the lowest element in the vector.
2915def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2916 MOVL_shuffle_mask)),
2917 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2918def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2919 MOVL_shuffle_mask)),
2920 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2921
2922// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
2923def : Pat<(v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
2924 MOVLP_shuffle_mask)),
2925 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2926def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2927 MOVLP_shuffle_mask)),
2928 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2929}
2930
2931// Set lowest element and zero upper elements.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002932let AddedComplexity = 15 in
2933def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc, VR128:$src,
2934 MOVL_shuffle_mask)),
2935 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
2936
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937
2938// FIXME: Temporary workaround since 2-wide shuffle is broken.
2939def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
2940 (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2941def : Pat<(int_x86_sse2_loadh_pd VR128:$src1, addr:$src2),
2942 (v2f64 (MOVHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2943def : Pat<(int_x86_sse2_loadl_pd VR128:$src1, addr:$src2),
2944 (v2f64 (MOVLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2945def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
2946 (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
2947 Requires<[HasSSE2]>;
2948def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (load addr:$src2), imm:$src3),
2949 (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
2950 Requires<[HasSSE2]>;
2951def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
2952 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2953def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (load addr:$src2)),
2954 (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2955def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
2956 (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2957def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (load addr:$src2)),
2958 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2959def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2),
2960 (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2961def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (load addr:$src2)),
2962 (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2963def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2),
2964 (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2965def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (load addr:$src2)),
2966 (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2967
2968// Some special case pandn patterns.
2969def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2970 VR128:$src2)),
2971 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2972def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
2973 VR128:$src2)),
2974 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2975def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
2976 VR128:$src2)),
2977 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2978
2979def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002980 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002981 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2982def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002983 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002984 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2985def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002986 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002987 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2988
Nate Begeman78246ca2007-11-17 03:58:34 +00002989// vector -> vector casts
2990def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
2991 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
2992def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
2993 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
2994
Evan Cheng51a49b22007-07-20 00:27:43 +00002995// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00002996def : Pat<(alignedloadv4i32 addr:$src),
2997 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
2998def : Pat<(loadv4i32 addr:$src),
2999 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00003000def : Pat<(alignedloadv2i64 addr:$src),
3001 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
3002def : Pat<(loadv2i64 addr:$src),
3003 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
3004
3005def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
3006 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3007def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
3008 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3009def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3010 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3011def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3012 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3013def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3014 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3015def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3016 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3017def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3018 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3019def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3020 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;