blob: 0c42caaf7a397838fad4ad3ba2cd7278027cdbdc [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))>;
131def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
132def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
133
Bill Wendling3b15d722007-08-11 09:52:53 +0000134// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
135// 16-byte boundary.
136def memop64 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
137 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
138 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
139 LD->getAddressingMode() == ISD::UNINDEXED &&
140 LD->getAlignment() >= 8;
141 return false;
142}]>;
143
144def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
145def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop64 node:$ptr))>;
146def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
147def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
148def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
149
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000150def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
151def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
152def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
153def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
154def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
155def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
156
157def fp32imm0 : PatLeaf<(f32 fpimm), [{
158 return N->isExactlyValue(+0.0);
159}]>;
160
161def PSxLDQ_imm : SDNodeXForm<imm, [{
162 // Transformation function: imm >> 3
163 return getI32Imm(N->getValue() >> 3);
164}]>;
165
166// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
167// SHUFP* etc. imm.
168def SHUFFLE_get_shuf_imm : SDNodeXForm<build_vector, [{
169 return getI8Imm(X86::getShuffleSHUFImmediate(N));
170}]>;
171
172// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
173// PSHUFHW imm.
174def SHUFFLE_get_pshufhw_imm : SDNodeXForm<build_vector, [{
175 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
176}]>;
177
178// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
179// PSHUFLW imm.
180def SHUFFLE_get_pshuflw_imm : SDNodeXForm<build_vector, [{
181 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
182}]>;
183
184def SSE_splat_mask : PatLeaf<(build_vector), [{
185 return X86::isSplatMask(N);
186}], SHUFFLE_get_shuf_imm>;
187
188def SSE_splat_lo_mask : PatLeaf<(build_vector), [{
189 return X86::isSplatLoMask(N);
190}]>;
191
192def MOVHLPS_shuffle_mask : PatLeaf<(build_vector), [{
193 return X86::isMOVHLPSMask(N);
194}]>;
195
196def MOVHLPS_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
197 return X86::isMOVHLPS_v_undef_Mask(N);
198}]>;
199
200def MOVHP_shuffle_mask : PatLeaf<(build_vector), [{
201 return X86::isMOVHPMask(N);
202}]>;
203
204def MOVLP_shuffle_mask : PatLeaf<(build_vector), [{
205 return X86::isMOVLPMask(N);
206}]>;
207
208def MOVL_shuffle_mask : PatLeaf<(build_vector), [{
209 return X86::isMOVLMask(N);
210}]>;
211
212def MOVSHDUP_shuffle_mask : PatLeaf<(build_vector), [{
213 return X86::isMOVSHDUPMask(N);
214}]>;
215
216def MOVSLDUP_shuffle_mask : PatLeaf<(build_vector), [{
217 return X86::isMOVSLDUPMask(N);
218}]>;
219
220def UNPCKL_shuffle_mask : PatLeaf<(build_vector), [{
221 return X86::isUNPCKLMask(N);
222}]>;
223
224def UNPCKH_shuffle_mask : PatLeaf<(build_vector), [{
225 return X86::isUNPCKHMask(N);
226}]>;
227
228def UNPCKL_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
229 return X86::isUNPCKL_v_undef_Mask(N);
230}]>;
231
232def UNPCKH_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
233 return X86::isUNPCKH_v_undef_Mask(N);
234}]>;
235
236def PSHUFD_shuffle_mask : PatLeaf<(build_vector), [{
237 return X86::isPSHUFDMask(N);
238}], SHUFFLE_get_shuf_imm>;
239
240def PSHUFHW_shuffle_mask : PatLeaf<(build_vector), [{
241 return X86::isPSHUFHWMask(N);
242}], SHUFFLE_get_pshufhw_imm>;
243
244def PSHUFLW_shuffle_mask : PatLeaf<(build_vector), [{
245 return X86::isPSHUFLWMask(N);
246}], SHUFFLE_get_pshuflw_imm>;
247
248def SHUFP_unary_shuffle_mask : PatLeaf<(build_vector), [{
249 return X86::isPSHUFDMask(N);
250}], SHUFFLE_get_shuf_imm>;
251
252def SHUFP_shuffle_mask : PatLeaf<(build_vector), [{
253 return X86::isSHUFPMask(N);
254}], SHUFFLE_get_shuf_imm>;
255
256def PSHUFD_binary_shuffle_mask : PatLeaf<(build_vector), [{
257 return X86::isSHUFPMask(N);
258}], SHUFFLE_get_shuf_imm>;
259
260//===----------------------------------------------------------------------===//
261// SSE scalar FP Instructions
262//===----------------------------------------------------------------------===//
263
264// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
265// scheduler into a branch sequence.
266let usesCustomDAGSchedInserter = 1 in { // Expanded by the scheduler.
267 def CMOV_FR32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000268 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269 "#CMOV_FR32 PSEUDO!",
270 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond))]>;
271 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000272 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273 "#CMOV_FR64 PSEUDO!",
274 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond))]>;
275 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000276 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000277 "#CMOV_V4F32 PSEUDO!",
278 [(set VR128:$dst,
279 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond)))]>;
280 def CMOV_V2F64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000281 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282 "#CMOV_V2F64 PSEUDO!",
283 [(set VR128:$dst,
284 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond)))]>;
285 def CMOV_V2I64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000286 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287 "#CMOV_V2I64 PSEUDO!",
288 [(set VR128:$dst,
289 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond)))]>;
290}
291
292//===----------------------------------------------------------------------===//
293// SSE1 Instructions
294//===----------------------------------------------------------------------===//
295
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000296// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000297def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000298 "movss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanca9f99d2007-08-02 14:27:55 +0000299let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000300def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000301 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000303def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000304 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305 [(store FR32:$src, addr:$dst)]>;
306
307// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000308def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000309 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000311def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000312 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000314def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000315 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000317def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000318 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
320
321// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000322def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000323 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000324 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000325def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000326 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327 [(set GR32:$dst, (int_x86_sse_cvtss2si
328 (load addr:$src)))]>;
329
330// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000331def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000332 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 [(set GR32:$dst,
334 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000335def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000336 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337 [(set GR32:$dst,
338 (int_x86_sse_cvttss2si(load addr:$src)))]>;
339
340let isTwoAddress = 1 in {
341 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000342 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000343 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
345 GR32:$src2))]>;
346 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000347 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000348 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
350 (loadi32 addr:$src2)))]>;
351}
352
353// Comparison instructions
354let isTwoAddress = 1 in {
355 def CMPSSrr : SSI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000356 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000357 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000358 def CMPSSrm : SSI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000359 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000360 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361}
362
Evan Chengb783fa32007-07-19 01:14:50 +0000363def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000364 "ucomiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365 [(X86cmp FR32:$src1, FR32:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000366def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000367 "ucomiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000368 [(X86cmp FR32:$src1, (loadf32 addr:$src2))]>;
369
370// Aliases to match intrinsics which expect XMM operand(s).
371let isTwoAddress = 1 in {
372 def Int_CMPSSrr : SSI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000373 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000374 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000375 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
376 VR128:$src, imm:$cc))]>;
377 def Int_CMPSSrm : SSI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000378 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000379 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
381 (load addr:$src), imm:$cc))]>;
382}
383
Evan Chengb783fa32007-07-19 01:14:50 +0000384def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000385 "ucomiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000386 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000387def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000388 "ucomiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000389 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2))]>;
390
Evan Chengb783fa32007-07-19 01:14:50 +0000391def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000392 "comiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393 [(X86comi (v4f32 VR128:$src1), VR128:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000394def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000395 "comiss\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000396 [(X86comi (v4f32 VR128:$src1), (load addr:$src2))]>;
397
398// Aliases of packed SSE1 instructions for scalar use. These all have names that
399// start with 'Fs'.
400
401// Alias instructions that map fld0 to pxor for sse.
Evan Chengb783fa32007-07-19 01:14:50 +0000402def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000403 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000404 Requires<[HasSSE1]>, TB, OpSize;
405
406// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
407// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +0000408def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000409 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410
411// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
412// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +0000413def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000414 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000415 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416
417// Alias bitwise logical operations using SSE logical ops on packed FP values.
418let isTwoAddress = 1 in {
419let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000420 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$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, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000423 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000424 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000425 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000426 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000427 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000428 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
429}
430
Evan Chengb783fa32007-07-19 01:14:50 +0000431def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000432 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000433 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000434 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000435def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000436 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000437 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000438 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000439def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000440 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000442 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443
444def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000445 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000446 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000447def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000448 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000449 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000450}
451
452/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
453///
454/// In addition, we also have a special variant of the scalar form here to
455/// represent the associated intrinsic operation. This form is unlike the
456/// plain scalar form, in that it takes an entire vector (instead of a scalar)
457/// and leaves the top elements undefined.
458///
459/// These three forms can each be reg+reg or reg+mem, so there are a total of
460/// six "instructions".
461///
462let isTwoAddress = 1 in {
463multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
464 SDNode OpNode, Intrinsic F32Int,
465 bit Commutable = 0> {
466 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000467 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000468 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000469 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
470 let isCommutable = Commutable;
471 }
472
473 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000474 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000475 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
477
478 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000479 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000480 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
482 let isCommutable = Commutable;
483 }
484
485 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000486 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000487 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000488 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489
490 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000491 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000492 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
494 let isCommutable = Commutable;
495 }
496
497 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000498 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000499 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500 [(set VR128:$dst, (F32Int VR128:$src1,
501 sse_load_f32:$src2))]>;
502}
503}
504
505// Arithmetic instructions
506defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
507defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
508defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
509defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
510
511/// sse1_fp_binop_rm - Other SSE1 binops
512///
513/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
514/// instructions for a full-vector intrinsic form. Operations that map
515/// onto C operators don't use this form since they just use the plain
516/// vector form instead of having a separate vector intrinsic form.
517///
518/// This provides a total of eight "instructions".
519///
520let isTwoAddress = 1 in {
521multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
522 SDNode OpNode,
523 Intrinsic F32Int,
524 Intrinsic V4F32Int,
525 bit Commutable = 0> {
526
527 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000528 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000529 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
531 let isCommutable = Commutable;
532 }
533
534 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000535 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000536 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
538
539 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000540 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000541 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
543 let isCommutable = Commutable;
544 }
545
546 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000547 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000548 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000549 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550
551 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000552 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000553 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000554 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
555 let isCommutable = Commutable;
556 }
557
558 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000559 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000560 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 [(set VR128:$dst, (F32Int VR128:$src1,
562 sse_load_f32:$src2))]>;
563
564 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000565 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000566 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000567 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
568 let isCommutable = Commutable;
569 }
570
571 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +0000572 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000573 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000574 [(set VR128:$dst, (V4F32Int VR128:$src1, (load addr:$src2)))]>;
575}
576}
577
578defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
579 int_x86_sse_max_ss, int_x86_sse_max_ps>;
580defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
581 int_x86_sse_min_ss, int_x86_sse_min_ps>;
582
583//===----------------------------------------------------------------------===//
584// SSE packed FP Instructions
585
586// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000587def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000588 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanca9f99d2007-08-02 14:27:55 +0000589let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000590def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000591 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000592 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000593
Evan Chengb783fa32007-07-19 01:14:50 +0000594def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000595 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000596 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597
Evan Chengb783fa32007-07-19 01:14:50 +0000598def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000599 "movups\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000600def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000601 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000602 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000603def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000604 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000605 [(store (v4f32 VR128:$src), addr:$dst)]>;
606
607// Intrinsic forms of MOVUPS load and store
Evan Chengb783fa32007-07-19 01:14:50 +0000608def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000609 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000610 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000611def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000612 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000613 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614
615let isTwoAddress = 1 in {
616 let AddedComplexity = 20 in {
617 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000618 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000619 "movlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000620 [(set VR128:$dst,
621 (v4f32 (vector_shuffle VR128:$src1,
622 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
623 MOVLP_shuffle_mask)))]>;
624 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000625 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000626 "movhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 [(set VR128:$dst,
628 (v4f32 (vector_shuffle VR128:$src1,
629 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
630 MOVHP_shuffle_mask)))]>;
631 } // AddedComplexity
632} // isTwoAddress
633
Evan Chengb783fa32007-07-19 01:14:50 +0000634def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000635 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000636 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
637 (iPTR 0))), addr:$dst)]>;
638
639// v2f64 extract element 1 is always custom lowered to unpack high to low
640// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000641def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000642 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000643 [(store (f64 (vector_extract
644 (v2f64 (vector_shuffle
645 (bc_v2f64 (v4f32 VR128:$src)), (undef),
646 UNPCKH_shuffle_mask)), (iPTR 0))),
647 addr:$dst)]>;
648
649let isTwoAddress = 1 in {
650let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000651def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000652 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653 [(set VR128:$dst,
654 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
655 MOVHP_shuffle_mask)))]>;
656
Evan Chengb783fa32007-07-19 01:14:50 +0000657def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000658 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 [(set VR128:$dst,
660 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
661 MOVHLPS_shuffle_mask)))]>;
662} // AddedComplexity
663} // isTwoAddress
664
665
666
667// Arithmetic
668
669/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
670///
671/// In addition, we also have a special variant of the scalar form here to
672/// represent the associated intrinsic operation. This form is unlike the
673/// plain scalar form, in that it takes an entire vector (instead of a
674/// scalar) and leaves the top elements undefined.
675///
676/// And, we have a special variant form for a full-vector intrinsic form.
677///
678/// These four forms can each have a reg or a mem operand, so there are a
679/// total of eight "instructions".
680///
681multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
682 SDNode OpNode,
683 Intrinsic F32Int,
684 Intrinsic V4F32Int,
685 bit Commutable = 0> {
686 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000687 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000688 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689 [(set FR32:$dst, (OpNode FR32:$src))]> {
690 let isCommutable = Commutable;
691 }
692
693 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000694 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000695 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
697
698 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000699 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000700 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000701 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
702 let isCommutable = Commutable;
703 }
704
705 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000706 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000707 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000708 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709
710 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000711 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000712 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713 [(set VR128:$dst, (F32Int VR128:$src))]> {
714 let isCommutable = Commutable;
715 }
716
717 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000718 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000719 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
721
722 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000723 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000724 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
726 let isCommutable = Commutable;
727 }
728
729 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000730 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000731 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000732 [(set VR128:$dst, (V4F32Int (load addr:$src)))]>;
733}
734
735// Square root.
736defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
737 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
738
739// Reciprocal approximations. Note that these typically require refinement
740// in order to obtain suitable precision.
741defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
742 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
743defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
744 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
745
746// Logical
747let isTwoAddress = 1 in {
748 let isCommutable = 1 in {
749 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000750 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 [(set VR128:$dst, (v2i64
753 (and VR128:$src1, VR128:$src2)))]>;
754 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000755 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000756 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757 [(set VR128:$dst, (v2i64
758 (or VR128:$src1, VR128:$src2)))]>;
759 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000760 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762 [(set VR128:$dst, (v2i64
763 (xor VR128:$src1, VR128:$src2)))]>;
764 }
765
766 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000767 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000768 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000769 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
770 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000772 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000773 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000774 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
775 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000777 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000778 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000779 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
780 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000781 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000782 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000783 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784 [(set VR128:$dst,
785 (v2i64 (and (xor VR128:$src1,
786 (bc_v2i64 (v4i32 immAllOnesV))),
787 VR128:$src2)))]>;
788 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000789 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000790 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000792 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000793 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000794 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795}
796
797let isTwoAddress = 1 in {
798 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000799 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000800 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
802 VR128:$src, imm:$cc))]>;
803 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000804 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000805 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
807 (load addr:$src), imm:$cc))]>;
808}
809
810// Shuffle and unpack instructions
811let isTwoAddress = 1 in {
812 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
813 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000814 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815 VR128:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000816 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 [(set VR128:$dst,
818 (v4f32 (vector_shuffle
819 VR128:$src1, VR128:$src2,
820 SHUFP_shuffle_mask:$src3)))]>;
821 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000822 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 f128mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000824 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825 [(set VR128:$dst,
826 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000827 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 SHUFP_shuffle_mask:$src3)))]>;
829
830 let AddedComplexity = 10 in {
831 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000832 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000833 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 [(set VR128:$dst,
835 (v4f32 (vector_shuffle
836 VR128:$src1, VR128:$src2,
837 UNPCKH_shuffle_mask)))]>;
838 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000839 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000840 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 [(set VR128:$dst,
842 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000843 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844 UNPCKH_shuffle_mask)))]>;
845
846 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000847 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000848 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849 [(set VR128:$dst,
850 (v4f32 (vector_shuffle
851 VR128:$src1, VR128:$src2,
852 UNPCKL_shuffle_mask)))]>;
853 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000854 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000855 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 [(set VR128:$dst,
857 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000858 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859 UNPCKL_shuffle_mask)))]>;
860 } // AddedComplexity
861} // isTwoAddress
862
863// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000864def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000865 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000867def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000868 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
870
871// Prefetching loads.
872// TODO: no intrinsics for these?
Dan Gohman91888f02007-07-31 20:11:57 +0000873def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), "prefetcht0\t$src", []>;
874def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src), "prefetcht1\t$src", []>;
875def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src), "prefetcht2\t$src", []>;
876def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src), "prefetchnta\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877
878// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000879def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000880 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
882
883// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +0000884def SFENCE : PSI<0xAE, MRM7m, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885
886// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000887def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000888 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000889def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000890 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891
892// Alias instructions that map zero vector to pxor / xorp* for sse.
893// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
894let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000895def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000896 "xorps\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 [(set VR128:$dst, (v4f32 immAllZerosV))]>;
898
899// FR32 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +0000900def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000901 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 [(set VR128:$dst,
903 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000904def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000905 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 [(set VR128:$dst,
907 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
908
909// FIXME: may not be able to eliminate this movss with coalescing the src and
910// dest register classes are different. We really want to write this pattern
911// like this:
912// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
913// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +0000914def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000915 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
917 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000918def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000919 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 [(store (f32 (vector_extract (v4f32 VR128:$src),
921 (iPTR 0))), addr:$dst)]>;
922
923
924// Move to lower bits of a VR128, leaving upper bits alone.
925// Three operand (but two address) aliases.
926let isTwoAddress = 1 in {
927 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000928 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000929 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930
931 let AddedComplexity = 15 in
932 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000933 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000934 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935 [(set VR128:$dst,
936 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
937 MOVL_shuffle_mask)))]>;
938}
939
940// Move to lower bits of a VR128 and zeroing upper bits.
941// Loading from memory automatically zeroing upper bits.
942let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +0000943def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000944 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 [(set VR128:$dst, (v4f32 (vector_shuffle immAllZerosV,
946 (v4f32 (scalar_to_vector (loadf32 addr:$src))),
947 MOVL_shuffle_mask)))]>;
948
949
950//===----------------------------------------------------------------------===//
951// SSE2 Instructions
952//===----------------------------------------------------------------------===//
953
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000955def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000956 "movsd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanca9f99d2007-08-02 14:27:55 +0000957let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000958def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000959 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000961def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(store FR64:$src, addr:$dst)]>;
964
965// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000966def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000967 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000969def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000970 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000972def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000973 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000975def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000976 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000978def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000979 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000981def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
984
985// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +0000986def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000987 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
989 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000990def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000991 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
993 Requires<[HasSSE2]>;
994
995// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000996def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000997 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000999def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001000 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1002 (load addr:$src)))]>;
1003
1004// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001005def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001006 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007 [(set GR32:$dst,
1008 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001009def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001010 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1012 (load addr:$src)))]>;
1013
1014// Comparison instructions
1015let isTwoAddress = 1 in {
1016 def CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001017 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001018 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019 def CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001020 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001021 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022}
1023
Evan Chengb783fa32007-07-19 01:14:50 +00001024def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001025 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 [(X86cmp FR64:$src1, FR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001027def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 [(X86cmp FR64:$src1, (loadf64 addr:$src2))]>;
1030
1031// Aliases to match intrinsics which expect XMM operand(s).
1032let isTwoAddress = 1 in {
1033 def Int_CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001034 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001035 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1037 VR128:$src, imm:$cc))]>;
1038 def Int_CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001039 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001040 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1042 (load addr:$src), imm:$cc))]>;
1043}
1044
Evan Chengb783fa32007-07-19 01:14:50 +00001045def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001046 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001048def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001049 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2))]>;
1051
Evan Chengb783fa32007-07-19 01:14:50 +00001052def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001053 "comisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001055def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001056 "comisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 [(X86comi (v2f64 VR128:$src1), (load addr:$src2))]>;
1058
1059// Aliases of packed SSE2 instructions for scalar use. These all have names that
1060// start with 'Fs'.
1061
1062// Alias instructions that map fld0 to pxor for sse.
Evan Chengb783fa32007-07-19 01:14:50 +00001063def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001064 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 Requires<[HasSSE2]>, TB, OpSize;
1066
1067// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1068// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +00001069def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001070 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071
1072// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1073// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +00001074def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001075 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001076 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077
1078// Alias bitwise logical operations using SSE logical ops on packed FP values.
1079let isTwoAddress = 1 in {
1080let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001081 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$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, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001084 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001085 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001087 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001088 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1090}
1091
Evan Chengb783fa32007-07-19 01:14:50 +00001092def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001093 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001095 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001096def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001097 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001099 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001100def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001103 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104
1105def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001106 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001109 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001110 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111}
1112
1113/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1114///
1115/// In addition, we also have a special variant of the scalar form here to
1116/// represent the associated intrinsic operation. This form is unlike the
1117/// plain scalar form, in that it takes an entire vector (instead of a scalar)
1118/// and leaves the top elements undefined.
1119///
1120/// These three forms can each be reg+reg or reg+mem, so there are a total of
1121/// six "instructions".
1122///
1123let isTwoAddress = 1 in {
1124multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1125 SDNode OpNode, Intrinsic F64Int,
1126 bit Commutable = 0> {
1127 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001128 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001129 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1131 let isCommutable = Commutable;
1132 }
1133
1134 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001135 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001136 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1138
1139 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001140 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001141 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1143 let isCommutable = Commutable;
1144 }
1145
1146 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001147 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001148 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001149 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150
1151 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001152 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001153 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1155 let isCommutable = Commutable;
1156 }
1157
1158 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001159 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001160 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161 [(set VR128:$dst, (F64Int VR128:$src1,
1162 sse_load_f64:$src2))]>;
1163}
1164}
1165
1166// Arithmetic instructions
1167defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1168defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1169defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1170defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1171
1172/// sse2_fp_binop_rm - Other SSE2 binops
1173///
1174/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1175/// instructions for a full-vector intrinsic form. Operations that map
1176/// onto C operators don't use this form since they just use the plain
1177/// vector form instead of having a separate vector intrinsic form.
1178///
1179/// This provides a total of eight "instructions".
1180///
1181let isTwoAddress = 1 in {
1182multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1183 SDNode OpNode,
1184 Intrinsic F64Int,
1185 Intrinsic V2F64Int,
1186 bit Commutable = 0> {
1187
1188 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001189 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001190 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001191 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1192 let isCommutable = Commutable;
1193 }
1194
1195 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001196 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001197 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1199
1200 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001201 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001202 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001203 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1204 let isCommutable = Commutable;
1205 }
1206
1207 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001208 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001209 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001210 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211
1212 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001213 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001214 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1216 let isCommutable = Commutable;
1217 }
1218
1219 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001220 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001221 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222 [(set VR128:$dst, (F64Int VR128:$src1,
1223 sse_load_f64:$src2))]>;
1224
1225 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001226 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001227 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1229 let isCommutable = Commutable;
1230 }
1231
1232 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +00001233 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001234 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235 [(set VR128:$dst, (V2F64Int VR128:$src1, (load addr:$src2)))]>;
1236}
1237}
1238
1239defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1240 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1241defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1242 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1243
1244//===----------------------------------------------------------------------===//
1245// SSE packed FP Instructions
1246
1247// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001248def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001249 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanca9f99d2007-08-02 14:27:55 +00001250let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001251def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001252 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001253 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254
Evan Chengb783fa32007-07-19 01:14:50 +00001255def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001256 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001257 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258
Evan Chengb783fa32007-07-19 01:14:50 +00001259def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001260 "movupd\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001261def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001263 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001264def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001265 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001266 [(store (v2f64 VR128:$src), addr:$dst)]>;
1267
1268// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001269def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001270 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001271 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001272def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001273 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001274 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275
1276let isTwoAddress = 1 in {
1277 let AddedComplexity = 20 in {
1278 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "movlpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(set VR128:$dst,
1282 (v2f64 (vector_shuffle VR128:$src1,
1283 (scalar_to_vector (loadf64 addr:$src2)),
1284 MOVLP_shuffle_mask)))]>;
1285 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001286 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001287 "movhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288 [(set VR128:$dst,
1289 (v2f64 (vector_shuffle VR128:$src1,
1290 (scalar_to_vector (loadf64 addr:$src2)),
1291 MOVHP_shuffle_mask)))]>;
1292 } // AddedComplexity
1293} // isTwoAddress
1294
Evan Chengb783fa32007-07-19 01:14:50 +00001295def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001296 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297 [(store (f64 (vector_extract (v2f64 VR128:$src),
1298 (iPTR 0))), addr:$dst)]>;
1299
1300// v2f64 extract element 1 is always custom lowered to unpack high to low
1301// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001302def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001303 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304 [(store (f64 (vector_extract
1305 (v2f64 (vector_shuffle VR128:$src, (undef),
1306 UNPCKH_shuffle_mask)), (iPTR 0))),
1307 addr:$dst)]>;
1308
1309// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001310def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001311 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1313 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001314def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001315 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
Dan Gohman4a4f1512007-07-18 20:23:34 +00001317 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318 TB, Requires<[HasSSE2]>;
1319
1320// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001321def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001322 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1324 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001325def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001326 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
Dan Gohman4a4f1512007-07-18 20:23:34 +00001328 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329 XS, Requires<[HasSSE2]>;
1330
Evan Chengb783fa32007-07-19 01:14:50 +00001331def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001332 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001334def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001335 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1337 (load addr:$src)))]>;
1338// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001339def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001340 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1342 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001343def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001344 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001345 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1346 (load addr:$src)))]>,
1347 XS, Requires<[HasSSE2]>;
1348
1349// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001350def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001351 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1353 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001354def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001355 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1357 (load addr:$src)))]>,
1358 XD, Requires<[HasSSE2]>;
1359
Evan Chengb783fa32007-07-19 01:14:50 +00001360def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001361 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001363def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001364 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1366 (load addr:$src)))]>;
1367
1368// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001369def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001370 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1372 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001373def Int_CVTPS2PDrm : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001374 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001375 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1376 (load addr:$src)))]>,
1377 TB, Requires<[HasSSE2]>;
1378
Evan Chengb783fa32007-07-19 01:14:50 +00001379def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001380 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001382def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001383 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1385 (load addr:$src)))]>;
1386
1387// Match intrinsics which expect XMM operand(s).
1388// Aliases for intrinsics
1389let isTwoAddress = 1 in {
1390def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001391 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001392 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1394 GR32:$src2))]>;
1395def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001396 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001397 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001398 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1399 (loadi32 addr:$src2)))]>;
1400def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001401 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001402 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1404 VR128:$src2))]>;
1405def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001406 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001407 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1409 (load addr:$src2)))]>;
1410def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001411 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001412 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1414 VR128:$src2))]>, XS,
1415 Requires<[HasSSE2]>;
1416def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001417 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001418 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1420 (load addr:$src2)))]>, XS,
1421 Requires<[HasSSE2]>;
1422}
1423
1424// Arithmetic
1425
1426/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1427///
1428/// In addition, we also have a special variant of the scalar form here to
1429/// represent the associated intrinsic operation. This form is unlike the
1430/// plain scalar form, in that it takes an entire vector (instead of a
1431/// scalar) and leaves the top elements undefined.
1432///
1433/// And, we have a special variant form for a full-vector intrinsic form.
1434///
1435/// These four forms can each have a reg or a mem operand, so there are a
1436/// total of eight "instructions".
1437///
1438multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1439 SDNode OpNode,
1440 Intrinsic F64Int,
1441 Intrinsic V2F64Int,
1442 bit Commutable = 0> {
1443 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001444 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001445 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446 [(set FR64:$dst, (OpNode FR64:$src))]> {
1447 let isCommutable = Commutable;
1448 }
1449
1450 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001451 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001452 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001453 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1454
1455 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001456 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001457 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001458 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1459 let isCommutable = Commutable;
1460 }
1461
1462 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001463 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001465 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001466
1467 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001468 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001470 [(set VR128:$dst, (F64Int VR128:$src))]> {
1471 let isCommutable = Commutable;
1472 }
1473
1474 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001475 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001476 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001477 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1478
1479 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001480 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1483 let isCommutable = Commutable;
1484 }
1485
1486 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001487 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001488 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489 [(set VR128:$dst, (V2F64Int (load addr:$src)))]>;
1490}
1491
1492// Square root.
1493defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1494 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1495
1496// There is no f64 version of the reciprocal approximation instructions.
1497
1498// Logical
1499let isTwoAddress = 1 in {
1500 let isCommutable = 1 in {
1501 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001502 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504 [(set VR128:$dst,
1505 (and (bc_v2i64 (v2f64 VR128:$src1)),
1506 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1507 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001508 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001509 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510 [(set VR128:$dst,
1511 (or (bc_v2i64 (v2f64 VR128:$src1)),
1512 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1513 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001514 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001515 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516 [(set VR128:$dst,
1517 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1518 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1519 }
1520
1521 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001522 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001523 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524 [(set VR128:$dst,
1525 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001526 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001527 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001528 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001529 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530 [(set VR128:$dst,
1531 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001532 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001534 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001535 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001536 [(set VR128:$dst,
1537 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001538 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001539 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001540 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001542 [(set VR128:$dst,
1543 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1544 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1545 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001546 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 [(set VR128:$dst,
1549 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001550 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551}
1552
1553let isTwoAddress = 1 in {
1554 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001555 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1558 VR128:$src, imm:$cc))]>;
1559 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001560 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001562 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1563 (load addr:$src), imm:$cc))]>;
1564}
1565
1566// Shuffle and unpack instructions
1567let isTwoAddress = 1 in {
1568 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001569 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001570 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571 [(set VR128:$dst, (v2f64 (vector_shuffle
1572 VR128:$src1, VR128:$src2,
1573 SHUFP_shuffle_mask:$src3)))]>;
1574 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001575 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001576 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001577 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578 [(set VR128:$dst,
1579 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001580 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581 SHUFP_shuffle_mask:$src3)))]>;
1582
1583 let AddedComplexity = 10 in {
1584 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001585 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001587 [(set VR128:$dst,
1588 (v2f64 (vector_shuffle
1589 VR128:$src1, VR128:$src2,
1590 UNPCKH_shuffle_mask)))]>;
1591 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001592 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001593 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001594 [(set VR128:$dst,
1595 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001596 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001597 UNPCKH_shuffle_mask)))]>;
1598
1599 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001600 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001601 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001602 [(set VR128:$dst,
1603 (v2f64 (vector_shuffle
1604 VR128:$src1, VR128:$src2,
1605 UNPCKL_shuffle_mask)))]>;
1606 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001607 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001608 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609 [(set VR128:$dst,
1610 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001611 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001612 UNPCKL_shuffle_mask)))]>;
1613 } // AddedComplexity
1614} // isTwoAddress
1615
1616
1617//===----------------------------------------------------------------------===//
1618// SSE integer instructions
1619
1620// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001621def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001622 "movdqa\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001623def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001624 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001625 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001626def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001627 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001628 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001629def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001631 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001633def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001634 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001635 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636 XS, Requires<[HasSSE2]>;
1637
Dan Gohman4a4f1512007-07-18 20:23:34 +00001638// Intrinsic forms of MOVDQU load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001639def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001640 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001641 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1642 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001643def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001644 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001645 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1646 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001647
1648let isTwoAddress = 1 in {
1649
1650multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1651 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001652 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001653 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001654 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1655 let isCommutable = Commutable;
1656 }
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))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661}
1662
1663multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1664 string OpcodeStr, Intrinsic IntId> {
Evan Chengb783fa32007-07-19 01:14:50 +00001665 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001666 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001668 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001671 (bitconvert (memopv2i64 addr:$src2))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001672 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001673 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001674 [(set VR128:$dst, (IntId VR128:$src1,
1675 (scalar_to_vector (i32 imm:$src2))))]>;
1676}
1677
1678
1679/// PDI_binop_rm - Simple SSE2 binary operator.
1680multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1681 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001682 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1685 let isCommutable = Commutable;
1686 }
Evan Chengb783fa32007-07-19 01:14:50 +00001687 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001688 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001690 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001691}
1692
1693/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1694///
1695/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1696/// to collapse (bitconvert VT to VT) into its operand.
1697///
1698multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1699 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001700 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001701 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001702 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1703 let isCommutable = Commutable;
1704 }
Evan Chengb783fa32007-07-19 01:14:50 +00001705 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001707 [(set VR128:$dst, (OpNode VR128:$src1,(memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001708}
1709
1710} // isTwoAddress
1711
1712// 128-bit Integer Arithmetic
1713
1714defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1715defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1716defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1717defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1718
1719defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1720defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1721defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1722defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1723
1724defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1725defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1726defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1727defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1728
1729defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1730defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1731defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1732defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1733
1734defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1735
1736defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1737defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1738defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1739
1740defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1741
1742defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1743defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1744
1745
1746defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1747defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1748defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1749defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1750defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>;
1751
1752
1753defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", int_x86_sse2_psll_w>;
1754defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", int_x86_sse2_psll_d>;
1755defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", int_x86_sse2_psll_q>;
1756
1757defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", int_x86_sse2_psrl_w>;
1758defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", int_x86_sse2_psrl_d>;
1759defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq", int_x86_sse2_psrl_q>;
1760
1761defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", int_x86_sse2_psra_w>;
1762defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad", int_x86_sse2_psra_d>;
1763// PSRAQ doesn't exist in SSE[1-3].
1764
1765// 128-bit logical shifts.
1766let isTwoAddress = 1 in {
1767 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001768 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001771 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001772 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001773 // PSRADQri doesn't exist in SSE[1-3].
1774}
1775
1776let Predicates = [HasSSE2] in {
1777 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1778 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1779 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1780 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1781 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1782 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1783}
1784
1785// Logical
1786defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1787defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1788defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1789
1790let isTwoAddress = 1 in {
1791 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001792 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001793 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001794 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1795 VR128:$src2)))]>;
1796
1797 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001798 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001799 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001800 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00001801 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802}
1803
1804// SSE2 Integer comparison
1805defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1806defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
1807defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
1808defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
1809defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
1810defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
1811
1812// Pack instructions
1813defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
1814defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
1815defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
1816
1817// Shuffle and unpack instructions
1818def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001819 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 [(set VR128:$dst, (v4i32 (vector_shuffle
1822 VR128:$src1, (undef),
1823 PSHUFD_shuffle_mask:$src2)))]>;
1824def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001825 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 [(set VR128:$dst, (v4i32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001828 (bc_v4i32(memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 (undef),
1830 PSHUFD_shuffle_mask:$src2)))]>;
1831
1832// SSE2 with ImmT == Imm8 and XS prefix.
1833def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001834 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(set VR128:$dst, (v8i16 (vector_shuffle
1837 VR128:$src1, (undef),
1838 PSHUFHW_shuffle_mask:$src2)))]>,
1839 XS, Requires<[HasSSE2]>;
1840def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001841 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001842 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001843 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001844 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845 (undef),
1846 PSHUFHW_shuffle_mask:$src2)))]>,
1847 XS, Requires<[HasSSE2]>;
1848
1849// SSE2 with ImmT == Imm8 and XD prefix.
1850def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001851 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001853 [(set VR128:$dst, (v8i16 (vector_shuffle
1854 VR128:$src1, (undef),
1855 PSHUFLW_shuffle_mask:$src2)))]>,
1856 XD, Requires<[HasSSE2]>;
1857def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001858 (outs VR128:$dst), (ins i128mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001861 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 (undef),
1863 PSHUFLW_shuffle_mask:$src2)))]>,
1864 XD, Requires<[HasSSE2]>;
1865
1866
1867let isTwoAddress = 1 in {
1868 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001869 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001870 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871 [(set VR128:$dst,
1872 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1873 UNPCKL_shuffle_mask)))]>;
1874 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001875 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001876 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001877 [(set VR128:$dst,
1878 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001879 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 UNPCKL_shuffle_mask)))]>;
1881 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001882 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001883 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001884 [(set VR128:$dst,
1885 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1886 UNPCKL_shuffle_mask)))]>;
1887 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001888 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001889 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890 [(set VR128:$dst,
1891 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001892 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001893 UNPCKL_shuffle_mask)))]>;
1894 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001895 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001897 [(set VR128:$dst,
1898 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1899 UNPCKL_shuffle_mask)))]>;
1900 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001901 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 [(set VR128:$dst,
1904 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001905 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906 UNPCKL_shuffle_mask)))]>;
1907 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001908 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001909 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910 [(set VR128:$dst,
1911 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1912 UNPCKL_shuffle_mask)))]>;
1913 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001914 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001915 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916 [(set VR128:$dst,
1917 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001918 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001919 UNPCKL_shuffle_mask)))]>;
1920
1921 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001922 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001924 [(set VR128:$dst,
1925 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1926 UNPCKH_shuffle_mask)))]>;
1927 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001928 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(set VR128:$dst,
1931 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001932 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001933 UNPCKH_shuffle_mask)))]>;
1934 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001935 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001936 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937 [(set VR128:$dst,
1938 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1939 UNPCKH_shuffle_mask)))]>;
1940 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001941 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001942 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 [(set VR128:$dst,
1944 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001945 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001946 UNPCKH_shuffle_mask)))]>;
1947 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001948 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950 [(set VR128:$dst,
1951 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1952 UNPCKH_shuffle_mask)))]>;
1953 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001954 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 [(set VR128:$dst,
1957 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001958 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001959 UNPCKH_shuffle_mask)))]>;
1960 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001961 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(set VR128:$dst,
1964 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1965 UNPCKH_shuffle_mask)))]>;
1966 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001967 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 [(set VR128:$dst,
1970 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001971 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 UNPCKH_shuffle_mask)))]>;
1973}
1974
1975// Extract / Insert
1976def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001977 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001979 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
1980 (iPTR imm:$src2)))]>;
1981let isTwoAddress = 1 in {
1982 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001983 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001985 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986 [(set VR128:$dst,
1987 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
1988 GR32:$src2, (iPTR imm:$src3))))]>;
1989 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001990 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001992 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 [(set VR128:$dst,
1994 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
1995 (i32 (anyext (loadi16 addr:$src2))),
1996 (iPTR imm:$src3))))]>;
1997}
1998
1999// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002000def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2003
2004// Conditional store
Evan Chengb783fa32007-07-19 01:14:50 +00002005def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002006 "maskmovdqu\t{$mask, $src|$src, $mask}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002007 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>,
2008 Imp<[EDI],[]>;
2009
2010// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002011def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002012 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002013 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002014def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002015 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002017def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002018 "movnti\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2020 TB, Requires<[HasSSE2]>;
2021
2022// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002023def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025 TB, Requires<[HasSSE2]>;
2026
2027// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +00002028def LFENCE : I<0xAE, MRM5m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002030def MFENCE : I<0xAE, MRM6m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002031 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2032
2033
2034// Alias instructions that map zero vector to pxor / xorp* for sse.
2035// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2036let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002037 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "pcmpeqd\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 [(set VR128:$dst, (v2f64 immAllOnesV))]>;
2040
2041// FR64 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +00002042def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002043 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044 [(set VR128:$dst,
2045 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002046def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002048 [(set VR128:$dst,
2049 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2050
Evan Chengb783fa32007-07-19 01:14:50 +00002051def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(set VR128:$dst,
2054 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002055def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002056 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 [(set VR128:$dst,
2058 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2059
Evan Chengb783fa32007-07-19 01:14:50 +00002060def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002061 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002062 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2063
Evan Chengb783fa32007-07-19 01:14:50 +00002064def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002065 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002066 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2067
2068// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002069def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002070 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 [(set VR128:$dst,
2072 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2073 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002074def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002075 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076 [(store (i64 (vector_extract (v2i64 VR128:$src),
2077 (iPTR 0))), addr:$dst)]>;
2078
2079// FIXME: may not be able to eliminate this movss with coalescing the src and
2080// dest register classes are different. We really want to write this pattern
2081// like this:
2082// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2083// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +00002084def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002086 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2087 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002088def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002089 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002090 [(store (f64 (vector_extract (v2f64 VR128:$src),
2091 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002092def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002093 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002094 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2095 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002096def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 [(store (i32 (vector_extract (v4i32 VR128:$src),
2099 (iPTR 0))), addr:$dst)]>;
2100
Evan Chengb783fa32007-07-19 01:14:50 +00002101def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002102 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002104def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002105 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002106 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2107
2108
2109// Move to lower bits of a VR128, leaving upper bits alone.
2110// Three operand (but two address) aliases.
2111let isTwoAddress = 1 in {
2112 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002113 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002114 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002115
2116 let AddedComplexity = 15 in
2117 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002118 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002119 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002120 [(set VR128:$dst,
2121 (v2f64 (vector_shuffle VR128:$src1, VR128:$src2,
2122 MOVL_shuffle_mask)))]>;
2123}
2124
2125// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002126def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002127 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2129
2130// Move to lower bits of a VR128 and zeroing upper bits.
2131// Loading from memory automatically zeroing upper bits.
2132let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002133 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002134 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002135 [(set VR128:$dst,
2136 (v2f64 (vector_shuffle immAllZerosV,
2137 (v2f64 (scalar_to_vector
2138 (loadf64 addr:$src))),
2139 MOVL_shuffle_mask)))]>;
2140
2141let AddedComplexity = 15 in
2142// movd / movq to XMM register zero-extends
Evan Chengb783fa32007-07-19 01:14:50 +00002143def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002144 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002145 [(set VR128:$dst,
2146 (v4i32 (vector_shuffle immAllZerosV,
2147 (v4i32 (scalar_to_vector GR32:$src)),
2148 MOVL_shuffle_mask)))]>;
2149let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002150def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(set VR128:$dst,
2153 (v4i32 (vector_shuffle immAllZerosV,
2154 (v4i32 (scalar_to_vector (loadi32 addr:$src))),
2155 MOVL_shuffle_mask)))]>;
2156
2157// Moving from XMM to XMM but still clear upper 64 bits.
2158let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002159def MOVZQI2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002160 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002161 [(set VR128:$dst, (int_x86_sse2_movl_dq VR128:$src))]>,
2162 XS, Requires<[HasSSE2]>;
2163let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002164def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002165 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002166 [(set VR128:$dst, (int_x86_sse2_movl_dq
Dan Gohman4a4f1512007-07-18 20:23:34 +00002167 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168 XS, Requires<[HasSSE2]>;
2169
2170
2171//===----------------------------------------------------------------------===//
2172// SSE3 Instructions
2173//===----------------------------------------------------------------------===//
2174
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002176def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002177 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002178 [(set VR128:$dst, (v4f32 (vector_shuffle
2179 VR128:$src, (undef),
2180 MOVSHDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002181def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002182 "movshdup\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 MOVSHDUP_shuffle_mask)))]>;
2186
Evan Chengb783fa32007-07-19 01:14:50 +00002187def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002188 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002189 [(set VR128:$dst, (v4f32 (vector_shuffle
2190 VR128:$src, (undef),
2191 MOVSLDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002192def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002195 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196 MOVSLDUP_shuffle_mask)))]>;
2197
Evan Chengb783fa32007-07-19 01:14:50 +00002198def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002199 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002200 [(set VR128:$dst, (v2f64 (vector_shuffle
2201 VR128:$src, (undef),
2202 SSE_splat_lo_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002203def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205 [(set VR128:$dst,
2206 (v2f64 (vector_shuffle
2207 (scalar_to_vector (loadf64 addr:$src)),
2208 (undef),
2209 SSE_splat_lo_mask)))]>;
2210
2211// Arithmetic
2212let isTwoAddress = 1 in {
2213 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002214 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002215 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002216 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2217 VR128:$src2))]>;
2218 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002219 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002220 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002221 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2222 (load addr:$src2)))]>;
2223 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002224 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2227 VR128:$src2))]>;
2228 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002229 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2232 (load addr:$src2)))]>;
2233}
2234
Evan Chengb783fa32007-07-19 01:14:50 +00002235def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002236 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002237 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2238
2239// Horizontal ops
2240class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002241 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002242 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002243 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2244class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002245 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (load addr:$src2))))]>;
2248class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002249 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002250 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2252class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002253 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002254 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002255 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (load addr:$src2))))]>;
2256
2257let isTwoAddress = 1 in {
2258 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2259 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2260 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2261 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2262 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2263 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2264 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2265 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2266}
2267
2268// Thread synchronization
Evan Chengb783fa32007-07-19 01:14:50 +00002269def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002270 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002271def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002272 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2273
2274// vector_shuffle v1, <undef> <1, 1, 3, 3>
2275let AddedComplexity = 15 in
2276def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2277 MOVSHDUP_shuffle_mask)),
2278 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2279let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002280def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002281 MOVSHDUP_shuffle_mask)),
2282 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2283
2284// vector_shuffle v1, <undef> <0, 0, 2, 2>
2285let AddedComplexity = 15 in
2286 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2287 MOVSLDUP_shuffle_mask)),
2288 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2289let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002290 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291 MOVSLDUP_shuffle_mask)),
2292 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2293
2294//===----------------------------------------------------------------------===//
2295// SSSE3 Instructions
2296//===----------------------------------------------------------------------===//
2297
Bill Wendling3b15d722007-08-11 09:52:53 +00002298// SSSE3 Instruction Templates:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002299//
Bill Wendling98680292007-08-10 06:22:27 +00002300// SS38I - SSSE3 instructions with T8 prefix.
2301// SS3AI - SSSE3 instructions with TA prefix.
Bill Wendling3b15d722007-08-11 09:52:53 +00002302//
2303// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
2304// uses the MMX registers. We put those instructions here because they better
2305// fit into the SSSE3 instruction category rather than the MMX category.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002306
Evan Chengb783fa32007-07-19 01:14:50 +00002307class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
2308 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002309 : I<o, F, outs, ins, asm, pattern>, T8, Requires<[HasSSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002310class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
2311 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002312 : I<o, F, outs, ins, asm, pattern>, TA, Requires<[HasSSSE3]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002313
Bill Wendling98680292007-08-10 06:22:27 +00002314/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002315let isTwoAddress = 1 in {
Bill Wendling98680292007-08-10 06:22:27 +00002316 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2317 Intrinsic IntId64, Intrinsic IntId128,
2318 bit Commutable = 0> {
2319 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2320 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2321 [(set VR64:$dst, (IntId64 VR64:$src))]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322 let isCommutable = Commutable;
2323 }
Bill Wendling98680292007-08-10 06:22:27 +00002324 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2325 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2326 [(set VR64:$dst,
2327 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2328
2329 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2330 (ins VR128:$src),
2331 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2332 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2333 OpSize {
2334 let isCommutable = Commutable;
2335 }
2336 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2337 (ins i128mem:$src),
2338 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2339 [(set VR128:$dst,
2340 (IntId128
2341 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002342 }
2343}
2344
Bill Wendling98680292007-08-10 06:22:27 +00002345/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2346let isTwoAddress = 1 in {
2347 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2348 Intrinsic IntId64, Intrinsic IntId128,
2349 bit Commutable = 0> {
2350 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2351 (ins VR64:$src),
2352 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2353 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2354 let isCommutable = Commutable;
2355 }
2356 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2357 (ins i64mem:$src),
2358 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2359 [(set VR64:$dst,
2360 (IntId64
2361 (bitconvert (memopv4i16 addr:$src))))]>;
2362
2363 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2364 (ins VR128:$src),
2365 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2366 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2367 OpSize {
2368 let isCommutable = Commutable;
2369 }
2370 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2371 (ins i128mem:$src),
2372 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2373 [(set VR128:$dst,
2374 (IntId128
2375 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2376 }
2377}
2378
2379/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2380let isTwoAddress = 1 in {
2381 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2382 Intrinsic IntId64, Intrinsic IntId128,
2383 bit Commutable = 0> {
2384 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2385 (ins VR64:$src),
2386 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2387 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2388 let isCommutable = Commutable;
2389 }
2390 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2391 (ins i64mem:$src),
2392 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2393 [(set VR64:$dst,
2394 (IntId64
2395 (bitconvert (memopv2i32 addr:$src))))]>;
2396
2397 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2398 (ins VR128:$src),
2399 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2400 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2401 OpSize {
2402 let isCommutable = Commutable;
2403 }
2404 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2405 (ins i128mem:$src),
2406 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2407 [(set VR128:$dst,
2408 (IntId128
2409 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2410 }
2411}
2412
2413defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2414 int_x86_ssse3_pabs_b,
2415 int_x86_ssse3_pabs_b_128>;
2416defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2417 int_x86_ssse3_pabs_w,
2418 int_x86_ssse3_pabs_w_128>;
2419defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2420 int_x86_ssse3_pabs_d,
2421 int_x86_ssse3_pabs_d_128>;
2422
2423/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2424let isTwoAddress = 1 in {
2425 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2426 Intrinsic IntId64, Intrinsic IntId128,
2427 bit Commutable = 0> {
2428 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2429 (ins VR64:$src1, VR64:$src2),
2430 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2431 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2432 let isCommutable = Commutable;
2433 }
2434 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2435 (ins VR64:$src1, i64mem:$src2),
2436 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2437 [(set VR64:$dst,
2438 (IntId64 VR64:$src1,
2439 (bitconvert (memopv8i8 addr:$src2))))]>;
2440
2441 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2442 (ins VR128:$src1, VR128:$src2),
2443 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2444 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2445 OpSize {
2446 let isCommutable = Commutable;
2447 }
2448 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2449 (ins VR128:$src1, i128mem:$src2),
2450 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2451 [(set VR128:$dst,
2452 (IntId128 VR128:$src1,
2453 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2454 }
2455}
2456
2457/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2458let isTwoAddress = 1 in {
2459 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2460 Intrinsic IntId64, Intrinsic IntId128,
2461 bit Commutable = 0> {
2462 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2463 (ins VR64:$src1, VR64:$src2),
2464 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2465 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2466 let isCommutable = Commutable;
2467 }
2468 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2469 (ins VR64:$src1, i64mem:$src2),
2470 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2471 [(set VR64:$dst,
2472 (IntId64 VR64:$src1,
2473 (bitconvert (memopv4i16 addr:$src2))))]>;
2474
2475 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2476 (ins VR128:$src1, VR128:$src2),
2477 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2478 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2479 OpSize {
2480 let isCommutable = Commutable;
2481 }
2482 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2483 (ins VR128:$src1, i128mem:$src2),
2484 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2485 [(set VR128:$dst,
2486 (IntId128 VR128:$src1,
2487 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2488 }
2489}
2490
2491/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2492let isTwoAddress = 1 in {
2493 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2494 Intrinsic IntId64, Intrinsic IntId128,
2495 bit Commutable = 0> {
2496 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2497 (ins VR64:$src1, VR64:$src2),
2498 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2499 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2500 let isCommutable = Commutable;
2501 }
2502 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2503 (ins VR64:$src1, i64mem:$src2),
2504 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2505 [(set VR64:$dst,
2506 (IntId64 VR64:$src1,
2507 (bitconvert (memopv2i32 addr:$src2))))]>;
2508
2509 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2510 (ins VR128:$src1, VR128:$src2),
2511 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2512 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2513 OpSize {
2514 let isCommutable = Commutable;
2515 }
2516 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2517 (ins VR128:$src1, i128mem:$src2),
2518 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2519 [(set VR128:$dst,
2520 (IntId128 VR128:$src1,
2521 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2522 }
2523}
2524
2525defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2526 int_x86_ssse3_phadd_w,
2527 int_x86_ssse3_phadd_w_128, 1>;
2528defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2529 int_x86_ssse3_phadd_d,
2530 int_x86_ssse3_phadd_d_128, 1>;
2531defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2532 int_x86_ssse3_phadd_sw,
2533 int_x86_ssse3_phadd_sw_128, 1>;
2534defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2535 int_x86_ssse3_phsub_w,
2536 int_x86_ssse3_phsub_w_128>;
2537defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2538 int_x86_ssse3_phsub_d,
2539 int_x86_ssse3_phsub_d_128>;
2540defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2541 int_x86_ssse3_phsub_sw,
2542 int_x86_ssse3_phsub_sw_128>;
2543defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2544 int_x86_ssse3_pmadd_ub_sw,
2545 int_x86_ssse3_pmadd_ub_sw_128, 1>;
2546defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2547 int_x86_ssse3_pmul_hr_sw,
2548 int_x86_ssse3_pmul_hr_sw_128, 1>;
2549defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2550 int_x86_ssse3_pshuf_b,
2551 int_x86_ssse3_pshuf_b_128>;
2552defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2553 int_x86_ssse3_psign_b,
2554 int_x86_ssse3_psign_b_128>;
2555defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2556 int_x86_ssse3_psign_w,
2557 int_x86_ssse3_psign_w_128>;
2558defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2559 int_x86_ssse3_psign_d,
2560 int_x86_ssse3_psign_d_128>;
2561
2562let isTwoAddress = 1 in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002563 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2564 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
2565 "palignr\t{$src2, $dst|$dst, $src2}",
2566 [(set VR64:$dst,
2567 (int_x86_ssse3_palign_r
2568 VR64:$src1, VR64:$src2,
2569 imm:$src3))]>;
2570 def PALIGNR64rm : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2571 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
2572 "palignr\t{$src2, $dst|$dst, $src2}",
2573 [(set VR64:$dst,
2574 (int_x86_ssse3_palign_r
2575 VR64:$src1,
2576 (bitconvert (memopv2i32 addr:$src2)),
2577 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002578
Bill Wendling1dc817c2007-08-10 09:00:17 +00002579 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2580 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
2581 "palignr\t{$src2, $dst|$dst, $src2}",
2582 [(set VR128:$dst,
2583 (int_x86_ssse3_palign_r_128
2584 VR128:$src1, VR128:$src2,
2585 imm:$src3))]>, OpSize;
2586 def PALIGNR128rm : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2587 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
2588 "palignr\t{$src2, $dst|$dst, $src2}",
2589 [(set VR128:$dst,
2590 (int_x86_ssse3_palign_r_128
2591 VR128:$src1,
2592 (bitconvert (memopv4i32 addr:$src2)),
2593 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002594}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002595
2596//===----------------------------------------------------------------------===//
2597// Non-Instruction Patterns
2598//===----------------------------------------------------------------------===//
2599
2600// 128-bit vector undef's.
Bill Wendling1dc817c2007-08-10 09:00:17 +00002601def : Pat<(v4f32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2603def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2604def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2605def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2606def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2607
2608// 128-bit vector all zero's.
2609def : Pat<(v16i8 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2610def : Pat<(v8i16 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2611def : Pat<(v4i32 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2612def : Pat<(v2i64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2613def : Pat<(v2f64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2614
2615// 128-bit vector all one's.
2616def : Pat<(v16i8 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2617def : Pat<(v8i16 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2618def : Pat<(v4i32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2619def : Pat<(v2i64 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2620def : Pat<(v4f32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE1]>;
2621
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002622
2623// Scalar to v8i16 / v16i8. The source may be a GR32, but only the lower 8 or
2624// 16-bits matter.
2625def : Pat<(v8i16 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2626 Requires<[HasSSE2]>;
2627def : Pat<(v16i8 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2628 Requires<[HasSSE2]>;
2629
2630// bit_convert
2631let Predicates = [HasSSE2] in {
2632 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2633 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2634 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2635 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2636 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2637 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2638 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2639 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2640 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2641 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2642 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2643 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2644 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2645 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2646 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2647 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2648 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2649 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2650 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2651 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2652 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2653 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2654 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2655 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2656 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2657 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2658 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2659 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2660 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2661 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2662}
2663
2664// Move scalar to XMM zero-extended
2665// movd to XMM register zero-extends
2666let AddedComplexity = 15 in {
2667def : Pat<(v8i16 (vector_shuffle immAllZerosV,
2668 (v8i16 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2669 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2670def : Pat<(v16i8 (vector_shuffle immAllZerosV,
2671 (v16i8 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2672 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2673// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
2674def : Pat<(v2f64 (vector_shuffle immAllZerosV,
2675 (v2f64 (scalar_to_vector FR64:$src)), MOVL_shuffle_mask)),
2676 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
2677def : Pat<(v4f32 (vector_shuffle immAllZerosV,
2678 (v4f32 (scalar_to_vector FR32:$src)), MOVL_shuffle_mask)),
2679 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>;
2680}
2681
2682// Splat v2f64 / v2i64
2683let AddedComplexity = 10 in {
2684def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2685 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2686def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2687 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2688def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2689 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2690def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2691 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2692}
2693
2694// Splat v4f32
2695def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SSE_splat_mask:$sm),
2696 (SHUFPSrri VR128:$src, VR128:$src, SSE_splat_mask:$sm)>,
2697 Requires<[HasSSE1]>;
2698
2699// Special unary SHUFPSrri case.
2700// FIXME: when we want non two-address code, then we should use PSHUFD?
2701def : Pat<(vector_shuffle (v4f32 VR128:$src1), (undef),
2702 SHUFP_unary_shuffle_mask:$sm),
2703 (SHUFPSrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2704 Requires<[HasSSE1]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002705// Special unary SHUFPDrri case.
2706def : Pat<(vector_shuffle (v2f64 VR128:$src1), (undef),
2707 SHUFP_unary_shuffle_mask:$sm),
2708 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2709 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002710// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Dan Gohman4a4f1512007-07-18 20:23:34 +00002711def : Pat<(vector_shuffle (memopv4f32 addr:$src1), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002712 SHUFP_unary_shuffle_mask:$sm),
2713 (PSHUFDmi addr:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2714 Requires<[HasSSE2]>;
2715// Special binary v4i32 shuffle cases with SHUFPS.
2716def : Pat<(vector_shuffle (v4i32 VR128:$src1), (v4i32 VR128:$src2),
2717 PSHUFD_binary_shuffle_mask:$sm),
2718 (SHUFPSrri VR128:$src1, VR128:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2719 Requires<[HasSSE2]>;
2720def : Pat<(vector_shuffle (v4i32 VR128:$src1),
Dan Gohman4a4f1512007-07-18 20:23:34 +00002721 (bc_v4i32 (memopv2i64 addr:$src2)), PSHUFD_binary_shuffle_mask:$sm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002722 (SHUFPSrmi VR128:$src1, addr:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2723 Requires<[HasSSE2]>;
2724
2725// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2726let AddedComplexity = 10 in {
2727def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2728 UNPCKL_v_undef_shuffle_mask)),
2729 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2730def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2731 UNPCKL_v_undef_shuffle_mask)),
2732 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2733def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2734 UNPCKL_v_undef_shuffle_mask)),
2735 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2736def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2737 UNPCKL_v_undef_shuffle_mask)),
2738 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2739}
2740
2741// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2742let AddedComplexity = 10 in {
2743def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2744 UNPCKH_v_undef_shuffle_mask)),
2745 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2746def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2747 UNPCKH_v_undef_shuffle_mask)),
2748 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2749def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2750 UNPCKH_v_undef_shuffle_mask)),
2751 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2752def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2753 UNPCKH_v_undef_shuffle_mask)),
2754 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2755}
2756
2757let AddedComplexity = 15 in {
2758// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2759def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2760 MOVHP_shuffle_mask)),
2761 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2762
2763// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2764def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2765 MOVHLPS_shuffle_mask)),
2766 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2767
2768// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2769def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2770 MOVHLPS_v_undef_shuffle_mask)),
2771 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2772def : Pat<(v4i32 (vector_shuffle VR128:$src1, (undef),
2773 MOVHLPS_v_undef_shuffle_mask)),
2774 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2775}
2776
2777let AddedComplexity = 20 in {
2778// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2779// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Dan Gohman4a4f1512007-07-18 20:23:34 +00002780def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002781 MOVLP_shuffle_mask)),
2782 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002783def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002784 MOVLP_shuffle_mask)),
2785 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002786def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002787 MOVHP_shuffle_mask)),
2788 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002789def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002790 MOVHP_shuffle_mask)),
2791 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2792
Dan Gohman4a4f1512007-07-18 20:23:34 +00002793def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002794 MOVLP_shuffle_mask)),
2795 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002796def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002797 MOVLP_shuffle_mask)),
2798 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002799def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002800 MOVHP_shuffle_mask)),
2801 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002802def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002803 MOVLP_shuffle_mask)),
2804 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2805}
2806
2807let AddedComplexity = 15 in {
2808// Setting the lowest element in the vector.
2809def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2810 MOVL_shuffle_mask)),
2811 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2812def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2813 MOVL_shuffle_mask)),
2814 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2815
2816// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
2817def : Pat<(v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
2818 MOVLP_shuffle_mask)),
2819 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2820def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2821 MOVLP_shuffle_mask)),
2822 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2823}
2824
2825// Set lowest element and zero upper elements.
2826let AddedComplexity = 20 in
2827def : Pat<(bc_v2i64 (vector_shuffle immAllZerosV,
2828 (v2f64 (scalar_to_vector (loadf64 addr:$src))),
2829 MOVL_shuffle_mask)),
2830 (MOVZQI2PQIrm addr:$src)>, Requires<[HasSSE2]>;
2831
2832// FIXME: Temporary workaround since 2-wide shuffle is broken.
2833def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
2834 (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2835def : Pat<(int_x86_sse2_loadh_pd VR128:$src1, addr:$src2),
2836 (v2f64 (MOVHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2837def : Pat<(int_x86_sse2_loadl_pd VR128:$src1, addr:$src2),
2838 (v2f64 (MOVLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2839def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
2840 (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
2841 Requires<[HasSSE2]>;
2842def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (load addr:$src2), imm:$src3),
2843 (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
2844 Requires<[HasSSE2]>;
2845def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
2846 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2847def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (load addr:$src2)),
2848 (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2849def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
2850 (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2851def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (load addr:$src2)),
2852 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2853def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2),
2854 (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2855def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (load addr:$src2)),
2856 (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2857def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2),
2858 (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2859def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (load addr:$src2)),
2860 (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2861
2862// Some special case pandn patterns.
2863def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2864 VR128:$src2)),
2865 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2866def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
2867 VR128:$src2)),
2868 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2869def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
2870 VR128:$src2)),
2871 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2872
2873def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002874 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002875 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2876def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002877 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002878 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2879def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002880 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002881 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2882
Evan Cheng51a49b22007-07-20 00:27:43 +00002883// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00002884def : Pat<(alignedloadv4i32 addr:$src),
2885 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
2886def : Pat<(loadv4i32 addr:$src),
2887 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00002888def : Pat<(alignedloadv2i64 addr:$src),
2889 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
2890def : Pat<(loadv2i64 addr:$src),
2891 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
2892
2893def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
2894 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2895def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
2896 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2897def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
2898 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2899def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
2900 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2901def : Pat<(store (v2i64 VR128:$src), addr:$dst),
2902 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2903def : Pat<(store (v4i32 VR128:$src), addr:$dst),
2904 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2905def : Pat<(store (v8i16 VR128:$src), addr:$dst),
2906 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2907def : Pat<(store (v16i8 VR128:$src), addr:$dst),
2908 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Evan Cheng86ab7d32007-07-31 08:04:03 +00002909
2910// (vextract (v4i32 bc (v4f32 s2v (f32 load $addr))), 0) -> (i32 load $addr)
2911def : Pat<(vector_extract
2912 (bc_v4i32 (v4f32 (scalar_to_vector (loadf32 addr:$src)))), (iPTR 0)),
Evan Cheng43a09ac2007-08-01 21:42:24 +00002913 (MOV32rm addr:$src)>, Requires<[HasSSE2]>;
Evan Cheng86ab7d32007-07-31 08:04:03 +00002914def : Pat<(vector_extract
2915 (bc_v2i64 (v2f64 (scalar_to_vector (loadf64 addr:$src)))), (iPTR 0)),
Evan Cheng43a09ac2007-08-01 21:42:24 +00002916 (MOV64rm addr:$src)>, Requires<[HasSSE2, In64BitMode]>;