blob: 63f041be7fe9e71800faa3f74a5486524e420a38 [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}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000299let isLoad = 1, 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.
Dan Gohman8aef09b2007-09-07 21:32:51 +0000402let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000403def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000404 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405 Requires<[HasSSE1]>, TB, OpSize;
406
407// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
408// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +0000409def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000410 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411
412// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
413// disregarded.
Evan Cheng4e84e452007-08-30 05:49:43 +0000414let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000415def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000416 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000417 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000418
419// Alias bitwise logical operations using SSE logical ops on packed FP values.
420let isTwoAddress = 1 in {
421let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000422 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000423 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000425 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000426 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000427 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000428 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000429 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
431}
432
Evan Chengb783fa32007-07-19 01:14:50 +0000433def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000434 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000436 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000437def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000438 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000440 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000441def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000442 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000444 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445
446def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000447 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000448 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000449def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000450 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000451 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452}
453
454/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
455///
456/// In addition, we also have a special variant of the scalar form here to
457/// represent the associated intrinsic operation. This form is unlike the
458/// plain scalar form, in that it takes an entire vector (instead of a scalar)
459/// and leaves the top elements undefined.
460///
461/// These three forms can each be reg+reg or reg+mem, so there are a total of
462/// six "instructions".
463///
464let isTwoAddress = 1 in {
465multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
466 SDNode OpNode, Intrinsic F32Int,
467 bit Commutable = 0> {
468 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000469 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000470 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
472 let isCommutable = Commutable;
473 }
474
475 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000476 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000477 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
479
480 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000481 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000482 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
484 let isCommutable = Commutable;
485 }
486
487 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000488 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000489 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000490 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491
492 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000493 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000494 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
496 let isCommutable = Commutable;
497 }
498
499 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000500 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000501 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502 [(set VR128:$dst, (F32Int VR128:$src1,
503 sse_load_f32:$src2))]>;
504}
505}
506
507// Arithmetic instructions
508defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
509defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
510defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
511defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
512
513/// sse1_fp_binop_rm - Other SSE1 binops
514///
515/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
516/// instructions for a full-vector intrinsic form. Operations that map
517/// onto C operators don't use this form since they just use the plain
518/// vector form instead of having a separate vector intrinsic form.
519///
520/// This provides a total of eight "instructions".
521///
522let isTwoAddress = 1 in {
523multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
524 SDNode OpNode,
525 Intrinsic F32Int,
526 Intrinsic V4F32Int,
527 bit Commutable = 0> {
528
529 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000530 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000531 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
533 let isCommutable = Commutable;
534 }
535
536 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000537 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000538 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
540
541 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000542 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000543 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
545 let isCommutable = Commutable;
546 }
547
548 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000549 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000550 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000551 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000552
553 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000554 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000555 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
557 let isCommutable = Commutable;
558 }
559
560 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000561 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000562 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563 [(set VR128:$dst, (F32Int VR128:$src1,
564 sse_load_f32:$src2))]>;
565
566 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000567 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000568 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
570 let isCommutable = Commutable;
571 }
572
573 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +0000574 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000575 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576 [(set VR128:$dst, (V4F32Int VR128:$src1, (load addr:$src2)))]>;
577}
578}
579
580defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
581 int_x86_sse_max_ss, int_x86_sse_max_ps>;
582defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
583 int_x86_sse_min_ss, int_x86_sse_min_ps>;
584
585//===----------------------------------------------------------------------===//
586// SSE packed FP Instructions
587
588// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000589def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000590 "movaps\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000591let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000592def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000593 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000594 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595
Evan Chengb783fa32007-07-19 01:14:50 +0000596def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000597 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000598 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000599
Evan Chengb783fa32007-07-19 01:14:50 +0000600def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000601 "movups\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000602let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000603def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000604 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000605 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000606def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000607 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000608 [(store (v4f32 VR128:$src), addr:$dst)]>;
609
610// Intrinsic forms of MOVUPS load and store
Evan Cheng4e84e452007-08-30 05:49:43 +0000611let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000612def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000613 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000614 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000615def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000616 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000617 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618
619let isTwoAddress = 1 in {
620 let AddedComplexity = 20 in {
621 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000622 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000623 "movlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000624 [(set VR128:$dst,
625 (v4f32 (vector_shuffle VR128:$src1,
626 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
627 MOVLP_shuffle_mask)))]>;
628 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000629 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000630 "movhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000631 [(set VR128:$dst,
632 (v4f32 (vector_shuffle VR128:$src1,
633 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
634 MOVHP_shuffle_mask)))]>;
635 } // AddedComplexity
636} // isTwoAddress
637
Evan Chengb783fa32007-07-19 01:14:50 +0000638def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000639 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
641 (iPTR 0))), addr:$dst)]>;
642
643// v2f64 extract element 1 is always custom lowered to unpack high to low
644// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000645def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000646 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000647 [(store (f64 (vector_extract
648 (v2f64 (vector_shuffle
649 (bc_v2f64 (v4f32 VR128:$src)), (undef),
650 UNPCKH_shuffle_mask)), (iPTR 0))),
651 addr:$dst)]>;
652
653let isTwoAddress = 1 in {
654let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000655def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000656 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000657 [(set VR128:$dst,
658 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
659 MOVHP_shuffle_mask)))]>;
660
Evan Chengb783fa32007-07-19 01:14:50 +0000661def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000662 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000663 [(set VR128:$dst,
664 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
665 MOVHLPS_shuffle_mask)))]>;
666} // AddedComplexity
667} // isTwoAddress
668
669
670
671// Arithmetic
672
673/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
674///
675/// In addition, we also have a special variant of the scalar form here to
676/// represent the associated intrinsic operation. This form is unlike the
677/// plain scalar form, in that it takes an entire vector (instead of a
678/// scalar) and leaves the top elements undefined.
679///
680/// And, we have a special variant form for a full-vector intrinsic form.
681///
682/// These four forms can each have a reg or a mem operand, so there are a
683/// total of eight "instructions".
684///
685multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
686 SDNode OpNode,
687 Intrinsic F32Int,
688 Intrinsic V4F32Int,
689 bit Commutable = 0> {
690 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000691 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000692 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693 [(set FR32:$dst, (OpNode FR32:$src))]> {
694 let isCommutable = Commutable;
695 }
696
697 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000698 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000699 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
701
702 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000703 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000704 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
706 let isCommutable = Commutable;
707 }
708
709 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000710 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000711 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000712 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713
714 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000715 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000716 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717 [(set VR128:$dst, (F32Int VR128:$src))]> {
718 let isCommutable = Commutable;
719 }
720
721 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000722 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000723 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000724 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
725
726 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000727 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000728 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
730 let isCommutable = Commutable;
731 }
732
733 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000734 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000735 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000736 [(set VR128:$dst, (V4F32Int (load addr:$src)))]>;
737}
738
739// Square root.
740defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
741 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
742
743// Reciprocal approximations. Note that these typically require refinement
744// in order to obtain suitable precision.
745defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
746 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
747defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
748 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
749
750// Logical
751let isTwoAddress = 1 in {
752 let isCommutable = 1 in {
753 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000754 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000755 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756 [(set VR128:$dst, (v2i64
757 (and VR128:$src1, VR128:$src2)))]>;
758 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000759 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000760 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761 [(set VR128:$dst, (v2i64
762 (or VR128:$src1, VR128:$src2)))]>;
763 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000764 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000765 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766 [(set VR128:$dst, (v2i64
767 (xor VR128:$src1, VR128:$src2)))]>;
768 }
769
770 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000771 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000772 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000773 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
774 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000776 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000777 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000778 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
779 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000781 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000782 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000783 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
784 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000786 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000787 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 [(set VR128:$dst,
789 (v2i64 (and (xor VR128:$src1,
790 (bc_v2i64 (v4i32 immAllOnesV))),
791 VR128:$src2)))]>;
792 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000793 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000794 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000796 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000797 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000798 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000799}
800
801let isTwoAddress = 1 in {
802 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000803 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000804 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
806 VR128:$src, imm:$cc))]>;
807 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000808 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000809 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
811 (load addr:$src), imm:$cc))]>;
812}
813
814// Shuffle and unpack instructions
815let isTwoAddress = 1 in {
816 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
817 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000818 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819 VR128:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000820 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821 [(set VR128:$dst,
822 (v4f32 (vector_shuffle
823 VR128:$src1, VR128:$src2,
824 SHUFP_shuffle_mask:$src3)))]>;
825 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000826 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 f128mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000828 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829 [(set VR128:$dst,
830 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000831 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832 SHUFP_shuffle_mask:$src3)))]>;
833
834 let AddedComplexity = 10 in {
835 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000836 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000837 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838 [(set VR128:$dst,
839 (v4f32 (vector_shuffle
840 VR128:$src1, VR128:$src2,
841 UNPCKH_shuffle_mask)))]>;
842 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000843 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 [(set VR128:$dst,
846 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000847 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 UNPCKH_shuffle_mask)))]>;
849
850 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000851 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000852 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853 [(set VR128:$dst,
854 (v4f32 (vector_shuffle
855 VR128:$src1, VR128:$src2,
856 UNPCKL_shuffle_mask)))]>;
857 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000858 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000859 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 [(set VR128:$dst,
861 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000862 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000863 UNPCKL_shuffle_mask)))]>;
864 } // AddedComplexity
865} // isTwoAddress
866
867// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000868def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000869 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000871def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000872 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
874
875// Prefetching loads.
876// TODO: no intrinsics for these?
Dan Gohman91888f02007-07-31 20:11:57 +0000877def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), "prefetcht0\t$src", []>;
878def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src), "prefetcht1\t$src", []>;
879def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src), "prefetcht2\t$src", []>;
880def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src), "prefetchnta\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881
882// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000883def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000884 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
886
887// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +0000888def SFENCE : PSI<0xAE, MRM7m, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889
890// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000891def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000892 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000893def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000894 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895
896// Alias instructions that map zero vector to pxor / xorp* for sse.
897// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
898let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000899def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000900 "xorps\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901 [(set VR128:$dst, (v4f32 immAllZerosV))]>;
902
903// FR32 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +0000904def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$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 FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000908def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000909 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910 [(set VR128:$dst,
911 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
912
913// FIXME: may not be able to eliminate this movss with coalescing the src and
914// dest register classes are different. We really want to write this pattern
915// like this:
916// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
917// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +0000918def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000919 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
921 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000922def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000923 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 [(store (f32 (vector_extract (v4f32 VR128:$src),
925 (iPTR 0))), addr:$dst)]>;
926
927
928// Move to lower bits of a VR128, leaving upper bits alone.
929// Three operand (but two address) aliases.
930let isTwoAddress = 1 in {
931 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000932 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000933 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934
935 let AddedComplexity = 15 in
936 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000937 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 [(set VR128:$dst,
940 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
941 MOVL_shuffle_mask)))]>;
942}
943
944// Move to lower bits of a VR128 and zeroing upper bits.
945// Loading from memory automatically zeroing upper bits.
946let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +0000947def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000948 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 [(set VR128:$dst, (v4f32 (vector_shuffle immAllZerosV,
950 (v4f32 (scalar_to_vector (loadf32 addr:$src))),
951 MOVL_shuffle_mask)))]>;
952
953
954//===----------------------------------------------------------------------===//
955// SSE2 Instructions
956//===----------------------------------------------------------------------===//
957
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000959def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000960 "movsd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000961let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000962def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000963 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000965def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000966 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 [(store FR64:$src, addr:$dst)]>;
968
969// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000970def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000971 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000973def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000974 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000976def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000977 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000979def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000980 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000982def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000983 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000985def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000986 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
988
989// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +0000990def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$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, (fextend FR32:$src))]>, XS,
993 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000994def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000995 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
997 Requires<[HasSSE2]>;
998
999// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001000def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001001 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001003def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001004 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1006 (load addr:$src)))]>;
1007
1008// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001009def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$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,
1012 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001013def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001014 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1016 (load addr:$src)))]>;
1017
1018// Comparison instructions
1019let isTwoAddress = 1 in {
1020 def CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001021 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001022 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 def CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001024 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001025 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026}
1027
Evan Chengb783fa32007-07-19 01:14:50 +00001028def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001029 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030 [(X86cmp FR64:$src1, FR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001031def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001032 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 [(X86cmp FR64:$src1, (loadf64 addr:$src2))]>;
1034
1035// Aliases to match intrinsics which expect XMM operand(s).
1036let isTwoAddress = 1 in {
1037 def Int_CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001038 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001039 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1041 VR128:$src, imm:$cc))]>;
1042 def Int_CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001043 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001044 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1046 (load addr:$src), imm:$cc))]>;
1047}
1048
Evan Chengb783fa32007-07-19 01:14:50 +00001049def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001050 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001051 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001052def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001053 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2))]>;
1055
Evan Chengb783fa32007-07-19 01:14:50 +00001056def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001057 "comisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001059def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001060 "comisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 [(X86comi (v2f64 VR128:$src1), (load addr:$src2))]>;
1062
1063// Aliases of packed SSE2 instructions for scalar use. These all have names that
1064// start with 'Fs'.
1065
1066// Alias instructions that map fld0 to pxor for sse.
Dan Gohman8aef09b2007-09-07 21:32:51 +00001067let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001068def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001069 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070 Requires<[HasSSE2]>, TB, OpSize;
1071
1072// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1073// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +00001074def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001075 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076
1077// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1078// disregarded.
Evan Cheng4e84e452007-08-30 05:49:43 +00001079let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001080def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001081 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001082 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083
1084// Alias bitwise logical operations using SSE logical ops on packed FP values.
1085let isTwoAddress = 1 in {
1086let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001087 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001088 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001090 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001091 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001093 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001094 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1096}
1097
Evan Chengb783fa32007-07-19 01:14:50 +00001098def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001099 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001101 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001102def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001103 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001105 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001106def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001109 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110
1111def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001112 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001113 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001114def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001115 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001116 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117}
1118
1119/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1120///
1121/// In addition, we also have a special variant of the scalar form here to
1122/// represent the associated intrinsic operation. This form is unlike the
1123/// plain scalar form, in that it takes an entire vector (instead of a scalar)
1124/// and leaves the top elements undefined.
1125///
1126/// These three forms can each be reg+reg or reg+mem, so there are a total of
1127/// six "instructions".
1128///
1129let isTwoAddress = 1 in {
1130multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1131 SDNode OpNode, Intrinsic F64Int,
1132 bit Commutable = 0> {
1133 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001134 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001135 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1137 let isCommutable = Commutable;
1138 }
1139
1140 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001141 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001142 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1144
1145 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001146 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001147 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1149 let isCommutable = Commutable;
1150 }
1151
1152 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001153 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001154 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001155 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156
1157 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001158 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001159 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1161 let isCommutable = Commutable;
1162 }
1163
1164 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001165 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001166 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001167 [(set VR128:$dst, (F64Int VR128:$src1,
1168 sse_load_f64:$src2))]>;
1169}
1170}
1171
1172// Arithmetic instructions
1173defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1174defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1175defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1176defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1177
1178/// sse2_fp_binop_rm - Other SSE2 binops
1179///
1180/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1181/// instructions for a full-vector intrinsic form. Operations that map
1182/// onto C operators don't use this form since they just use the plain
1183/// vector form instead of having a separate vector intrinsic form.
1184///
1185/// This provides a total of eight "instructions".
1186///
1187let isTwoAddress = 1 in {
1188multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1189 SDNode OpNode,
1190 Intrinsic F64Int,
1191 Intrinsic V2F64Int,
1192 bit Commutable = 0> {
1193
1194 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001195 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001196 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1198 let isCommutable = Commutable;
1199 }
1200
1201 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001202 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001203 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1205
1206 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001207 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001208 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1210 let isCommutable = Commutable;
1211 }
1212
1213 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001214 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001215 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001216 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217
1218 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001219 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001220 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001221 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1222 let isCommutable = Commutable;
1223 }
1224
1225 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001226 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001227 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 [(set VR128:$dst, (F64Int VR128:$src1,
1229 sse_load_f64:$src2))]>;
1230
1231 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001232 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001233 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1235 let isCommutable = Commutable;
1236 }
1237
1238 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +00001239 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001240 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 [(set VR128:$dst, (V2F64Int VR128:$src1, (load addr:$src2)))]>;
1242}
1243}
1244
1245defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1246 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1247defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1248 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1249
1250//===----------------------------------------------------------------------===//
1251// SSE packed FP Instructions
1252
1253// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001254def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001255 "movapd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001256let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001257def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001258 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001259 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260
Evan Chengb783fa32007-07-19 01:14:50 +00001261def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001263 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264
Evan Chengb783fa32007-07-19 01:14:50 +00001265def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001266 "movupd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001267let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001268def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001269 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001270 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001271def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001272 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001273 [(store (v2f64 VR128:$src), addr:$dst)]>;
1274
1275// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001276def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001277 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001278 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001279def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001281 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282
1283let isTwoAddress = 1 in {
1284 let AddedComplexity = 20 in {
1285 def MOVLPDrm : PDI<0x12, 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 "movlpd\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 MOVLP_shuffle_mask)))]>;
1292 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001293 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001294 "movhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 [(set VR128:$dst,
1296 (v2f64 (vector_shuffle VR128:$src1,
1297 (scalar_to_vector (loadf64 addr:$src2)),
1298 MOVHP_shuffle_mask)))]>;
1299 } // AddedComplexity
1300} // isTwoAddress
1301
Evan Chengb783fa32007-07-19 01:14:50 +00001302def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001303 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304 [(store (f64 (vector_extract (v2f64 VR128:$src),
1305 (iPTR 0))), addr:$dst)]>;
1306
1307// v2f64 extract element 1 is always custom lowered to unpack high to low
1308// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001309def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001310 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311 [(store (f64 (vector_extract
1312 (v2f64 (vector_shuffle VR128:$src, (undef),
1313 UNPCKH_shuffle_mask)), (iPTR 0))),
1314 addr:$dst)]>;
1315
1316// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001317def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001318 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1320 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001321def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001322 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
Dan Gohman4a4f1512007-07-18 20:23:34 +00001324 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325 TB, Requires<[HasSSE2]>;
1326
1327// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001328def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001329 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1331 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001332def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001333 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
Dan Gohman4a4f1512007-07-18 20:23:34 +00001335 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336 XS, Requires<[HasSSE2]>;
1337
Evan Chengb783fa32007-07-19 01:14:50 +00001338def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001339 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001341def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001342 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1344 (load addr:$src)))]>;
1345// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001346def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001347 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1349 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001350def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001351 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1353 (load addr:$src)))]>,
1354 XS, Requires<[HasSSE2]>;
1355
1356// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001357def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001358 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1360 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001361def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001362 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1364 (load addr:$src)))]>,
1365 XD, Requires<[HasSSE2]>;
1366
Evan Chengb783fa32007-07-19 01:14:50 +00001367def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001368 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001370def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001371 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1373 (load addr:$src)))]>;
1374
1375// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001376def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001377 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1379 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001380def Int_CVTPS2PDrm : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001381 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001382 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1383 (load addr:$src)))]>,
1384 TB, Requires<[HasSSE2]>;
1385
Evan Chengb783fa32007-07-19 01:14:50 +00001386def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001387 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001388 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001389def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001390 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001391 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1392 (load addr:$src)))]>;
1393
1394// Match intrinsics which expect XMM operand(s).
1395// Aliases for intrinsics
1396let isTwoAddress = 1 in {
1397def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001398 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001399 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1401 GR32:$src2))]>;
1402def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001403 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001404 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001405 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1406 (loadi32 addr:$src2)))]>;
1407def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001408 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001409 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1411 VR128:$src2))]>;
1412def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001413 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001414 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001415 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1416 (load addr:$src2)))]>;
1417def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001418 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001419 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001420 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1421 VR128:$src2))]>, XS,
1422 Requires<[HasSSE2]>;
1423def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001424 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1427 (load addr:$src2)))]>, XS,
1428 Requires<[HasSSE2]>;
1429}
1430
1431// Arithmetic
1432
1433/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1434///
1435/// In addition, we also have a special variant of the scalar form here to
1436/// represent the associated intrinsic operation. This form is unlike the
1437/// plain scalar form, in that it takes an entire vector (instead of a
1438/// scalar) and leaves the top elements undefined.
1439///
1440/// And, we have a special variant form for a full-vector intrinsic form.
1441///
1442/// These four forms can each have a reg or a mem operand, so there are a
1443/// total of eight "instructions".
1444///
1445multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1446 SDNode OpNode,
1447 Intrinsic F64Int,
1448 Intrinsic V2F64Int,
1449 bit Commutable = 0> {
1450 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001451 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$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 FR64:$src))]> {
1454 let isCommutable = Commutable;
1455 }
1456
1457 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001458 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001459 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001460 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1461
1462 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001463 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001465 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1466 let isCommutable = Commutable;
1467 }
1468
1469 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001470 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001471 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001472 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473
1474 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001475 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$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 VR128:$src))]> {
1478 let isCommutable = Commutable;
1479 }
1480
1481 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001482 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001483 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001484 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1485
1486 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001487 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$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 VR128:$src))]> {
1490 let isCommutable = Commutable;
1491 }
1492
1493 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001494 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001495 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001496 [(set VR128:$dst, (V2F64Int (load addr:$src)))]>;
1497}
1498
1499// Square root.
1500defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1501 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1502
1503// There is no f64 version of the reciprocal approximation instructions.
1504
1505// Logical
1506let isTwoAddress = 1 in {
1507 let isCommutable = 1 in {
1508 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001509 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001510 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511 [(set VR128:$dst,
1512 (and (bc_v2i64 (v2f64 VR128:$src1)),
1513 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1514 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001515 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517 [(set VR128:$dst,
1518 (or (bc_v2i64 (v2f64 VR128:$src1)),
1519 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1520 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001521 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001523 [(set VR128:$dst,
1524 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1525 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1526 }
1527
1528 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001529 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531 [(set VR128:$dst,
1532 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001533 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001534 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001535 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537 [(set VR128:$dst,
1538 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001539 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001541 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543 [(set VR128:$dst,
1544 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001545 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001547 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549 [(set VR128:$dst,
1550 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1551 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1552 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001553 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001554 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001555 [(set VR128:$dst,
1556 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001557 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558}
1559
1560let isTwoAddress = 1 in {
1561 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001562 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001563 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1565 VR128:$src, imm:$cc))]>;
1566 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001567 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001568 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1570 (load addr:$src), imm:$cc))]>;
1571}
1572
1573// Shuffle and unpack instructions
1574let isTwoAddress = 1 in {
1575 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001576 (outs VR128:$dst), (ins VR128:$src1, VR128:$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, (v2f64 (vector_shuffle
1579 VR128:$src1, VR128:$src2,
1580 SHUFP_shuffle_mask:$src3)))]>;
1581 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001582 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001584 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001585 [(set VR128:$dst,
1586 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001587 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001588 SHUFP_shuffle_mask:$src3)))]>;
1589
1590 let AddedComplexity = 10 in {
1591 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001592 (outs VR128:$dst), (ins VR128:$src1, VR128:$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
1596 VR128:$src1, VR128:$src2,
1597 UNPCKH_shuffle_mask)))]>;
1598 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001599 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601 [(set VR128:$dst,
1602 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001603 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001604 UNPCKH_shuffle_mask)))]>;
1605
1606 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001607 (outs VR128:$dst), (ins VR128:$src1, VR128:$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
1611 VR128:$src1, VR128:$src2,
1612 UNPCKL_shuffle_mask)))]>;
1613 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001614 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001615 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001616 [(set VR128:$dst,
1617 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001618 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001619 UNPCKL_shuffle_mask)))]>;
1620 } // AddedComplexity
1621} // isTwoAddress
1622
1623
1624//===----------------------------------------------------------------------===//
1625// SSE integer instructions
1626
1627// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001628def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001629 "movdqa\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001630let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001631def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001632 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001633 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001634def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001635 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001636 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001637let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001638def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001639 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001640 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001642def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001643 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001644 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645 XS, Requires<[HasSSE2]>;
1646
Dan Gohman4a4f1512007-07-18 20:23:34 +00001647// Intrinsic forms of MOVDQU load and store
Evan Cheng4e84e452007-08-30 05:49:43 +00001648let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001649def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001650 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001651 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1652 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001653def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001654 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001655 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1656 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001657
1658let isTwoAddress = 1 in {
1659
1660multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1661 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001662 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001664 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1665 let isCommutable = Commutable;
1666 }
Evan Chengb783fa32007-07-19 01:14:50 +00001667 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001668 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001669 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001670 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001671}
1672
1673multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1674 string OpcodeStr, Intrinsic IntId> {
Evan Chengb783fa32007-07-19 01:14:50 +00001675 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001676 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001678 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001679 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001680 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001681 (bitconvert (memopv2i64 addr:$src2))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001682 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$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, (IntId VR128:$src1,
1685 (scalar_to_vector (i32 imm:$src2))))]>;
1686}
1687
1688
1689/// PDI_binop_rm - Simple SSE2 binary operator.
1690multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1691 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001692 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001693 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001694 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1695 let isCommutable = Commutable;
1696 }
Evan Chengb783fa32007-07-19 01:14:50 +00001697 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001700 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701}
1702
1703/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1704///
1705/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1706/// to collapse (bitconvert VT to VT) into its operand.
1707///
1708multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1709 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001710 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1713 let isCommutable = Commutable;
1714 }
Evan Chengb783fa32007-07-19 01:14:50 +00001715 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001717 [(set VR128:$dst, (OpNode VR128:$src1,(memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001718}
1719
1720} // isTwoAddress
1721
1722// 128-bit Integer Arithmetic
1723
1724defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1725defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1726defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1727defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1728
1729defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1730defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1731defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1732defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1733
1734defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1735defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1736defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1737defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1738
1739defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1740defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1741defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1742defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1743
1744defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1745
1746defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1747defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1748defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1749
1750defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1751
1752defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1753defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1754
1755
1756defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1757defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1758defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1759defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1760defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>;
1761
1762
1763defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", int_x86_sse2_psll_w>;
1764defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", int_x86_sse2_psll_d>;
1765defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", int_x86_sse2_psll_q>;
1766
1767defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", int_x86_sse2_psrl_w>;
1768defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", int_x86_sse2_psrl_d>;
1769defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq", int_x86_sse2_psrl_q>;
1770
1771defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", int_x86_sse2_psra_w>;
1772defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad", int_x86_sse2_psra_d>;
1773// PSRAQ doesn't exist in SSE[1-3].
1774
1775// 128-bit logical shifts.
1776let isTwoAddress = 1 in {
1777 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001778 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001779 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001780 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001781 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001782 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783 // PSRADQri doesn't exist in SSE[1-3].
1784}
1785
1786let Predicates = [HasSSE2] in {
1787 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1788 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1789 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1790 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1791 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1792 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1793}
1794
1795// Logical
1796defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1797defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1798defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1799
1800let isTwoAddress = 1 in {
1801 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001802 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001803 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001804 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1805 VR128:$src2)))]>;
1806
1807 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001808 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00001811 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812}
1813
1814// SSE2 Integer comparison
1815defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1816defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
1817defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
1818defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
1819defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
1820defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
1821
1822// Pack instructions
1823defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
1824defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
1825defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
1826
1827// Shuffle and unpack instructions
1828def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001829 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001830 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001831 [(set VR128:$dst, (v4i32 (vector_shuffle
1832 VR128:$src1, (undef),
1833 PSHUFD_shuffle_mask:$src2)))]>;
1834def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001835 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 [(set VR128:$dst, (v4i32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001838 (bc_v4i32(memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001839 (undef),
1840 PSHUFD_shuffle_mask:$src2)))]>;
1841
1842// SSE2 with ImmT == Imm8 and XS prefix.
1843def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001844 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001845 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001846 [(set VR128:$dst, (v8i16 (vector_shuffle
1847 VR128:$src1, (undef),
1848 PSHUFHW_shuffle_mask:$src2)))]>,
1849 XS, Requires<[HasSSE2]>;
1850def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001851 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001853 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001854 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855 (undef),
1856 PSHUFHW_shuffle_mask:$src2)))]>,
1857 XS, Requires<[HasSSE2]>;
1858
1859// SSE2 with ImmT == Imm8 and XD prefix.
1860def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001861 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001862 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001863 [(set VR128:$dst, (v8i16 (vector_shuffle
1864 VR128:$src1, (undef),
1865 PSHUFLW_shuffle_mask:$src2)))]>,
1866 XD, Requires<[HasSSE2]>;
1867def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001868 (outs VR128:$dst), (ins i128mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001869 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001871 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 (undef),
1873 PSHUFLW_shuffle_mask:$src2)))]>,
1874 XD, Requires<[HasSSE2]>;
1875
1876
1877let isTwoAddress = 1 in {
1878 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001879 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001881 [(set VR128:$dst,
1882 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1883 UNPCKL_shuffle_mask)))]>;
1884 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001885 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001886 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001887 [(set VR128:$dst,
1888 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001889 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890 UNPCKL_shuffle_mask)))]>;
1891 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001892 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894 [(set VR128:$dst,
1895 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1896 UNPCKL_shuffle_mask)))]>;
1897 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001898 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900 [(set VR128:$dst,
1901 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001902 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 UNPCKL_shuffle_mask)))]>;
1904 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001905 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(set VR128:$dst,
1908 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1909 UNPCKL_shuffle_mask)))]>;
1910 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001911 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(set VR128:$dst,
1914 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001915 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916 UNPCKL_shuffle_mask)))]>;
1917 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001918 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001920 [(set VR128:$dst,
1921 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1922 UNPCKL_shuffle_mask)))]>;
1923 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001924 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(set VR128:$dst,
1927 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001928 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 UNPCKL_shuffle_mask)))]>;
1930
1931 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001932 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001934 [(set VR128:$dst,
1935 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1936 UNPCKH_shuffle_mask)))]>;
1937 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001938 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001939 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001940 [(set VR128:$dst,
1941 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001942 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 UNPCKH_shuffle_mask)))]>;
1944 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001945 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 [(set VR128:$dst,
1948 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1949 UNPCKH_shuffle_mask)))]>;
1950 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001951 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001953 [(set VR128:$dst,
1954 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001955 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 UNPCKH_shuffle_mask)))]>;
1957 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001958 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(set VR128:$dst,
1961 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1962 UNPCKH_shuffle_mask)))]>;
1963 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001964 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001965 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001966 [(set VR128:$dst,
1967 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001968 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 UNPCKH_shuffle_mask)))]>;
1970 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001971 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 [(set VR128:$dst,
1974 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1975 UNPCKH_shuffle_mask)))]>;
1976 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001977 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001979 [(set VR128:$dst,
1980 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001981 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001982 UNPCKH_shuffle_mask)))]>;
1983}
1984
1985// Extract / Insert
1986def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001987 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001988 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001989 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
1990 (iPTR imm:$src2)))]>;
1991let isTwoAddress = 1 in {
1992 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001993 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(set VR128:$dst,
1997 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
1998 GR32:$src2, (iPTR imm:$src3))))]>;
1999 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002000 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002002 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002003 [(set VR128:$dst,
2004 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
2005 (i32 (anyext (loadi16 addr:$src2))),
2006 (iPTR imm:$src3))))]>;
2007}
2008
2009// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002010def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002011 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002012 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2013
2014// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002015let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002016def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002017 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002018 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019
2020// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002021def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002024def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002025 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002026 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002027def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002028 "movnti\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2030 TB, Requires<[HasSSE2]>;
2031
2032// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002033def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002034 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035 TB, Requires<[HasSSE2]>;
2036
2037// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +00002038def LFENCE : I<0xAE, MRM5m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002040def MFENCE : I<0xAE, MRM6m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2042
2043
2044// Alias instructions that map zero vector to pxor / xorp* for sse.
2045// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2046let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002047 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002048 "pcmpeqd\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 [(set VR128:$dst, (v2f64 immAllOnesV))]>;
2050
2051// FR64 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +00002052def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002053 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002054 [(set VR128:$dst,
2055 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002056def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002057 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058 [(set VR128:$dst,
2059 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2060
Evan Chengb783fa32007-07-19 01:14:50 +00002061def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002062 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002063 [(set VR128:$dst,
2064 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002065def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(set VR128:$dst,
2068 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2069
Evan Chengb783fa32007-07-19 01:14:50 +00002070def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002071 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2073
Evan Chengb783fa32007-07-19 01:14:50 +00002074def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002075 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2077
2078// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002079def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081 [(set VR128:$dst,
2082 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2083 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002084def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002086 [(store (i64 (vector_extract (v2i64 VR128:$src),
2087 (iPTR 0))), addr:$dst)]>;
2088
2089// FIXME: may not be able to eliminate this movss with coalescing the src and
2090// dest register classes are different. We really want to write this pattern
2091// like this:
2092// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2093// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +00002094def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002095 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2097 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002098def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002099 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002100 [(store (f64 (vector_extract (v2f64 VR128:$src),
2101 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002102def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002103 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2105 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002106def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002107 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002108 [(store (i32 (vector_extract (v4i32 VR128:$src),
2109 (iPTR 0))), addr:$dst)]>;
2110
Evan Chengb783fa32007-07-19 01:14:50 +00002111def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002112 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002114def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002115 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002116 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2117
2118
2119// Move to lower bits of a VR128, leaving upper bits alone.
2120// Three operand (but two address) aliases.
2121let isTwoAddress = 1 in {
2122 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002123 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002124 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002125
2126 let AddedComplexity = 15 in
2127 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002128 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002129 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130 [(set VR128:$dst,
2131 (v2f64 (vector_shuffle VR128:$src1, VR128:$src2,
2132 MOVL_shuffle_mask)))]>;
2133}
2134
2135// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002136def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002137 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2139
2140// Move to lower bits of a VR128 and zeroing upper bits.
2141// Loading from memory automatically zeroing upper bits.
2142let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002143 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002144 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002145 [(set VR128:$dst,
2146 (v2f64 (vector_shuffle immAllZerosV,
2147 (v2f64 (scalar_to_vector
2148 (loadf64 addr:$src))),
2149 MOVL_shuffle_mask)))]>;
2150
2151let AddedComplexity = 15 in
2152// movd / movq to XMM register zero-extends
Evan Chengb783fa32007-07-19 01:14:50 +00002153def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155 [(set VR128:$dst,
2156 (v4i32 (vector_shuffle immAllZerosV,
2157 (v4i32 (scalar_to_vector GR32:$src)),
2158 MOVL_shuffle_mask)))]>;
2159let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002160def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002161 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002162 [(set VR128:$dst,
2163 (v4i32 (vector_shuffle immAllZerosV,
2164 (v4i32 (scalar_to_vector (loadi32 addr:$src))),
2165 MOVL_shuffle_mask)))]>;
2166
2167// Moving from XMM to XMM but still clear upper 64 bits.
2168let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002169def MOVZQI2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002170 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171 [(set VR128:$dst, (int_x86_sse2_movl_dq VR128:$src))]>,
2172 XS, Requires<[HasSSE2]>;
2173let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002174def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002175 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002176 [(set VR128:$dst, (int_x86_sse2_movl_dq
Dan Gohman4a4f1512007-07-18 20:23:34 +00002177 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002178 XS, Requires<[HasSSE2]>;
2179
2180
2181//===----------------------------------------------------------------------===//
2182// SSE3 Instructions
2183//===----------------------------------------------------------------------===//
2184
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002185// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002186def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188 [(set VR128:$dst, (v4f32 (vector_shuffle
2189 VR128:$src, (undef),
2190 MOVSHDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002191def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002192 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002194 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002195 MOVSHDUP_shuffle_mask)))]>;
2196
Evan Chengb783fa32007-07-19 01:14:50 +00002197def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002198 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002199 [(set VR128:$dst, (v4f32 (vector_shuffle
2200 VR128:$src, (undef),
2201 MOVSLDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002202def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002205 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 MOVSLDUP_shuffle_mask)))]>;
2207
Evan Chengb783fa32007-07-19 01:14:50 +00002208def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210 [(set VR128:$dst, (v2f64 (vector_shuffle
2211 VR128:$src, (undef),
2212 SSE_splat_lo_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002213def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002214 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002215 [(set VR128:$dst,
2216 (v2f64 (vector_shuffle
2217 (scalar_to_vector (loadf64 addr:$src)),
2218 (undef),
2219 SSE_splat_lo_mask)))]>;
2220
2221// Arithmetic
2222let isTwoAddress = 1 in {
2223 def ADDSUBPSrr : S3DI<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 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2227 VR128:$src2))]>;
2228 def ADDSUBPSrm : S3DI<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 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2232 (load addr:$src2)))]>;
2233 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002234 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002235 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2237 VR128:$src2))]>;
2238 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002239 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002241 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2242 (load addr:$src2)))]>;
2243}
2244
Evan Chengb783fa32007-07-19 01:14:50 +00002245def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2248
2249// Horizontal ops
2250class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002251 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002253 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2254class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002255 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (load addr:$src2))))]>;
2258class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002259 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2262class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002263 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002264 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002265 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (load addr:$src2))))]>;
2266
2267let isTwoAddress = 1 in {
2268 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2269 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2270 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2271 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2272 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2273 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2274 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2275 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2276}
2277
2278// Thread synchronization
Evan Chengb783fa32007-07-19 01:14:50 +00002279def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002281def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2283
2284// vector_shuffle v1, <undef> <1, 1, 3, 3>
2285let AddedComplexity = 15 in
2286def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2287 MOVSHDUP_shuffle_mask)),
2288 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2289let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002290def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291 MOVSHDUP_shuffle_mask)),
2292 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2293
2294// vector_shuffle v1, <undef> <0, 0, 2, 2>
2295let AddedComplexity = 15 in
2296 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2297 MOVSLDUP_shuffle_mask)),
2298 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2299let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002300 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002301 MOVSLDUP_shuffle_mask)),
2302 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2303
2304//===----------------------------------------------------------------------===//
2305// SSSE3 Instructions
2306//===----------------------------------------------------------------------===//
2307
Bill Wendling3b15d722007-08-11 09:52:53 +00002308// SSSE3 Instruction Templates:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002309//
Bill Wendling98680292007-08-10 06:22:27 +00002310// SS38I - SSSE3 instructions with T8 prefix.
2311// SS3AI - SSSE3 instructions with TA prefix.
Bill Wendling3b15d722007-08-11 09:52:53 +00002312//
2313// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
2314// uses the MMX registers. We put those instructions here because they better
2315// fit into the SSSE3 instruction category rather than the MMX category.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002316
Evan Chengb783fa32007-07-19 01:14:50 +00002317class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
2318 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002319 : I<o, F, outs, ins, asm, pattern>, T8, Requires<[HasSSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002320class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
2321 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002322 : I<o, F, outs, ins, asm, pattern>, TA, Requires<[HasSSSE3]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323
Bill Wendling98680292007-08-10 06:22:27 +00002324/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002325let isTwoAddress = 1 in {
Bill Wendling98680292007-08-10 06:22:27 +00002326 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2327 Intrinsic IntId64, Intrinsic IntId128,
2328 bit Commutable = 0> {
2329 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2330 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2331 [(set VR64:$dst, (IntId64 VR64:$src))]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002332 let isCommutable = Commutable;
2333 }
Bill Wendling98680292007-08-10 06:22:27 +00002334 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2335 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2336 [(set VR64:$dst,
2337 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2338
2339 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2340 (ins VR128:$src),
2341 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2342 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2343 OpSize {
2344 let isCommutable = Commutable;
2345 }
2346 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2347 (ins i128mem:$src),
2348 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2349 [(set VR128:$dst,
2350 (IntId128
2351 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002352 }
2353}
2354
Bill Wendling98680292007-08-10 06:22:27 +00002355/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2356let isTwoAddress = 1 in {
2357 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2358 Intrinsic IntId64, Intrinsic IntId128,
2359 bit Commutable = 0> {
2360 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2361 (ins VR64:$src),
2362 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2363 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2364 let isCommutable = Commutable;
2365 }
2366 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2367 (ins i64mem:$src),
2368 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2369 [(set VR64:$dst,
2370 (IntId64
2371 (bitconvert (memopv4i16 addr:$src))))]>;
2372
2373 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2374 (ins VR128:$src),
2375 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2376 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2377 OpSize {
2378 let isCommutable = Commutable;
2379 }
2380 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2381 (ins i128mem:$src),
2382 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2383 [(set VR128:$dst,
2384 (IntId128
2385 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2386 }
2387}
2388
2389/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2390let isTwoAddress = 1 in {
2391 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2392 Intrinsic IntId64, Intrinsic IntId128,
2393 bit Commutable = 0> {
2394 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2395 (ins VR64:$src),
2396 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2397 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2398 let isCommutable = Commutable;
2399 }
2400 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2401 (ins i64mem:$src),
2402 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2403 [(set VR64:$dst,
2404 (IntId64
2405 (bitconvert (memopv2i32 addr:$src))))]>;
2406
2407 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2408 (ins VR128:$src),
2409 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2410 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2411 OpSize {
2412 let isCommutable = Commutable;
2413 }
2414 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2415 (ins i128mem:$src),
2416 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2417 [(set VR128:$dst,
2418 (IntId128
2419 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2420 }
2421}
2422
2423defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2424 int_x86_ssse3_pabs_b,
2425 int_x86_ssse3_pabs_b_128>;
2426defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2427 int_x86_ssse3_pabs_w,
2428 int_x86_ssse3_pabs_w_128>;
2429defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2430 int_x86_ssse3_pabs_d,
2431 int_x86_ssse3_pabs_d_128>;
2432
2433/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2434let isTwoAddress = 1 in {
2435 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2436 Intrinsic IntId64, Intrinsic IntId128,
2437 bit Commutable = 0> {
2438 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2439 (ins VR64:$src1, VR64:$src2),
2440 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2441 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2442 let isCommutable = Commutable;
2443 }
2444 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2445 (ins VR64:$src1, i64mem:$src2),
2446 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2447 [(set VR64:$dst,
2448 (IntId64 VR64:$src1,
2449 (bitconvert (memopv8i8 addr:$src2))))]>;
2450
2451 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2452 (ins VR128:$src1, VR128:$src2),
2453 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2454 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2455 OpSize {
2456 let isCommutable = Commutable;
2457 }
2458 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2459 (ins VR128:$src1, i128mem:$src2),
2460 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2461 [(set VR128:$dst,
2462 (IntId128 VR128:$src1,
2463 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2464 }
2465}
2466
2467/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2468let isTwoAddress = 1 in {
2469 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2470 Intrinsic IntId64, Intrinsic IntId128,
2471 bit Commutable = 0> {
2472 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2473 (ins VR64:$src1, VR64:$src2),
2474 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2475 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2476 let isCommutable = Commutable;
2477 }
2478 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2479 (ins VR64:$src1, i64mem:$src2),
2480 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2481 [(set VR64:$dst,
2482 (IntId64 VR64:$src1,
2483 (bitconvert (memopv4i16 addr:$src2))))]>;
2484
2485 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2486 (ins VR128:$src1, VR128:$src2),
2487 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2488 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2489 OpSize {
2490 let isCommutable = Commutable;
2491 }
2492 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2493 (ins VR128:$src1, i128mem:$src2),
2494 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2495 [(set VR128:$dst,
2496 (IntId128 VR128:$src1,
2497 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2498 }
2499}
2500
2501/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2502let isTwoAddress = 1 in {
2503 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2504 Intrinsic IntId64, Intrinsic IntId128,
2505 bit Commutable = 0> {
2506 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2507 (ins VR64:$src1, VR64:$src2),
2508 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2509 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2510 let isCommutable = Commutable;
2511 }
2512 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2513 (ins VR64:$src1, i64mem:$src2),
2514 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2515 [(set VR64:$dst,
2516 (IntId64 VR64:$src1,
2517 (bitconvert (memopv2i32 addr:$src2))))]>;
2518
2519 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2520 (ins VR128:$src1, VR128:$src2),
2521 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2522 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2523 OpSize {
2524 let isCommutable = Commutable;
2525 }
2526 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2527 (ins VR128:$src1, i128mem:$src2),
2528 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2529 [(set VR128:$dst,
2530 (IntId128 VR128:$src1,
2531 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2532 }
2533}
2534
2535defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2536 int_x86_ssse3_phadd_w,
2537 int_x86_ssse3_phadd_w_128, 1>;
2538defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2539 int_x86_ssse3_phadd_d,
2540 int_x86_ssse3_phadd_d_128, 1>;
2541defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2542 int_x86_ssse3_phadd_sw,
2543 int_x86_ssse3_phadd_sw_128, 1>;
2544defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2545 int_x86_ssse3_phsub_w,
2546 int_x86_ssse3_phsub_w_128>;
2547defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2548 int_x86_ssse3_phsub_d,
2549 int_x86_ssse3_phsub_d_128>;
2550defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2551 int_x86_ssse3_phsub_sw,
2552 int_x86_ssse3_phsub_sw_128>;
2553defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2554 int_x86_ssse3_pmadd_ub_sw,
2555 int_x86_ssse3_pmadd_ub_sw_128, 1>;
2556defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2557 int_x86_ssse3_pmul_hr_sw,
2558 int_x86_ssse3_pmul_hr_sw_128, 1>;
2559defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2560 int_x86_ssse3_pshuf_b,
2561 int_x86_ssse3_pshuf_b_128>;
2562defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2563 int_x86_ssse3_psign_b,
2564 int_x86_ssse3_psign_b_128>;
2565defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2566 int_x86_ssse3_psign_w,
2567 int_x86_ssse3_psign_w_128>;
2568defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2569 int_x86_ssse3_psign_d,
2570 int_x86_ssse3_psign_d_128>;
2571
2572let isTwoAddress = 1 in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002573 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2574 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
2575 "palignr\t{$src2, $dst|$dst, $src2}",
2576 [(set VR64:$dst,
2577 (int_x86_ssse3_palign_r
2578 VR64:$src1, VR64:$src2,
2579 imm:$src3))]>;
2580 def PALIGNR64rm : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2581 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
2582 "palignr\t{$src2, $dst|$dst, $src2}",
2583 [(set VR64:$dst,
2584 (int_x86_ssse3_palign_r
2585 VR64:$src1,
2586 (bitconvert (memopv2i32 addr:$src2)),
2587 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002588
Bill Wendling1dc817c2007-08-10 09:00:17 +00002589 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2590 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
2591 "palignr\t{$src2, $dst|$dst, $src2}",
2592 [(set VR128:$dst,
2593 (int_x86_ssse3_palign_r_128
2594 VR128:$src1, VR128:$src2,
2595 imm:$src3))]>, OpSize;
2596 def PALIGNR128rm : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2597 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
2598 "palignr\t{$src2, $dst|$dst, $src2}",
2599 [(set VR128:$dst,
2600 (int_x86_ssse3_palign_r_128
2601 VR128:$src1,
2602 (bitconvert (memopv4i32 addr:$src2)),
2603 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002604}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002605
2606//===----------------------------------------------------------------------===//
2607// Non-Instruction Patterns
2608//===----------------------------------------------------------------------===//
2609
2610// 128-bit vector undef's.
Bill Wendling1dc817c2007-08-10 09:00:17 +00002611def : Pat<(v4f32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002612def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2613def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2614def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2615def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2616def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2617
2618// 128-bit vector all zero's.
2619def : Pat<(v16i8 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2620def : Pat<(v8i16 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2621def : Pat<(v4i32 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2622def : Pat<(v2i64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2623def : Pat<(v2f64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2624
2625// 128-bit vector all one's.
2626def : Pat<(v16i8 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2627def : Pat<(v8i16 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2628def : Pat<(v4i32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2629def : Pat<(v2i64 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2630def : Pat<(v4f32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE1]>;
2631
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002632
2633// Scalar to v8i16 / v16i8. The source may be a GR32, but only the lower 8 or
2634// 16-bits matter.
2635def : Pat<(v8i16 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2636 Requires<[HasSSE2]>;
2637def : Pat<(v16i8 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2638 Requires<[HasSSE2]>;
2639
2640// bit_convert
2641let Predicates = [HasSSE2] in {
2642 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2643 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2644 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2645 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2646 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2647 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2648 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2649 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2650 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2651 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2652 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2653 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2654 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2655 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2656 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2657 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2658 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2659 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2660 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2661 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2662 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2663 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2664 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2665 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2666 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2667 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2668 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2669 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2670 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2671 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2672}
2673
2674// Move scalar to XMM zero-extended
2675// movd to XMM register zero-extends
2676let AddedComplexity = 15 in {
2677def : Pat<(v8i16 (vector_shuffle immAllZerosV,
2678 (v8i16 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2679 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2680def : Pat<(v16i8 (vector_shuffle immAllZerosV,
2681 (v16i8 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2682 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2683// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
2684def : Pat<(v2f64 (vector_shuffle immAllZerosV,
2685 (v2f64 (scalar_to_vector FR64:$src)), MOVL_shuffle_mask)),
2686 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
2687def : Pat<(v4f32 (vector_shuffle immAllZerosV,
2688 (v4f32 (scalar_to_vector FR32:$src)), MOVL_shuffle_mask)),
2689 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>;
2690}
2691
2692// Splat v2f64 / v2i64
2693let AddedComplexity = 10 in {
2694def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2695 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2696def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2697 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2698def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2699 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2700def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2701 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2702}
2703
2704// Splat v4f32
2705def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SSE_splat_mask:$sm),
2706 (SHUFPSrri VR128:$src, VR128:$src, SSE_splat_mask:$sm)>,
2707 Requires<[HasSSE1]>;
2708
2709// Special unary SHUFPSrri case.
2710// FIXME: when we want non two-address code, then we should use PSHUFD?
2711def : Pat<(vector_shuffle (v4f32 VR128:$src1), (undef),
2712 SHUFP_unary_shuffle_mask:$sm),
2713 (SHUFPSrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2714 Requires<[HasSSE1]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002715// Special unary SHUFPDrri case.
2716def : Pat<(vector_shuffle (v2f64 VR128:$src1), (undef),
2717 SHUFP_unary_shuffle_mask:$sm),
2718 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2719 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002720// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Dan Gohman4a4f1512007-07-18 20:23:34 +00002721def : Pat<(vector_shuffle (memopv4f32 addr:$src1), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002722 SHUFP_unary_shuffle_mask:$sm),
2723 (PSHUFDmi addr:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2724 Requires<[HasSSE2]>;
2725// Special binary v4i32 shuffle cases with SHUFPS.
2726def : Pat<(vector_shuffle (v4i32 VR128:$src1), (v4i32 VR128:$src2),
2727 PSHUFD_binary_shuffle_mask:$sm),
2728 (SHUFPSrri VR128:$src1, VR128:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2729 Requires<[HasSSE2]>;
2730def : Pat<(vector_shuffle (v4i32 VR128:$src1),
Dan Gohman4a4f1512007-07-18 20:23:34 +00002731 (bc_v4i32 (memopv2i64 addr:$src2)), PSHUFD_binary_shuffle_mask:$sm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002732 (SHUFPSrmi VR128:$src1, addr:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2733 Requires<[HasSSE2]>;
2734
2735// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2736let AddedComplexity = 10 in {
2737def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2738 UNPCKL_v_undef_shuffle_mask)),
2739 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2740def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2741 UNPCKL_v_undef_shuffle_mask)),
2742 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2743def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2744 UNPCKL_v_undef_shuffle_mask)),
2745 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2746def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2747 UNPCKL_v_undef_shuffle_mask)),
2748 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2749}
2750
2751// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2752let AddedComplexity = 10 in {
2753def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2754 UNPCKH_v_undef_shuffle_mask)),
2755 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2756def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2757 UNPCKH_v_undef_shuffle_mask)),
2758 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2759def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2760 UNPCKH_v_undef_shuffle_mask)),
2761 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2762def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2763 UNPCKH_v_undef_shuffle_mask)),
2764 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2765}
2766
2767let AddedComplexity = 15 in {
2768// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2769def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2770 MOVHP_shuffle_mask)),
2771 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2772
2773// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2774def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2775 MOVHLPS_shuffle_mask)),
2776 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2777
2778// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2779def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2780 MOVHLPS_v_undef_shuffle_mask)),
2781 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2782def : Pat<(v4i32 (vector_shuffle VR128:$src1, (undef),
2783 MOVHLPS_v_undef_shuffle_mask)),
2784 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2785}
2786
2787let AddedComplexity = 20 in {
2788// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2789// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Dan Gohman4a4f1512007-07-18 20:23:34 +00002790def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002791 MOVLP_shuffle_mask)),
2792 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002793def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002794 MOVLP_shuffle_mask)),
2795 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002796def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002797 MOVHP_shuffle_mask)),
2798 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002799def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002800 MOVHP_shuffle_mask)),
2801 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2802
Dan Gohman4a4f1512007-07-18 20:23:34 +00002803def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002804 MOVLP_shuffle_mask)),
2805 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002806def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002807 MOVLP_shuffle_mask)),
2808 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002809def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002810 MOVHP_shuffle_mask)),
2811 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002812def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002813 MOVLP_shuffle_mask)),
2814 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2815}
2816
2817let AddedComplexity = 15 in {
2818// Setting the lowest element in the vector.
2819def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2820 MOVL_shuffle_mask)),
2821 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2822def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2823 MOVL_shuffle_mask)),
2824 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2825
2826// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
2827def : Pat<(v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
2828 MOVLP_shuffle_mask)),
2829 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2830def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2831 MOVLP_shuffle_mask)),
2832 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2833}
2834
2835// Set lowest element and zero upper elements.
2836let AddedComplexity = 20 in
2837def : Pat<(bc_v2i64 (vector_shuffle immAllZerosV,
2838 (v2f64 (scalar_to_vector (loadf64 addr:$src))),
2839 MOVL_shuffle_mask)),
2840 (MOVZQI2PQIrm addr:$src)>, Requires<[HasSSE2]>;
2841
2842// FIXME: Temporary workaround since 2-wide shuffle is broken.
2843def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
2844 (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2845def : Pat<(int_x86_sse2_loadh_pd VR128:$src1, addr:$src2),
2846 (v2f64 (MOVHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2847def : Pat<(int_x86_sse2_loadl_pd VR128:$src1, addr:$src2),
2848 (v2f64 (MOVLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2849def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
2850 (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
2851 Requires<[HasSSE2]>;
2852def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (load addr:$src2), imm:$src3),
2853 (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
2854 Requires<[HasSSE2]>;
2855def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
2856 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2857def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (load addr:$src2)),
2858 (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2859def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
2860 (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2861def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (load addr:$src2)),
2862 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2863def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2),
2864 (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2865def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (load addr:$src2)),
2866 (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2867def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2),
2868 (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2869def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (load addr:$src2)),
2870 (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2871
2872// Some special case pandn patterns.
2873def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2874 VR128:$src2)),
2875 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2876def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
2877 VR128:$src2)),
2878 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2879def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
2880 VR128:$src2)),
2881 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2882
2883def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002884 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002885 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2886def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002887 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002888 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2889def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002890 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002891 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2892
Evan Cheng51a49b22007-07-20 00:27:43 +00002893// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00002894def : Pat<(alignedloadv4i32 addr:$src),
2895 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
2896def : Pat<(loadv4i32 addr:$src),
2897 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00002898def : Pat<(alignedloadv2i64 addr:$src),
2899 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
2900def : Pat<(loadv2i64 addr:$src),
2901 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
2902
2903def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
2904 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2905def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
2906 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2907def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
2908 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2909def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
2910 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2911def : Pat<(store (v2i64 VR128:$src), addr:$dst),
2912 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2913def : Pat<(store (v4i32 VR128:$src), addr:$dst),
2914 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2915def : Pat<(store (v8i16 VR128:$src), addr:$dst),
2916 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2917def : Pat<(store (v16i8 VR128:$src), addr:$dst),
2918 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Evan Cheng86ab7d32007-07-31 08:04:03 +00002919
2920// (vextract (v4i32 bc (v4f32 s2v (f32 load $addr))), 0) -> (i32 load $addr)
2921def : Pat<(vector_extract
2922 (bc_v4i32 (v4f32 (scalar_to_vector (loadf32 addr:$src)))), (iPTR 0)),
Evan Cheng43a09ac2007-08-01 21:42:24 +00002923 (MOV32rm addr:$src)>, Requires<[HasSSE2]>;
Evan Cheng86ab7d32007-07-31 08:04:03 +00002924def : Pat<(vector_extract
2925 (bc_v2i64 (v2f64 (scalar_to_vector (loadf64 addr:$src)))), (iPTR 0)),
Evan Cheng43a09ac2007-08-01 21:42:24 +00002926 (MOV64rm addr:$src)>, Requires<[HasSSE2, In64BitMode]>;