blob: 19b1a7d26628090f3053c2bf12ff63454b847fa4 [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.
Evan Chengb783fa32007-07-19 01:14:50 +0000402def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000403 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000404 Requires<[HasSSE1]>, TB, OpSize;
405
406// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
407// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +0000408def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000409 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410
411// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
412// disregarded.
Evan Cheng4e84e452007-08-30 05:49:43 +0000413let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000414def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000415 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000416 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417
418// Alias bitwise logical operations using SSE logical ops on packed FP values.
419let isTwoAddress = 1 in {
420let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000421 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000422 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000424 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000425 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000427 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000428 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000429 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
430}
431
Evan Chengb783fa32007-07-19 01:14:50 +0000432def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000433 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000435 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000436def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000437 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000438 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000439 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000440def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000441 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000443 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444
445def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000446 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000447 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000448def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000449 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000450 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000451}
452
453/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
454///
455/// In addition, we also have a special variant of the scalar form here to
456/// represent the associated intrinsic operation. This form is unlike the
457/// plain scalar form, in that it takes an entire vector (instead of a scalar)
458/// and leaves the top elements undefined.
459///
460/// These three forms can each be reg+reg or reg+mem, so there are a total of
461/// six "instructions".
462///
463let isTwoAddress = 1 in {
464multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
465 SDNode OpNode, Intrinsic F32Int,
466 bit Commutable = 0> {
467 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000468 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000469 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
471 let isCommutable = Commutable;
472 }
473
474 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000475 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000476 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000477 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
478
479 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000480 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000481 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000482 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
483 let isCommutable = Commutable;
484 }
485
486 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000487 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000488 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000489 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000490
491 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000492 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000493 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
495 let isCommutable = Commutable;
496 }
497
498 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000499 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000500 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501 [(set VR128:$dst, (F32Int VR128:$src1,
502 sse_load_f32:$src2))]>;
503}
504}
505
506// Arithmetic instructions
507defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
508defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
509defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
510defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
511
512/// sse1_fp_binop_rm - Other SSE1 binops
513///
514/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
515/// instructions for a full-vector intrinsic form. Operations that map
516/// onto C operators don't use this form since they just use the plain
517/// vector form instead of having a separate vector intrinsic form.
518///
519/// This provides a total of eight "instructions".
520///
521let isTwoAddress = 1 in {
522multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
523 SDNode OpNode,
524 Intrinsic F32Int,
525 Intrinsic V4F32Int,
526 bit Commutable = 0> {
527
528 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000529 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000530 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
532 let isCommutable = Commutable;
533 }
534
535 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000536 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000537 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000538 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
539
540 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000541 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000542 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
544 let isCommutable = Commutable;
545 }
546
547 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000548 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000549 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000550 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551
552 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000553 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000554 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
556 let isCommutable = Commutable;
557 }
558
559 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000560 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000561 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000562 [(set VR128:$dst, (F32Int VR128:$src1,
563 sse_load_f32:$src2))]>;
564
565 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000566 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000567 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
569 let isCommutable = Commutable;
570 }
571
572 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +0000573 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000574 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575 [(set VR128:$dst, (V4F32Int VR128:$src1, (load addr:$src2)))]>;
576}
577}
578
579defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
580 int_x86_sse_max_ss, int_x86_sse_max_ps>;
581defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
582 int_x86_sse_min_ss, int_x86_sse_min_ps>;
583
584//===----------------------------------------------------------------------===//
585// SSE packed FP Instructions
586
587// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000588def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000589 "movaps\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000590let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000591def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000592 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000593 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594
Evan Chengb783fa32007-07-19 01:14:50 +0000595def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000596 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000597 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598
Evan Chengb783fa32007-07-19 01:14:50 +0000599def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000600 "movups\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000601let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000602def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000603 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000604 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000605def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000606 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000607 [(store (v4f32 VR128:$src), addr:$dst)]>;
608
609// Intrinsic forms of MOVUPS load and store
Evan Cheng4e84e452007-08-30 05:49:43 +0000610let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000611def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000612 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000613 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000614def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000615 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000616 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000617
618let isTwoAddress = 1 in {
619 let AddedComplexity = 20 in {
620 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000621 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000622 "movlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623 [(set VR128:$dst,
624 (v4f32 (vector_shuffle VR128:$src1,
625 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
626 MOVLP_shuffle_mask)))]>;
627 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000628 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000629 "movhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630 [(set VR128:$dst,
631 (v4f32 (vector_shuffle VR128:$src1,
632 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
633 MOVHP_shuffle_mask)))]>;
634 } // AddedComplexity
635} // isTwoAddress
636
Evan Chengb783fa32007-07-19 01:14:50 +0000637def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000638 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
640 (iPTR 0))), addr:$dst)]>;
641
642// v2f64 extract element 1 is always custom lowered to unpack high to low
643// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000644def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000645 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000646 [(store (f64 (vector_extract
647 (v2f64 (vector_shuffle
648 (bc_v2f64 (v4f32 VR128:$src)), (undef),
649 UNPCKH_shuffle_mask)), (iPTR 0))),
650 addr:$dst)]>;
651
652let isTwoAddress = 1 in {
653let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000654def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000655 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656 [(set VR128:$dst,
657 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
658 MOVHP_shuffle_mask)))]>;
659
Evan Chengb783fa32007-07-19 01:14:50 +0000660def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000661 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662 [(set VR128:$dst,
663 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
664 MOVHLPS_shuffle_mask)))]>;
665} // AddedComplexity
666} // isTwoAddress
667
668
669
670// Arithmetic
671
672/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
673///
674/// In addition, we also have a special variant of the scalar form here to
675/// represent the associated intrinsic operation. This form is unlike the
676/// plain scalar form, in that it takes an entire vector (instead of a
677/// scalar) and leaves the top elements undefined.
678///
679/// And, we have a special variant form for a full-vector intrinsic form.
680///
681/// These four forms can each have a reg or a mem operand, so there are a
682/// total of eight "instructions".
683///
684multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
685 SDNode OpNode,
686 Intrinsic F32Int,
687 Intrinsic V4F32Int,
688 bit Commutable = 0> {
689 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000690 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000691 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692 [(set FR32:$dst, (OpNode FR32:$src))]> {
693 let isCommutable = Commutable;
694 }
695
696 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000697 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000698 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000699 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
700
701 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000702 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000703 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000704 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
705 let isCommutable = Commutable;
706 }
707
708 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000709 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000710 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000711 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712
713 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000714 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000715 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716 [(set VR128:$dst, (F32Int VR128:$src))]> {
717 let isCommutable = Commutable;
718 }
719
720 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000721 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000722 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
724
725 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000726 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000727 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
729 let isCommutable = Commutable;
730 }
731
732 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000733 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000734 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735 [(set VR128:$dst, (V4F32Int (load addr:$src)))]>;
736}
737
738// Square root.
739defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
740 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
741
742// Reciprocal approximations. Note that these typically require refinement
743// in order to obtain suitable precision.
744defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
745 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
746defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
747 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
748
749// Logical
750let isTwoAddress = 1 in {
751 let isCommutable = 1 in {
752 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000753 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000754 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000755 [(set VR128:$dst, (v2i64
756 (and VR128:$src1, VR128:$src2)))]>;
757 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000758 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000759 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760 [(set VR128:$dst, (v2i64
761 (or VR128:$src1, VR128:$src2)))]>;
762 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000763 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000764 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765 [(set VR128:$dst, (v2i64
766 (xor VR128:$src1, VR128:$src2)))]>;
767 }
768
769 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000770 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000771 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000772 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
773 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000775 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000776 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000777 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
778 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000780 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000781 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000782 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
783 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000785 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000786 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000787 [(set VR128:$dst,
788 (v2i64 (and (xor VR128:$src1,
789 (bc_v2i64 (v4i32 immAllOnesV))),
790 VR128:$src2)))]>;
791 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000792 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000793 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000794 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000795 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000797 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798}
799
800let isTwoAddress = 1 in {
801 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000802 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000803 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
805 VR128:$src, imm:$cc))]>;
806 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000807 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000808 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
810 (load addr:$src), imm:$cc))]>;
811}
812
813// Shuffle and unpack instructions
814let isTwoAddress = 1 in {
815 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
816 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000817 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818 VR128:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000819 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 [(set VR128:$dst,
821 (v4f32 (vector_shuffle
822 VR128:$src1, VR128:$src2,
823 SHUFP_shuffle_mask:$src3)))]>;
824 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000825 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826 f128mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 [(set VR128:$dst,
829 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000830 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000831 SHUFP_shuffle_mask:$src3)))]>;
832
833 let AddedComplexity = 10 in {
834 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000835 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000836 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 [(set VR128:$dst,
838 (v4f32 (vector_shuffle
839 VR128:$src1, VR128:$src2,
840 UNPCKH_shuffle_mask)))]>;
841 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000842 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000843 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844 [(set VR128:$dst,
845 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000846 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847 UNPCKH_shuffle_mask)))]>;
848
849 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000850 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000851 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 [(set VR128:$dst,
853 (v4f32 (vector_shuffle
854 VR128:$src1, VR128:$src2,
855 UNPCKL_shuffle_mask)))]>;
856 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000857 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000858 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859 [(set VR128:$dst,
860 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000861 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 UNPCKL_shuffle_mask)))]>;
863 } // AddedComplexity
864} // isTwoAddress
865
866// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000867def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000868 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000870def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000871 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
873
874// Prefetching loads.
875// TODO: no intrinsics for these?
Dan Gohman91888f02007-07-31 20:11:57 +0000876def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), "prefetcht0\t$src", []>;
877def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src), "prefetcht1\t$src", []>;
878def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src), "prefetcht2\t$src", []>;
879def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src), "prefetchnta\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880
881// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000882def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000883 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
885
886// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +0000887def SFENCE : PSI<0xAE, MRM7m, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888
889// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000890def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000891 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000892def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000893 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894
895// Alias instructions that map zero vector to pxor / xorp* for sse.
896// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
897let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000898def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000899 "xorps\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 [(set VR128:$dst, (v4f32 immAllZerosV))]>;
901
902// FR32 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +0000903def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000904 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 [(set VR128:$dst,
906 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000907def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000908 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 [(set VR128:$dst,
910 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
911
912// FIXME: may not be able to eliminate this movss with coalescing the src and
913// dest register classes are different. We really want to write this pattern
914// like this:
915// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
916// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +0000917def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000918 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
920 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000921def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000922 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923 [(store (f32 (vector_extract (v4f32 VR128:$src),
924 (iPTR 0))), addr:$dst)]>;
925
926
927// Move to lower bits of a VR128, leaving upper bits alone.
928// Three operand (but two address) aliases.
929let isTwoAddress = 1 in {
930 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000931 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000932 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933
934 let AddedComplexity = 15 in
935 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000936 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000937 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938 [(set VR128:$dst,
939 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
940 MOVL_shuffle_mask)))]>;
941}
942
943// Move to lower bits of a VR128 and zeroing upper bits.
944// Loading from memory automatically zeroing upper bits.
945let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +0000946def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000947 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948 [(set VR128:$dst, (v4f32 (vector_shuffle immAllZerosV,
949 (v4f32 (scalar_to_vector (loadf32 addr:$src))),
950 MOVL_shuffle_mask)))]>;
951
952
953//===----------------------------------------------------------------------===//
954// SSE2 Instructions
955//===----------------------------------------------------------------------===//
956
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000958def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000959 "movsd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000960let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000961def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000964def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000965 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 [(store FR64:$src, addr:$dst)]>;
967
968// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000969def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000970 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000972def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000973 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000975def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000976 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000978def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000979 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000981def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000984def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000985 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
987
988// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +0000989def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000990 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
992 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000993def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000994 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
996 Requires<[HasSSE2]>;
997
998// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000999def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001000 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001002def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001003 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1005 (load addr:$src)))]>;
1006
1007// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001008def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001009 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010 [(set GR32:$dst,
1011 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001012def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001013 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1015 (load addr:$src)))]>;
1016
1017// Comparison instructions
1018let isTwoAddress = 1 in {
1019 def CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001020 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001021 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 def CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001023 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001024 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025}
1026
Evan Chengb783fa32007-07-19 01:14:50 +00001027def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 [(X86cmp FR64:$src1, FR64:$src2)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001030def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001031 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 [(X86cmp FR64:$src1, (loadf64 addr:$src2))]>;
1033
1034// Aliases to match intrinsics which expect XMM operand(s).
1035let isTwoAddress = 1 in {
1036 def Int_CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001037 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001038 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1040 VR128:$src, imm:$cc))]>;
1041 def Int_CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001042 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001043 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1045 (load addr:$src), imm:$cc))]>;
1046}
1047
Evan Chengb783fa32007-07-19 01:14:50 +00001048def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001049 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001051def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001052 "ucomisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2))]>;
1054
Evan Chengb783fa32007-07-19 01:14:50 +00001055def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001056 "comisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001058def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001059 "comisd\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 [(X86comi (v2f64 VR128:$src1), (load addr:$src2))]>;
1061
1062// Aliases of packed SSE2 instructions for scalar use. These all have names that
1063// start with 'Fs'.
1064
1065// Alias instructions that map fld0 to pxor for sse.
Evan Chengb783fa32007-07-19 01:14:50 +00001066def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001067 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068 Requires<[HasSSE2]>, TB, OpSize;
1069
1070// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1071// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +00001072def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001073 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074
1075// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1076// disregarded.
Evan Cheng4e84e452007-08-30 05:49:43 +00001077let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001078def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001079 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001080 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081
1082// Alias bitwise logical operations using SSE logical ops on packed FP values.
1083let isTwoAddress = 1 in {
1084let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001085 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001086 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001088 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001089 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001091 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001092 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1094}
1095
Evan Chengb783fa32007-07-19 01:14:50 +00001096def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001097 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001099 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001100def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001103 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001104def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001105 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001107 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108
1109def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001110 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001111 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001113 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001114 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115}
1116
1117/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1118///
1119/// In addition, we also have a special variant of the scalar form here to
1120/// represent the associated intrinsic operation. This form is unlike the
1121/// plain scalar form, in that it takes an entire vector (instead of a scalar)
1122/// and leaves the top elements undefined.
1123///
1124/// These three forms can each be reg+reg or reg+mem, so there are a total of
1125/// six "instructions".
1126///
1127let isTwoAddress = 1 in {
1128multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1129 SDNode OpNode, Intrinsic F64Int,
1130 bit Commutable = 0> {
1131 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001132 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001133 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1135 let isCommutable = Commutable;
1136 }
1137
1138 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001139 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001140 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001141 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1142
1143 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001144 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001145 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1147 let isCommutable = Commutable;
1148 }
1149
1150 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001151 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001152 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001153 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154
1155 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001156 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001157 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1159 let isCommutable = Commutable;
1160 }
1161
1162 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001163 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001164 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 [(set VR128:$dst, (F64Int VR128:$src1,
1166 sse_load_f64:$src2))]>;
1167}
1168}
1169
1170// Arithmetic instructions
1171defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1172defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1173defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1174defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1175
1176/// sse2_fp_binop_rm - Other SSE2 binops
1177///
1178/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1179/// instructions for a full-vector intrinsic form. Operations that map
1180/// onto C operators don't use this form since they just use the plain
1181/// vector form instead of having a separate vector intrinsic form.
1182///
1183/// This provides a total of eight "instructions".
1184///
1185let isTwoAddress = 1 in {
1186multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1187 SDNode OpNode,
1188 Intrinsic F64Int,
1189 Intrinsic V2F64Int,
1190 bit Commutable = 0> {
1191
1192 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001193 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001194 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001195 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1196 let isCommutable = Commutable;
1197 }
1198
1199 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001200 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001201 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1203
1204 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001205 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001206 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1208 let isCommutable = Commutable;
1209 }
1210
1211 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001212 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001213 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001214 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215
1216 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001217 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001218 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1220 let isCommutable = Commutable;
1221 }
1222
1223 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001224 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001225 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001226 [(set VR128:$dst, (F64Int VR128:$src1,
1227 sse_load_f64:$src2))]>;
1228
1229 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001230 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001231 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001232 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1233 let isCommutable = Commutable;
1234 }
1235
1236 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +00001237 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001238 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001239 [(set VR128:$dst, (V2F64Int VR128:$src1, (load addr:$src2)))]>;
1240}
1241}
1242
1243defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1244 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1245defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1246 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1247
1248//===----------------------------------------------------------------------===//
1249// SSE packed FP Instructions
1250
1251// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001252def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001253 "movapd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001254let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001255def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001256 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001257 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258
Evan Chengb783fa32007-07-19 01:14:50 +00001259def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001260 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001261 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001262
Evan Chengb783fa32007-07-19 01:14:50 +00001263def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001264 "movupd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001265let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001266def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001267 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001268 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001269def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001270 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001271 [(store (v2f64 VR128:$src), addr:$dst)]>;
1272
1273// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001274def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001275 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001276 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001277def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001278 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001279 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001280
1281let isTwoAddress = 1 in {
1282 let AddedComplexity = 20 in {
1283 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001284 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001285 "movlpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286 [(set VR128:$dst,
1287 (v2f64 (vector_shuffle VR128:$src1,
1288 (scalar_to_vector (loadf64 addr:$src2)),
1289 MOVLP_shuffle_mask)))]>;
1290 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001291 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001292 "movhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 [(set VR128:$dst,
1294 (v2f64 (vector_shuffle VR128:$src1,
1295 (scalar_to_vector (loadf64 addr:$src2)),
1296 MOVHP_shuffle_mask)))]>;
1297 } // AddedComplexity
1298} // isTwoAddress
1299
Evan Chengb783fa32007-07-19 01:14:50 +00001300def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001301 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [(store (f64 (vector_extract (v2f64 VR128:$src),
1303 (iPTR 0))), addr:$dst)]>;
1304
1305// v2f64 extract element 1 is always custom lowered to unpack high to low
1306// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001307def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001308 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309 [(store (f64 (vector_extract
1310 (v2f64 (vector_shuffle VR128:$src, (undef),
1311 UNPCKH_shuffle_mask)), (iPTR 0))),
1312 addr:$dst)]>;
1313
1314// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001315def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001316 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1318 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001319def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001320 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
Dan Gohman4a4f1512007-07-18 20:23:34 +00001322 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323 TB, Requires<[HasSSE2]>;
1324
1325// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001326def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001327 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001328 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1329 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001330def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001331 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
Dan Gohman4a4f1512007-07-18 20:23:34 +00001333 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334 XS, Requires<[HasSSE2]>;
1335
Evan Chengb783fa32007-07-19 01:14:50 +00001336def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001337 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001338 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001339def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001340 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1342 (load addr:$src)))]>;
1343// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001344def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001345 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1347 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001348def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001349 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1351 (load addr:$src)))]>,
1352 XS, Requires<[HasSSE2]>;
1353
1354// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001355def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001356 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001357 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1358 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001359def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001360 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1362 (load addr:$src)))]>,
1363 XD, Requires<[HasSSE2]>;
1364
Evan Chengb783fa32007-07-19 01:14:50 +00001365def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001366 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001368def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001369 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001370 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1371 (load addr:$src)))]>;
1372
1373// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001374def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001375 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1377 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001378def Int_CVTPS2PDrm : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001379 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1381 (load addr:$src)))]>,
1382 TB, Requires<[HasSSE2]>;
1383
Evan Chengb783fa32007-07-19 01:14:50 +00001384def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001385 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001387def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001388 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1390 (load addr:$src)))]>;
1391
1392// Match intrinsics which expect XMM operand(s).
1393// Aliases for intrinsics
1394let isTwoAddress = 1 in {
1395def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001396 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001397 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001398 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1399 GR32:$src2))]>;
1400def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001401 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001402 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1404 (loadi32 addr:$src2)))]>;
1405def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001406 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001407 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1409 VR128:$src2))]>;
1410def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001411 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001412 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1414 (load addr:$src2)))]>;
1415def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001416 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1419 VR128:$src2))]>, XS,
1420 Requires<[HasSSE2]>;
1421def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001422 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001423 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001424 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1425 (load addr:$src2)))]>, XS,
1426 Requires<[HasSSE2]>;
1427}
1428
1429// Arithmetic
1430
1431/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1432///
1433/// In addition, we also have a special variant of the scalar form here to
1434/// represent the associated intrinsic operation. This form is unlike the
1435/// plain scalar form, in that it takes an entire vector (instead of a
1436/// scalar) and leaves the top elements undefined.
1437///
1438/// And, we have a special variant form for a full-vector intrinsic form.
1439///
1440/// These four forms can each have a reg or a mem operand, so there are a
1441/// total of eight "instructions".
1442///
1443multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1444 SDNode OpNode,
1445 Intrinsic F64Int,
1446 Intrinsic V2F64Int,
1447 bit Commutable = 0> {
1448 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001449 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451 [(set FR64:$dst, (OpNode FR64:$src))]> {
1452 let isCommutable = Commutable;
1453 }
1454
1455 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001456 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001457 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001458 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1459
1460 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001461 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001462 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1464 let isCommutable = Commutable;
1465 }
1466
1467 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001468 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001470 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471
1472 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001473 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001474 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001475 [(set VR128:$dst, (F64Int VR128:$src))]> {
1476 let isCommutable = Commutable;
1477 }
1478
1479 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001480 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1483
1484 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001485 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001487 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1488 let isCommutable = Commutable;
1489 }
1490
1491 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001492 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494 [(set VR128:$dst, (V2F64Int (load addr:$src)))]>;
1495}
1496
1497// Square root.
1498defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1499 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1500
1501// There is no f64 version of the reciprocal approximation instructions.
1502
1503// Logical
1504let isTwoAddress = 1 in {
1505 let isCommutable = 1 in {
1506 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001507 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001508 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001509 [(set VR128:$dst,
1510 (and (bc_v2i64 (v2f64 VR128:$src1)),
1511 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1512 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001513 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001515 [(set VR128:$dst,
1516 (or (bc_v2i64 (v2f64 VR128:$src1)),
1517 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1518 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001519 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001520 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001521 [(set VR128:$dst,
1522 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1523 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1524 }
1525
1526 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001527 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001529 [(set VR128:$dst,
1530 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001531 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001532 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001533 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001534 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001535 [(set VR128:$dst,
1536 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001537 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001538 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001539 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001540 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001541 [(set VR128:$dst,
1542 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001543 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001544 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001545 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001546 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001547 [(set VR128:$dst,
1548 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1549 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1550 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001551 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001552 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001553 [(set VR128:$dst,
1554 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001555 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556}
1557
1558let isTwoAddress = 1 in {
1559 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001560 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001562 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1563 VR128:$src, imm:$cc))]>;
1564 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001565 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1568 (load addr:$src), imm:$cc))]>;
1569}
1570
1571// Shuffle and unpack instructions
1572let isTwoAddress = 1 in {
1573 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001574 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001576 [(set VR128:$dst, (v2f64 (vector_shuffle
1577 VR128:$src1, VR128:$src2,
1578 SHUFP_shuffle_mask:$src3)))]>;
1579 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001580 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001582 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583 [(set VR128:$dst,
1584 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001585 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001586 SHUFP_shuffle_mask:$src3)))]>;
1587
1588 let AddedComplexity = 10 in {
1589 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001590 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001591 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001592 [(set VR128:$dst,
1593 (v2f64 (vector_shuffle
1594 VR128:$src1, VR128:$src2,
1595 UNPCKH_shuffle_mask)))]>;
1596 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001597 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001598 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 [(set VR128:$dst,
1600 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001601 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001602 UNPCKH_shuffle_mask)))]>;
1603
1604 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001605 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001607 [(set VR128:$dst,
1608 (v2f64 (vector_shuffle
1609 VR128:$src1, VR128:$src2,
1610 UNPCKL_shuffle_mask)))]>;
1611 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001612 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614 [(set VR128:$dst,
1615 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001616 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617 UNPCKL_shuffle_mask)))]>;
1618 } // AddedComplexity
1619} // isTwoAddress
1620
1621
1622//===----------------------------------------------------------------------===//
1623// SSE integer instructions
1624
1625// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001626def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001627 "movdqa\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001628let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001629def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001631 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001632def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001633 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001634 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001635let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001636def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001637 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001638 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001640def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001642 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001643 XS, Requires<[HasSSE2]>;
1644
Dan Gohman4a4f1512007-07-18 20:23:34 +00001645// Intrinsic forms of MOVDQU load and store
Evan Cheng4e84e452007-08-30 05:49:43 +00001646let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001647def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001648 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001649 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1650 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001651def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001652 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001653 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1654 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001655
1656let isTwoAddress = 1 in {
1657
1658multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1659 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001660 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001661 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001662 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1663 let isCommutable = Commutable;
1664 }
Evan Chengb783fa32007-07-19 01:14:50 +00001665 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001666 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001668 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001669}
1670
1671multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1672 string OpcodeStr, Intrinsic IntId> {
Evan Chengb783fa32007-07-19 01:14:50 +00001673 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001675 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001676 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001679 (bitconvert (memopv2i64 addr:$src2))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001680 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001681 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001682 [(set VR128:$dst, (IntId VR128:$src1,
1683 (scalar_to_vector (i32 imm:$src2))))]>;
1684}
1685
1686
1687/// PDI_binop_rm - Simple SSE2 binary operator.
1688multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1689 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001690 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001691 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1693 let isCommutable = Commutable;
1694 }
Evan Chengb783fa32007-07-19 01:14:50 +00001695 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001696 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001698 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699}
1700
1701/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1702///
1703/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1704/// to collapse (bitconvert VT to VT) into its operand.
1705///
1706multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1707 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001708 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001710 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1711 let isCommutable = Commutable;
1712 }
Evan Chengb783fa32007-07-19 01:14:50 +00001713 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001715 [(set VR128:$dst, (OpNode VR128:$src1,(memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716}
1717
1718} // isTwoAddress
1719
1720// 128-bit Integer Arithmetic
1721
1722defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1723defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1724defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1725defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1726
1727defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1728defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1729defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1730defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1731
1732defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1733defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1734defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1735defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1736
1737defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1738defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1739defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1740defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1741
1742defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1743
1744defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1745defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1746defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1747
1748defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1749
1750defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1751defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1752
1753
1754defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1755defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1756defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1757defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1758defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>;
1759
1760
1761defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", int_x86_sse2_psll_w>;
1762defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", int_x86_sse2_psll_d>;
1763defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", int_x86_sse2_psll_q>;
1764
1765defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", int_x86_sse2_psrl_w>;
1766defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", int_x86_sse2_psrl_d>;
1767defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq", int_x86_sse2_psrl_q>;
1768
1769defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", int_x86_sse2_psra_w>;
1770defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad", int_x86_sse2_psra_d>;
1771// PSRAQ doesn't exist in SSE[1-3].
1772
1773// 128-bit logical shifts.
1774let isTwoAddress = 1 in {
1775 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001776 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001779 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781 // PSRADQri doesn't exist in SSE[1-3].
1782}
1783
1784let Predicates = [HasSSE2] in {
1785 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1786 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1787 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1788 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1789 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1790 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1791}
1792
1793// Logical
1794defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1795defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1796defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1797
1798let isTwoAddress = 1 in {
1799 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001800 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1803 VR128:$src2)))]>;
1804
1805 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001806 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001808 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00001809 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810}
1811
1812// SSE2 Integer comparison
1813defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1814defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
1815defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
1816defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
1817defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
1818defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
1819
1820// Pack instructions
1821defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
1822defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
1823defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
1824
1825// Shuffle and unpack instructions
1826def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001827 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(set VR128:$dst, (v4i32 (vector_shuffle
1830 VR128:$src1, (undef),
1831 PSHUFD_shuffle_mask:$src2)))]>;
1832def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001833 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001835 [(set VR128:$dst, (v4i32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001836 (bc_v4i32(memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 (undef),
1838 PSHUFD_shuffle_mask:$src2)))]>;
1839
1840// SSE2 with ImmT == Imm8 and XS prefix.
1841def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001842 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001843 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001844 [(set VR128:$dst, (v8i16 (vector_shuffle
1845 VR128:$src1, (undef),
1846 PSHUFHW_shuffle_mask:$src2)))]>,
1847 XS, Requires<[HasSSE2]>;
1848def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001849 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001850 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001851 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001852 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001853 (undef),
1854 PSHUFHW_shuffle_mask:$src2)))]>,
1855 XS, Requires<[HasSSE2]>;
1856
1857// SSE2 with ImmT == Imm8 and XD prefix.
1858def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001859 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001860 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001861 [(set VR128:$dst, (v8i16 (vector_shuffle
1862 VR128:$src1, (undef),
1863 PSHUFLW_shuffle_mask:$src2)))]>,
1864 XD, Requires<[HasSSE2]>;
1865def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001866 (outs VR128:$dst), (ins i128mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001868 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001869 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870 (undef),
1871 PSHUFLW_shuffle_mask:$src2)))]>,
1872 XD, Requires<[HasSSE2]>;
1873
1874
1875let isTwoAddress = 1 in {
1876 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001877 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(set VR128:$dst,
1880 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1881 UNPCKL_shuffle_mask)))]>;
1882 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001883 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001884 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001885 [(set VR128:$dst,
1886 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001887 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 UNPCKL_shuffle_mask)))]>;
1889 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001890 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001892 [(set VR128:$dst,
1893 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1894 UNPCKL_shuffle_mask)))]>;
1895 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001896 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001897 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898 [(set VR128:$dst,
1899 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001900 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001901 UNPCKL_shuffle_mask)))]>;
1902 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001903 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905 [(set VR128:$dst,
1906 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1907 UNPCKL_shuffle_mask)))]>;
1908 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001909 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001910 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001911 [(set VR128:$dst,
1912 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001913 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001914 UNPCKL_shuffle_mask)))]>;
1915 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001916 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001918 [(set VR128:$dst,
1919 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1920 UNPCKL_shuffle_mask)))]>;
1921 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001922 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001924 [(set VR128:$dst,
1925 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001926 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927 UNPCKL_shuffle_mask)))]>;
1928
1929 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001930 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 [(set VR128:$dst,
1933 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1934 UNPCKH_shuffle_mask)))]>;
1935 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001936 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001937 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938 [(set VR128:$dst,
1939 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001940 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941 UNPCKH_shuffle_mask)))]>;
1942 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001943 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(set VR128:$dst,
1946 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1947 UNPCKH_shuffle_mask)))]>;
1948 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001949 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001950 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001951 [(set VR128:$dst,
1952 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001953 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001954 UNPCKH_shuffle_mask)))]>;
1955 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001956 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(set VR128:$dst,
1959 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1960 UNPCKH_shuffle_mask)))]>;
1961 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001962 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(set VR128:$dst,
1965 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001966 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967 UNPCKH_shuffle_mask)))]>;
1968 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001969 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001970 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001971 [(set VR128:$dst,
1972 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1973 UNPCKH_shuffle_mask)))]>;
1974 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001975 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001976 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(set VR128:$dst,
1978 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001979 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 UNPCKH_shuffle_mask)))]>;
1981}
1982
1983// Extract / Insert
1984def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001985 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001986 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001987 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
1988 (iPTR imm:$src2)))]>;
1989let isTwoAddress = 1 in {
1990 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001991 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994 [(set VR128:$dst,
1995 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
1996 GR32:$src2, (iPTR imm:$src3))))]>;
1997 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001998 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001999 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(set VR128:$dst,
2002 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
2003 (i32 (anyext (loadi16 addr:$src2))),
2004 (iPTR imm:$src3))))]>;
2005}
2006
2007// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002008def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002009 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2011
2012// Conditional store
Evan Chengb783fa32007-07-19 01:14:50 +00002013def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "maskmovdqu\t{$mask, $src|$src, $mask}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>,
2016 Imp<[EDI],[]>;
2017
2018// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002019def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002021 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002022def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002023 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002024 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002025def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002026 "movnti\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2028 TB, Requires<[HasSSE2]>;
2029
2030// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002031def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002032 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033 TB, Requires<[HasSSE2]>;
2034
2035// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +00002036def LFENCE : I<0xAE, MRM5m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002037 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002038def MFENCE : I<0xAE, MRM6m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2040
2041
2042// Alias instructions that map zero vector to pxor / xorp* for sse.
2043// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2044let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002045 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "pcmpeqd\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 [(set VR128:$dst, (v2f64 immAllOnesV))]>;
2048
2049// FR64 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +00002050def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002052 [(set VR128:$dst,
2053 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002054def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002055 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002056 [(set VR128:$dst,
2057 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2058
Evan Chengb783fa32007-07-19 01:14:50 +00002059def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061 [(set VR128:$dst,
2062 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002063def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(set VR128:$dst,
2066 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2067
Evan Chengb783fa32007-07-19 01:14:50 +00002068def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2071
Evan Chengb783fa32007-07-19 01:14:50 +00002072def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2075
2076// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002077def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079 [(set VR128:$dst,
2080 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2081 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002082def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(store (i64 (vector_extract (v2i64 VR128:$src),
2085 (iPTR 0))), addr:$dst)]>;
2086
2087// FIXME: may not be able to eliminate this movss with coalescing the src and
2088// dest register classes are different. We really want to write this pattern
2089// like this:
2090// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2091// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +00002092def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002093 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002094 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2095 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002096def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 [(store (f64 (vector_extract (v2f64 VR128:$src),
2099 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002100def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002101 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002102 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2103 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002104def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002105 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002106 [(store (i32 (vector_extract (v4i32 VR128:$src),
2107 (iPTR 0))), addr:$dst)]>;
2108
Evan Chengb783fa32007-07-19 01:14:50 +00002109def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002110 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002111 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002112def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002113 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002114 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2115
2116
2117// Move to lower bits of a VR128, leaving upper bits alone.
2118// Three operand (but two address) aliases.
2119let isTwoAddress = 1 in {
2120 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002121 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123
2124 let AddedComplexity = 15 in
2125 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002126 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002127 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128 [(set VR128:$dst,
2129 (v2f64 (vector_shuffle VR128:$src1, VR128:$src2,
2130 MOVL_shuffle_mask)))]>;
2131}
2132
2133// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002134def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002135 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2137
2138// Move to lower bits of a VR128 and zeroing upper bits.
2139// Loading from memory automatically zeroing upper bits.
2140let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002141 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002143 [(set VR128:$dst,
2144 (v2f64 (vector_shuffle immAllZerosV,
2145 (v2f64 (scalar_to_vector
2146 (loadf64 addr:$src))),
2147 MOVL_shuffle_mask)))]>;
2148
2149let AddedComplexity = 15 in
2150// movd / movq to XMM register zero-extends
Evan Chengb783fa32007-07-19 01:14:50 +00002151def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(set VR128:$dst,
2154 (v4i32 (vector_shuffle immAllZerosV,
2155 (v4i32 (scalar_to_vector GR32:$src)),
2156 MOVL_shuffle_mask)))]>;
2157let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002158def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160 [(set VR128:$dst,
2161 (v4i32 (vector_shuffle immAllZerosV,
2162 (v4i32 (scalar_to_vector (loadi32 addr:$src))),
2163 MOVL_shuffle_mask)))]>;
2164
2165// Moving from XMM to XMM but still clear upper 64 bits.
2166let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002167def MOVZQI2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002168 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002169 [(set VR128:$dst, (int_x86_sse2_movl_dq VR128:$src))]>,
2170 XS, Requires<[HasSSE2]>;
2171let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002172def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002173 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 [(set VR128:$dst, (int_x86_sse2_movl_dq
Dan Gohman4a4f1512007-07-18 20:23:34 +00002175 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002176 XS, Requires<[HasSSE2]>;
2177
2178
2179//===----------------------------------------------------------------------===//
2180// SSE3 Instructions
2181//===----------------------------------------------------------------------===//
2182
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002183// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002184def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 [(set VR128:$dst, (v4f32 (vector_shuffle
2187 VR128:$src, (undef),
2188 MOVSHDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002189def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002190 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002191 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002192 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193 MOVSHDUP_shuffle_mask)))]>;
2194
Evan Chengb783fa32007-07-19 01:14:50 +00002195def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002197 [(set VR128:$dst, (v4f32 (vector_shuffle
2198 VR128:$src, (undef),
2199 MOVSLDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002200def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002203 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204 MOVSLDUP_shuffle_mask)))]>;
2205
Evan Chengb783fa32007-07-19 01:14:50 +00002206def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002208 [(set VR128:$dst, (v2f64 (vector_shuffle
2209 VR128:$src, (undef),
2210 SSE_splat_lo_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002211def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002212 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002213 [(set VR128:$dst,
2214 (v2f64 (vector_shuffle
2215 (scalar_to_vector (loadf64 addr:$src)),
2216 (undef),
2217 SSE_splat_lo_mask)))]>;
2218
2219// Arithmetic
2220let isTwoAddress = 1 in {
2221 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002222 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002224 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2225 VR128:$src2))]>;
2226 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002227 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2230 (load addr:$src2)))]>;
2231 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002232 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002233 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2235 VR128:$src2))]>;
2236 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002237 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002238 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002239 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2240 (load addr:$src2)))]>;
2241}
2242
Evan Chengb783fa32007-07-19 01:14:50 +00002243def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002245 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2246
2247// Horizontal ops
2248class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002249 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002250 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2252class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002253 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002254 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002255 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (load addr:$src2))))]>;
2256class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002257 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002258 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2260class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002261 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002262 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (load addr:$src2))))]>;
2264
2265let isTwoAddress = 1 in {
2266 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2267 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2268 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2269 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2270 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2271 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2272 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2273 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2274}
2275
2276// Thread synchronization
Evan Chengb783fa32007-07-19 01:14:50 +00002277def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002278 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002279def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2281
2282// vector_shuffle v1, <undef> <1, 1, 3, 3>
2283let AddedComplexity = 15 in
2284def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2285 MOVSHDUP_shuffle_mask)),
2286 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2287let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002288def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289 MOVSHDUP_shuffle_mask)),
2290 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2291
2292// vector_shuffle v1, <undef> <0, 0, 2, 2>
2293let AddedComplexity = 15 in
2294 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2295 MOVSLDUP_shuffle_mask)),
2296 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2297let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002298 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002299 MOVSLDUP_shuffle_mask)),
2300 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2301
2302//===----------------------------------------------------------------------===//
2303// SSSE3 Instructions
2304//===----------------------------------------------------------------------===//
2305
Bill Wendling3b15d722007-08-11 09:52:53 +00002306// SSSE3 Instruction Templates:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002307//
Bill Wendling98680292007-08-10 06:22:27 +00002308// SS38I - SSSE3 instructions with T8 prefix.
2309// SS3AI - SSSE3 instructions with TA prefix.
Bill Wendling3b15d722007-08-11 09:52:53 +00002310//
2311// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
2312// uses the MMX registers. We put those instructions here because they better
2313// fit into the SSSE3 instruction category rather than the MMX category.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002314
Evan Chengb783fa32007-07-19 01:14:50 +00002315class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
2316 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002317 : I<o, F, outs, ins, asm, pattern>, T8, Requires<[HasSSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002318class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
2319 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002320 : I<o, F, outs, ins, asm, pattern>, TA, Requires<[HasSSSE3]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002321
Bill Wendling98680292007-08-10 06:22:27 +00002322/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323let isTwoAddress = 1 in {
Bill Wendling98680292007-08-10 06:22:27 +00002324 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2325 Intrinsic IntId64, Intrinsic IntId128,
2326 bit Commutable = 0> {
2327 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2328 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2329 [(set VR64:$dst, (IntId64 VR64:$src))]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002330 let isCommutable = Commutable;
2331 }
Bill Wendling98680292007-08-10 06:22:27 +00002332 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2333 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2334 [(set VR64:$dst,
2335 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2336
2337 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2338 (ins VR128:$src),
2339 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2340 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2341 OpSize {
2342 let isCommutable = Commutable;
2343 }
2344 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2345 (ins i128mem:$src),
2346 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2347 [(set VR128:$dst,
2348 (IntId128
2349 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002350 }
2351}
2352
Bill Wendling98680292007-08-10 06:22:27 +00002353/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2354let isTwoAddress = 1 in {
2355 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2356 Intrinsic IntId64, Intrinsic IntId128,
2357 bit Commutable = 0> {
2358 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2359 (ins VR64:$src),
2360 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2361 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2362 let isCommutable = Commutable;
2363 }
2364 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2365 (ins i64mem:$src),
2366 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2367 [(set VR64:$dst,
2368 (IntId64
2369 (bitconvert (memopv4i16 addr:$src))))]>;
2370
2371 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2372 (ins VR128:$src),
2373 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2374 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2375 OpSize {
2376 let isCommutable = Commutable;
2377 }
2378 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2379 (ins i128mem:$src),
2380 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2381 [(set VR128:$dst,
2382 (IntId128
2383 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2384 }
2385}
2386
2387/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2388let isTwoAddress = 1 in {
2389 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2390 Intrinsic IntId64, Intrinsic IntId128,
2391 bit Commutable = 0> {
2392 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2393 (ins VR64:$src),
2394 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2395 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2396 let isCommutable = Commutable;
2397 }
2398 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2399 (ins i64mem:$src),
2400 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2401 [(set VR64:$dst,
2402 (IntId64
2403 (bitconvert (memopv2i32 addr:$src))))]>;
2404
2405 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2406 (ins VR128:$src),
2407 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2408 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2409 OpSize {
2410 let isCommutable = Commutable;
2411 }
2412 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2413 (ins i128mem:$src),
2414 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2415 [(set VR128:$dst,
2416 (IntId128
2417 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2418 }
2419}
2420
2421defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2422 int_x86_ssse3_pabs_b,
2423 int_x86_ssse3_pabs_b_128>;
2424defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2425 int_x86_ssse3_pabs_w,
2426 int_x86_ssse3_pabs_w_128>;
2427defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2428 int_x86_ssse3_pabs_d,
2429 int_x86_ssse3_pabs_d_128>;
2430
2431/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2432let isTwoAddress = 1 in {
2433 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2434 Intrinsic IntId64, Intrinsic IntId128,
2435 bit Commutable = 0> {
2436 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2437 (ins VR64:$src1, VR64:$src2),
2438 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2439 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2440 let isCommutable = Commutable;
2441 }
2442 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2443 (ins VR64:$src1, i64mem:$src2),
2444 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2445 [(set VR64:$dst,
2446 (IntId64 VR64:$src1,
2447 (bitconvert (memopv8i8 addr:$src2))))]>;
2448
2449 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2450 (ins VR128:$src1, VR128:$src2),
2451 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2452 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2453 OpSize {
2454 let isCommutable = Commutable;
2455 }
2456 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2457 (ins VR128:$src1, i128mem:$src2),
2458 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2459 [(set VR128:$dst,
2460 (IntId128 VR128:$src1,
2461 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2462 }
2463}
2464
2465/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2466let isTwoAddress = 1 in {
2467 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2468 Intrinsic IntId64, Intrinsic IntId128,
2469 bit Commutable = 0> {
2470 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2471 (ins VR64:$src1, VR64:$src2),
2472 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2473 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2474 let isCommutable = Commutable;
2475 }
2476 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2477 (ins VR64:$src1, i64mem:$src2),
2478 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2479 [(set VR64:$dst,
2480 (IntId64 VR64:$src1,
2481 (bitconvert (memopv4i16 addr:$src2))))]>;
2482
2483 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2484 (ins VR128:$src1, VR128:$src2),
2485 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2486 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2487 OpSize {
2488 let isCommutable = Commutable;
2489 }
2490 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2491 (ins VR128:$src1, i128mem:$src2),
2492 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2493 [(set VR128:$dst,
2494 (IntId128 VR128:$src1,
2495 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2496 }
2497}
2498
2499/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2500let isTwoAddress = 1 in {
2501 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2502 Intrinsic IntId64, Intrinsic IntId128,
2503 bit Commutable = 0> {
2504 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2505 (ins VR64:$src1, VR64:$src2),
2506 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2507 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2508 let isCommutable = Commutable;
2509 }
2510 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2511 (ins VR64:$src1, i64mem:$src2),
2512 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2513 [(set VR64:$dst,
2514 (IntId64 VR64:$src1,
2515 (bitconvert (memopv2i32 addr:$src2))))]>;
2516
2517 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2518 (ins VR128:$src1, VR128:$src2),
2519 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2520 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2521 OpSize {
2522 let isCommutable = Commutable;
2523 }
2524 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2525 (ins VR128:$src1, i128mem:$src2),
2526 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2527 [(set VR128:$dst,
2528 (IntId128 VR128:$src1,
2529 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2530 }
2531}
2532
2533defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2534 int_x86_ssse3_phadd_w,
2535 int_x86_ssse3_phadd_w_128, 1>;
2536defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2537 int_x86_ssse3_phadd_d,
2538 int_x86_ssse3_phadd_d_128, 1>;
2539defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2540 int_x86_ssse3_phadd_sw,
2541 int_x86_ssse3_phadd_sw_128, 1>;
2542defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2543 int_x86_ssse3_phsub_w,
2544 int_x86_ssse3_phsub_w_128>;
2545defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2546 int_x86_ssse3_phsub_d,
2547 int_x86_ssse3_phsub_d_128>;
2548defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2549 int_x86_ssse3_phsub_sw,
2550 int_x86_ssse3_phsub_sw_128>;
2551defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2552 int_x86_ssse3_pmadd_ub_sw,
2553 int_x86_ssse3_pmadd_ub_sw_128, 1>;
2554defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2555 int_x86_ssse3_pmul_hr_sw,
2556 int_x86_ssse3_pmul_hr_sw_128, 1>;
2557defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2558 int_x86_ssse3_pshuf_b,
2559 int_x86_ssse3_pshuf_b_128>;
2560defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2561 int_x86_ssse3_psign_b,
2562 int_x86_ssse3_psign_b_128>;
2563defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2564 int_x86_ssse3_psign_w,
2565 int_x86_ssse3_psign_w_128>;
2566defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2567 int_x86_ssse3_psign_d,
2568 int_x86_ssse3_psign_d_128>;
2569
2570let isTwoAddress = 1 in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002571 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2572 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
2573 "palignr\t{$src2, $dst|$dst, $src2}",
2574 [(set VR64:$dst,
2575 (int_x86_ssse3_palign_r
2576 VR64:$src1, VR64:$src2,
2577 imm:$src3))]>;
2578 def PALIGNR64rm : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2579 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
2580 "palignr\t{$src2, $dst|$dst, $src2}",
2581 [(set VR64:$dst,
2582 (int_x86_ssse3_palign_r
2583 VR64:$src1,
2584 (bitconvert (memopv2i32 addr:$src2)),
2585 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002586
Bill Wendling1dc817c2007-08-10 09:00:17 +00002587 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2588 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
2589 "palignr\t{$src2, $dst|$dst, $src2}",
2590 [(set VR128:$dst,
2591 (int_x86_ssse3_palign_r_128
2592 VR128:$src1, VR128:$src2,
2593 imm:$src3))]>, OpSize;
2594 def PALIGNR128rm : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2595 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
2596 "palignr\t{$src2, $dst|$dst, $src2}",
2597 [(set VR128:$dst,
2598 (int_x86_ssse3_palign_r_128
2599 VR128:$src1,
2600 (bitconvert (memopv4i32 addr:$src2)),
2601 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002602}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002603
2604//===----------------------------------------------------------------------===//
2605// Non-Instruction Patterns
2606//===----------------------------------------------------------------------===//
2607
2608// 128-bit vector undef's.
Bill Wendling1dc817c2007-08-10 09:00:17 +00002609def : Pat<(v4f32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002610def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2611def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2612def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2613def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2614def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2615
2616// 128-bit vector all zero's.
2617def : Pat<(v16i8 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2618def : Pat<(v8i16 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2619def : Pat<(v4i32 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2620def : Pat<(v2i64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2621def : Pat<(v2f64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2622
2623// 128-bit vector all one's.
2624def : Pat<(v16i8 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2625def : Pat<(v8i16 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2626def : Pat<(v4i32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2627def : Pat<(v2i64 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2628def : Pat<(v4f32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE1]>;
2629
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002630
2631// Scalar to v8i16 / v16i8. The source may be a GR32, but only the lower 8 or
2632// 16-bits matter.
2633def : Pat<(v8i16 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2634 Requires<[HasSSE2]>;
2635def : Pat<(v16i8 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2636 Requires<[HasSSE2]>;
2637
2638// bit_convert
2639let Predicates = [HasSSE2] in {
2640 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2641 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2642 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2643 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2644 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2645 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2646 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2647 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2648 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2649 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2650 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2651 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2652 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2653 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2654 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2655 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2656 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2657 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2658 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2659 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2660 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2661 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2662 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2663 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2664 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2665 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2666 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2667 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2668 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2669 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2670}
2671
2672// Move scalar to XMM zero-extended
2673// movd to XMM register zero-extends
2674let AddedComplexity = 15 in {
2675def : Pat<(v8i16 (vector_shuffle immAllZerosV,
2676 (v8i16 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2677 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2678def : Pat<(v16i8 (vector_shuffle immAllZerosV,
2679 (v16i8 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2680 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2681// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
2682def : Pat<(v2f64 (vector_shuffle immAllZerosV,
2683 (v2f64 (scalar_to_vector FR64:$src)), MOVL_shuffle_mask)),
2684 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
2685def : Pat<(v4f32 (vector_shuffle immAllZerosV,
2686 (v4f32 (scalar_to_vector FR32:$src)), MOVL_shuffle_mask)),
2687 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>;
2688}
2689
2690// Splat v2f64 / v2i64
2691let AddedComplexity = 10 in {
2692def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2693 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2694def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2695 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2696def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2697 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2698def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2699 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2700}
2701
2702// Splat v4f32
2703def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SSE_splat_mask:$sm),
2704 (SHUFPSrri VR128:$src, VR128:$src, SSE_splat_mask:$sm)>,
2705 Requires<[HasSSE1]>;
2706
2707// Special unary SHUFPSrri case.
2708// FIXME: when we want non two-address code, then we should use PSHUFD?
2709def : Pat<(vector_shuffle (v4f32 VR128:$src1), (undef),
2710 SHUFP_unary_shuffle_mask:$sm),
2711 (SHUFPSrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2712 Requires<[HasSSE1]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002713// Special unary SHUFPDrri case.
2714def : Pat<(vector_shuffle (v2f64 VR128:$src1), (undef),
2715 SHUFP_unary_shuffle_mask:$sm),
2716 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2717 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002718// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Dan Gohman4a4f1512007-07-18 20:23:34 +00002719def : Pat<(vector_shuffle (memopv4f32 addr:$src1), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002720 SHUFP_unary_shuffle_mask:$sm),
2721 (PSHUFDmi addr:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2722 Requires<[HasSSE2]>;
2723// Special binary v4i32 shuffle cases with SHUFPS.
2724def : Pat<(vector_shuffle (v4i32 VR128:$src1), (v4i32 VR128:$src2),
2725 PSHUFD_binary_shuffle_mask:$sm),
2726 (SHUFPSrri VR128:$src1, VR128:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2727 Requires<[HasSSE2]>;
2728def : Pat<(vector_shuffle (v4i32 VR128:$src1),
Dan Gohman4a4f1512007-07-18 20:23:34 +00002729 (bc_v4i32 (memopv2i64 addr:$src2)), PSHUFD_binary_shuffle_mask:$sm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002730 (SHUFPSrmi VR128:$src1, addr:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2731 Requires<[HasSSE2]>;
2732
2733// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2734let AddedComplexity = 10 in {
2735def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2736 UNPCKL_v_undef_shuffle_mask)),
2737 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2738def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2739 UNPCKL_v_undef_shuffle_mask)),
2740 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2741def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2742 UNPCKL_v_undef_shuffle_mask)),
2743 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2744def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2745 UNPCKL_v_undef_shuffle_mask)),
2746 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2747}
2748
2749// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2750let AddedComplexity = 10 in {
2751def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2752 UNPCKH_v_undef_shuffle_mask)),
2753 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2754def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2755 UNPCKH_v_undef_shuffle_mask)),
2756 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2757def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2758 UNPCKH_v_undef_shuffle_mask)),
2759 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2760def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2761 UNPCKH_v_undef_shuffle_mask)),
2762 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2763}
2764
2765let AddedComplexity = 15 in {
2766// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2767def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2768 MOVHP_shuffle_mask)),
2769 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2770
2771// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2772def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2773 MOVHLPS_shuffle_mask)),
2774 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2775
2776// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2777def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2778 MOVHLPS_v_undef_shuffle_mask)),
2779 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2780def : Pat<(v4i32 (vector_shuffle VR128:$src1, (undef),
2781 MOVHLPS_v_undef_shuffle_mask)),
2782 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2783}
2784
2785let AddedComplexity = 20 in {
2786// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2787// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Dan Gohman4a4f1512007-07-18 20:23:34 +00002788def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002789 MOVLP_shuffle_mask)),
2790 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002791def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002792 MOVLP_shuffle_mask)),
2793 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002794def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002795 MOVHP_shuffle_mask)),
2796 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002797def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002798 MOVHP_shuffle_mask)),
2799 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2800
Dan Gohman4a4f1512007-07-18 20:23:34 +00002801def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002802 MOVLP_shuffle_mask)),
2803 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002804def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002805 MOVLP_shuffle_mask)),
2806 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002807def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002808 MOVHP_shuffle_mask)),
2809 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002810def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002811 MOVLP_shuffle_mask)),
2812 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2813}
2814
2815let AddedComplexity = 15 in {
2816// Setting the lowest element in the vector.
2817def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2818 MOVL_shuffle_mask)),
2819 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2820def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2821 MOVL_shuffle_mask)),
2822 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2823
2824// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
2825def : Pat<(v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
2826 MOVLP_shuffle_mask)),
2827 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2828def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2829 MOVLP_shuffle_mask)),
2830 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2831}
2832
2833// Set lowest element and zero upper elements.
2834let AddedComplexity = 20 in
2835def : Pat<(bc_v2i64 (vector_shuffle immAllZerosV,
2836 (v2f64 (scalar_to_vector (loadf64 addr:$src))),
2837 MOVL_shuffle_mask)),
2838 (MOVZQI2PQIrm addr:$src)>, Requires<[HasSSE2]>;
2839
2840// FIXME: Temporary workaround since 2-wide shuffle is broken.
2841def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
2842 (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2843def : Pat<(int_x86_sse2_loadh_pd VR128:$src1, addr:$src2),
2844 (v2f64 (MOVHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2845def : Pat<(int_x86_sse2_loadl_pd VR128:$src1, addr:$src2),
2846 (v2f64 (MOVLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2847def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
2848 (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
2849 Requires<[HasSSE2]>;
2850def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (load addr:$src2), imm:$src3),
2851 (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
2852 Requires<[HasSSE2]>;
2853def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
2854 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2855def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (load addr:$src2)),
2856 (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2857def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
2858 (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2859def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (load addr:$src2)),
2860 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2861def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2),
2862 (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2863def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (load addr:$src2)),
2864 (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2865def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2),
2866 (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2867def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (load addr:$src2)),
2868 (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2869
2870// Some special case pandn patterns.
2871def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2872 VR128:$src2)),
2873 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2874def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
2875 VR128:$src2)),
2876 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2877def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
2878 VR128:$src2)),
2879 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2880
2881def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002882 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2884def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002885 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002886 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2887def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002888 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002889 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2890
Evan Cheng51a49b22007-07-20 00:27:43 +00002891// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00002892def : Pat<(alignedloadv4i32 addr:$src),
2893 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
2894def : Pat<(loadv4i32 addr:$src),
2895 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00002896def : Pat<(alignedloadv2i64 addr:$src),
2897 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
2898def : Pat<(loadv2i64 addr:$src),
2899 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
2900
2901def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
2902 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2903def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
2904 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2905def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
2906 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2907def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
2908 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2909def : Pat<(store (v2i64 VR128:$src), addr:$dst),
2910 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2911def : Pat<(store (v4i32 VR128:$src), addr:$dst),
2912 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2913def : Pat<(store (v8i16 VR128:$src), addr:$dst),
2914 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2915def : Pat<(store (v16i8 VR128:$src), addr:$dst),
2916 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
Evan Cheng86ab7d32007-07-31 08:04:03 +00002917
2918// (vextract (v4i32 bc (v4f32 s2v (f32 load $addr))), 0) -> (i32 load $addr)
2919def : Pat<(vector_extract
2920 (bc_v4i32 (v4f32 (scalar_to_vector (loadf32 addr:$src)))), (iPTR 0)),
Evan Cheng43a09ac2007-08-01 21:42:24 +00002921 (MOV32rm addr:$src)>, Requires<[HasSSE2]>;
Evan Cheng86ab7d32007-07-31 08:04:03 +00002922def : Pat<(vector_extract
2923 (bc_v2i64 (v2f64 (scalar_to_vector (loadf64 addr:$src)))), (iPTR 0)),
Evan Cheng43a09ac2007-08-01 21:42:24 +00002924 (MOV64rm addr:$src)>, Requires<[HasSSE2, In64BitMode]>;