blob: 26767a5b617d3bd8766d6b60bf39c2c3ac636029 [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//====- X86InstrSSE.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
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>;
Evan Chengf37bf452007-10-01 18:12:48 +000035def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest>;
Evan Cheng621216e2007-09-29 00:00:36 +000036def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037def X86s2vec : SDNode<"X86ISD::S2VEC", SDTypeProfile<1, 1, []>, []>;
38def X86pextrw : SDNode<"X86ISD::PEXTRW", SDTypeProfile<1, 2, []>, []>;
39def X86pinsrw : SDNode<"X86ISD::PINSRW", SDTypeProfile<1, 3, []>, []>;
40
41//===----------------------------------------------------------------------===//
42// SSE 'Special' Instructions
43//===----------------------------------------------------------------------===//
44
Evan Chenge399fbb2007-12-12 23:12:09 +000045let isImplicitDef = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +000046def IMPLICIT_DEF_VR128 : I<0, Pseudo, (outs VR128:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000047 "#IMPLICIT_DEF $dst",
48 [(set VR128:$dst, (v4f32 (undef)))]>,
49 Requires<[HasSSE1]>;
Evan Chengb783fa32007-07-19 01:14:50 +000050def IMPLICIT_DEF_FR32 : I<0, Pseudo, (outs FR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000051 "#IMPLICIT_DEF $dst",
Dale Johannesene0e0fd02007-09-23 14:52:20 +000052 [(set FR32:$dst, (undef))]>, Requires<[HasSSE1]>;
Evan Chengb783fa32007-07-19 01:14:50 +000053def IMPLICIT_DEF_FR64 : I<0, Pseudo, (outs FR64:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000054 "#IMPLICIT_DEF $dst",
55 [(set FR64:$dst, (undef))]>, Requires<[HasSSE2]>;
56
57//===----------------------------------------------------------------------===//
58// SSE Complex Patterns
59//===----------------------------------------------------------------------===//
60
61// These are 'extloads' from a scalar to the low element of a vector, zeroing
62// the top elements. These are used for the SSE 'ss' and 'sd' instruction
63// forms.
64def sse_load_f32 : ComplexPattern<v4f32, 4, "SelectScalarSSELoad", [],
65 [SDNPHasChain]>;
66def sse_load_f64 : ComplexPattern<v2f64, 4, "SelectScalarSSELoad", [],
67 [SDNPHasChain]>;
68
69def ssmem : Operand<v4f32> {
70 let PrintMethod = "printf32mem";
71 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
72}
73def sdmem : Operand<v2f64> {
74 let PrintMethod = "printf64mem";
75 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
76}
77
78//===----------------------------------------------------------------------===//
79// SSE pattern fragments
80//===----------------------------------------------------------------------===//
81
Dan Gohmanf17a25c2007-07-18 16:29:46 +000082def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
83def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
84def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
85def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
86
Dan Gohman11821702007-07-27 17:16:43 +000087// Like 'store', but always requires vector alignment.
Dan Gohman4a4f1512007-07-18 20:23:34 +000088def alignedstore : PatFrag<(ops node:$val, node:$ptr),
89 (st node:$val, node:$ptr), [{
90 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
91 return !ST->isTruncatingStore() &&
92 ST->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +000093 ST->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +000094 return false;
95}]>;
96
Dan Gohman11821702007-07-27 17:16:43 +000097// Like 'load', but always requires vector alignment.
Dan Gohman4a4f1512007-07-18 20:23:34 +000098def alignedload : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
99 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
100 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
101 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +0000102 LD->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000103 return false;
104}]>;
105
Dan Gohman11821702007-07-27 17:16:43 +0000106def alignedloadfsf32 : PatFrag<(ops node:$ptr), (f32 (alignedload node:$ptr))>;
107def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000108def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>;
109def alignedloadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (alignedload node:$ptr))>;
110def alignedloadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (alignedload node:$ptr))>;
111def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>;
112
113// Like 'load', but uses special alignment checks suitable for use in
114// memory operands in most SSE instructions, which are required to
115// be naturally aligned on some targets but not on others.
116// FIXME: Actually implement support for targets that don't require the
117// alignment. This probably wants a subtarget predicate.
118def memop : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
119 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
120 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
121 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +0000122 LD->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000123 return false;
124}]>;
125
Dan Gohman11821702007-07-27 17:16:43 +0000126def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
127def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000128def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
129def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
130def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
131def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
132
Bill Wendling3b15d722007-08-11 09:52:53 +0000133// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
134// 16-byte boundary.
135def memop64 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
136 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
137 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
138 LD->getAddressingMode() == ISD::UNINDEXED &&
139 LD->getAlignment() >= 8;
140 return false;
141}]>;
142
143def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
144def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop64 node:$ptr))>;
145def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
146def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
147def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
148
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
150def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
151def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
152def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
153def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
154def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
155
156def fp32imm0 : PatLeaf<(f32 fpimm), [{
157 return N->isExactlyValue(+0.0);
158}]>;
159
160def PSxLDQ_imm : SDNodeXForm<imm, [{
161 // Transformation function: imm >> 3
162 return getI32Imm(N->getValue() >> 3);
163}]>;
164
165// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
166// SHUFP* etc. imm.
167def SHUFFLE_get_shuf_imm : SDNodeXForm<build_vector, [{
168 return getI8Imm(X86::getShuffleSHUFImmediate(N));
169}]>;
170
171// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
172// PSHUFHW imm.
173def SHUFFLE_get_pshufhw_imm : SDNodeXForm<build_vector, [{
174 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
175}]>;
176
177// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
178// PSHUFLW imm.
179def SHUFFLE_get_pshuflw_imm : SDNodeXForm<build_vector, [{
180 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
181}]>;
182
183def SSE_splat_mask : PatLeaf<(build_vector), [{
184 return X86::isSplatMask(N);
185}], SHUFFLE_get_shuf_imm>;
186
187def SSE_splat_lo_mask : PatLeaf<(build_vector), [{
188 return X86::isSplatLoMask(N);
189}]>;
190
191def MOVHLPS_shuffle_mask : PatLeaf<(build_vector), [{
192 return X86::isMOVHLPSMask(N);
193}]>;
194
195def MOVHLPS_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
196 return X86::isMOVHLPS_v_undef_Mask(N);
197}]>;
198
199def MOVHP_shuffle_mask : PatLeaf<(build_vector), [{
200 return X86::isMOVHPMask(N);
201}]>;
202
203def MOVLP_shuffle_mask : PatLeaf<(build_vector), [{
204 return X86::isMOVLPMask(N);
205}]>;
206
207def MOVL_shuffle_mask : PatLeaf<(build_vector), [{
208 return X86::isMOVLMask(N);
209}]>;
210
211def MOVSHDUP_shuffle_mask : PatLeaf<(build_vector), [{
212 return X86::isMOVSHDUPMask(N);
213}]>;
214
215def MOVSLDUP_shuffle_mask : PatLeaf<(build_vector), [{
216 return X86::isMOVSLDUPMask(N);
217}]>;
218
219def UNPCKL_shuffle_mask : PatLeaf<(build_vector), [{
220 return X86::isUNPCKLMask(N);
221}]>;
222
223def UNPCKH_shuffle_mask : PatLeaf<(build_vector), [{
224 return X86::isUNPCKHMask(N);
225}]>;
226
227def UNPCKL_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
228 return X86::isUNPCKL_v_undef_Mask(N);
229}]>;
230
231def UNPCKH_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
232 return X86::isUNPCKH_v_undef_Mask(N);
233}]>;
234
235def PSHUFD_shuffle_mask : PatLeaf<(build_vector), [{
236 return X86::isPSHUFDMask(N);
237}], SHUFFLE_get_shuf_imm>;
238
239def PSHUFHW_shuffle_mask : PatLeaf<(build_vector), [{
240 return X86::isPSHUFHWMask(N);
241}], SHUFFLE_get_pshufhw_imm>;
242
243def PSHUFLW_shuffle_mask : PatLeaf<(build_vector), [{
244 return X86::isPSHUFLWMask(N);
245}], SHUFFLE_get_pshuflw_imm>;
246
247def SHUFP_unary_shuffle_mask : PatLeaf<(build_vector), [{
248 return X86::isPSHUFDMask(N);
249}], SHUFFLE_get_shuf_imm>;
250
251def SHUFP_shuffle_mask : PatLeaf<(build_vector), [{
252 return X86::isSHUFPMask(N);
253}], SHUFFLE_get_shuf_imm>;
254
255def PSHUFD_binary_shuffle_mask : PatLeaf<(build_vector), [{
256 return X86::isSHUFPMask(N);
257}], SHUFFLE_get_shuf_imm>;
258
259//===----------------------------------------------------------------------===//
260// SSE scalar FP Instructions
261//===----------------------------------------------------------------------===//
262
263// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
264// scheduler into a branch sequence.
Evan Cheng950aac02007-09-25 01:57:46 +0000265// These are expanded by the scheduler.
266let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000267 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!",
Evan Cheng621216e2007-09-29 00:00:36 +0000270 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
271 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000273 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274 "#CMOV_FR64 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000275 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
276 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000277 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000278 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000279 "#CMOV_V4F32 PSEUDO!",
280 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000281 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
282 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000283 def CMOV_V2F64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000284 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000285 "#CMOV_V2F64 PSEUDO!",
286 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000287 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
288 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000289 def CMOV_V2I64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000290 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291 "#CMOV_V2I64 PSEUDO!",
292 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000293 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng950aac02007-09-25 01:57:46 +0000294 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295}
296
297//===----------------------------------------------------------------------===//
298// SSE1 Instructions
299//===----------------------------------------------------------------------===//
300
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000301// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000302def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000303 "movss\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000304let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000305def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000306 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000308def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000309 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310 [(store FR32:$src, addr:$dst)]>;
311
312// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000313def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000314 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000316def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000317 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000319def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000320 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000321 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000322def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000323 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000324 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
325
326// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000327def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000328 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000330def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000331 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000332 [(set GR32:$dst, (int_x86_sse_cvtss2si
333 (load addr:$src)))]>;
334
Dale Johannesen1fbb4a52007-10-30 22:15:38 +0000335// Match intrinisics which expect MM and XMM operand(s).
336def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
337 "cvtps2pi\t{$src, $dst|$dst, $src}",
338 [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
339def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
340 "cvtps2pi\t{$src, $dst|$dst, $src}",
341 [(set VR64:$dst, (int_x86_sse_cvtps2pi
342 (load addr:$src)))]>;
343def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
344 "cvttps2pi\t{$src, $dst|$dst, $src}",
345 [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>;
346def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
347 "cvttps2pi\t{$src, $dst|$dst, $src}",
348 [(set VR64:$dst, (int_x86_sse_cvttps2pi
349 (load addr:$src)))]>;
350let isTwoAddress = 1 in {
351 def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg,
352 (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
353 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
354 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
355 VR64:$src2))]>;
356 def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem,
357 (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
358 "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
359 [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
360 (load addr:$src2)))]>;
361}
362
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000363// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000364def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000365 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000366 [(set GR32:$dst,
367 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000368def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000369 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000370 [(set GR32:$dst,
371 (int_x86_sse_cvttss2si(load addr:$src)))]>;
372
373let isTwoAddress = 1 in {
374 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000375 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000376 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000377 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
378 GR32:$src2))]>;
379 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000380 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
383 (loadi32 addr:$src2)))]>;
384}
385
386// Comparison instructions
387let isTwoAddress = 1 in {
388 def CMPSSrr : SSI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000389 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000390 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391 def CMPSSrm : SSI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000392 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000393 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394}
395
Evan Cheng55687072007-09-14 21:48:26 +0000396let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000397def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000398 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000399 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000400def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000401 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000402 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000403 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000404} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405
406// Aliases to match intrinsics which expect XMM operand(s).
407let isTwoAddress = 1 in {
408 def Int_CMPSSrr : SSI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000409 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000410 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
412 VR128:$src, imm:$cc))]>;
413 def Int_CMPSSrm : SSI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000414 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000415 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
417 (load addr:$src), imm:$cc))]>;
418}
419
Evan Cheng55687072007-09-14 21:48:26 +0000420let Defs = [EFLAGS] in {
Evan Cheng621216e2007-09-29 00:00:36 +0000421def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000422 (ins VR128:$src1, VR128:$src2),
423 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000424 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000425 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000426def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000427 (ins VR128:$src1, f128mem:$src2),
428 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000429 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000430 (implicit EFLAGS)]>;
431
Evan Cheng621216e2007-09-29 00:00:36 +0000432def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000433 (ins VR128:$src1, VR128:$src2),
434 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000435 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000436 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000437def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000438 (ins VR128:$src1, f128mem:$src2),
439 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000440 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000441 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000442} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443
444// Aliases of packed SSE1 instructions for scalar use. These all have names that
445// start with 'Fs'.
446
447// Alias instructions that map fld0 to pxor for sse.
Dan Gohman8aef09b2007-09-07 21:32:51 +0000448let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000449def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000450 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000451 Requires<[HasSSE1]>, TB, OpSize;
452
453// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
454// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +0000455def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000456 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000457
458// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
459// disregarded.
Evan Cheng4e84e452007-08-30 05:49:43 +0000460let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000461def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000462 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000463 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464
465// Alias bitwise logical operations using SSE logical ops on packed FP values.
466let isTwoAddress = 1 in {
467let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000468 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000469 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000471 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000472 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000474 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000475 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
477}
478
Evan Chengb783fa32007-07-19 01:14:50 +0000479def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000480 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000482 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000483def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000484 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000486 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000487def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000488 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000490 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491
492def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000493 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000494 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000496 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000497 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000498}
499
500/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
501///
502/// In addition, we also have a special variant of the scalar form here to
503/// represent the associated intrinsic operation. This form is unlike the
504/// plain scalar form, in that it takes an entire vector (instead of a scalar)
505/// and leaves the top elements undefined.
506///
507/// These three forms can each be reg+reg or reg+mem, so there are a total of
508/// six "instructions".
509///
510let isTwoAddress = 1 in {
511multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
512 SDNode OpNode, Intrinsic F32Int,
513 bit Commutable = 0> {
514 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000515 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000516 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
518 let isCommutable = Commutable;
519 }
520
521 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000522 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000523 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000524 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
525
526 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000527 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000528 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
530 let isCommutable = Commutable;
531 }
532
533 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000534 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000535 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000536 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537
538 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000539 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000540 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
542 let isCommutable = Commutable;
543 }
544
545 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000546 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000547 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548 [(set VR128:$dst, (F32Int VR128:$src1,
549 sse_load_f32:$src2))]>;
550}
551}
552
553// Arithmetic instructions
554defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
555defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
556defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
557defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
558
559/// sse1_fp_binop_rm - Other SSE1 binops
560///
561/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
562/// instructions for a full-vector intrinsic form. Operations that map
563/// onto C operators don't use this form since they just use the plain
564/// vector form instead of having a separate vector intrinsic form.
565///
566/// This provides a total of eight "instructions".
567///
568let isTwoAddress = 1 in {
569multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
570 SDNode OpNode,
571 Intrinsic F32Int,
572 Intrinsic V4F32Int,
573 bit Commutable = 0> {
574
575 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000576 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000577 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000578 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
579 let isCommutable = Commutable;
580 }
581
582 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000583 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000584 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000585 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
586
587 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000588 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000589 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
591 let isCommutable = Commutable;
592 }
593
594 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000595 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000596 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000597 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598
599 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000600 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000601 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000602 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
603 let isCommutable = Commutable;
604 }
605
606 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000607 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000608 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609 [(set VR128:$dst, (F32Int VR128:$src1,
610 sse_load_f32:$src2))]>;
611
612 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000613 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000614 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
616 let isCommutable = Commutable;
617 }
618
619 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +0000620 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000621 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000622 [(set VR128:$dst, (V4F32Int VR128:$src1, (load addr:$src2)))]>;
623}
624}
625
626defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
627 int_x86_sse_max_ss, int_x86_sse_max_ps>;
628defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
629 int_x86_sse_min_ss, int_x86_sse_min_ps>;
630
631//===----------------------------------------------------------------------===//
632// SSE packed FP Instructions
633
634// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000635def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000636 "movaps\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000637let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000638def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000639 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000640 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641
Evan Chengb783fa32007-07-19 01:14:50 +0000642def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000643 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000644 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645
Evan Chengb783fa32007-07-19 01:14:50 +0000646def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 "movups\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000648let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000649def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000650 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000651 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000652def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000653 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000654 [(store (v4f32 VR128:$src), addr:$dst)]>;
655
656// Intrinsic forms of MOVUPS load and store
Evan Cheng4e84e452007-08-30 05:49:43 +0000657let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000658def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000659 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000660 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000661def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000662 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000663 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664
665let isTwoAddress = 1 in {
666 let AddedComplexity = 20 in {
667 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000668 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000669 "movlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670 [(set VR128:$dst,
671 (v4f32 (vector_shuffle VR128:$src1,
672 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
673 MOVLP_shuffle_mask)))]>;
674 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000675 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000676 "movhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677 [(set VR128:$dst,
678 (v4f32 (vector_shuffle VR128:$src1,
679 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
680 MOVHP_shuffle_mask)))]>;
681 } // AddedComplexity
682} // isTwoAddress
683
Evan Chengb783fa32007-07-19 01:14:50 +0000684def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000685 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
687 (iPTR 0))), addr:$dst)]>;
688
689// v2f64 extract element 1 is always custom lowered to unpack high to low
690// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000691def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000692 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693 [(store (f64 (vector_extract
694 (v2f64 (vector_shuffle
695 (bc_v2f64 (v4f32 VR128:$src)), (undef),
696 UNPCKH_shuffle_mask)), (iPTR 0))),
697 addr:$dst)]>;
698
699let isTwoAddress = 1 in {
700let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000701def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000702 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703 [(set VR128:$dst,
704 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
705 MOVHP_shuffle_mask)))]>;
706
Evan Chengb783fa32007-07-19 01:14:50 +0000707def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 [(set VR128:$dst,
710 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
711 MOVHLPS_shuffle_mask)))]>;
712} // AddedComplexity
713} // isTwoAddress
714
715
716
717// Arithmetic
718
719/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
720///
721/// In addition, we also have a special variant of the scalar form here to
722/// represent the associated intrinsic operation. This form is unlike the
723/// plain scalar form, in that it takes an entire vector (instead of a
724/// scalar) and leaves the top elements undefined.
725///
726/// And, we have a special variant form for a full-vector intrinsic form.
727///
728/// These four forms can each have a reg or a mem operand, so there are a
729/// total of eight "instructions".
730///
731multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
732 SDNode OpNode,
733 Intrinsic F32Int,
734 Intrinsic V4F32Int,
735 bit Commutable = 0> {
736 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000737 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000738 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739 [(set FR32:$dst, (OpNode FR32:$src))]> {
740 let isCommutable = Commutable;
741 }
742
743 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000744 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000745 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
747
748 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000749 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000750 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
752 let isCommutable = Commutable;
753 }
754
755 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000756 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000757 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000758 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759
760 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000761 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000762 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763 [(set VR128:$dst, (F32Int VR128:$src))]> {
764 let isCommutable = Commutable;
765 }
766
767 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000768 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000769 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
771
772 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000773 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000774 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
776 let isCommutable = Commutable;
777 }
778
779 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000780 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000781 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 [(set VR128:$dst, (V4F32Int (load addr:$src)))]>;
783}
784
785// Square root.
786defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
787 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
788
789// Reciprocal approximations. Note that these typically require refinement
790// in order to obtain suitable precision.
791defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
792 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
793defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
794 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
795
796// Logical
797let isTwoAddress = 1 in {
798 let isCommutable = 1 in {
799 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000800 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000801 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 [(set VR128:$dst, (v2i64
803 (and VR128:$src1, VR128:$src2)))]>;
804 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000805 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000806 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807 [(set VR128:$dst, (v2i64
808 (or VR128:$src1, VR128:$src2)))]>;
809 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000810 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000811 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 [(set VR128:$dst, (v2i64
813 (xor VR128:$src1, VR128:$src2)))]>;
814 }
815
816 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000817 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000818 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000819 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
820 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000822 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000823 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000824 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
825 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000827 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000828 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000829 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
830 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000831 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000832 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000833 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 [(set VR128:$dst,
835 (v2i64 (and (xor VR128:$src1,
836 (bc_v2i64 (v4i32 immAllOnesV))),
837 VR128:$src2)))]>;
838 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000839 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000840 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000842 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000844 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845}
846
847let isTwoAddress = 1 in {
848 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000849 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000850 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
852 VR128:$src, imm:$cc))]>;
853 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000854 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000855 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
857 (load addr:$src), imm:$cc))]>;
858}
859
860// Shuffle and unpack instructions
861let isTwoAddress = 1 in {
862 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
863 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000864 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865 VR128:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000866 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867 [(set VR128:$dst,
868 (v4f32 (vector_shuffle
869 VR128:$src1, VR128:$src2,
870 SHUFP_shuffle_mask:$src3)))]>;
871 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000872 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873 f128mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000874 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875 [(set VR128:$dst,
876 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000877 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878 SHUFP_shuffle_mask:$src3)))]>;
879
880 let AddedComplexity = 10 in {
881 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000882 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000883 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 [(set VR128:$dst,
885 (v4f32 (vector_shuffle
886 VR128:$src1, VR128:$src2,
887 UNPCKH_shuffle_mask)))]>;
888 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000889 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000890 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 [(set VR128:$dst,
892 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000893 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894 UNPCKH_shuffle_mask)))]>;
895
896 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000897 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000898 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899 [(set VR128:$dst,
900 (v4f32 (vector_shuffle
901 VR128:$src1, VR128:$src2,
902 UNPCKL_shuffle_mask)))]>;
903 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000904 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000905 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 [(set VR128:$dst,
907 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000908 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 UNPCKL_shuffle_mask)))]>;
910 } // AddedComplexity
911} // isTwoAddress
912
913// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000914def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000915 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000917def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000918 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
920
921// Prefetching loads.
922// TODO: no intrinsics for these?
Dan Gohman91888f02007-07-31 20:11:57 +0000923def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), "prefetcht0\t$src", []>;
924def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src), "prefetcht1\t$src", []>;
925def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src), "prefetcht2\t$src", []>;
926def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src), "prefetchnta\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927
928// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000929def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000930 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
932
933// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +0000934def SFENCE : PSI<0xAE, MRM7m, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935
936// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000937def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000939def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000940 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941
942// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000944def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000945 "xorps\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000946 [(set VR128:$dst, (v4i32 immAllZerosV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947
948// FR32 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +0000949def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000950 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 [(set VR128:$dst,
952 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000953def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000954 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955 [(set VR128:$dst,
956 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
957
958// FIXME: may not be able to eliminate this movss with coalescing the src and
959// dest register classes are different. We really want to write this pattern
960// like this:
961// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
962// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +0000963def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000964 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
966 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000967def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000968 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 [(store (f32 (vector_extract (v4f32 VR128:$src),
970 (iPTR 0))), addr:$dst)]>;
971
972
973// Move to lower bits of a VR128, leaving upper bits alone.
974// Three operand (but two address) aliases.
975let isTwoAddress = 1 in {
976 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000977 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000978 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979
980 let AddedComplexity = 15 in
981 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000982 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000983 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984 [(set VR128:$dst,
985 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
986 MOVL_shuffle_mask)))]>;
987}
988
989// Move to lower bits of a VR128 and zeroing upper bits.
990// Loading from memory automatically zeroing upper bits.
991let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +0000992def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000993 "movss\t{$src, $dst|$dst, $src}",
Chris Lattnere6aa3862007-11-25 00:24:49 +0000994 [(set VR128:$dst, (v4f32 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 (v4f32 (scalar_to_vector (loadf32 addr:$src))),
996 MOVL_shuffle_mask)))]>;
997
998
999//===----------------------------------------------------------------------===//
1000// SSE2 Instructions
1001//===----------------------------------------------------------------------===//
1002
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001004def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001005 "movsd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001006let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001007def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001008 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001010def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001011 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 [(store FR64:$src, addr:$dst)]>;
1013
1014// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001015def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001016 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001018def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001019 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001021def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001022 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001024def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001025 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001027def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001030def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001031 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1033
1034// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001035def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001036 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1038 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001039def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001040 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1042 Requires<[HasSSE2]>;
1043
1044// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001045def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001046 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001048def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001049 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1051 (load addr:$src)))]>;
1052
Dale Johannesen1fbb4a52007-10-30 22:15:38 +00001053// Match intrinisics which expect MM and XMM operand(s).
1054def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1055 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1056 [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
1057def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1058 "cvtpd2pi\t{$src, $dst|$dst, $src}",
1059 [(set VR64:$dst, (int_x86_sse_cvtpd2pi
1060 (load addr:$src)))]>;
1061def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
1062 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1063 [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>;
1064def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src),
1065 "cvttpd2pi\t{$src, $dst|$dst, $src}",
1066 [(set VR64:$dst, (int_x86_sse_cvttpd2pi
1067 (load addr:$src)))]>;
1068def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src),
1069 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1070 [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>;
1071def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
1072 "cvtpi2pd\t{$src, $dst|$dst, $src}",
1073 [(set VR128:$dst, (int_x86_sse_cvtpi2pd
1074 (load addr:$src)))]>;
1075
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001077def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001078 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 [(set GR32:$dst,
1080 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001081def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001082 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1084 (load addr:$src)))]>;
1085
1086// Comparison instructions
1087let isTwoAddress = 1 in {
1088 def CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001089 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001090 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 def CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001092 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001093 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094}
1095
Evan Cheng950aac02007-09-25 01:57:46 +00001096let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001097def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001098 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001099 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001100def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001102 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001103 (implicit EFLAGS)]>;
1104}
1105
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106// Aliases to match intrinsics which expect XMM operand(s).
1107let isTwoAddress = 1 in {
1108 def Int_CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001109 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001110 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1112 VR128:$src, imm:$cc))]>;
1113 def Int_CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001114 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001115 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1117 (load addr:$src), imm:$cc))]>;
1118}
1119
Evan Cheng950aac02007-09-25 01:57:46 +00001120let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001121def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001122 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001123 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1124 (implicit EFLAGS)]>;
1125def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001126 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001127 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1128 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129
Evan Chengb783fa32007-07-19 01:14:50 +00001130def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001131 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001132 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1133 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001134def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001135 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001136 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001137 (implicit EFLAGS)]>;
1138} // Defs = EFLAGS]
1139
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140// Aliases of packed SSE2 instructions for scalar use. These all have names that
1141// start with 'Fs'.
1142
1143// Alias instructions that map fld0 to pxor for sse.
Dan Gohman8aef09b2007-09-07 21:32:51 +00001144let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001145def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001146 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147 Requires<[HasSSE2]>, TB, OpSize;
1148
1149// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1150// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +00001151def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001152 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153
1154// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1155// disregarded.
Evan Cheng4e84e452007-08-30 05:49:43 +00001156let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001157def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001158 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001159 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160
1161// Alias bitwise logical operations using SSE logical ops on packed FP values.
1162let isTwoAddress = 1 in {
1163let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001164 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001165 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001167 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001168 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001170 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001171 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001172 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1173}
1174
Evan Chengb783fa32007-07-19 01:14:50 +00001175def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001176 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001178 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001179def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001180 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001182 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001183def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001184 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001186 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187
1188def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001189 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001190 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001191def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001192 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001193 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194}
1195
1196/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1197///
1198/// In addition, we also have a special variant of the scalar form here to
1199/// represent the associated intrinsic operation. This form is unlike the
1200/// plain scalar form, in that it takes an entire vector (instead of a scalar)
1201/// and leaves the top elements undefined.
1202///
1203/// These three forms can each be reg+reg or reg+mem, so there are a total of
1204/// six "instructions".
1205///
1206let isTwoAddress = 1 in {
1207multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1208 SDNode OpNode, Intrinsic F64Int,
1209 bit Commutable = 0> {
1210 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001211 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001212 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001213 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1214 let isCommutable = Commutable;
1215 }
1216
1217 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001218 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001219 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001220 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1221
1222 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001223 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001224 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1226 let isCommutable = Commutable;
1227 }
1228
1229 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001230 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001231 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001232 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233
1234 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001235 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001236 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001237 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1238 let isCommutable = Commutable;
1239 }
1240
1241 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001242 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001243 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001244 [(set VR128:$dst, (F64Int VR128:$src1,
1245 sse_load_f64:$src2))]>;
1246}
1247}
1248
1249// Arithmetic instructions
1250defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1251defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1252defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1253defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1254
1255/// sse2_fp_binop_rm - Other SSE2 binops
1256///
1257/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1258/// instructions for a full-vector intrinsic form. Operations that map
1259/// onto C operators don't use this form since they just use the plain
1260/// vector form instead of having a separate vector intrinsic form.
1261///
1262/// This provides a total of eight "instructions".
1263///
1264let isTwoAddress = 1 in {
1265multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1266 SDNode OpNode,
1267 Intrinsic F64Int,
1268 Intrinsic V2F64Int,
1269 bit Commutable = 0> {
1270
1271 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001272 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001273 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001274 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1275 let isCommutable = Commutable;
1276 }
1277
1278 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001279 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1282
1283 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001284 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001285 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1287 let isCommutable = Commutable;
1288 }
1289
1290 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001291 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001292 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001293 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294
1295 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001296 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001297 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001298 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1299 let isCommutable = Commutable;
1300 }
1301
1302 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001303 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001304 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(set VR128:$dst, (F64Int VR128:$src1,
1306 sse_load_f64:$src2))]>;
1307
1308 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001309 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001310 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1312 let isCommutable = Commutable;
1313 }
1314
1315 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +00001316 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001317 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318 [(set VR128:$dst, (V2F64Int VR128:$src1, (load addr:$src2)))]>;
1319}
1320}
1321
1322defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1323 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1324defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1325 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1326
1327//===----------------------------------------------------------------------===//
1328// SSE packed FP Instructions
1329
1330// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001331def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001332 "movapd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001333let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001334def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001335 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001336 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337
Evan Chengb783fa32007-07-19 01:14:50 +00001338def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001339 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001340 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341
Evan Chengb783fa32007-07-19 01:14:50 +00001342def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001343 "movupd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001344let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001345def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001346 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001347 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001348def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001349 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001350 [(store (v2f64 VR128:$src), addr:$dst)]>;
1351
1352// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001353def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001354 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001355 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001356def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001357 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001358 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359
1360let isTwoAddress = 1 in {
1361 let AddedComplexity = 20 in {
1362 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001363 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001364 "movlpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 [(set VR128:$dst,
1366 (v2f64 (vector_shuffle VR128:$src1,
1367 (scalar_to_vector (loadf64 addr:$src2)),
1368 MOVLP_shuffle_mask)))]>;
1369 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001370 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001371 "movhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 [(set VR128:$dst,
1373 (v2f64 (vector_shuffle VR128:$src1,
1374 (scalar_to_vector (loadf64 addr:$src2)),
1375 MOVHP_shuffle_mask)))]>;
1376 } // AddedComplexity
1377} // isTwoAddress
1378
Evan Chengb783fa32007-07-19 01:14:50 +00001379def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001380 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381 [(store (f64 (vector_extract (v2f64 VR128:$src),
1382 (iPTR 0))), addr:$dst)]>;
1383
1384// v2f64 extract element 1 is always custom lowered to unpack high to low
1385// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001386def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001387 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001388 [(store (f64 (vector_extract
1389 (v2f64 (vector_shuffle VR128:$src, (undef),
1390 UNPCKH_shuffle_mask)), (iPTR 0))),
1391 addr:$dst)]>;
1392
1393// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001394def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001395 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001396 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1397 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001398def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001399 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
Dan Gohman4a4f1512007-07-18 20:23:34 +00001401 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001402 TB, Requires<[HasSSE2]>;
1403
1404// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001405def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001406 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001407 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1408 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001409def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001410 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
Dan Gohman4a4f1512007-07-18 20:23:34 +00001412 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413 XS, Requires<[HasSSE2]>;
1414
Evan Chengb783fa32007-07-19 01:14:50 +00001415def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001416 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001417 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001418def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001419 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001420 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1421 (load addr:$src)))]>;
1422// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001423def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001424 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001425 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1426 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001427def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001428 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001429 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1430 (load addr:$src)))]>,
1431 XS, Requires<[HasSSE2]>;
1432
1433// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001434def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1437 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001438def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1441 (load addr:$src)))]>,
1442 XD, Requires<[HasSSE2]>;
1443
Evan Chengb783fa32007-07-19 01:14:50 +00001444def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001445 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001447def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001448 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001449 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1450 (load addr:$src)))]>;
1451
1452// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001453def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001454 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1456 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001457def Int_CVTPS2PDrm : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001459 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1460 (load addr:$src)))]>,
1461 TB, Requires<[HasSSE2]>;
1462
Evan Chengb783fa32007-07-19 01:14:50 +00001463def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001465 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001466def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001467 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001468 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1469 (load addr:$src)))]>;
1470
1471// Match intrinsics which expect XMM operand(s).
1472// Aliases for intrinsics
1473let isTwoAddress = 1 in {
1474def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001475 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001476 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001477 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1478 GR32:$src2))]>;
1479def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001480 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1483 (loadi32 addr:$src2)))]>;
1484def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001485 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001487 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1488 VR128:$src2))]>;
1489def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001490 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001491 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001492 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1493 (load addr:$src2)))]>;
1494def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001495 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001497 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1498 VR128:$src2))]>, XS,
1499 Requires<[HasSSE2]>;
1500def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001501 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001502 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001503 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1504 (load addr:$src2)))]>, XS,
1505 Requires<[HasSSE2]>;
1506}
1507
1508// Arithmetic
1509
1510/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1511///
1512/// In addition, we also have a special variant of the scalar form here to
1513/// represent the associated intrinsic operation. This form is unlike the
1514/// plain scalar form, in that it takes an entire vector (instead of a
1515/// scalar) and leaves the top elements undefined.
1516///
1517/// And, we have a special variant form for a full-vector intrinsic form.
1518///
1519/// These four forms can each have a reg or a mem operand, so there are a
1520/// total of eight "instructions".
1521///
1522multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1523 SDNode OpNode,
1524 Intrinsic F64Int,
1525 Intrinsic V2F64Int,
1526 bit Commutable = 0> {
1527 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001528 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001529 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530 [(set FR64:$dst, (OpNode FR64:$src))]> {
1531 let isCommutable = Commutable;
1532 }
1533
1534 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001535 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1538
1539 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001540 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001542 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1543 let isCommutable = Commutable;
1544 }
1545
1546 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001547 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001549 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001550
1551 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001552 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554 [(set VR128:$dst, (F64Int VR128:$src))]> {
1555 let isCommutable = Commutable;
1556 }
1557
1558 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001559 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001560 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1562
1563 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001564 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001565 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001566 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1567 let isCommutable = Commutable;
1568 }
1569
1570 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001571 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001572 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001573 [(set VR128:$dst, (V2F64Int (load addr:$src)))]>;
1574}
1575
1576// Square root.
1577defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1578 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1579
1580// There is no f64 version of the reciprocal approximation instructions.
1581
1582// Logical
1583let isTwoAddress = 1 in {
1584 let isCommutable = 1 in {
1585 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001586 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001587 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001588 [(set VR128:$dst,
1589 (and (bc_v2i64 (v2f64 VR128:$src1)),
1590 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1591 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001592 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001593 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001594 [(set VR128:$dst,
1595 (or (bc_v2i64 (v2f64 VR128:$src1)),
1596 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1597 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001598 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001599 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600 [(set VR128:$dst,
1601 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1602 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1603 }
1604
1605 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001606 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001607 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001608 [(set VR128:$dst,
1609 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001610 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001611 def ORPDrm : PDI<0x56, 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 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614 [(set VR128:$dst,
1615 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001616 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001618 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620 [(set VR128:$dst,
1621 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001622 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001624 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001625 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626 [(set VR128:$dst,
1627 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1628 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1629 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001630 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001631 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632 [(set VR128:$dst,
1633 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001634 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001635}
1636
1637let isTwoAddress = 1 in {
1638 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001639 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001640 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1642 VR128:$src, imm:$cc))]>;
1643 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001644 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001645 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001646 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1647 (load addr:$src), imm:$cc))]>;
1648}
1649
1650// Shuffle and unpack instructions
1651let isTwoAddress = 1 in {
1652 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001653 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001654 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001655 [(set VR128:$dst, (v2f64 (vector_shuffle
1656 VR128:$src1, VR128:$src2,
1657 SHUFP_shuffle_mask:$src3)))]>;
1658 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001659 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001660 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001661 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001662 [(set VR128:$dst,
1663 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001664 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 SHUFP_shuffle_mask:$src3)))]>;
1666
1667 let AddedComplexity = 10 in {
1668 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001669 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001670 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001671 [(set VR128:$dst,
1672 (v2f64 (vector_shuffle
1673 VR128:$src1, VR128:$src2,
1674 UNPCKH_shuffle_mask)))]>;
1675 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001676 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678 [(set VR128:$dst,
1679 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001680 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001681 UNPCKH_shuffle_mask)))]>;
1682
1683 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001684 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001685 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001686 [(set VR128:$dst,
1687 (v2f64 (vector_shuffle
1688 VR128:$src1, VR128:$src2,
1689 UNPCKL_shuffle_mask)))]>;
1690 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001691 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001692 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693 [(set VR128:$dst,
1694 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001695 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001696 UNPCKL_shuffle_mask)))]>;
1697 } // AddedComplexity
1698} // isTwoAddress
1699
1700
1701//===----------------------------------------------------------------------===//
1702// SSE integer instructions
1703
1704// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001705def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "movdqa\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001707let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001708def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001710 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001711def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001712 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001713 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001714let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001715def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001717 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001718 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001719def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001721 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722 XS, Requires<[HasSSE2]>;
1723
Dan Gohman4a4f1512007-07-18 20:23:34 +00001724// Intrinsic forms of MOVDQU load and store
Evan Cheng4e84e452007-08-30 05:49:43 +00001725let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001726def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001727 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001728 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1729 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001730def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001731 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001732 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1733 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001734
1735let isTwoAddress = 1 in {
1736
1737multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1738 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001739 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1742 let isCommutable = Commutable;
1743 }
Evan Chengb783fa32007-07-19 01:14:50 +00001744 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001745 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001747 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001748}
1749
1750multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1751 string OpcodeStr, Intrinsic IntId> {
Evan Chengb783fa32007-07-19 01:14:50 +00001752 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001753 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001754 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001755 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001758 (bitconvert (memopv2i64 addr:$src2))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001759 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001760 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761 [(set VR128:$dst, (IntId VR128:$src1,
1762 (scalar_to_vector (i32 imm:$src2))))]>;
1763}
1764
1765
1766/// PDI_binop_rm - Simple SSE2 binary operator.
1767multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1768 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001769 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001770 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001771 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1772 let isCommutable = Commutable;
1773 }
Evan Chengb783fa32007-07-19 01:14:50 +00001774 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001775 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001777 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778}
1779
1780/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1781///
1782/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1783/// to collapse (bitconvert VT to VT) into its operand.
1784///
1785multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1786 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001787 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001788 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001789 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1790 let isCommutable = Commutable;
1791 }
Evan Chengb783fa32007-07-19 01:14:50 +00001792 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001793 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001794 [(set VR128:$dst, (OpNode VR128:$src1,(memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795}
1796
1797} // isTwoAddress
1798
1799// 128-bit Integer Arithmetic
1800
1801defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1802defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1803defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1804defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1805
1806defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1807defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1808defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1809defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1810
1811defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1812defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1813defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1814defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1815
1816defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1817defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1818defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1819defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1820
1821defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1822
1823defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1824defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1825defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1826
1827defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1828
1829defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1830defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1831
1832
1833defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1834defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1835defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1836defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1837defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>;
1838
1839
1840defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", int_x86_sse2_psll_w>;
1841defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", int_x86_sse2_psll_d>;
1842defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", int_x86_sse2_psll_q>;
1843
1844defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", int_x86_sse2_psrl_w>;
1845defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", int_x86_sse2_psrl_d>;
1846defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq", int_x86_sse2_psrl_q>;
1847
1848defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", int_x86_sse2_psra_w>;
1849defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad", int_x86_sse2_psra_d>;
1850// PSRAQ doesn't exist in SSE[1-3].
1851
1852// 128-bit logical shifts.
1853let isTwoAddress = 1 in {
1854 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001855 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001858 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 // PSRADQri doesn't exist in SSE[1-3].
1861}
1862
1863let Predicates = [HasSSE2] in {
1864 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1865 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1866 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1867 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1868 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1869 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1870}
1871
1872// Logical
1873defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1874defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1875defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1876
1877let isTwoAddress = 1 in {
1878 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001879 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001881 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1882 VR128:$src2)))]>;
1883
1884 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001885 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001886 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001887 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00001888 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001889}
1890
1891// SSE2 Integer comparison
1892defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1893defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
1894defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
1895defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
1896defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
1897defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
1898
1899// Pack instructions
1900defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
1901defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
1902defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
1903
1904// Shuffle and unpack instructions
1905def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001906 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 [(set VR128:$dst, (v4i32 (vector_shuffle
1909 VR128:$src1, (undef),
1910 PSHUFD_shuffle_mask:$src2)))]>;
1911def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001912 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001913 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001914 [(set VR128:$dst, (v4i32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001915 (bc_v4i32(memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916 (undef),
1917 PSHUFD_shuffle_mask:$src2)))]>;
1918
1919// SSE2 with ImmT == Imm8 and XS prefix.
1920def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001921 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923 [(set VR128:$dst, (v8i16 (vector_shuffle
1924 VR128:$src1, (undef),
1925 PSHUFHW_shuffle_mask:$src2)))]>,
1926 XS, Requires<[HasSSE2]>;
1927def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001928 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001931 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 (undef),
1933 PSHUFHW_shuffle_mask:$src2)))]>,
1934 XS, Requires<[HasSSE2]>;
1935
1936// SSE2 with ImmT == Imm8 and XD prefix.
1937def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001938 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001939 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001940 [(set VR128:$dst, (v8i16 (vector_shuffle
1941 VR128:$src1, (undef),
1942 PSHUFLW_shuffle_mask:$src2)))]>,
1943 XD, Requires<[HasSSE2]>;
1944def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001945 (outs VR128:$dst), (ins i128mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001948 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001949 (undef),
1950 PSHUFLW_shuffle_mask:$src2)))]>,
1951 XD, Requires<[HasSSE2]>;
1952
1953
1954let isTwoAddress = 1 in {
1955 def PUNPCKLBWrr : PDI<0x60, 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 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(set VR128:$dst,
1959 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1960 UNPCKL_shuffle_mask)))]>;
1961 def PUNPCKLBWrm : PDI<0x60, 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 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(set VR128:$dst,
1965 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001966 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967 UNPCKL_shuffle_mask)))]>;
1968 def PUNPCKLWDrr : PDI<0x61, 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 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001971 [(set VR128:$dst,
1972 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1973 UNPCKL_shuffle_mask)))]>;
1974 def PUNPCKLWDrm : PDI<0x61, 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 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(set VR128:$dst,
1978 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001979 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 UNPCKL_shuffle_mask)))]>;
1981 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001982 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 [(set VR128:$dst,
1985 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1986 UNPCKL_shuffle_mask)))]>;
1987 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001988 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001989 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001990 [(set VR128:$dst,
1991 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001992 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 UNPCKL_shuffle_mask)))]>;
1994 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001995 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001996 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001997 [(set VR128:$dst,
1998 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1999 UNPCKL_shuffle_mask)))]>;
2000 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002001 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002002 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002003 [(set VR128:$dst,
2004 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002005 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002006 UNPCKL_shuffle_mask)))]>;
2007
2008 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002009 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002010 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011 [(set VR128:$dst,
2012 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
2013 UNPCKH_shuffle_mask)))]>;
2014 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002015 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002016 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017 [(set VR128:$dst,
2018 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002019 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020 UNPCKH_shuffle_mask)))]>;
2021 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002022 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002023 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002024 [(set VR128:$dst,
2025 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
2026 UNPCKH_shuffle_mask)))]>;
2027 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002028 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002029 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 [(set VR128:$dst,
2031 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002032 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033 UNPCKH_shuffle_mask)))]>;
2034 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002035 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002036 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002037 [(set VR128:$dst,
2038 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2039 UNPCKH_shuffle_mask)))]>;
2040 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002041 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002042 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043 [(set VR128:$dst,
2044 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002045 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 UNPCKH_shuffle_mask)))]>;
2047 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002048 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 [(set VR128:$dst,
2051 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2052 UNPCKH_shuffle_mask)))]>;
2053 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002054 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002055 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002056 [(set VR128:$dst,
2057 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002058 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002059 UNPCKH_shuffle_mask)))]>;
2060}
2061
2062// Extract / Insert
2063def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002064 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002065 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002066 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
2067 (iPTR imm:$src2)))]>;
2068let isTwoAddress = 1 in {
2069 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002070 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002072 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002073 [(set VR128:$dst,
2074 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
2075 GR32:$src2, (iPTR imm:$src3))))]>;
2076 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002077 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002080 [(set VR128:$dst,
2081 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
2082 (i32 (anyext (loadi16 addr:$src2))),
2083 (iPTR imm:$src3))))]>;
2084}
2085
2086// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002087def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002088 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2090
2091// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002092let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002093def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002094 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002095 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096
2097// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002098def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002099 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002100 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002101def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002102 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002104def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002105 "movnti\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002106 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2107 TB, Requires<[HasSSE2]>;
2108
2109// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002110def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 TB, Requires<[HasSSE2]>;
2113
2114// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +00002115def LFENCE : I<0xAE, MRM5m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002116 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002117def MFENCE : I<0xAE, MRM6m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2119
2120
2121// Alias instructions that map zero vector to pxor / xorp* for sse.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002122let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002123 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002124 "pcmpeqd\t$dst, $dst",
Chris Lattnere6aa3862007-11-25 00:24:49 +00002125 [(set VR128:$dst, (v4i32 immAllOnesV))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126
2127// FR64 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +00002128def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002129 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130 [(set VR128:$dst,
2131 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002132def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(set VR128:$dst,
2135 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2136
Evan Chengb783fa32007-07-19 01:14:50 +00002137def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002138 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 [(set VR128:$dst,
2140 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002141def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002143 [(set VR128:$dst,
2144 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2145
Evan Chengb783fa32007-07-19 01:14:50 +00002146def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2149
Evan Chengb783fa32007-07-19 01:14:50 +00002150def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2153
2154// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002155def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002156 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002157 [(set VR128:$dst,
2158 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2159 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002160def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002161 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002162 [(store (i64 (vector_extract (v2i64 VR128:$src),
2163 (iPTR 0))), addr:$dst)]>;
2164
2165// FIXME: may not be able to eliminate this movss with coalescing the src and
2166// dest register classes are different. We really want to write this pattern
2167// like this:
2168// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2169// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +00002170def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2173 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002174def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002175 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002176 [(store (f64 (vector_extract (v2f64 VR128:$src),
2177 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002178def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002179 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002180 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2181 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002182def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002183 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 [(store (i32 (vector_extract (v4i32 VR128:$src),
2185 (iPTR 0))), addr:$dst)]>;
2186
Evan Chengb783fa32007-07-19 01:14:50 +00002187def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002188 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002189 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002190def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002191 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2193
2194
2195// Move to lower bits of a VR128, leaving upper bits alone.
2196// Three operand (but two address) aliases.
2197let isTwoAddress = 1 in {
2198 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002199 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002200 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002201
2202 let AddedComplexity = 15 in
2203 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002204 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 [(set VR128:$dst,
2207 (v2f64 (vector_shuffle VR128:$src1, VR128:$src2,
2208 MOVL_shuffle_mask)))]>;
2209}
2210
2211// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002212def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2215
2216// Move to lower bits of a VR128 and zeroing upper bits.
2217// Loading from memory automatically zeroing upper bits.
2218let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002219 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002220 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002221 [(set VR128:$dst,
Chris Lattnere6aa3862007-11-25 00:24:49 +00002222 (v2f64 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002223 (v2f64 (scalar_to_vector
2224 (loadf64 addr:$src))),
2225 MOVL_shuffle_mask)))]>;
2226
2227let AddedComplexity = 15 in
2228// movd / movq to XMM register zero-extends
Evan Chengb783fa32007-07-19 01:14:50 +00002229def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231 [(set VR128:$dst,
2232 (v4i32 (vector_shuffle immAllZerosV,
2233 (v4i32 (scalar_to_vector GR32:$src)),
2234 MOVL_shuffle_mask)))]>;
2235let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002236def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002237 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238 [(set VR128:$dst,
2239 (v4i32 (vector_shuffle immAllZerosV,
2240 (v4i32 (scalar_to_vector (loadi32 addr:$src))),
2241 MOVL_shuffle_mask)))]>;
2242
2243// Moving from XMM to XMM but still clear upper 64 bits.
2244let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002245def MOVZQI2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247 [(set VR128:$dst, (int_x86_sse2_movl_dq VR128:$src))]>,
2248 XS, Requires<[HasSSE2]>;
2249let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002250def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002251 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252 [(set VR128:$dst, (int_x86_sse2_movl_dq
Dan Gohman4a4f1512007-07-18 20:23:34 +00002253 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254 XS, Requires<[HasSSE2]>;
2255
2256
2257//===----------------------------------------------------------------------===//
2258// SSE3 Instructions
2259//===----------------------------------------------------------------------===//
2260
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002262def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002263 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002264 [(set VR128:$dst, (v4f32 (vector_shuffle
2265 VR128:$src, (undef),
2266 MOVSHDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002267def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002268 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002270 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002271 MOVSHDUP_shuffle_mask)))]>;
2272
Evan Chengb783fa32007-07-19 01:14:50 +00002273def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002274 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002275 [(set VR128:$dst, (v4f32 (vector_shuffle
2276 VR128:$src, (undef),
2277 MOVSLDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002278def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002279 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002281 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282 MOVSLDUP_shuffle_mask)))]>;
2283
Evan Chengb783fa32007-07-19 01:14:50 +00002284def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002286 [(set VR128:$dst, (v2f64 (vector_shuffle
2287 VR128:$src, (undef),
2288 SSE_splat_lo_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002289def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002290 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291 [(set VR128:$dst,
2292 (v2f64 (vector_shuffle
2293 (scalar_to_vector (loadf64 addr:$src)),
2294 (undef),
2295 SSE_splat_lo_mask)))]>;
2296
2297// Arithmetic
2298let isTwoAddress = 1 in {
2299 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002300 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002302 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2303 VR128:$src2))]>;
2304 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002305 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002306 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002307 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2308 (load addr:$src2)))]>;
2309 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002310 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002311 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002312 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2313 VR128:$src2))]>;
2314 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002315 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2318 (load addr:$src2)))]>;
2319}
2320
Evan Chengb783fa32007-07-19 01:14:50 +00002321def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002322 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2324
2325// Horizontal ops
2326class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002327 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002328 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002329 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2330class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002331 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002332 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002333 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (load addr:$src2))))]>;
2334class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002335 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002336 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002337 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2338class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002339 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002340 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002341 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (load addr:$src2))))]>;
2342
2343let isTwoAddress = 1 in {
2344 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2345 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2346 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2347 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2348 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2349 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2350 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2351 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2352}
2353
2354// Thread synchronization
Evan Chengb783fa32007-07-19 01:14:50 +00002355def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002357def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002358 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2359
2360// vector_shuffle v1, <undef> <1, 1, 3, 3>
2361let AddedComplexity = 15 in
2362def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2363 MOVSHDUP_shuffle_mask)),
2364 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2365let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002366def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002367 MOVSHDUP_shuffle_mask)),
2368 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2369
2370// vector_shuffle v1, <undef> <0, 0, 2, 2>
2371let AddedComplexity = 15 in
2372 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2373 MOVSLDUP_shuffle_mask)),
2374 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2375let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002376 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002377 MOVSLDUP_shuffle_mask)),
2378 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2379
2380//===----------------------------------------------------------------------===//
2381// SSSE3 Instructions
2382//===----------------------------------------------------------------------===//
2383
Bill Wendling3b15d722007-08-11 09:52:53 +00002384// SSSE3 Instruction Templates:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002385//
Bill Wendling98680292007-08-10 06:22:27 +00002386// SS38I - SSSE3 instructions with T8 prefix.
2387// SS3AI - SSSE3 instructions with TA prefix.
Bill Wendling3b15d722007-08-11 09:52:53 +00002388//
2389// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
2390// uses the MMX registers. We put those instructions here because they better
2391// fit into the SSSE3 instruction category rather than the MMX category.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002392
Evan Chengb783fa32007-07-19 01:14:50 +00002393class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
2394 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002395 : I<o, F, outs, ins, asm, pattern>, T8, Requires<[HasSSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002396class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
2397 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002398 : I<o, F, outs, ins, asm, pattern>, TA, Requires<[HasSSSE3]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002399
Bill Wendling98680292007-08-10 06:22:27 +00002400/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002401let isTwoAddress = 1 in {
Bill Wendling98680292007-08-10 06:22:27 +00002402 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2403 Intrinsic IntId64, Intrinsic IntId128,
2404 bit Commutable = 0> {
2405 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2406 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2407 [(set VR64:$dst, (IntId64 VR64:$src))]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002408 let isCommutable = Commutable;
2409 }
Bill Wendling98680292007-08-10 06:22:27 +00002410 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2411 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2412 [(set VR64:$dst,
2413 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2414
2415 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2416 (ins VR128:$src),
2417 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2418 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2419 OpSize {
2420 let isCommutable = Commutable;
2421 }
2422 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2423 (ins i128mem:$src),
2424 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2425 [(set VR128:$dst,
2426 (IntId128
2427 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002428 }
2429}
2430
Bill Wendling98680292007-08-10 06:22:27 +00002431/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2432let isTwoAddress = 1 in {
2433 multiclass SS3I_unop_rm_int_16<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:$src),
2438 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2439 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2440 let isCommutable = Commutable;
2441 }
2442 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2443 (ins i64mem:$src),
2444 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2445 [(set VR64:$dst,
2446 (IntId64
2447 (bitconvert (memopv4i16 addr:$src))))]>;
2448
2449 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2450 (ins VR128:$src),
2451 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2452 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2453 OpSize {
2454 let isCommutable = Commutable;
2455 }
2456 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2457 (ins i128mem:$src),
2458 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2459 [(set VR128:$dst,
2460 (IntId128
2461 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2462 }
2463}
2464
2465/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2466let isTwoAddress = 1 in {
2467 multiclass SS3I_unop_rm_int_32<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:$src),
2472 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2473 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2474 let isCommutable = Commutable;
2475 }
2476 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2477 (ins i64mem:$src),
2478 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2479 [(set VR64:$dst,
2480 (IntId64
2481 (bitconvert (memopv2i32 addr:$src))))]>;
2482
2483 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2484 (ins VR128:$src),
2485 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2486 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2487 OpSize {
2488 let isCommutable = Commutable;
2489 }
2490 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2491 (ins i128mem:$src),
2492 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2493 [(set VR128:$dst,
2494 (IntId128
2495 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2496 }
2497}
2498
2499defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2500 int_x86_ssse3_pabs_b,
2501 int_x86_ssse3_pabs_b_128>;
2502defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2503 int_x86_ssse3_pabs_w,
2504 int_x86_ssse3_pabs_w_128>;
2505defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2506 int_x86_ssse3_pabs_d,
2507 int_x86_ssse3_pabs_d_128>;
2508
2509/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2510let isTwoAddress = 1 in {
2511 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2512 Intrinsic IntId64, Intrinsic IntId128,
2513 bit Commutable = 0> {
2514 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2515 (ins VR64:$src1, VR64:$src2),
2516 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2517 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2518 let isCommutable = Commutable;
2519 }
2520 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2521 (ins VR64:$src1, i64mem:$src2),
2522 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2523 [(set VR64:$dst,
2524 (IntId64 VR64:$src1,
2525 (bitconvert (memopv8i8 addr:$src2))))]>;
2526
2527 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2528 (ins VR128:$src1, VR128:$src2),
2529 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2530 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2531 OpSize {
2532 let isCommutable = Commutable;
2533 }
2534 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2535 (ins VR128:$src1, i128mem:$src2),
2536 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2537 [(set VR128:$dst,
2538 (IntId128 VR128:$src1,
2539 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2540 }
2541}
2542
2543/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2544let isTwoAddress = 1 in {
2545 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2546 Intrinsic IntId64, Intrinsic IntId128,
2547 bit Commutable = 0> {
2548 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2549 (ins VR64:$src1, VR64:$src2),
2550 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2551 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2552 let isCommutable = Commutable;
2553 }
2554 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2555 (ins VR64:$src1, i64mem:$src2),
2556 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2557 [(set VR64:$dst,
2558 (IntId64 VR64:$src1,
2559 (bitconvert (memopv4i16 addr:$src2))))]>;
2560
2561 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2562 (ins VR128:$src1, VR128:$src2),
2563 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2564 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2565 OpSize {
2566 let isCommutable = Commutable;
2567 }
2568 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2569 (ins VR128:$src1, i128mem:$src2),
2570 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2571 [(set VR128:$dst,
2572 (IntId128 VR128:$src1,
2573 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2574 }
2575}
2576
2577/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2578let isTwoAddress = 1 in {
2579 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2580 Intrinsic IntId64, Intrinsic IntId128,
2581 bit Commutable = 0> {
2582 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2583 (ins VR64:$src1, VR64:$src2),
2584 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2585 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2586 let isCommutable = Commutable;
2587 }
2588 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2589 (ins VR64:$src1, i64mem:$src2),
2590 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2591 [(set VR64:$dst,
2592 (IntId64 VR64:$src1,
2593 (bitconvert (memopv2i32 addr:$src2))))]>;
2594
2595 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2596 (ins VR128:$src1, VR128:$src2),
2597 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2598 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2599 OpSize {
2600 let isCommutable = Commutable;
2601 }
2602 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2603 (ins VR128:$src1, i128mem:$src2),
2604 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2605 [(set VR128:$dst,
2606 (IntId128 VR128:$src1,
2607 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2608 }
2609}
2610
2611defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2612 int_x86_ssse3_phadd_w,
2613 int_x86_ssse3_phadd_w_128, 1>;
2614defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2615 int_x86_ssse3_phadd_d,
2616 int_x86_ssse3_phadd_d_128, 1>;
2617defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2618 int_x86_ssse3_phadd_sw,
2619 int_x86_ssse3_phadd_sw_128, 1>;
2620defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2621 int_x86_ssse3_phsub_w,
2622 int_x86_ssse3_phsub_w_128>;
2623defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2624 int_x86_ssse3_phsub_d,
2625 int_x86_ssse3_phsub_d_128>;
2626defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2627 int_x86_ssse3_phsub_sw,
2628 int_x86_ssse3_phsub_sw_128>;
2629defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2630 int_x86_ssse3_pmadd_ub_sw,
2631 int_x86_ssse3_pmadd_ub_sw_128, 1>;
2632defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2633 int_x86_ssse3_pmul_hr_sw,
2634 int_x86_ssse3_pmul_hr_sw_128, 1>;
2635defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2636 int_x86_ssse3_pshuf_b,
2637 int_x86_ssse3_pshuf_b_128>;
2638defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2639 int_x86_ssse3_psign_b,
2640 int_x86_ssse3_psign_b_128>;
2641defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2642 int_x86_ssse3_psign_w,
2643 int_x86_ssse3_psign_w_128>;
2644defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2645 int_x86_ssse3_psign_d,
2646 int_x86_ssse3_psign_d_128>;
2647
2648let isTwoAddress = 1 in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002649 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2650 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002651 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002652 [(set VR64:$dst,
2653 (int_x86_ssse3_palign_r
2654 VR64:$src1, VR64:$src2,
2655 imm:$src3))]>;
2656 def PALIGNR64rm : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2657 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002658 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002659 [(set VR64:$dst,
2660 (int_x86_ssse3_palign_r
2661 VR64:$src1,
2662 (bitconvert (memopv2i32 addr:$src2)),
2663 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002664
Bill Wendling1dc817c2007-08-10 09:00:17 +00002665 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2666 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002667 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002668 [(set VR128:$dst,
2669 (int_x86_ssse3_palign_r_128
2670 VR128:$src1, VR128:$src2,
2671 imm:$src3))]>, OpSize;
2672 def PALIGNR128rm : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2673 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002674 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002675 [(set VR128:$dst,
2676 (int_x86_ssse3_palign_r_128
2677 VR128:$src1,
2678 (bitconvert (memopv4i32 addr:$src2)),
2679 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002680}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002681
2682//===----------------------------------------------------------------------===//
2683// Non-Instruction Patterns
2684//===----------------------------------------------------------------------===//
2685
2686// 128-bit vector undef's.
Bill Wendling1dc817c2007-08-10 09:00:17 +00002687def : Pat<(v4f32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002688def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2689def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2690def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2691def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2692def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2693
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002694// Scalar to v8i16 / v16i8. The source may be a GR32, but only the lower 8 or
2695// 16-bits matter.
2696def : Pat<(v8i16 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2697 Requires<[HasSSE2]>;
2698def : Pat<(v16i8 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2699 Requires<[HasSSE2]>;
2700
2701// bit_convert
2702let Predicates = [HasSSE2] in {
2703 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2704 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2705 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2706 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2707 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2708 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2709 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2710 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2711 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2712 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2713 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2714 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2715 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2716 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2717 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2718 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2719 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2720 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2721 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2722 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2723 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2724 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2725 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2726 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2727 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2728 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2729 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2730 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2731 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2732 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2733}
2734
2735// Move scalar to XMM zero-extended
2736// movd to XMM register zero-extends
2737let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002738// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Chris Lattnere6aa3862007-11-25 00:24:49 +00002739def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002740 (v2f64 (scalar_to_vector FR64:$src)), MOVL_shuffle_mask)),
2741 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Chris Lattnere6aa3862007-11-25 00:24:49 +00002742def : Pat<(v4f32 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002743 (v4f32 (scalar_to_vector FR32:$src)), MOVL_shuffle_mask)),
2744 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>;
2745}
2746
2747// Splat v2f64 / v2i64
2748let AddedComplexity = 10 in {
2749def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2750 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2751def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2752 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2753def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2754 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2755def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2756 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2757}
2758
2759// Splat v4f32
2760def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SSE_splat_mask:$sm),
2761 (SHUFPSrri VR128:$src, VR128:$src, SSE_splat_mask:$sm)>,
2762 Requires<[HasSSE1]>;
2763
2764// Special unary SHUFPSrri case.
2765// FIXME: when we want non two-address code, then we should use PSHUFD?
2766def : Pat<(vector_shuffle (v4f32 VR128:$src1), (undef),
2767 SHUFP_unary_shuffle_mask:$sm),
2768 (SHUFPSrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2769 Requires<[HasSSE1]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002770// Special unary SHUFPDrri case.
2771def : Pat<(vector_shuffle (v2f64 VR128:$src1), (undef),
2772 SHUFP_unary_shuffle_mask:$sm),
2773 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2774 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002775// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Dan Gohman4a4f1512007-07-18 20:23:34 +00002776def : Pat<(vector_shuffle (memopv4f32 addr:$src1), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002777 SHUFP_unary_shuffle_mask:$sm),
2778 (PSHUFDmi addr:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2779 Requires<[HasSSE2]>;
2780// Special binary v4i32 shuffle cases with SHUFPS.
2781def : Pat<(vector_shuffle (v4i32 VR128:$src1), (v4i32 VR128:$src2),
2782 PSHUFD_binary_shuffle_mask:$sm),
2783 (SHUFPSrri VR128:$src1, VR128:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2784 Requires<[HasSSE2]>;
2785def : Pat<(vector_shuffle (v4i32 VR128:$src1),
Dan Gohman4a4f1512007-07-18 20:23:34 +00002786 (bc_v4i32 (memopv2i64 addr:$src2)), PSHUFD_binary_shuffle_mask:$sm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002787 (SHUFPSrmi VR128:$src1, addr:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2788 Requires<[HasSSE2]>;
2789
2790// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2791let AddedComplexity = 10 in {
2792def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2793 UNPCKL_v_undef_shuffle_mask)),
2794 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2795def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2796 UNPCKL_v_undef_shuffle_mask)),
2797 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2798def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2799 UNPCKL_v_undef_shuffle_mask)),
2800 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2801def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2802 UNPCKL_v_undef_shuffle_mask)),
2803 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2804}
2805
2806// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2807let AddedComplexity = 10 in {
2808def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2809 UNPCKH_v_undef_shuffle_mask)),
2810 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2811def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2812 UNPCKH_v_undef_shuffle_mask)),
2813 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2814def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2815 UNPCKH_v_undef_shuffle_mask)),
2816 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2817def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2818 UNPCKH_v_undef_shuffle_mask)),
2819 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2820}
2821
2822let AddedComplexity = 15 in {
2823// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2824def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2825 MOVHP_shuffle_mask)),
2826 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2827
2828// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2829def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2830 MOVHLPS_shuffle_mask)),
2831 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2832
2833// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2834def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2835 MOVHLPS_v_undef_shuffle_mask)),
2836 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2837def : Pat<(v4i32 (vector_shuffle VR128:$src1, (undef),
2838 MOVHLPS_v_undef_shuffle_mask)),
2839 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2840}
2841
2842let AddedComplexity = 20 in {
2843// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2844// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Dan Gohman4a4f1512007-07-18 20:23:34 +00002845def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002846 MOVLP_shuffle_mask)),
2847 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002848def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002849 MOVLP_shuffle_mask)),
2850 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002851def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002852 MOVHP_shuffle_mask)),
2853 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002854def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002855 MOVHP_shuffle_mask)),
2856 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2857
Dan Gohman4a4f1512007-07-18 20:23:34 +00002858def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002859 MOVLP_shuffle_mask)),
2860 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002861def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002862 MOVLP_shuffle_mask)),
2863 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002864def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002865 MOVHP_shuffle_mask)),
2866 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002867def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002868 MOVLP_shuffle_mask)),
2869 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2870}
2871
2872let AddedComplexity = 15 in {
2873// Setting the lowest element in the vector.
2874def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2875 MOVL_shuffle_mask)),
2876 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2877def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2878 MOVL_shuffle_mask)),
2879 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2880
2881// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
2882def : Pat<(v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
2883 MOVLP_shuffle_mask)),
2884 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2885def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2886 MOVLP_shuffle_mask)),
2887 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2888}
2889
2890// Set lowest element and zero upper elements.
2891let AddedComplexity = 20 in
Chris Lattnere6aa3862007-11-25 00:24:49 +00002892def : Pat<(bc_v2i64 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002893 (v2f64 (scalar_to_vector (loadf64 addr:$src))),
2894 MOVL_shuffle_mask)),
2895 (MOVZQI2PQIrm addr:$src)>, Requires<[HasSSE2]>;
2896
2897// FIXME: Temporary workaround since 2-wide shuffle is broken.
2898def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
2899 (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2900def : Pat<(int_x86_sse2_loadh_pd VR128:$src1, addr:$src2),
2901 (v2f64 (MOVHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2902def : Pat<(int_x86_sse2_loadl_pd VR128:$src1, addr:$src2),
2903 (v2f64 (MOVLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2904def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
2905 (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
2906 Requires<[HasSSE2]>;
2907def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (load addr:$src2), imm:$src3),
2908 (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
2909 Requires<[HasSSE2]>;
2910def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
2911 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2912def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (load addr:$src2)),
2913 (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2914def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
2915 (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2916def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (load addr:$src2)),
2917 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2918def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2),
2919 (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2920def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (load addr:$src2)),
2921 (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2922def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2),
2923 (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2924def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (load addr:$src2)),
2925 (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2926
2927// Some special case pandn patterns.
2928def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2929 VR128:$src2)),
2930 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2931def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
2932 VR128:$src2)),
2933 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2934def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
2935 VR128:$src2)),
2936 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2937
2938def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002939 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002940 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2941def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002942 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002943 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2944def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002945 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002946 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2947
Nate Begeman78246ca2007-11-17 03:58:34 +00002948// vector -> vector casts
2949def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
2950 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
2951def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
2952 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
2953
Evan Cheng51a49b22007-07-20 00:27:43 +00002954// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00002955def : Pat<(alignedloadv4i32 addr:$src),
2956 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
2957def : Pat<(loadv4i32 addr:$src),
2958 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00002959def : Pat<(alignedloadv2i64 addr:$src),
2960 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
2961def : Pat<(loadv2i64 addr:$src),
2962 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
2963
2964def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
2965 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2966def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
2967 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2968def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
2969 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2970def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
2971 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2972def : Pat<(store (v2i64 VR128:$src), addr:$dst),
2973 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2974def : Pat<(store (v4i32 VR128:$src), addr:$dst),
2975 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2976def : Pat<(store (v8i16 VR128:$src), addr:$dst),
2977 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2978def : Pat<(store (v16i8 VR128:$src), addr:$dst),
2979 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;