blob: 9060978feed9f318d45c4741b7917de8ec44ce2e [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//====- X86InstrSSE.td - Describe the X86 Instruction Set -------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Evan Cheng and is distributed under the University
6// of Illinois Open Source License. See LICENSE.TXT for details.
7//
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>;
35def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest,
36 [SDNPHasChain, SDNPOutFlag]>;
37def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest,
38 [SDNPHasChain, SDNPOutFlag]>;
39def X86s2vec : SDNode<"X86ISD::S2VEC", SDTypeProfile<1, 1, []>, []>;
40def X86pextrw : SDNode<"X86ISD::PEXTRW", SDTypeProfile<1, 2, []>, []>;
41def X86pinsrw : SDNode<"X86ISD::PINSRW", SDTypeProfile<1, 3, []>, []>;
42
43//===----------------------------------------------------------------------===//
44// SSE 'Special' Instructions
45//===----------------------------------------------------------------------===//
46
Evan Chengb783fa32007-07-19 01:14:50 +000047def IMPLICIT_DEF_VR128 : I<0, Pseudo, (outs VR128:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000048 "#IMPLICIT_DEF $dst",
49 [(set VR128:$dst, (v4f32 (undef)))]>,
50 Requires<[HasSSE1]>;
Evan Chengb783fa32007-07-19 01:14:50 +000051def IMPLICIT_DEF_FR32 : I<0, Pseudo, (outs FR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052 "#IMPLICIT_DEF $dst",
53 [(set FR32:$dst, (undef))]>, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +000054def IMPLICIT_DEF_FR64 : I<0, Pseudo, (outs FR64:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055 "#IMPLICIT_DEF $dst",
56 [(set FR64:$dst, (undef))]>, Requires<[HasSSE2]>;
57
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", [],
66 [SDNPHasChain]>;
67def sse_load_f64 : ComplexPattern<v2f64, 4, "SelectScalarSSELoad", [],
68 [SDNPHasChain]>;
69
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))>;
Bill Wendling98680292007-08-10 06:22:27 +0000131def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop node:$ptr))>;
132def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>;
133def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop node:$ptr))>;
134def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop node:$ptr))>;
135def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000136def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
137def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
138
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
140def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
141def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
142def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
143def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
144def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
145
146def fp32imm0 : PatLeaf<(f32 fpimm), [{
147 return N->isExactlyValue(+0.0);
148}]>;
149
150def PSxLDQ_imm : SDNodeXForm<imm, [{
151 // Transformation function: imm >> 3
152 return getI32Imm(N->getValue() >> 3);
153}]>;
154
155// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
156// SHUFP* etc. imm.
157def SHUFFLE_get_shuf_imm : SDNodeXForm<build_vector, [{
158 return getI8Imm(X86::getShuffleSHUFImmediate(N));
159}]>;
160
161// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
162// PSHUFHW imm.
163def SHUFFLE_get_pshufhw_imm : SDNodeXForm<build_vector, [{
164 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
165}]>;
166
167// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
168// PSHUFLW imm.
169def SHUFFLE_get_pshuflw_imm : SDNodeXForm<build_vector, [{
170 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
171}]>;
172
173def SSE_splat_mask : PatLeaf<(build_vector), [{
174 return X86::isSplatMask(N);
175}], SHUFFLE_get_shuf_imm>;
176
177def SSE_splat_lo_mask : PatLeaf<(build_vector), [{
178 return X86::isSplatLoMask(N);
179}]>;
180
181def MOVHLPS_shuffle_mask : PatLeaf<(build_vector), [{
182 return X86::isMOVHLPSMask(N);
183}]>;
184
185def MOVHLPS_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
186 return X86::isMOVHLPS_v_undef_Mask(N);
187}]>;
188
189def MOVHP_shuffle_mask : PatLeaf<(build_vector), [{
190 return X86::isMOVHPMask(N);
191}]>;
192
193def MOVLP_shuffle_mask : PatLeaf<(build_vector), [{
194 return X86::isMOVLPMask(N);
195}]>;
196
197def MOVL_shuffle_mask : PatLeaf<(build_vector), [{
198 return X86::isMOVLMask(N);
199}]>;
200
201def MOVSHDUP_shuffle_mask : PatLeaf<(build_vector), [{
202 return X86::isMOVSHDUPMask(N);
203}]>;
204
205def MOVSLDUP_shuffle_mask : PatLeaf<(build_vector), [{
206 return X86::isMOVSLDUPMask(N);
207}]>;
208
209def UNPCKL_shuffle_mask : PatLeaf<(build_vector), [{
210 return X86::isUNPCKLMask(N);
211}]>;
212
213def UNPCKH_shuffle_mask : PatLeaf<(build_vector), [{
214 return X86::isUNPCKHMask(N);
215}]>;
216
217def UNPCKL_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
218 return X86::isUNPCKL_v_undef_Mask(N);
219}]>;
220
221def UNPCKH_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
222 return X86::isUNPCKH_v_undef_Mask(N);
223}]>;
224
225def PSHUFD_shuffle_mask : PatLeaf<(build_vector), [{
226 return X86::isPSHUFDMask(N);
227}], SHUFFLE_get_shuf_imm>;
228
229def PSHUFHW_shuffle_mask : PatLeaf<(build_vector), [{
230 return X86::isPSHUFHWMask(N);
231}], SHUFFLE_get_pshufhw_imm>;
232
233def PSHUFLW_shuffle_mask : PatLeaf<(build_vector), [{
234 return X86::isPSHUFLWMask(N);
235}], SHUFFLE_get_pshuflw_imm>;
236
237def SHUFP_unary_shuffle_mask : PatLeaf<(build_vector), [{
238 return X86::isPSHUFDMask(N);
239}], SHUFFLE_get_shuf_imm>;
240
241def SHUFP_shuffle_mask : PatLeaf<(build_vector), [{
242 return X86::isSHUFPMask(N);
243}], SHUFFLE_get_shuf_imm>;
244
245def PSHUFD_binary_shuffle_mask : PatLeaf<(build_vector), [{
246 return X86::isSHUFPMask(N);
247}], SHUFFLE_get_shuf_imm>;
248
249//===----------------------------------------------------------------------===//
250// SSE scalar FP Instructions
251//===----------------------------------------------------------------------===//
252
253// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
254// scheduler into a branch sequence.
255let usesCustomDAGSchedInserter = 1 in { // Expanded by the scheduler.
256 def CMOV_FR32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000257 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000258 "#CMOV_FR32 PSEUDO!",
259 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond))]>;
260 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000261 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262 "#CMOV_FR64 PSEUDO!",
263 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond))]>;
264 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000265 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266 "#CMOV_V4F32 PSEUDO!",
267 [(set VR128:$dst,
268 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond)))]>;
269 def CMOV_V2F64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000270 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271 "#CMOV_V2F64 PSEUDO!",
272 [(set VR128:$dst,
273 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond)))]>;
274 def CMOV_V2I64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000275 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276 "#CMOV_V2I64 PSEUDO!",
277 [(set VR128:$dst,
278 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond)))]>;
279}
280
281//===----------------------------------------------------------------------===//
282// SSE1 Instructions
283//===----------------------------------------------------------------------===//
284
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000285// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000286def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000287 "movss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanca9f99d2007-08-02 14:27:55 +0000288let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000289def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000290 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000292def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000293 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294 [(store FR32:$src, addr:$dst)]>;
295
296// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000297def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000298 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000299 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000300def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000301 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000303def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000304 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000306def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000307 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000308 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
309
310// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000311def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000312 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000314def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000315 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316 [(set GR32:$dst, (int_x86_sse_cvtss2si
317 (load addr:$src)))]>;
318
319// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000320def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000321 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322 [(set GR32:$dst,
323 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000324def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000325 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000326 [(set GR32:$dst,
327 (int_x86_sse_cvttss2si(load addr:$src)))]>;
328
329let isTwoAddress = 1 in {
330 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000331 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000332 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
334 GR32:$src2))]>;
335 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000336 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000337 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000338 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
339 (loadi32 addr:$src2)))]>;
340}
341
342// Comparison instructions
343let isTwoAddress = 1 in {
344 def CMPSSrr : SSI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000345 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000346 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000347 def CMPSSrm : SSI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000348 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000349 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000350}
351
Evan Chengb783fa32007-07-19 01:14:50 +0000352def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000353 "ucomiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 [(X86cmp FR32:$src1, FR32:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000355def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000356 "ucomiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357 [(X86cmp FR32:$src1, (loadf32 addr:$src2))]>;
358
359// Aliases to match intrinsics which expect XMM operand(s).
360let isTwoAddress = 1 in {
361 def Int_CMPSSrr : SSI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000362 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000363 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
365 VR128:$src, imm:$cc))]>;
366 def Int_CMPSSrm : SSI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000367 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000368 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
370 (load addr:$src), imm:$cc))]>;
371}
372
Evan Chengb783fa32007-07-19 01:14:50 +0000373def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000374 "ucomiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000375 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000376def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000377 "ucomiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000378 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2))]>;
379
Evan Chengb783fa32007-07-19 01:14:50 +0000380def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "comiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 [(X86comi (v4f32 VR128:$src1), VR128:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000383def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000384 "comiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385 [(X86comi (v4f32 VR128:$src1), (load addr:$src2))]>;
386
387// Aliases of packed SSE1 instructions for scalar use. These all have names that
388// start with 'Fs'.
389
390// Alias instructions that map fld0 to pxor for sse.
Evan Chengb783fa32007-07-19 01:14:50 +0000391def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000392 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393 Requires<[HasSSE1]>, TB, OpSize;
394
395// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
396// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +0000397def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000398 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399
400// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
401// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +0000402def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000403 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000404 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405
406// Alias bitwise logical operations using SSE logical ops on packed FP values.
407let isTwoAddress = 1 in {
408let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000409 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000410 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000412 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000413 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000414 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000415 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000416 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
418}
419
Evan Chengb783fa32007-07-19 01:14:50 +0000420def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000421 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000423 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000424def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000425 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000427 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000428def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000429 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000431 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000432
433def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000434 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000435 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000437 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000438 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439}
440
441/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
442///
443/// In addition, we also have a special variant of the scalar form here to
444/// represent the associated intrinsic operation. This form is unlike the
445/// plain scalar form, in that it takes an entire vector (instead of a scalar)
446/// and leaves the top elements undefined.
447///
448/// These three forms can each be reg+reg or reg+mem, so there are a total of
449/// six "instructions".
450///
451let isTwoAddress = 1 in {
452multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
453 SDNode OpNode, Intrinsic F32Int,
454 bit Commutable = 0> {
455 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000456 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000457 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
459 let isCommutable = Commutable;
460 }
461
462 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000463 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000464 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000465 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
466
467 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000468 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000469 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
471 let isCommutable = Commutable;
472 }
473
474 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000475 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000476 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000477 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478
479 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000480 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000481 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000482 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
483 let isCommutable = Commutable;
484 }
485
486 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000487 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000488 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489 [(set VR128:$dst, (F32Int VR128:$src1,
490 sse_load_f32:$src2))]>;
491}
492}
493
494// Arithmetic instructions
495defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
496defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
497defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
498defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
499
500/// sse1_fp_binop_rm - Other SSE1 binops
501///
502/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
503/// instructions for a full-vector intrinsic form. Operations that map
504/// onto C operators don't use this form since they just use the plain
505/// vector form instead of having a separate vector intrinsic form.
506///
507/// This provides a total of eight "instructions".
508///
509let isTwoAddress = 1 in {
510multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
511 SDNode OpNode,
512 Intrinsic F32Int,
513 Intrinsic V4F32Int,
514 bit Commutable = 0> {
515
516 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000517 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000518 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
520 let isCommutable = Commutable;
521 }
522
523 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000524 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000525 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
527
528 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000529 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000530 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
532 let isCommutable = Commutable;
533 }
534
535 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000536 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000537 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000538 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539
540 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000541 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000542 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
544 let isCommutable = Commutable;
545 }
546
547 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000548 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000549 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550 [(set VR128:$dst, (F32Int VR128:$src1,
551 sse_load_f32:$src2))]>;
552
553 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000554 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000555 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
557 let isCommutable = Commutable;
558 }
559
560 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +0000561 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000562 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563 [(set VR128:$dst, (V4F32Int VR128:$src1, (load addr:$src2)))]>;
564}
565}
566
567defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
568 int_x86_sse_max_ss, int_x86_sse_max_ps>;
569defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
570 int_x86_sse_min_ss, int_x86_sse_min_ps>;
571
572//===----------------------------------------------------------------------===//
573// SSE packed FP Instructions
574
575// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000576def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000577 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanca9f99d2007-08-02 14:27:55 +0000578let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000579def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000580 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000581 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000582
Evan Chengb783fa32007-07-19 01:14:50 +0000583def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000584 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000585 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586
Evan Chengb783fa32007-07-19 01:14:50 +0000587def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000588 "movups\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000589def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000590 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000591 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000592def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000593 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000594 [(store (v4f32 VR128:$src), addr:$dst)]>;
595
596// Intrinsic forms of MOVUPS load and store
Evan Chengb783fa32007-07-19 01:14:50 +0000597def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000598 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000599 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000600def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000601 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000602 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603
604let isTwoAddress = 1 in {
605 let AddedComplexity = 20 in {
606 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000607 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000608 "movlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609 [(set VR128:$dst,
610 (v4f32 (vector_shuffle VR128:$src1,
611 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
612 MOVLP_shuffle_mask)))]>;
613 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000614 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000615 "movhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000616 [(set VR128:$dst,
617 (v4f32 (vector_shuffle VR128:$src1,
618 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
619 MOVHP_shuffle_mask)))]>;
620 } // AddedComplexity
621} // isTwoAddress
622
Evan Chengb783fa32007-07-19 01:14:50 +0000623def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000624 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
626 (iPTR 0))), addr:$dst)]>;
627
628// v2f64 extract element 1 is always custom lowered to unpack high to low
629// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000630def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000631 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000632 [(store (f64 (vector_extract
633 (v2f64 (vector_shuffle
634 (bc_v2f64 (v4f32 VR128:$src)), (undef),
635 UNPCKH_shuffle_mask)), (iPTR 0))),
636 addr:$dst)]>;
637
638let isTwoAddress = 1 in {
639let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000640def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000641 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642 [(set VR128:$dst,
643 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
644 MOVHP_shuffle_mask)))]>;
645
Evan Chengb783fa32007-07-19 01:14:50 +0000646def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648 [(set VR128:$dst,
649 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
650 MOVHLPS_shuffle_mask)))]>;
651} // AddedComplexity
652} // isTwoAddress
653
654
655
656// Arithmetic
657
658/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
659///
660/// In addition, we also have a special variant of the scalar form here to
661/// represent the associated intrinsic operation. This form is unlike the
662/// plain scalar form, in that it takes an entire vector (instead of a
663/// scalar) and leaves the top elements undefined.
664///
665/// And, we have a special variant form for a full-vector intrinsic form.
666///
667/// These four forms can each have a reg or a mem operand, so there are a
668/// total of eight "instructions".
669///
670multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
671 SDNode OpNode,
672 Intrinsic F32Int,
673 Intrinsic V4F32Int,
674 bit Commutable = 0> {
675 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000676 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000677 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000678 [(set FR32:$dst, (OpNode FR32:$src))]> {
679 let isCommutable = Commutable;
680 }
681
682 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000683 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000684 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000685 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
686
687 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000688 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000689 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
691 let isCommutable = Commutable;
692 }
693
694 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000695 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000696 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000697 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698
699 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000700 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000701 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702 [(set VR128:$dst, (F32Int VR128:$src))]> {
703 let isCommutable = Commutable;
704 }
705
706 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000707 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
710
711 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000712 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000713 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
715 let isCommutable = Commutable;
716 }
717
718 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000719 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000720 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721 [(set VR128:$dst, (V4F32Int (load addr:$src)))]>;
722}
723
724// Square root.
725defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
726 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
727
728// Reciprocal approximations. Note that these typically require refinement
729// in order to obtain suitable precision.
730defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
731 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
732defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
733 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
734
735// Logical
736let isTwoAddress = 1 in {
737 let isCommutable = 1 in {
738 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000739 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000740 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741 [(set VR128:$dst, (v2i64
742 (and VR128:$src1, VR128:$src2)))]>;
743 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000744 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000745 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 [(set VR128:$dst, (v2i64
747 (or VR128:$src1, VR128:$src2)))]>;
748 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000749 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000750 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751 [(set VR128:$dst, (v2i64
752 (xor VR128:$src1, VR128:$src2)))]>;
753 }
754
755 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000756 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000757 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000758 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
759 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000761 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000762 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000763 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
764 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000766 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000767 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000768 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
769 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000771 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000772 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 [(set VR128:$dst,
774 (v2i64 (and (xor VR128:$src1,
775 (bc_v2i64 (v4i32 immAllOnesV))),
776 VR128:$src2)))]>;
777 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000778 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000779 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000781 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000783 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784}
785
786let isTwoAddress = 1 in {
787 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000788 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000789 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000790 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
791 VR128:$src, imm:$cc))]>;
792 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000793 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000794 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
796 (load addr:$src), imm:$cc))]>;
797}
798
799// Shuffle and unpack instructions
800let isTwoAddress = 1 in {
801 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
802 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000803 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804 VR128:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000805 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 [(set VR128:$dst,
807 (v4f32 (vector_shuffle
808 VR128:$src1, VR128:$src2,
809 SHUFP_shuffle_mask:$src3)))]>;
810 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000811 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 f128mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000813 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 [(set VR128:$dst,
815 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000816 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 SHUFP_shuffle_mask:$src3)))]>;
818
819 let AddedComplexity = 10 in {
820 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000821 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000822 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 [(set VR128:$dst,
824 (v4f32 (vector_shuffle
825 VR128:$src1, VR128:$src2,
826 UNPCKH_shuffle_mask)))]>;
827 def UNPCKHPSrm : PSI<0x15, 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 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830 [(set VR128:$dst,
831 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000832 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833 UNPCKH_shuffle_mask)))]>;
834
835 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000836 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000837 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838 [(set VR128:$dst,
839 (v4f32 (vector_shuffle
840 VR128:$src1, VR128:$src2,
841 UNPCKL_shuffle_mask)))]>;
842 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000843 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 [(set VR128:$dst,
846 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000847 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 UNPCKL_shuffle_mask)))]>;
849 } // AddedComplexity
850} // isTwoAddress
851
852// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000853def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000854 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000856def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000857 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
859
860// Prefetching loads.
861// TODO: no intrinsics for these?
Dan Gohman91888f02007-07-31 20:11:57 +0000862def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), "prefetcht0\t$src", []>;
863def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src), "prefetcht1\t$src", []>;
864def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src), "prefetcht2\t$src", []>;
865def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src), "prefetchnta\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866
867// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000868def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000869 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
871
872// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +0000873def SFENCE : PSI<0xAE, MRM7m, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874
875// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000876def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000877 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000878def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000879 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880
881// Alias instructions that map zero vector to pxor / xorp* for sse.
882// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
883let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000884def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000885 "xorps\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 [(set VR128:$dst, (v4f32 immAllZerosV))]>;
887
888// FR32 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +0000889def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000890 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 [(set VR128:$dst,
892 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000893def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000894 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895 [(set VR128:$dst,
896 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
897
898// FIXME: may not be able to eliminate this movss with coalescing the src and
899// dest register classes are different. We really want to write this pattern
900// like this:
901// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
902// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +0000903def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000904 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
906 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000907def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000908 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 [(store (f32 (vector_extract (v4f32 VR128:$src),
910 (iPTR 0))), addr:$dst)]>;
911
912
913// Move to lower bits of a VR128, leaving upper bits alone.
914// Three operand (but two address) aliases.
915let isTwoAddress = 1 in {
916 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000917 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000918 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919
920 let AddedComplexity = 15 in
921 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000922 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000923 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 [(set VR128:$dst,
925 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
926 MOVL_shuffle_mask)))]>;
927}
928
929// Move to lower bits of a VR128 and zeroing upper bits.
930// Loading from memory automatically zeroing upper bits.
931let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +0000932def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000933 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 [(set VR128:$dst, (v4f32 (vector_shuffle immAllZerosV,
935 (v4f32 (scalar_to_vector (loadf32 addr:$src))),
936 MOVL_shuffle_mask)))]>;
937
938
939//===----------------------------------------------------------------------===//
940// SSE2 Instructions
941//===----------------------------------------------------------------------===//
942
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000944def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000945 "movsd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanca9f99d2007-08-02 14:27:55 +0000946let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000947def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000948 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000950def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000951 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 [(store FR64:$src, addr:$dst)]>;
953
954// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000955def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000956 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000958def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000959 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000961def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000964def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000965 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000967def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000968 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000970def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000971 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
973
974// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +0000975def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000976 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
978 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000979def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000980 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
982 Requires<[HasSSE2]>;
983
984// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000985def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000986 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000988def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000989 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
991 (load addr:$src)))]>;
992
993// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000994def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000995 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 [(set GR32:$dst,
997 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000998def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000999 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1001 (load addr:$src)))]>;
1002
1003// Comparison instructions
1004let isTwoAddress = 1 in {
1005 def CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001006 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001007 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008 def CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001009 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001010 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011}
1012
Evan Chengb783fa32007-07-19 01:14:50 +00001013def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001014 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 [(X86cmp FR64:$src1, FR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001016def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001017 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 [(X86cmp FR64:$src1, (loadf64 addr:$src2))]>;
1019
1020// Aliases to match intrinsics which expect XMM operand(s).
1021let isTwoAddress = 1 in {
1022 def Int_CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001023 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001024 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1026 VR128:$src, imm:$cc))]>;
1027 def Int_CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001028 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001029 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1031 (load addr:$src), imm:$cc))]>;
1032}
1033
Evan Chengb783fa32007-07-19 01:14:50 +00001034def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001035 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001037def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001038 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2))]>;
1040
Evan Chengb783fa32007-07-19 01:14:50 +00001041def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001042 "comisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001044def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001045 "comisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 [(X86comi (v2f64 VR128:$src1), (load addr:$src2))]>;
1047
1048// Aliases of packed SSE2 instructions for scalar use. These all have names that
1049// start with 'Fs'.
1050
1051// Alias instructions that map fld0 to pxor for sse.
Evan Chengb783fa32007-07-19 01:14:50 +00001052def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001053 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 Requires<[HasSSE2]>, TB, OpSize;
1055
1056// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1057// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +00001058def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001059 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060
1061// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1062// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +00001063def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001064 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001065 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066
1067// Alias bitwise logical operations using SSE logical ops on packed FP values.
1068let isTwoAddress = 1 in {
1069let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001070 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001071 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001073 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001074 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001076 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001077 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1079}
1080
Evan Chengb783fa32007-07-19 01:14:50 +00001081def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001082 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001084 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001085def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001086 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001088 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001089def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001090 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001092 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093
1094def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001095 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001096 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001098 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001099 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100}
1101
1102/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1103///
1104/// In addition, we also have a special variant of the scalar form here to
1105/// represent the associated intrinsic operation. This form is unlike the
1106/// plain scalar form, in that it takes an entire vector (instead of a scalar)
1107/// and leaves the top elements undefined.
1108///
1109/// These three forms can each be reg+reg or reg+mem, so there are a total of
1110/// six "instructions".
1111///
1112let isTwoAddress = 1 in {
1113multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1114 SDNode OpNode, Intrinsic F64Int,
1115 bit Commutable = 0> {
1116 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001117 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001118 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1120 let isCommutable = Commutable;
1121 }
1122
1123 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001124 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001125 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1127
1128 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001129 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001130 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001131 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1132 let isCommutable = Commutable;
1133 }
1134
1135 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001136 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001137 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001138 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139
1140 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001141 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001142 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1144 let isCommutable = Commutable;
1145 }
1146
1147 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001148 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001149 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 [(set VR128:$dst, (F64Int VR128:$src1,
1151 sse_load_f64:$src2))]>;
1152}
1153}
1154
1155// Arithmetic instructions
1156defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1157defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1158defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1159defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1160
1161/// sse2_fp_binop_rm - Other SSE2 binops
1162///
1163/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1164/// instructions for a full-vector intrinsic form. Operations that map
1165/// onto C operators don't use this form since they just use the plain
1166/// vector form instead of having a separate vector intrinsic form.
1167///
1168/// This provides a total of eight "instructions".
1169///
1170let isTwoAddress = 1 in {
1171multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1172 SDNode OpNode,
1173 Intrinsic F64Int,
1174 Intrinsic V2F64Int,
1175 bit Commutable = 0> {
1176
1177 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001178 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001179 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001180 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1181 let isCommutable = Commutable;
1182 }
1183
1184 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001185 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001186 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1188
1189 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001190 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001191 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001192 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1193 let isCommutable = Commutable;
1194 }
1195
1196 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001197 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001198 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001199 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200
1201 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001202 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001203 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1205 let isCommutable = Commutable;
1206 }
1207
1208 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001209 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001210 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 [(set VR128:$dst, (F64Int VR128:$src1,
1212 sse_load_f64:$src2))]>;
1213
1214 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001215 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001216 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1218 let isCommutable = Commutable;
1219 }
1220
1221 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +00001222 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001223 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224 [(set VR128:$dst, (V2F64Int VR128:$src1, (load addr:$src2)))]>;
1225}
1226}
1227
1228defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1229 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1230defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1231 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1232
1233//===----------------------------------------------------------------------===//
1234// SSE packed FP Instructions
1235
1236// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001237def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001238 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanca9f99d2007-08-02 14:27:55 +00001239let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001240def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001241 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001242 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243
Evan Chengb783fa32007-07-19 01:14:50 +00001244def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001245 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001246 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247
Evan Chengb783fa32007-07-19 01:14:50 +00001248def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001249 "movupd\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001250def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001251 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001252 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001253def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001254 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001255 [(store (v2f64 VR128:$src), addr:$dst)]>;
1256
1257// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001258def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001259 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001260 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001261def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001263 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264
1265let isTwoAddress = 1 in {
1266 let AddedComplexity = 20 in {
1267 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001268 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001269 "movlpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 [(set VR128:$dst,
1271 (v2f64 (vector_shuffle VR128:$src1,
1272 (scalar_to_vector (loadf64 addr:$src2)),
1273 MOVLP_shuffle_mask)))]>;
1274 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001275 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001276 "movhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 [(set VR128:$dst,
1278 (v2f64 (vector_shuffle VR128:$src1,
1279 (scalar_to_vector (loadf64 addr:$src2)),
1280 MOVHP_shuffle_mask)))]>;
1281 } // AddedComplexity
1282} // isTwoAddress
1283
Evan Chengb783fa32007-07-19 01:14:50 +00001284def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001285 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286 [(store (f64 (vector_extract (v2f64 VR128:$src),
1287 (iPTR 0))), addr:$dst)]>;
1288
1289// v2f64 extract element 1 is always custom lowered to unpack high to low
1290// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001291def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001292 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 [(store (f64 (vector_extract
1294 (v2f64 (vector_shuffle VR128:$src, (undef),
1295 UNPCKH_shuffle_mask)), (iPTR 0))),
1296 addr:$dst)]>;
1297
1298// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001299def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001300 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1302 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001303def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001304 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
Dan Gohman4a4f1512007-07-18 20:23:34 +00001306 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 TB, Requires<[HasSSE2]>;
1308
1309// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001310def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001311 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1313 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001314def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001315 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
Dan Gohman4a4f1512007-07-18 20:23:34 +00001317 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318 XS, Requires<[HasSSE2]>;
1319
Evan Chengb783fa32007-07-19 01:14:50 +00001320def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001321 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001323def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001324 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1326 (load addr:$src)))]>;
1327// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001328def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001329 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1331 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001332def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001333 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1335 (load addr:$src)))]>,
1336 XS, Requires<[HasSSE2]>;
1337
1338// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001339def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001340 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1342 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001343def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001344 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001345 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1346 (load addr:$src)))]>,
1347 XD, Requires<[HasSSE2]>;
1348
Evan Chengb783fa32007-07-19 01:14:50 +00001349def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001350 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001352def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001353 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1355 (load addr:$src)))]>;
1356
1357// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001358def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001359 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1361 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001362def Int_CVTPS2PDrm : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001363 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1365 (load addr:$src)))]>,
1366 TB, Requires<[HasSSE2]>;
1367
Evan Chengb783fa32007-07-19 01:14:50 +00001368def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001369 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001370 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001371def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001372 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1374 (load addr:$src)))]>;
1375
1376// Match intrinsics which expect XMM operand(s).
1377// Aliases for intrinsics
1378let isTwoAddress = 1 in {
1379def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001380 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001381 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001382 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1383 GR32:$src2))]>;
1384def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001385 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001386 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1388 (loadi32 addr:$src2)))]>;
1389def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001390 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001391 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001392 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1393 VR128:$src2))]>;
1394def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001395 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001396 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1398 (load addr:$src2)))]>;
1399def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001400 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001401 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001402 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1403 VR128:$src2))]>, XS,
1404 Requires<[HasSSE2]>;
1405def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001406 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001407 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1409 (load addr:$src2)))]>, XS,
1410 Requires<[HasSSE2]>;
1411}
1412
1413// Arithmetic
1414
1415/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1416///
1417/// In addition, we also have a special variant of the scalar form here to
1418/// represent the associated intrinsic operation. This form is unlike the
1419/// plain scalar form, in that it takes an entire vector (instead of a
1420/// scalar) and leaves the top elements undefined.
1421///
1422/// And, we have a special variant form for a full-vector intrinsic form.
1423///
1424/// These four forms can each have a reg or a mem operand, so there are a
1425/// total of eight "instructions".
1426///
1427multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1428 SDNode OpNode,
1429 Intrinsic F64Int,
1430 Intrinsic V2F64Int,
1431 bit Commutable = 0> {
1432 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001433 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001435 [(set FR64:$dst, (OpNode FR64:$src))]> {
1436 let isCommutable = Commutable;
1437 }
1438
1439 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001440 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001441 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1443
1444 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001445 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001446 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1448 let isCommutable = Commutable;
1449 }
1450
1451 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001452 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001453 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001454 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455
1456 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001457 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001459 [(set VR128:$dst, (F64Int VR128:$src))]> {
1460 let isCommutable = Commutable;
1461 }
1462
1463 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001464 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001465 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001466 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1467
1468 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001469 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001470 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1472 let isCommutable = Commutable;
1473 }
1474
1475 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001476 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001477 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001478 [(set VR128:$dst, (V2F64Int (load addr:$src)))]>;
1479}
1480
1481// Square root.
1482defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1483 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1484
1485// There is no f64 version of the reciprocal approximation instructions.
1486
1487// Logical
1488let isTwoAddress = 1 in {
1489 let isCommutable = 1 in {
1490 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001491 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001492 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001493 [(set VR128:$dst,
1494 (and (bc_v2i64 (v2f64 VR128:$src1)),
1495 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1496 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001497 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001498 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001499 [(set VR128:$dst,
1500 (or (bc_v2i64 (v2f64 VR128:$src1)),
1501 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1502 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001503 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001504 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505 [(set VR128:$dst,
1506 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1507 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1508 }
1509
1510 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001511 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001512 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001513 [(set VR128:$dst,
1514 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001515 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001517 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001519 [(set VR128:$dst,
1520 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001521 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001523 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525 [(set VR128:$dst,
1526 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001527 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001529 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531 [(set VR128:$dst,
1532 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1533 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1534 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001535 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537 [(set VR128:$dst,
1538 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001539 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540}
1541
1542let isTwoAddress = 1 in {
1543 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001544 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1547 VR128:$src, imm:$cc))]>;
1548 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001549 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001550 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1552 (load addr:$src), imm:$cc))]>;
1553}
1554
1555// Shuffle and unpack instructions
1556let isTwoAddress = 1 in {
1557 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001558 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 [(set VR128:$dst, (v2f64 (vector_shuffle
1561 VR128:$src1, VR128:$src2,
1562 SHUFP_shuffle_mask:$src3)))]>;
1563 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001564 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567 [(set VR128:$dst,
1568 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001569 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570 SHUFP_shuffle_mask:$src3)))]>;
1571
1572 let AddedComplexity = 10 in {
1573 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001574 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001576 [(set VR128:$dst,
1577 (v2f64 (vector_shuffle
1578 VR128:$src1, VR128:$src2,
1579 UNPCKH_shuffle_mask)))]>;
1580 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001581 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001582 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583 [(set VR128:$dst,
1584 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001585 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001586 UNPCKH_shuffle_mask)))]>;
1587
1588 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001589 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001590 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591 [(set VR128:$dst,
1592 (v2f64 (vector_shuffle
1593 VR128:$src1, VR128:$src2,
1594 UNPCKL_shuffle_mask)))]>;
1595 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001596 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001598 [(set VR128:$dst,
1599 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001600 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601 UNPCKL_shuffle_mask)))]>;
1602 } // AddedComplexity
1603} // isTwoAddress
1604
1605
1606//===----------------------------------------------------------------------===//
1607// SSE integer instructions
1608
1609// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001610def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001611 "movdqa\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001612def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001614 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001615def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001616 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001617 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001618def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001620 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001622def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001624 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625 XS, Requires<[HasSSE2]>;
1626
Dan Gohman4a4f1512007-07-18 20:23:34 +00001627// Intrinsic forms of MOVDQU load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001628def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001629 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001630 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1631 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001632def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001633 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001634 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1635 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636
1637let isTwoAddress = 1 in {
1638
1639multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1640 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001641 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001642 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001643 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1644 let isCommutable = Commutable;
1645 }
Evan Chengb783fa32007-07-19 01:14:50 +00001646 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001649 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650}
1651
1652multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1653 string OpcodeStr, Intrinsic IntId> {
Evan Chengb783fa32007-07-19 01:14:50 +00001654 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001657 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001660 (bitconvert (memopv2i64 addr:$src2))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001661 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001662 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001663 [(set VR128:$dst, (IntId VR128:$src1,
1664 (scalar_to_vector (i32 imm:$src2))))]>;
1665}
1666
1667
1668/// PDI_binop_rm - Simple SSE2 binary operator.
1669multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1670 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001671 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001672 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001673 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1674 let isCommutable = Commutable;
1675 }
Evan Chengb783fa32007-07-19 01:14:50 +00001676 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001679 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001680}
1681
1682/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1683///
1684/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1685/// to collapse (bitconvert VT to VT) into its operand.
1686///
1687multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1688 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001689 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001691 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1692 let isCommutable = Commutable;
1693 }
Evan Chengb783fa32007-07-19 01:14:50 +00001694 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001696 [(set VR128:$dst, (OpNode VR128:$src1,(memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697}
1698
1699} // isTwoAddress
1700
1701// 128-bit Integer Arithmetic
1702
1703defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1704defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1705defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1706defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1707
1708defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1709defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1710defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1711defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1712
1713defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1714defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1715defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1716defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1717
1718defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1719defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1720defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1721defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1722
1723defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1724
1725defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1726defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1727defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1728
1729defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1730
1731defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1732defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1733
1734
1735defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1736defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1737defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1738defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1739defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>;
1740
1741
1742defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", int_x86_sse2_psll_w>;
1743defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", int_x86_sse2_psll_d>;
1744defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", int_x86_sse2_psll_q>;
1745
1746defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", int_x86_sse2_psrl_w>;
1747defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", int_x86_sse2_psrl_d>;
1748defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq", int_x86_sse2_psrl_q>;
1749
1750defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", int_x86_sse2_psra_w>;
1751defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad", int_x86_sse2_psra_d>;
1752// PSRAQ doesn't exist in SSE[1-3].
1753
1754// 128-bit logical shifts.
1755let isTwoAddress = 1 in {
1756 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001757 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001758 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001759 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001760 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 // PSRADQri doesn't exist in SSE[1-3].
1763}
1764
1765let Predicates = [HasSSE2] in {
1766 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1767 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1768 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1769 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1770 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1771 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1772}
1773
1774// Logical
1775defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1776defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1777defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1778
1779let isTwoAddress = 1 in {
1780 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001781 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001782 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1784 VR128:$src2)))]>;
1785
1786 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001787 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001788 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001789 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00001790 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001791}
1792
1793// SSE2 Integer comparison
1794defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1795defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
1796defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
1797defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
1798defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
1799defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
1800
1801// Pack instructions
1802defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
1803defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
1804defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
1805
1806// Shuffle and unpack instructions
1807def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001808 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810 [(set VR128:$dst, (v4i32 (vector_shuffle
1811 VR128:$src1, (undef),
1812 PSHUFD_shuffle_mask:$src2)))]>;
1813def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001814 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001815 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816 [(set VR128:$dst, (v4i32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001817 (bc_v4i32(memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818 (undef),
1819 PSHUFD_shuffle_mask:$src2)))]>;
1820
1821// SSE2 with ImmT == Imm8 and XS prefix.
1822def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001823 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001824 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001825 [(set VR128:$dst, (v8i16 (vector_shuffle
1826 VR128:$src1, (undef),
1827 PSHUFHW_shuffle_mask:$src2)))]>,
1828 XS, Requires<[HasSSE2]>;
1829def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001830 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001833 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001834 (undef),
1835 PSHUFHW_shuffle_mask:$src2)))]>,
1836 XS, Requires<[HasSSE2]>;
1837
1838// SSE2 with ImmT == Imm8 and XD prefix.
1839def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001840 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001842 [(set VR128:$dst, (v8i16 (vector_shuffle
1843 VR128:$src1, (undef),
1844 PSHUFLW_shuffle_mask:$src2)))]>,
1845 XD, Requires<[HasSSE2]>;
1846def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001847 (outs VR128:$dst), (ins i128mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001848 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001849 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001850 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001851 (undef),
1852 PSHUFLW_shuffle_mask:$src2)))]>,
1853 XD, Requires<[HasSSE2]>;
1854
1855
1856let isTwoAddress = 1 in {
1857 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001858 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 [(set VR128:$dst,
1861 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1862 UNPCKL_shuffle_mask)))]>;
1863 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001864 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001865 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866 [(set VR128:$dst,
1867 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001868 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869 UNPCKL_shuffle_mask)))]>;
1870 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001871 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001872 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001873 [(set VR128:$dst,
1874 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1875 UNPCKL_shuffle_mask)))]>;
1876 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001877 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(set VR128:$dst,
1880 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001881 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001882 UNPCKL_shuffle_mask)))]>;
1883 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001884 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886 [(set VR128:$dst,
1887 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1888 UNPCKL_shuffle_mask)))]>;
1889 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001890 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001892 [(set VR128:$dst,
1893 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001894 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 UNPCKL_shuffle_mask)))]>;
1896 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001897 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899 [(set VR128:$dst,
1900 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1901 UNPCKL_shuffle_mask)))]>;
1902 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001903 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905 [(set VR128:$dst,
1906 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001907 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 UNPCKL_shuffle_mask)))]>;
1909
1910 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001911 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(set VR128:$dst,
1914 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1915 UNPCKH_shuffle_mask)))]>;
1916 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001917 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001919 [(set VR128:$dst,
1920 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001921 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922 UNPCKH_shuffle_mask)))]>;
1923 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001924 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(set VR128:$dst,
1927 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1928 UNPCKH_shuffle_mask)))]>;
1929 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001930 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 [(set VR128:$dst,
1933 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001934 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001935 UNPCKH_shuffle_mask)))]>;
1936 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001937 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(set VR128:$dst,
1940 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1941 UNPCKH_shuffle_mask)))]>;
1942 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001943 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(set VR128:$dst,
1946 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001947 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948 UNPCKH_shuffle_mask)))]>;
1949 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001950 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001951 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001952 [(set VR128:$dst,
1953 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1954 UNPCKH_shuffle_mask)))]>;
1955 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001956 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(set VR128:$dst,
1959 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001960 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961 UNPCKH_shuffle_mask)))]>;
1962}
1963
1964// Extract / Insert
1965def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001966 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001967 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
1969 (iPTR imm:$src2)))]>;
1970let isTwoAddress = 1 in {
1971 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001972 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001974 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 [(set VR128:$dst,
1976 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
1977 GR32:$src2, (iPTR imm:$src3))))]>;
1978 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001979 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001981 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001982 [(set VR128:$dst,
1983 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
1984 (i32 (anyext (loadi16 addr:$src2))),
1985 (iPTR imm:$src3))))]>;
1986}
1987
1988// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00001989def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001990 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
1992
1993// Conditional store
Evan Chengb783fa32007-07-19 01:14:50 +00001994def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "maskmovdqu\t{$mask, $src|$src, $mask}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>,
1997 Imp<[EDI],[]>;
1998
1999// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002000def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002003def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002006def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002007 "movnti\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002008 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2009 TB, Requires<[HasSSE2]>;
2010
2011// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002012def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 TB, Requires<[HasSSE2]>;
2015
2016// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +00002017def LFENCE : I<0xAE, MRM5m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002018 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002019def MFENCE : I<0xAE, MRM6m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2021
2022
2023// Alias instructions that map zero vector to pxor / xorp* for sse.
2024// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2025let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002026 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "pcmpeqd\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 [(set VR128:$dst, (v2f64 immAllOnesV))]>;
2029
2030// FR64 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +00002031def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002032 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033 [(set VR128:$dst,
2034 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002035def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002036 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002037 [(set VR128:$dst,
2038 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2039
Evan Chengb783fa32007-07-19 01:14:50 +00002040def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042 [(set VR128:$dst,
2043 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002044def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(set VR128:$dst,
2047 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2048
Evan Chengb783fa32007-07-19 01:14:50 +00002049def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002050 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002051 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2052
Evan Chengb783fa32007-07-19 01:14:50 +00002053def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002054 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2056
2057// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002058def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002059 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002060 [(set VR128:$dst,
2061 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2062 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002063def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(store (i64 (vector_extract (v2i64 VR128:$src),
2066 (iPTR 0))), addr:$dst)]>;
2067
2068// FIXME: may not be able to eliminate this movss with coalescing the src and
2069// dest register classes are different. We really want to write this pattern
2070// like this:
2071// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2072// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +00002073def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002075 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2076 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002077def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079 [(store (f64 (vector_extract (v2f64 VR128:$src),
2080 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002081def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002082 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002083 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2084 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002085def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002086 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002087 [(store (i32 (vector_extract (v4i32 VR128:$src),
2088 (iPTR 0))), addr:$dst)]>;
2089
Evan Chengb783fa32007-07-19 01:14:50 +00002090def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002093def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002094 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002095 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2096
2097
2098// Move to lower bits of a VR128, leaving upper bits alone.
2099// Three operand (but two address) aliases.
2100let isTwoAddress = 1 in {
2101 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002102 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002103 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104
2105 let AddedComplexity = 15 in
2106 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002107 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109 [(set VR128:$dst,
2110 (v2f64 (vector_shuffle VR128:$src1, VR128:$src2,
2111 MOVL_shuffle_mask)))]>;
2112}
2113
2114// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002115def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002116 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2118
2119// Move to lower bits of a VR128 and zeroing upper bits.
2120// Loading from memory automatically zeroing upper bits.
2121let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002122 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002123 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002124 [(set VR128:$dst,
2125 (v2f64 (vector_shuffle immAllZerosV,
2126 (v2f64 (scalar_to_vector
2127 (loadf64 addr:$src))),
2128 MOVL_shuffle_mask)))]>;
2129
2130let AddedComplexity = 15 in
2131// movd / movq to XMM register zero-extends
Evan Chengb783fa32007-07-19 01:14:50 +00002132def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(set VR128:$dst,
2135 (v4i32 (vector_shuffle immAllZerosV,
2136 (v4i32 (scalar_to_vector GR32:$src)),
2137 MOVL_shuffle_mask)))]>;
2138let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002139def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141 [(set VR128:$dst,
2142 (v4i32 (vector_shuffle immAllZerosV,
2143 (v4i32 (scalar_to_vector (loadi32 addr:$src))),
2144 MOVL_shuffle_mask)))]>;
2145
2146// Moving from XMM to XMM but still clear upper 64 bits.
2147let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002148def MOVZQI2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002149 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002150 [(set VR128:$dst, (int_x86_sse2_movl_dq VR128:$src))]>,
2151 XS, Requires<[HasSSE2]>;
2152let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002153def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155 [(set VR128:$dst, (int_x86_sse2_movl_dq
Dan Gohman4a4f1512007-07-18 20:23:34 +00002156 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002157 XS, Requires<[HasSSE2]>;
2158
2159
2160//===----------------------------------------------------------------------===//
2161// SSE3 Instructions
2162//===----------------------------------------------------------------------===//
2163
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002165def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 [(set VR128:$dst, (v4f32 (vector_shuffle
2168 VR128:$src, (undef),
2169 MOVSHDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002170def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002173 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 MOVSHDUP_shuffle_mask)))]>;
2175
Evan Chengb783fa32007-07-19 01:14:50 +00002176def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002177 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002178 [(set VR128:$dst, (v4f32 (vector_shuffle
2179 VR128:$src, (undef),
2180 MOVSLDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002181def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002182 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002183 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002184 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002185 MOVSLDUP_shuffle_mask)))]>;
2186
Evan Chengb783fa32007-07-19 01:14:50 +00002187def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002188 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002189 [(set VR128:$dst, (v2f64 (vector_shuffle
2190 VR128:$src, (undef),
2191 SSE_splat_lo_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002192def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194 [(set VR128:$dst,
2195 (v2f64 (vector_shuffle
2196 (scalar_to_vector (loadf64 addr:$src)),
2197 (undef),
2198 SSE_splat_lo_mask)))]>;
2199
2200// Arithmetic
2201let isTwoAddress = 1 in {
2202 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002203 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2206 VR128:$src2))]>;
2207 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002208 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2211 (load addr:$src2)))]>;
2212 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002213 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002214 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002215 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2216 VR128:$src2))]>;
2217 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002218 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002219 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002220 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2221 (load addr:$src2)))]>;
2222}
2223
Evan Chengb783fa32007-07-19 01:14:50 +00002224def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2227
2228// Horizontal ops
2229class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002230 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002231 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002232 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2233class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002234 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002235 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (load addr:$src2))))]>;
2237class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002238 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002239 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002240 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2241class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002242 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002243 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (load addr:$src2))))]>;
2245
2246let isTwoAddress = 1 in {
2247 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2248 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2249 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2250 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2251 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2252 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2253 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2254 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2255}
2256
2257// Thread synchronization
Evan Chengb783fa32007-07-19 01:14:50 +00002258def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002260def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2262
2263// vector_shuffle v1, <undef> <1, 1, 3, 3>
2264let AddedComplexity = 15 in
2265def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2266 MOVSHDUP_shuffle_mask)),
2267 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2268let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002269def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002270 MOVSHDUP_shuffle_mask)),
2271 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2272
2273// vector_shuffle v1, <undef> <0, 0, 2, 2>
2274let AddedComplexity = 15 in
2275 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2276 MOVSLDUP_shuffle_mask)),
2277 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2278let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002279 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280 MOVSLDUP_shuffle_mask)),
2281 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2282
2283//===----------------------------------------------------------------------===//
2284// SSSE3 Instructions
2285//===----------------------------------------------------------------------===//
2286
2287// SSE3 Instruction Templates:
2288//
Bill Wendling98680292007-08-10 06:22:27 +00002289// SS38I - SSSE3 instructions with T8 prefix.
2290// SS3AI - SSSE3 instructions with TA prefix.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291
Evan Chengb783fa32007-07-19 01:14:50 +00002292class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
2293 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002294 : I<o, F, outs, ins, asm, pattern>, T8, Requires<[HasSSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002295class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
2296 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002297 : I<o, F, outs, ins, asm, pattern>, TA, Requires<[HasSSSE3]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002298
Bill Wendling98680292007-08-10 06:22:27 +00002299/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300let isTwoAddress = 1 in {
Bill Wendling98680292007-08-10 06:22:27 +00002301 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2302 Intrinsic IntId64, Intrinsic IntId128,
2303 bit Commutable = 0> {
2304 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2305 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2306 [(set VR64:$dst, (IntId64 VR64:$src))]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002307 let isCommutable = Commutable;
2308 }
Bill Wendling98680292007-08-10 06:22:27 +00002309 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2310 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2311 [(set VR64:$dst,
2312 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2313
2314 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2315 (ins VR128:$src),
2316 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2317 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2318 OpSize {
2319 let isCommutable = Commutable;
2320 }
2321 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2322 (ins i128mem:$src),
2323 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2324 [(set VR128:$dst,
2325 (IntId128
2326 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327 }
2328}
2329
Bill Wendling98680292007-08-10 06:22:27 +00002330/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2331let isTwoAddress = 1 in {
2332 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2333 Intrinsic IntId64, Intrinsic IntId128,
2334 bit Commutable = 0> {
2335 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2336 (ins VR64:$src),
2337 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2338 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2339 let isCommutable = Commutable;
2340 }
2341 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2342 (ins i64mem:$src),
2343 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2344 [(set VR64:$dst,
2345 (IntId64
2346 (bitconvert (memopv4i16 addr:$src))))]>;
2347
2348 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2349 (ins VR128:$src),
2350 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2351 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2352 OpSize {
2353 let isCommutable = Commutable;
2354 }
2355 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2356 (ins i128mem:$src),
2357 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2358 [(set VR128:$dst,
2359 (IntId128
2360 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2361 }
2362}
2363
2364/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2365let isTwoAddress = 1 in {
2366 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2367 Intrinsic IntId64, Intrinsic IntId128,
2368 bit Commutable = 0> {
2369 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2370 (ins VR64:$src),
2371 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2372 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2373 let isCommutable = Commutable;
2374 }
2375 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2376 (ins i64mem:$src),
2377 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2378 [(set VR64:$dst,
2379 (IntId64
2380 (bitconvert (memopv2i32 addr:$src))))]>;
2381
2382 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2383 (ins VR128:$src),
2384 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2385 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2386 OpSize {
2387 let isCommutable = Commutable;
2388 }
2389 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2390 (ins i128mem:$src),
2391 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2392 [(set VR128:$dst,
2393 (IntId128
2394 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2395 }
2396}
2397
2398defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2399 int_x86_ssse3_pabs_b,
2400 int_x86_ssse3_pabs_b_128>;
2401defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2402 int_x86_ssse3_pabs_w,
2403 int_x86_ssse3_pabs_w_128>;
2404defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2405 int_x86_ssse3_pabs_d,
2406 int_x86_ssse3_pabs_d_128>;
2407
2408/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2409let isTwoAddress = 1 in {
2410 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2411 Intrinsic IntId64, Intrinsic IntId128,
2412 bit Commutable = 0> {
2413 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2414 (ins VR64:$src1, VR64:$src2),
2415 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2416 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2417 let isCommutable = Commutable;
2418 }
2419 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2420 (ins VR64:$src1, i64mem:$src2),
2421 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2422 [(set VR64:$dst,
2423 (IntId64 VR64:$src1,
2424 (bitconvert (memopv8i8 addr:$src2))))]>;
2425
2426 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2427 (ins VR128:$src1, VR128:$src2),
2428 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2429 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2430 OpSize {
2431 let isCommutable = Commutable;
2432 }
2433 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2434 (ins VR128:$src1, i128mem:$src2),
2435 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2436 [(set VR128:$dst,
2437 (IntId128 VR128:$src1,
2438 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2439 }
2440}
2441
2442/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2443let isTwoAddress = 1 in {
2444 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2445 Intrinsic IntId64, Intrinsic IntId128,
2446 bit Commutable = 0> {
2447 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2448 (ins VR64:$src1, VR64:$src2),
2449 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2450 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2451 let isCommutable = Commutable;
2452 }
2453 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2454 (ins VR64:$src1, i64mem:$src2),
2455 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2456 [(set VR64:$dst,
2457 (IntId64 VR64:$src1,
2458 (bitconvert (memopv4i16 addr:$src2))))]>;
2459
2460 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2461 (ins VR128:$src1, VR128:$src2),
2462 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2463 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2464 OpSize {
2465 let isCommutable = Commutable;
2466 }
2467 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2468 (ins VR128:$src1, i128mem:$src2),
2469 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2470 [(set VR128:$dst,
2471 (IntId128 VR128:$src1,
2472 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2473 }
2474}
2475
2476/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2477let isTwoAddress = 1 in {
2478 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2479 Intrinsic IntId64, Intrinsic IntId128,
2480 bit Commutable = 0> {
2481 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2482 (ins VR64:$src1, VR64:$src2),
2483 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2484 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2485 let isCommutable = Commutable;
2486 }
2487 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2488 (ins VR64:$src1, i64mem:$src2),
2489 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2490 [(set VR64:$dst,
2491 (IntId64 VR64:$src1,
2492 (bitconvert (memopv2i32 addr:$src2))))]>;
2493
2494 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2495 (ins VR128:$src1, VR128:$src2),
2496 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2497 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2498 OpSize {
2499 let isCommutable = Commutable;
2500 }
2501 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2502 (ins VR128:$src1, i128mem:$src2),
2503 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2504 [(set VR128:$dst,
2505 (IntId128 VR128:$src1,
2506 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2507 }
2508}
2509
2510defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2511 int_x86_ssse3_phadd_w,
2512 int_x86_ssse3_phadd_w_128, 1>;
2513defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2514 int_x86_ssse3_phadd_d,
2515 int_x86_ssse3_phadd_d_128, 1>;
2516defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2517 int_x86_ssse3_phadd_sw,
2518 int_x86_ssse3_phadd_sw_128, 1>;
2519defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2520 int_x86_ssse3_phsub_w,
2521 int_x86_ssse3_phsub_w_128>;
2522defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2523 int_x86_ssse3_phsub_d,
2524 int_x86_ssse3_phsub_d_128>;
2525defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2526 int_x86_ssse3_phsub_sw,
2527 int_x86_ssse3_phsub_sw_128>;
2528defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2529 int_x86_ssse3_pmadd_ub_sw,
2530 int_x86_ssse3_pmadd_ub_sw_128, 1>;
2531defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2532 int_x86_ssse3_pmul_hr_sw,
2533 int_x86_ssse3_pmul_hr_sw_128, 1>;
2534defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2535 int_x86_ssse3_pshuf_b,
2536 int_x86_ssse3_pshuf_b_128>;
2537defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2538 int_x86_ssse3_psign_b,
2539 int_x86_ssse3_psign_b_128>;
2540defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2541 int_x86_ssse3_psign_w,
2542 int_x86_ssse3_psign_w_128>;
2543defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2544 int_x86_ssse3_psign_d,
2545 int_x86_ssse3_psign_d_128>;
2546
2547let isTwoAddress = 1 in {
2548 def PALIGN64rr : SS38I<0x0F, MRMSrcReg, (outs VR64:$dst),
2549 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
2550 "palignr\t{$src2, $dst|$dst, $src2}",
2551 [(set VR64:$dst,
2552 (int_x86_ssse3_palign_r
2553 VR64:$src1, VR64:$src2,
2554 imm:$src3))]>;
2555 def PALIGN64rm : SS38I<0x0F, MRMSrcReg, (outs VR64:$dst),
2556 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
2557 "palignr\t{$src2, $dst|$dst, $src2}",
2558 [(set VR64:$dst,
2559 (int_x86_ssse3_palign_r
2560 VR64:$src1,
2561 (bitconvert (memopv2i32 addr:$src2)),
2562 imm:$src3))]>;
2563
2564 def PALIGN128rr : SS38I<0x0F, MRMSrcReg, (outs VR128:$dst),
2565 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
2566 "palignr\t{$src2, $dst|$dst, $src2}",
2567 [(set VR128:$dst,
2568 (int_x86_ssse3_palign_r_128
2569 VR128:$src1, VR128:$src2,
2570 imm:$src3))]>, OpSize;
2571 def PALIGN128rm : SS38I<0x0F, MRMSrcReg, (outs VR128:$dst),
2572 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
2573 "palignr\t{$src2, $dst|$dst, $src2}",
2574 [(set VR128:$dst,
2575 (int_x86_ssse3_palign_r_128
2576 VR128:$src1,
2577 (bitconvert (memopv4i32 addr:$src2)),
2578 imm:$src3))]>, OpSize;
2579}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002580
2581//===----------------------------------------------------------------------===//
2582// Non-Instruction Patterns
2583//===----------------------------------------------------------------------===//
2584
2585// 128-bit vector undef's.
2586def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2587def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2588def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2589def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2590def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2591
2592// 128-bit vector all zero's.
2593def : Pat<(v16i8 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2594def : Pat<(v8i16 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2595def : Pat<(v4i32 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2596def : Pat<(v2i64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2597def : Pat<(v2f64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2598
2599// 128-bit vector all one's.
2600def : Pat<(v16i8 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2601def : Pat<(v8i16 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2602def : Pat<(v4i32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2603def : Pat<(v2i64 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2604def : Pat<(v4f32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE1]>;
2605
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002606
2607// Scalar to v8i16 / v16i8. The source may be a GR32, but only the lower 8 or
2608// 16-bits matter.
2609def : Pat<(v8i16 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2610 Requires<[HasSSE2]>;
2611def : Pat<(v16i8 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2612 Requires<[HasSSE2]>;
2613
2614// bit_convert
2615let Predicates = [HasSSE2] in {
2616 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2617 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2618 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2619 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2620 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2621 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2622 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2623 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2624 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2625 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2626 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2627 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2628 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2629 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2630 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2631 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2632 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2633 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2634 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2635 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2636 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2637 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2638 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2639 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2640 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2641 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2642 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2643 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2644 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2645 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2646}
2647
2648// Move scalar to XMM zero-extended
2649// movd to XMM register zero-extends
2650let AddedComplexity = 15 in {
2651def : Pat<(v8i16 (vector_shuffle immAllZerosV,
2652 (v8i16 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2653 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2654def : Pat<(v16i8 (vector_shuffle immAllZerosV,
2655 (v16i8 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2656 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2657// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
2658def : Pat<(v2f64 (vector_shuffle immAllZerosV,
2659 (v2f64 (scalar_to_vector FR64:$src)), MOVL_shuffle_mask)),
2660 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
2661def : Pat<(v4f32 (vector_shuffle immAllZerosV,
2662 (v4f32 (scalar_to_vector FR32:$src)), MOVL_shuffle_mask)),
2663 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>;
2664}
2665
2666// Splat v2f64 / v2i64
2667let AddedComplexity = 10 in {
2668def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2669 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2670def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2671 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2672def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2673 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2674def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2675 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2676}
2677
2678// Splat v4f32
2679def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SSE_splat_mask:$sm),
2680 (SHUFPSrri VR128:$src, VR128:$src, SSE_splat_mask:$sm)>,
2681 Requires<[HasSSE1]>;
2682
2683// Special unary SHUFPSrri case.
2684// FIXME: when we want non two-address code, then we should use PSHUFD?
2685def : Pat<(vector_shuffle (v4f32 VR128:$src1), (undef),
2686 SHUFP_unary_shuffle_mask:$sm),
2687 (SHUFPSrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2688 Requires<[HasSSE1]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002689// Special unary SHUFPDrri case.
2690def : Pat<(vector_shuffle (v2f64 VR128:$src1), (undef),
2691 SHUFP_unary_shuffle_mask:$sm),
2692 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2693 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002694// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Dan Gohman4a4f1512007-07-18 20:23:34 +00002695def : Pat<(vector_shuffle (memopv4f32 addr:$src1), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002696 SHUFP_unary_shuffle_mask:$sm),
2697 (PSHUFDmi addr:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2698 Requires<[HasSSE2]>;
2699// Special binary v4i32 shuffle cases with SHUFPS.
2700def : Pat<(vector_shuffle (v4i32 VR128:$src1), (v4i32 VR128:$src2),
2701 PSHUFD_binary_shuffle_mask:$sm),
2702 (SHUFPSrri VR128:$src1, VR128:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2703 Requires<[HasSSE2]>;
2704def : Pat<(vector_shuffle (v4i32 VR128:$src1),
Dan Gohman4a4f1512007-07-18 20:23:34 +00002705 (bc_v4i32 (memopv2i64 addr:$src2)), PSHUFD_binary_shuffle_mask:$sm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002706 (SHUFPSrmi VR128:$src1, addr:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2707 Requires<[HasSSE2]>;
2708
2709// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2710let AddedComplexity = 10 in {
2711def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2712 UNPCKL_v_undef_shuffle_mask)),
2713 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2714def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2715 UNPCKL_v_undef_shuffle_mask)),
2716 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2717def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2718 UNPCKL_v_undef_shuffle_mask)),
2719 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2720def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2721 UNPCKL_v_undef_shuffle_mask)),
2722 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2723}
2724
2725// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2726let AddedComplexity = 10 in {
2727def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2728 UNPCKH_v_undef_shuffle_mask)),
2729 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2730def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2731 UNPCKH_v_undef_shuffle_mask)),
2732 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2733def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2734 UNPCKH_v_undef_shuffle_mask)),
2735 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2736def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2737 UNPCKH_v_undef_shuffle_mask)),
2738 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2739}
2740
2741let AddedComplexity = 15 in {
2742// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2743def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2744 MOVHP_shuffle_mask)),
2745 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2746
2747// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2748def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2749 MOVHLPS_shuffle_mask)),
2750 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2751
2752// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2753def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2754 MOVHLPS_v_undef_shuffle_mask)),
2755 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2756def : Pat<(v4i32 (vector_shuffle VR128:$src1, (undef),
2757 MOVHLPS_v_undef_shuffle_mask)),
2758 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2759}
2760
2761let AddedComplexity = 20 in {
2762// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2763// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Dan Gohman4a4f1512007-07-18 20:23:34 +00002764def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002765 MOVLP_shuffle_mask)),
2766 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002767def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002768 MOVLP_shuffle_mask)),
2769 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002770def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002771 MOVHP_shuffle_mask)),
2772 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002773def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002774 MOVHP_shuffle_mask)),
2775 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2776
Dan Gohman4a4f1512007-07-18 20:23:34 +00002777def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002778 MOVLP_shuffle_mask)),
2779 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002780def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002781 MOVLP_shuffle_mask)),
2782 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002783def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002784 MOVHP_shuffle_mask)),
2785 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002786def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002787 MOVLP_shuffle_mask)),
2788 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2789}
2790
2791let AddedComplexity = 15 in {
2792// Setting the lowest element in the vector.
2793def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2794 MOVL_shuffle_mask)),
2795 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2796def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2797 MOVL_shuffle_mask)),
2798 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2799
2800// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
2801def : Pat<(v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
2802 MOVLP_shuffle_mask)),
2803 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2804def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2805 MOVLP_shuffle_mask)),
2806 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2807}
2808
2809// Set lowest element and zero upper elements.
2810let AddedComplexity = 20 in
2811def : Pat<(bc_v2i64 (vector_shuffle immAllZerosV,
2812 (v2f64 (scalar_to_vector (loadf64 addr:$src))),
2813 MOVL_shuffle_mask)),
2814 (MOVZQI2PQIrm addr:$src)>, Requires<[HasSSE2]>;
2815
2816// FIXME: Temporary workaround since 2-wide shuffle is broken.
2817def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
2818 (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2819def : Pat<(int_x86_sse2_loadh_pd VR128:$src1, addr:$src2),
2820 (v2f64 (MOVHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2821def : Pat<(int_x86_sse2_loadl_pd VR128:$src1, addr:$src2),
2822 (v2f64 (MOVLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2823def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
2824 (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
2825 Requires<[HasSSE2]>;
2826def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (load addr:$src2), imm:$src3),
2827 (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
2828 Requires<[HasSSE2]>;
2829def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
2830 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2831def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (load addr:$src2)),
2832 (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2833def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
2834 (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2835def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (load addr:$src2)),
2836 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2837def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2),
2838 (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2839def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (load addr:$src2)),
2840 (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2841def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2),
2842 (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2843def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (load addr:$src2)),
2844 (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2845
2846// Some special case pandn patterns.
2847def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2848 VR128:$src2)),
2849 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2850def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
2851 VR128:$src2)),
2852 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2853def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
2854 VR128:$src2)),
2855 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2856
2857def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002858 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002859 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2860def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002861 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002862 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2863def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002864 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002865 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2866
Evan Cheng51a49b22007-07-20 00:27:43 +00002867// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00002868def : Pat<(alignedloadv4i32 addr:$src),
2869 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
2870def : Pat<(loadv4i32 addr:$src),
2871 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00002872def : Pat<(alignedloadv2i64 addr:$src),
2873 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
2874def : Pat<(loadv2i64 addr:$src),
2875 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
2876
2877def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
2878 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2879def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
2880 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2881def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
2882 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2883def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
2884 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2885def : Pat<(store (v2i64 VR128:$src), addr:$dst),
2886 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2887def : Pat<(store (v4i32 VR128:$src), addr:$dst),
2888 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2889def : Pat<(store (v8i16 VR128:$src), addr:$dst),
2890 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2891def : Pat<(store (v16i8 VR128:$src), addr:$dst),
2892 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Evan Cheng86ab7d32007-07-31 08:04:03 +00002893
2894// (vextract (v4i32 bc (v4f32 s2v (f32 load $addr))), 0) -> (i32 load $addr)
2895def : Pat<(vector_extract
2896 (bc_v4i32 (v4f32 (scalar_to_vector (loadf32 addr:$src)))), (iPTR 0)),
Evan Cheng43a09ac2007-08-01 21:42:24 +00002897 (MOV32rm addr:$src)>, Requires<[HasSSE2]>;
Evan Cheng86ab7d32007-07-31 08:04:03 +00002898def : Pat<(vector_extract
2899 (bc_v2i64 (v2f64 (scalar_to_vector (loadf64 addr:$src)))), (iPTR 0)),
Evan Cheng43a09ac2007-08-01 21:42:24 +00002900 (MOV64rm addr:$src)>, Requires<[HasSSE2, In64BitMode]>;