blob: 3c2eb6f41b8a881e6a9031cf6abbfb6052ff72c3 [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//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +0000304let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 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 {
Chris Lattnera9f545f2007-12-16 20:12:41 +0000388 def CMPSSrr : SSIi8<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}", []>;
Chris Lattnera9f545f2007-12-16 20:12:41 +0000391 def CMPSSrm : SSIi8<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 {
Chris Lattnera9f545f2007-12-16 20:12:41 +0000408 def Int_CMPSSrr : SSIi8<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))]>;
Chris Lattnera9f545f2007-12-16 20:12:41 +0000413 def Int_CMPSSrm : SSIi8<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.
Bill Wendling57e31d62007-12-17 23:07:56 +0000448let isReMaterializable = 1, neverHasSideEffects = 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.
Chris Lattner1a1932c2008-01-06 23:38:27 +0000460let isSimpleLoad = 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}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +0000637let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 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}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +0000648let isSimpleLoad = 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
Chris Lattner1a1932c2008-01-06 23:38:27 +0000657let isSimpleLoad = 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.
Bill Wendling57e31d62007-12-17 23:07:56 +0000943let isReMaterializable = 1, neverHasSideEffects = 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}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001006let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 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 {
Evan Cheng653c7ac2007-12-20 19:57:09 +00001088 def CMPSDrr : SDIi8<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}", []>;
Evan Cheng653c7ac2007-12-20 19:57:09 +00001091 def CMPSDrm : SDIi8<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 {
Evan Cheng653c7ac2007-12-20 19:57:09 +00001108 def Int_CMPSDrr : SDIi8<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))]>;
Evan Cheng653c7ac2007-12-20 19:57:09 +00001113 def Int_CMPSDrm : SDIi8<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.
Bill Wendling57e31d62007-12-17 23:07:56 +00001144let isReMaterializable = 1, neverHasSideEffects = 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.
Chris Lattner1a1932c2008-01-06 23:38:27 +00001156let isSimpleLoad = 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}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001333let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 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}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001344let isSimpleLoad = 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}", []>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001707let isSimpleLoad = 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)*/]>;
Chris Lattner1a1932c2008-01-06 23:38:27 +00001714let isSimpleLoad = 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
Chris Lattner1a1932c2008-01-06 23:38:27 +00001725let isSimpleLoad = 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.
Bill Wendling57e31d62007-12-17 23:07:56 +00002122let isReMaterializable = 1, neverHasSideEffects = 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
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002227// movd / movq to XMM register zero-extends
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002228let AddedComplexity = 15 in {
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)))]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002235// This is X86-64 only.
2236def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src),
2237 "mov{d|q}\t{$src, $dst|$dst, $src}",
2238 [(set VR128:$dst,
2239 (v2i64 (vector_shuffle immAllZerosV_bc,
2240 (v2i64 (scalar_to_vector GR64:$src)),
2241 MOVL_shuffle_mask)))]>;
2242}
2243
2244let AddedComplexity = 20 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002245def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247 [(set VR128:$dst,
2248 (v4i32 (vector_shuffle immAllZerosV,
2249 (v4i32 (scalar_to_vector (loadi32 addr:$src))),
2250 MOVL_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002251def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "movq\t{$src, $dst|$dst, $src}",
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002253 [(set VR128:$dst,
2254 (v2i64 (vector_shuffle immAllZerosV_bc,
2255 (v2i64 (scalar_to_vector (loadi64 addr:$src))),
2256 MOVL_shuffle_mask)))]>, XS,
2257 Requires<[HasSSE2]>;
2258}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002260// Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in
2261// IA32 document. movq xmm1, xmm2 does clear the high bits.
2262let AddedComplexity = 15 in
2263def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
2264 "movq\t{$src, $dst|$dst, $src}",
2265 [(set VR128:$dst, (v2i64 (vector_shuffle immAllZerosV_bc,
2266 VR128:$src,
2267 MOVL_shuffle_mask)))]>,
2268 XS, Requires<[HasSSE2]>;
2269
2270let AddedComplexity = 20 in
2271def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
2272 "movq\t{$src, $dst|$dst, $src}",
2273 [(set VR128:$dst, (v2i64 (vector_shuffle immAllZerosV_bc,
2274 (memopv2i64 addr:$src),
2275 MOVL_shuffle_mask)))]>,
2276 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002277
2278//===----------------------------------------------------------------------===//
2279// SSE3 Instructions
2280//===----------------------------------------------------------------------===//
2281
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002283def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002284 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002285 [(set VR128:$dst, (v4f32 (vector_shuffle
2286 VR128:$src, (undef),
2287 MOVSHDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002288def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002289 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002291 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002292 MOVSHDUP_shuffle_mask)))]>;
2293
Evan Chengb783fa32007-07-19 01:14:50 +00002294def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002295 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002296 [(set VR128:$dst, (v4f32 (vector_shuffle
2297 VR128:$src, (undef),
2298 MOVSLDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002299def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002300 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002301 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002302 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002303 MOVSLDUP_shuffle_mask)))]>;
2304
Evan Chengb783fa32007-07-19 01:14:50 +00002305def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002306 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002307 [(set VR128:$dst, (v2f64 (vector_shuffle
2308 VR128:$src, (undef),
2309 SSE_splat_lo_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002310def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002311 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002312 [(set VR128:$dst,
2313 (v2f64 (vector_shuffle
2314 (scalar_to_vector (loadf64 addr:$src)),
2315 (undef),
2316 SSE_splat_lo_mask)))]>;
2317
2318// Arithmetic
2319let isTwoAddress = 1 in {
2320 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002321 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002322 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2324 VR128:$src2))]>;
2325 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002326 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002327 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002328 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2329 (load addr:$src2)))]>;
2330 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002331 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002332 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002333 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2334 VR128:$src2))]>;
2335 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002336 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002337 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002338 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2339 (load addr:$src2)))]>;
2340}
2341
Evan Chengb783fa32007-07-19 01:14:50 +00002342def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002343 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002344 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2345
2346// Horizontal ops
2347class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002348 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002350 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2351class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002352 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002353 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002354 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (load addr:$src2))))]>;
2355class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002356 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002358 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2359class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002360 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002361 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002362 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (load addr:$src2))))]>;
2363
2364let isTwoAddress = 1 in {
2365 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2366 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2367 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2368 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2369 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2370 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2371 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2372 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2373}
2374
2375// Thread synchronization
Evan Chengb783fa32007-07-19 01:14:50 +00002376def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002377 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002378def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002379 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2380
2381// vector_shuffle v1, <undef> <1, 1, 3, 3>
2382let AddedComplexity = 15 in
2383def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2384 MOVSHDUP_shuffle_mask)),
2385 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2386let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002387def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002388 MOVSHDUP_shuffle_mask)),
2389 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2390
2391// vector_shuffle v1, <undef> <0, 0, 2, 2>
2392let AddedComplexity = 15 in
2393 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2394 MOVSLDUP_shuffle_mask)),
2395 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2396let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002397 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398 MOVSLDUP_shuffle_mask)),
2399 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2400
2401//===----------------------------------------------------------------------===//
2402// SSSE3 Instructions
2403//===----------------------------------------------------------------------===//
2404
Bill Wendling3b15d722007-08-11 09:52:53 +00002405// SSSE3 Instruction Templates:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002406//
Bill Wendling98680292007-08-10 06:22:27 +00002407// SS38I - SSSE3 instructions with T8 prefix.
2408// SS3AI - SSSE3 instructions with TA prefix.
Bill Wendling3b15d722007-08-11 09:52:53 +00002409//
2410// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
2411// uses the MMX registers. We put those instructions here because they better
2412// fit into the SSSE3 instruction category rather than the MMX category.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002413
Evan Chengb783fa32007-07-19 01:14:50 +00002414class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
2415 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002416 : I<o, F, outs, ins, asm, pattern>, T8, Requires<[HasSSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002417class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
2418 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002419 : I<o, F, outs, ins, asm, pattern>, TA, Requires<[HasSSSE3]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002420
Bill Wendling98680292007-08-10 06:22:27 +00002421/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002422let isTwoAddress = 1 in {
Bill Wendling98680292007-08-10 06:22:27 +00002423 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2424 Intrinsic IntId64, Intrinsic IntId128,
2425 bit Commutable = 0> {
2426 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2427 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2428 [(set VR64:$dst, (IntId64 VR64:$src))]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002429 let isCommutable = Commutable;
2430 }
Bill Wendling98680292007-08-10 06:22:27 +00002431 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2432 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2433 [(set VR64:$dst,
2434 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2435
2436 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2437 (ins VR128:$src),
2438 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2439 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2440 OpSize {
2441 let isCommutable = Commutable;
2442 }
2443 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2444 (ins i128mem:$src),
2445 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2446 [(set VR128:$dst,
2447 (IntId128
2448 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002449 }
2450}
2451
Bill Wendling98680292007-08-10 06:22:27 +00002452/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2453let isTwoAddress = 1 in {
2454 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2455 Intrinsic IntId64, Intrinsic IntId128,
2456 bit Commutable = 0> {
2457 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2458 (ins VR64:$src),
2459 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2460 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2461 let isCommutable = Commutable;
2462 }
2463 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2464 (ins i64mem:$src),
2465 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2466 [(set VR64:$dst,
2467 (IntId64
2468 (bitconvert (memopv4i16 addr:$src))))]>;
2469
2470 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2471 (ins VR128:$src),
2472 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2473 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2474 OpSize {
2475 let isCommutable = Commutable;
2476 }
2477 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2478 (ins i128mem:$src),
2479 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2480 [(set VR128:$dst,
2481 (IntId128
2482 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2483 }
2484}
2485
2486/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2487let isTwoAddress = 1 in {
2488 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2489 Intrinsic IntId64, Intrinsic IntId128,
2490 bit Commutable = 0> {
2491 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2492 (ins VR64:$src),
2493 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2494 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2495 let isCommutable = Commutable;
2496 }
2497 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2498 (ins i64mem:$src),
2499 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2500 [(set VR64:$dst,
2501 (IntId64
2502 (bitconvert (memopv2i32 addr:$src))))]>;
2503
2504 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2505 (ins VR128:$src),
2506 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2507 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2508 OpSize {
2509 let isCommutable = Commutable;
2510 }
2511 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2512 (ins i128mem:$src),
2513 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2514 [(set VR128:$dst,
2515 (IntId128
2516 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2517 }
2518}
2519
2520defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2521 int_x86_ssse3_pabs_b,
2522 int_x86_ssse3_pabs_b_128>;
2523defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2524 int_x86_ssse3_pabs_w,
2525 int_x86_ssse3_pabs_w_128>;
2526defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2527 int_x86_ssse3_pabs_d,
2528 int_x86_ssse3_pabs_d_128>;
2529
2530/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2531let isTwoAddress = 1 in {
2532 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2533 Intrinsic IntId64, Intrinsic IntId128,
2534 bit Commutable = 0> {
2535 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2536 (ins VR64:$src1, VR64:$src2),
2537 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2538 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2539 let isCommutable = Commutable;
2540 }
2541 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2542 (ins VR64:$src1, i64mem:$src2),
2543 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2544 [(set VR64:$dst,
2545 (IntId64 VR64:$src1,
2546 (bitconvert (memopv8i8 addr:$src2))))]>;
2547
2548 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2549 (ins VR128:$src1, VR128:$src2),
2550 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2551 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2552 OpSize {
2553 let isCommutable = Commutable;
2554 }
2555 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2556 (ins VR128:$src1, i128mem:$src2),
2557 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2558 [(set VR128:$dst,
2559 (IntId128 VR128:$src1,
2560 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2561 }
2562}
2563
2564/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2565let isTwoAddress = 1 in {
2566 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2567 Intrinsic IntId64, Intrinsic IntId128,
2568 bit Commutable = 0> {
2569 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2570 (ins VR64:$src1, VR64:$src2),
2571 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2572 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2573 let isCommutable = Commutable;
2574 }
2575 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2576 (ins VR64:$src1, i64mem:$src2),
2577 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2578 [(set VR64:$dst,
2579 (IntId64 VR64:$src1,
2580 (bitconvert (memopv4i16 addr:$src2))))]>;
2581
2582 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2583 (ins VR128:$src1, VR128:$src2),
2584 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2585 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2586 OpSize {
2587 let isCommutable = Commutable;
2588 }
2589 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2590 (ins VR128:$src1, i128mem:$src2),
2591 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2592 [(set VR128:$dst,
2593 (IntId128 VR128:$src1,
2594 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2595 }
2596}
2597
2598/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2599let isTwoAddress = 1 in {
2600 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2601 Intrinsic IntId64, Intrinsic IntId128,
2602 bit Commutable = 0> {
2603 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2604 (ins VR64:$src1, VR64:$src2),
2605 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2606 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2607 let isCommutable = Commutable;
2608 }
2609 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2610 (ins VR64:$src1, i64mem:$src2),
2611 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2612 [(set VR64:$dst,
2613 (IntId64 VR64:$src1,
2614 (bitconvert (memopv2i32 addr:$src2))))]>;
2615
2616 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2617 (ins VR128:$src1, VR128:$src2),
2618 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2619 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2620 OpSize {
2621 let isCommutable = Commutable;
2622 }
2623 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2624 (ins VR128:$src1, i128mem:$src2),
2625 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2626 [(set VR128:$dst,
2627 (IntId128 VR128:$src1,
2628 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2629 }
2630}
2631
2632defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2633 int_x86_ssse3_phadd_w,
2634 int_x86_ssse3_phadd_w_128, 1>;
2635defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2636 int_x86_ssse3_phadd_d,
2637 int_x86_ssse3_phadd_d_128, 1>;
2638defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2639 int_x86_ssse3_phadd_sw,
2640 int_x86_ssse3_phadd_sw_128, 1>;
2641defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2642 int_x86_ssse3_phsub_w,
2643 int_x86_ssse3_phsub_w_128>;
2644defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2645 int_x86_ssse3_phsub_d,
2646 int_x86_ssse3_phsub_d_128>;
2647defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2648 int_x86_ssse3_phsub_sw,
2649 int_x86_ssse3_phsub_sw_128>;
2650defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2651 int_x86_ssse3_pmadd_ub_sw,
2652 int_x86_ssse3_pmadd_ub_sw_128, 1>;
2653defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2654 int_x86_ssse3_pmul_hr_sw,
2655 int_x86_ssse3_pmul_hr_sw_128, 1>;
2656defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2657 int_x86_ssse3_pshuf_b,
2658 int_x86_ssse3_pshuf_b_128>;
2659defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2660 int_x86_ssse3_psign_b,
2661 int_x86_ssse3_psign_b_128>;
2662defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2663 int_x86_ssse3_psign_w,
2664 int_x86_ssse3_psign_w_128>;
2665defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2666 int_x86_ssse3_psign_d,
2667 int_x86_ssse3_psign_d_128>;
2668
2669let isTwoAddress = 1 in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002670 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2671 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002672 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002673 [(set VR64:$dst,
2674 (int_x86_ssse3_palign_r
2675 VR64:$src1, VR64:$src2,
2676 imm:$src3))]>;
2677 def PALIGNR64rm : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2678 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002679 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002680 [(set VR64:$dst,
2681 (int_x86_ssse3_palign_r
2682 VR64:$src1,
2683 (bitconvert (memopv2i32 addr:$src2)),
2684 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002685
Bill Wendling1dc817c2007-08-10 09:00:17 +00002686 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2687 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002688 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002689 [(set VR128:$dst,
2690 (int_x86_ssse3_palign_r_128
2691 VR128:$src1, VR128:$src2,
2692 imm:$src3))]>, OpSize;
2693 def PALIGNR128rm : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2694 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002695 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002696 [(set VR128:$dst,
2697 (int_x86_ssse3_palign_r_128
2698 VR128:$src1,
2699 (bitconvert (memopv4i32 addr:$src2)),
2700 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002701}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002702
2703//===----------------------------------------------------------------------===//
2704// Non-Instruction Patterns
2705//===----------------------------------------------------------------------===//
2706
2707// 128-bit vector undef's.
Bill Wendling1dc817c2007-08-10 09:00:17 +00002708def : Pat<(v4f32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002709def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2710def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2711def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2712def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2713def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2714
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002715// Scalar to v8i16 / v16i8. The source may be a GR32, but only the lower 8 or
2716// 16-bits matter.
2717def : Pat<(v8i16 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2718 Requires<[HasSSE2]>;
2719def : Pat<(v16i8 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2720 Requires<[HasSSE2]>;
2721
2722// bit_convert
2723let Predicates = [HasSSE2] in {
2724 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2725 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2726 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2727 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2728 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2729 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2730 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2731 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2732 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2733 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2734 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2735 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2736 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2737 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2738 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2739 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2740 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2741 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2742 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2743 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2744 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2745 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2746 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2747 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2748 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2749 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2750 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2751 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2752 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2753 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2754}
2755
2756// Move scalar to XMM zero-extended
2757// movd to XMM register zero-extends
2758let AddedComplexity = 15 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002759// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
Chris Lattnere6aa3862007-11-25 00:24:49 +00002760def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002761 (v2f64 (scalar_to_vector FR64:$src)), MOVL_shuffle_mask)),
2762 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
Chris Lattnere6aa3862007-11-25 00:24:49 +00002763def : Pat<(v4f32 (vector_shuffle immAllZerosV_bc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002764 (v4f32 (scalar_to_vector FR32:$src)), MOVL_shuffle_mask)),
2765 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>;
2766}
2767
2768// Splat v2f64 / v2i64
2769let AddedComplexity = 10 in {
2770def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2771 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2772def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2773 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2774def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2775 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2776def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2777 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2778}
2779
2780// Splat v4f32
2781def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SSE_splat_mask:$sm),
2782 (SHUFPSrri VR128:$src, VR128:$src, SSE_splat_mask:$sm)>,
2783 Requires<[HasSSE1]>;
2784
2785// Special unary SHUFPSrri case.
2786// FIXME: when we want non two-address code, then we should use PSHUFD?
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002787def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2788 SHUFP_unary_shuffle_mask:$sm)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002789 (SHUFPSrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2790 Requires<[HasSSE1]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002791// Special unary SHUFPDrri case.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002792def : Pat<(v2f64 (vector_shuffle VR128:$src1, (undef),
2793 SHUFP_unary_shuffle_mask:$sm)),
Dan Gohman7dc19012007-08-02 21:17:01 +00002794 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2795 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002796// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Dan Gohman4a4f1512007-07-18 20:23:34 +00002797def : Pat<(vector_shuffle (memopv4f32 addr:$src1), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002798 SHUFP_unary_shuffle_mask:$sm),
2799 (PSHUFDmi addr:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2800 Requires<[HasSSE2]>;
2801// Special binary v4i32 shuffle cases with SHUFPS.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002802def : Pat<(v4i32 (vector_shuffle VR128:$src1, (v4i32 VR128:$src2),
2803 PSHUFD_binary_shuffle_mask:$sm)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002804 (SHUFPSrri VR128:$src1, VR128:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2805 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002806def : Pat<(v4i32 (vector_shuffle VR128:$src1,
2807 (bc_v4i32 (memopv2i64 addr:$src2)), PSHUFD_binary_shuffle_mask:$sm)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002808 (SHUFPSrmi VR128:$src1, addr:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2809 Requires<[HasSSE2]>;
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002810// Special binary v2i64 shuffle cases using SHUFPDrri.
2811def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2812 SHUFP_shuffle_mask:$sm)),
2813 (SHUFPDrri VR128:$src1, VR128:$src2, SHUFP_shuffle_mask:$sm)>,
2814 Requires<[HasSSE2]>;
2815// Special unary SHUFPDrri case.
2816def : Pat<(v2i64 (vector_shuffle VR128:$src1, (undef),
2817 SHUFP_unary_shuffle_mask:$sm)),
2818 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2819 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002820
2821// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2822let AddedComplexity = 10 in {
2823def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2824 UNPCKL_v_undef_shuffle_mask)),
2825 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2826def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2827 UNPCKL_v_undef_shuffle_mask)),
2828 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2829def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2830 UNPCKL_v_undef_shuffle_mask)),
2831 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2832def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2833 UNPCKL_v_undef_shuffle_mask)),
2834 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2835}
2836
2837// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2838let AddedComplexity = 10 in {
2839def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2840 UNPCKH_v_undef_shuffle_mask)),
2841 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2842def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2843 UNPCKH_v_undef_shuffle_mask)),
2844 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2845def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2846 UNPCKH_v_undef_shuffle_mask)),
2847 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2848def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2849 UNPCKH_v_undef_shuffle_mask)),
2850 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2851}
2852
2853let AddedComplexity = 15 in {
2854// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2855def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2856 MOVHP_shuffle_mask)),
2857 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2858
2859// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2860def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2861 MOVHLPS_shuffle_mask)),
2862 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2863
2864// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2865def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2866 MOVHLPS_v_undef_shuffle_mask)),
2867 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2868def : Pat<(v4i32 (vector_shuffle VR128:$src1, (undef),
2869 MOVHLPS_v_undef_shuffle_mask)),
2870 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2871}
2872
2873let AddedComplexity = 20 in {
2874// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2875// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Dan Gohman4a4f1512007-07-18 20:23:34 +00002876def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002877 MOVLP_shuffle_mask)),
2878 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002879def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002880 MOVLP_shuffle_mask)),
2881 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002882def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883 MOVHP_shuffle_mask)),
2884 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002885def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002886 MOVHP_shuffle_mask)),
2887 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2888
Dan Gohman4a4f1512007-07-18 20:23:34 +00002889def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002890 MOVLP_shuffle_mask)),
2891 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002892def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002893 MOVLP_shuffle_mask)),
2894 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002895def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002896 MOVHP_shuffle_mask)),
2897 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002898def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002899 MOVLP_shuffle_mask)),
2900 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2901}
2902
2903let AddedComplexity = 15 in {
2904// Setting the lowest element in the vector.
2905def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2906 MOVL_shuffle_mask)),
2907 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2908def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2909 MOVL_shuffle_mask)),
2910 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2911
2912// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
2913def : Pat<(v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
2914 MOVLP_shuffle_mask)),
2915 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2916def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2917 MOVLP_shuffle_mask)),
2918 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2919}
2920
2921// Set lowest element and zero upper elements.
Evan Cheng15e8f5a2007-12-15 03:00:47 +00002922let AddedComplexity = 15 in
2923def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc, VR128:$src,
2924 MOVL_shuffle_mask)),
2925 (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>;
2926
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002927
2928// FIXME: Temporary workaround since 2-wide shuffle is broken.
2929def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
2930 (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2931def : Pat<(int_x86_sse2_loadh_pd VR128:$src1, addr:$src2),
2932 (v2f64 (MOVHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2933def : Pat<(int_x86_sse2_loadl_pd VR128:$src1, addr:$src2),
2934 (v2f64 (MOVLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2935def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
2936 (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
2937 Requires<[HasSSE2]>;
2938def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (load addr:$src2), imm:$src3),
2939 (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
2940 Requires<[HasSSE2]>;
2941def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
2942 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2943def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (load addr:$src2)),
2944 (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2945def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
2946 (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2947def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (load addr:$src2)),
2948 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2949def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2),
2950 (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2951def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (load addr:$src2)),
2952 (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2953def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2),
2954 (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2955def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (load addr:$src2)),
2956 (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2957
2958// Some special case pandn patterns.
2959def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2960 VR128:$src2)),
2961 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2962def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
2963 VR128:$src2)),
2964 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2965def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
2966 VR128:$src2)),
2967 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2968
2969def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002970 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002971 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2972def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002973 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002974 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2975def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002976 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002977 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2978
Nate Begeman78246ca2007-11-17 03:58:34 +00002979// vector -> vector casts
2980def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))),
2981 (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>;
2982def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))),
2983 (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>;
2984
Evan Cheng51a49b22007-07-20 00:27:43 +00002985// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00002986def : Pat<(alignedloadv4i32 addr:$src),
2987 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
2988def : Pat<(loadv4i32 addr:$src),
2989 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00002990def : Pat<(alignedloadv2i64 addr:$src),
2991 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
2992def : Pat<(loadv2i64 addr:$src),
2993 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
2994
2995def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
2996 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2997def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
2998 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2999def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
3000 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3001def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
3002 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3003def : Pat<(store (v2i64 VR128:$src), addr:$dst),
3004 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3005def : Pat<(store (v4i32 VR128:$src), addr:$dst),
3006 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3007def : Pat<(store (v8i16 VR128:$src), addr:$dst),
3008 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
3009def : Pat<(store (v16i8 VR128:$src), addr:$dst),
3010 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;