blob: bbcc7530d59275582d33829bf1a1c643eaf62433 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//====- X86InstrSSE.td - Describe the X86 Instruction Set -------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Evan Cheng and is distributed under the University
6// of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 SSE instruction set, defining the instructions,
11// and properties of the instructions which are needed for code generation,
12// machine code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16
17//===----------------------------------------------------------------------===//
18// SSE specific DAG Nodes.
19//===----------------------------------------------------------------------===//
20
21def SDTX86FPShiftOp : SDTypeProfile<1, 2, [ SDTCisSameAs<0, 1>,
22 SDTCisFP<0>, SDTCisInt<2> ]>;
23
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024def X86fmin : SDNode<"X86ISD::FMIN", SDTFPBinOp>;
25def X86fmax : SDNode<"X86ISD::FMAX", SDTFPBinOp>;
26def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
27 [SDNPCommutative, SDNPAssociative]>;
28def X86for : SDNode<"X86ISD::FOR", SDTFPBinOp,
29 [SDNPCommutative, SDNPAssociative]>;
30def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
31 [SDNPCommutative, SDNPAssociative]>;
32def X86frsqrt : SDNode<"X86ISD::FRSQRT", SDTFPUnaryOp>;
33def X86frcp : SDNode<"X86ISD::FRCP", SDTFPUnaryOp>;
34def X86fsrl : SDNode<"X86ISD::FSRL", SDTX86FPShiftOp>;
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 Chengb783fa32007-07-19 01:14:50 +000045def IMPLICIT_DEF_VR128 : I<0, Pseudo, (outs VR128:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000046 "#IMPLICIT_DEF $dst",
47 [(set VR128:$dst, (v4f32 (undef)))]>,
48 Requires<[HasSSE1]>;
Evan Chengb783fa32007-07-19 01:14:50 +000049def IMPLICIT_DEF_FR32 : I<0, Pseudo, (outs FR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000050 "#IMPLICIT_DEF $dst",
Dale Johannesene0e0fd02007-09-23 14:52:20 +000051 [(set FR32:$dst, (undef))]>, Requires<[HasSSE1]>;
Evan Chengb783fa32007-07-19 01:14:50 +000052def IMPLICIT_DEF_FR64 : I<0, Pseudo, (outs FR64:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000053 "#IMPLICIT_DEF $dst",
54 [(set FR64:$dst, (undef))]>, Requires<[HasSSE2]>;
55
56//===----------------------------------------------------------------------===//
57// SSE Complex Patterns
58//===----------------------------------------------------------------------===//
59
60// These are 'extloads' from a scalar to the low element of a vector, zeroing
61// the top elements. These are used for the SSE 'ss' and 'sd' instruction
62// forms.
63def sse_load_f32 : ComplexPattern<v4f32, 4, "SelectScalarSSELoad", [],
64 [SDNPHasChain]>;
65def sse_load_f64 : ComplexPattern<v2f64, 4, "SelectScalarSSELoad", [],
66 [SDNPHasChain]>;
67
68def ssmem : Operand<v4f32> {
69 let PrintMethod = "printf32mem";
70 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
71}
72def sdmem : Operand<v2f64> {
73 let PrintMethod = "printf64mem";
74 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
75}
76
77//===----------------------------------------------------------------------===//
78// SSE pattern fragments
79//===----------------------------------------------------------------------===//
80
Dan Gohmanf17a25c2007-07-18 16:29:46 +000081def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
82def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
83def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>;
84def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>;
85
Dan Gohman11821702007-07-27 17:16:43 +000086// Like 'store', but always requires vector alignment.
Dan Gohman4a4f1512007-07-18 20:23:34 +000087def alignedstore : PatFrag<(ops node:$val, node:$ptr),
88 (st node:$val, node:$ptr), [{
89 if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
90 return !ST->isTruncatingStore() &&
91 ST->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +000092 ST->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +000093 return false;
94}]>;
95
Dan Gohman11821702007-07-27 17:16:43 +000096// Like 'load', but always requires vector alignment.
Dan Gohman4a4f1512007-07-18 20:23:34 +000097def alignedload : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
98 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
99 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
100 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +0000101 LD->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000102 return false;
103}]>;
104
Dan Gohman11821702007-07-27 17:16:43 +0000105def alignedloadfsf32 : PatFrag<(ops node:$ptr), (f32 (alignedload node:$ptr))>;
106def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000107def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>;
108def alignedloadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (alignedload node:$ptr))>;
109def alignedloadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (alignedload node:$ptr))>;
110def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>;
111
112// Like 'load', but uses special alignment checks suitable for use in
113// memory operands in most SSE instructions, which are required to
114// be naturally aligned on some targets but not on others.
115// FIXME: Actually implement support for targets that don't require the
116// alignment. This probably wants a subtarget predicate.
117def memop : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
118 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
119 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
120 LD->getAddressingMode() == ISD::UNINDEXED &&
Dan Gohman11821702007-07-27 17:16:43 +0000121 LD->getAlignment() >= 16;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000122 return false;
123}]>;
124
Dan Gohman11821702007-07-27 17:16:43 +0000125def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>;
126def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>;
Dan Gohman4a4f1512007-07-18 20:23:34 +0000127def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>;
128def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>;
129def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>;
130def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>;
131
Bill Wendling3b15d722007-08-11 09:52:53 +0000132// SSSE3 uses MMX registers for some instructions. They aren't aligned on a
133// 16-byte boundary.
134def memop64 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
135 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N))
136 return LD->getExtensionType() == ISD::NON_EXTLOAD &&
137 LD->getAddressingMode() == ISD::UNINDEXED &&
138 LD->getAlignment() >= 8;
139 return false;
140}]>;
141
142def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>;
143def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop64 node:$ptr))>;
144def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>;
145def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>;
146def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>;
147
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000148def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>;
149def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>;
150def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>;
151def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>;
152def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>;
153def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>;
154
155def fp32imm0 : PatLeaf<(f32 fpimm), [{
156 return N->isExactlyValue(+0.0);
157}]>;
158
159def PSxLDQ_imm : SDNodeXForm<imm, [{
160 // Transformation function: imm >> 3
161 return getI32Imm(N->getValue() >> 3);
162}]>;
163
164// SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*,
165// SHUFP* etc. imm.
166def SHUFFLE_get_shuf_imm : SDNodeXForm<build_vector, [{
167 return getI8Imm(X86::getShuffleSHUFImmediate(N));
168}]>;
169
170// SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to
171// PSHUFHW imm.
172def SHUFFLE_get_pshufhw_imm : SDNodeXForm<build_vector, [{
173 return getI8Imm(X86::getShufflePSHUFHWImmediate(N));
174}]>;
175
176// SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to
177// PSHUFLW imm.
178def SHUFFLE_get_pshuflw_imm : SDNodeXForm<build_vector, [{
179 return getI8Imm(X86::getShufflePSHUFLWImmediate(N));
180}]>;
181
182def SSE_splat_mask : PatLeaf<(build_vector), [{
183 return X86::isSplatMask(N);
184}], SHUFFLE_get_shuf_imm>;
185
186def SSE_splat_lo_mask : PatLeaf<(build_vector), [{
187 return X86::isSplatLoMask(N);
188}]>;
189
190def MOVHLPS_shuffle_mask : PatLeaf<(build_vector), [{
191 return X86::isMOVHLPSMask(N);
192}]>;
193
194def MOVHLPS_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
195 return X86::isMOVHLPS_v_undef_Mask(N);
196}]>;
197
198def MOVHP_shuffle_mask : PatLeaf<(build_vector), [{
199 return X86::isMOVHPMask(N);
200}]>;
201
202def MOVLP_shuffle_mask : PatLeaf<(build_vector), [{
203 return X86::isMOVLPMask(N);
204}]>;
205
206def MOVL_shuffle_mask : PatLeaf<(build_vector), [{
207 return X86::isMOVLMask(N);
208}]>;
209
210def MOVSHDUP_shuffle_mask : PatLeaf<(build_vector), [{
211 return X86::isMOVSHDUPMask(N);
212}]>;
213
214def MOVSLDUP_shuffle_mask : PatLeaf<(build_vector), [{
215 return X86::isMOVSLDUPMask(N);
216}]>;
217
218def UNPCKL_shuffle_mask : PatLeaf<(build_vector), [{
219 return X86::isUNPCKLMask(N);
220}]>;
221
222def UNPCKH_shuffle_mask : PatLeaf<(build_vector), [{
223 return X86::isUNPCKHMask(N);
224}]>;
225
226def UNPCKL_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
227 return X86::isUNPCKL_v_undef_Mask(N);
228}]>;
229
230def UNPCKH_v_undef_shuffle_mask : PatLeaf<(build_vector), [{
231 return X86::isUNPCKH_v_undef_Mask(N);
232}]>;
233
234def PSHUFD_shuffle_mask : PatLeaf<(build_vector), [{
235 return X86::isPSHUFDMask(N);
236}], SHUFFLE_get_shuf_imm>;
237
238def PSHUFHW_shuffle_mask : PatLeaf<(build_vector), [{
239 return X86::isPSHUFHWMask(N);
240}], SHUFFLE_get_pshufhw_imm>;
241
242def PSHUFLW_shuffle_mask : PatLeaf<(build_vector), [{
243 return X86::isPSHUFLWMask(N);
244}], SHUFFLE_get_pshuflw_imm>;
245
246def SHUFP_unary_shuffle_mask : PatLeaf<(build_vector), [{
247 return X86::isPSHUFDMask(N);
248}], SHUFFLE_get_shuf_imm>;
249
250def SHUFP_shuffle_mask : PatLeaf<(build_vector), [{
251 return X86::isSHUFPMask(N);
252}], SHUFFLE_get_shuf_imm>;
253
254def PSHUFD_binary_shuffle_mask : PatLeaf<(build_vector), [{
255 return X86::isSHUFPMask(N);
256}], SHUFFLE_get_shuf_imm>;
257
258//===----------------------------------------------------------------------===//
259// SSE scalar FP Instructions
260//===----------------------------------------------------------------------===//
261
262// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
263// scheduler into a branch sequence.
Evan Cheng950aac02007-09-25 01:57:46 +0000264// These are expanded by the scheduler.
265let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266 def CMOV_FR32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000267 (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268 "#CMOV_FR32 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000269 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
270 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271 def CMOV_FR64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000272 (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273 "#CMOV_FR64 PSEUDO!",
Evan Cheng621216e2007-09-29 00:00:36 +0000274 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
275 EFLAGS))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276 def CMOV_V4F32 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000277 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278 "#CMOV_V4F32 PSEUDO!",
279 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000280 (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond,
281 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282 def CMOV_V2F64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000283 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284 "#CMOV_V2F64 PSEUDO!",
285 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000286 (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
287 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000288 def CMOV_V2I64 : I<0, Pseudo,
Evan Chengb783fa32007-07-19 01:14:50 +0000289 (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290 "#CMOV_V2I64 PSEUDO!",
291 [(set VR128:$dst,
Evan Cheng621216e2007-09-29 00:00:36 +0000292 (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond,
Evan Cheng950aac02007-09-25 01:57:46 +0000293 EFLAGS)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294}
295
296//===----------------------------------------------------------------------===//
297// SSE1 Instructions
298//===----------------------------------------------------------------------===//
299
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000301def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000302 "movss\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000303let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000304def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000305 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306 [(set FR32:$dst, (loadf32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000307def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000308 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309 [(store FR32:$src, addr:$dst)]>;
310
311// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000312def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000313 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000314 [(set GR32:$dst, (fp_to_sint FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000315def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000316 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317 [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000318def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000319 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320 [(set FR32:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000321def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000322 "cvtsi2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
324
325// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +0000326def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000327 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328 [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000329def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000330 "cvtss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 [(set GR32:$dst, (int_x86_sse_cvtss2si
332 (load addr:$src)))]>;
333
334// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +0000335def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000336 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337 [(set GR32:$dst,
338 (int_x86_sse_cvttss2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000339def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000340 "cvttss2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341 [(set GR32:$dst,
342 (int_x86_sse_cvttss2si(load addr:$src)))]>;
343
344let isTwoAddress = 1 in {
345 def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000346 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000347 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000348 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
349 GR32:$src2))]>;
350 def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000351 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000352 "cvtsi2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000353 [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1,
354 (loadi32 addr:$src2)))]>;
355}
356
357// Comparison instructions
358let isTwoAddress = 1 in {
359 def CMPSSrr : SSI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000360 (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000361 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362 def CMPSSrm : SSI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000363 (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000364 "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365}
366
Evan Cheng55687072007-09-14 21:48:26 +0000367let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000368def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000369 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000370 [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000371def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000372 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000373 [(X86cmp FR32:$src1, (loadf32 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000374 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000375} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376
377// Aliases to match intrinsics which expect XMM operand(s).
378let isTwoAddress = 1 in {
379 def Int_CMPSSrr : SSI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000380 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
383 VR128:$src, imm:$cc))]>;
384 def Int_CMPSSrm : SSI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000385 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000386 "cmp${cc}ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000387 [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1,
388 (load addr:$src), imm:$cc))]>;
389}
390
Evan Cheng55687072007-09-14 21:48:26 +0000391let Defs = [EFLAGS] in {
Evan Cheng621216e2007-09-29 00:00:36 +0000392def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000393 (ins VR128:$src1, VR128:$src2),
394 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000395 [(X86ucomi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000396 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000397def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000398 (ins VR128:$src1, f128mem:$src2),
399 "ucomiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000400 [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000401 (implicit EFLAGS)]>;
402
Evan Cheng621216e2007-09-29 00:00:36 +0000403def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000404 (ins VR128:$src1, VR128:$src2),
405 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000406 [(X86comi (v4f32 VR128:$src1), VR128:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000407 (implicit EFLAGS)]>;
Evan Cheng621216e2007-09-29 00:00:36 +0000408def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs),
Evan Cheng950aac02007-09-25 01:57:46 +0000409 (ins VR128:$src1, f128mem:$src2),
410 "comiss\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +0000411 [(X86comi (v4f32 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +0000412 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +0000413} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000414
415// Aliases of packed SSE1 instructions for scalar use. These all have names that
416// start with 'Fs'.
417
418// Alias instructions that map fld0 to pxor for sse.
Dan Gohman8aef09b2007-09-07 21:32:51 +0000419let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000420def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000421 "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422 Requires<[HasSSE1]>, TB, OpSize;
423
424// Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are
425// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +0000426def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000427 "movaps\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000428
429// Alias instruction to load FR32 from f128mem using movaps. Upper bits are
430// disregarded.
Evan Cheng4e84e452007-08-30 05:49:43 +0000431let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000432def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000433 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +0000434 [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435
436// Alias bitwise logical operations using SSE logical ops on packed FP values.
437let isTwoAddress = 1 in {
438let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000439 def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000440 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441 [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000442 def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000443 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444 [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000445 def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000446 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000447 [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>;
448}
449
Evan Chengb783fa32007-07-19 01:14:50 +0000450def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000451 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452 [(set FR32:$dst, (X86fand FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000453 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000454def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000455 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456 [(set FR32:$dst, (X86for FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000457 (memopfsf32 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000458def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000459 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460 [(set FR32:$dst, (X86fxor FR32:$src1,
Dan Gohman11821702007-07-27 17:16:43 +0000461 (memopfsf32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000462
463def FsANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000464 (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000465 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000466def FsANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000467 (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000468 "andnps\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000469}
470
471/// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms.
472///
473/// In addition, we also have a special variant of the scalar form here to
474/// represent the associated intrinsic operation. This form is unlike the
475/// plain scalar form, in that it takes an entire vector (instead of a scalar)
476/// and leaves the top elements undefined.
477///
478/// These three forms can each be reg+reg or reg+mem, so there are a total of
479/// six "instructions".
480///
481let isTwoAddress = 1 in {
482multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
483 SDNode OpNode, Intrinsic F32Int,
484 bit Commutable = 0> {
485 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000486 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000487 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000488 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
489 let isCommutable = Commutable;
490 }
491
492 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000493 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000494 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
496
497 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000498 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000499 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
501 let isCommutable = Commutable;
502 }
503
504 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000505 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000506 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000507 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508
509 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000510 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000511 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
513 let isCommutable = Commutable;
514 }
515
516 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000517 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000518 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519 [(set VR128:$dst, (F32Int VR128:$src1,
520 sse_load_f32:$src2))]>;
521}
522}
523
524// Arithmetic instructions
525defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>;
526defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>;
527defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>;
528defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>;
529
530/// sse1_fp_binop_rm - Other SSE1 binops
531///
532/// This multiclass is like basic_sse1_fp_binop_rm, with the addition of
533/// instructions for a full-vector intrinsic form. Operations that map
534/// onto C operators don't use this form since they just use the plain
535/// vector form instead of having a separate vector intrinsic form.
536///
537/// This provides a total of eight "instructions".
538///
539let isTwoAddress = 1 in {
540multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr,
541 SDNode OpNode,
542 Intrinsic F32Int,
543 Intrinsic V4F32Int,
544 bit Commutable = 0> {
545
546 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000547 def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000548 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
550 let isCommutable = Commutable;
551 }
552
553 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000554 def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins FR32:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000555 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
557
558 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000559 def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000560 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> {
562 let isCommutable = Commutable;
563 }
564
565 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000566 def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000567 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000568 [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569
570 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000571 def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000572 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573 [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> {
574 let isCommutable = Commutable;
575 }
576
577 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000578 def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, ssmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000579 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580 [(set VR128:$dst, (F32Int VR128:$src1,
581 sse_load_f32:$src2))]>;
582
583 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000584 def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000585 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586 [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> {
587 let isCommutable = Commutable;
588 }
589
590 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +0000591 def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000592 !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000593 [(set VR128:$dst, (V4F32Int VR128:$src1, (load addr:$src2)))]>;
594}
595}
596
597defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax,
598 int_x86_sse_max_ss, int_x86_sse_max_ps>;
599defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin,
600 int_x86_sse_min_ss, int_x86_sse_min_ps>;
601
602//===----------------------------------------------------------------------===//
603// SSE packed FP Instructions
604
605// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000606def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000607 "movaps\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000608let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000609def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000610 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000611 [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612
Evan Chengb783fa32007-07-19 01:14:50 +0000613def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000614 "movaps\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000615 [(alignedstore (v4f32 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000616
Evan Chengb783fa32007-07-19 01:14:50 +0000617def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000618 "movups\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000619let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000620def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000621 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000622 [(set VR128:$dst, (loadv4f32 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000623def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000624 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000625 [(store (v4f32 VR128:$src), addr:$dst)]>;
626
627// Intrinsic forms of MOVUPS load and store
Evan Cheng4e84e452007-08-30 05:49:43 +0000628let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000629def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000630 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000631 [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000632def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000633 "movups\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +0000634 [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635
636let isTwoAddress = 1 in {
637 let AddedComplexity = 20 in {
638 def MOVLPSrm : PSI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000639 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000640 "movlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641 [(set VR128:$dst,
642 (v4f32 (vector_shuffle VR128:$src1,
643 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
644 MOVLP_shuffle_mask)))]>;
645 def MOVHPSrm : PSI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000646 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 "movhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648 [(set VR128:$dst,
649 (v4f32 (vector_shuffle VR128:$src1,
650 (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2)))),
651 MOVHP_shuffle_mask)))]>;
652 } // AddedComplexity
653} // isTwoAddress
654
Evan Chengb783fa32007-07-19 01:14:50 +0000655def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000656 "movlps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000657 [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)),
658 (iPTR 0))), addr:$dst)]>;
659
660// v2f64 extract element 1 is always custom lowered to unpack high to low
661// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +0000662def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000663 "movhps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664 [(store (f64 (vector_extract
665 (v2f64 (vector_shuffle
666 (bc_v2f64 (v4f32 VR128:$src)), (undef),
667 UNPCKH_shuffle_mask)), (iPTR 0))),
668 addr:$dst)]>;
669
670let isTwoAddress = 1 in {
671let AddedComplexity = 15 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000672def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000673 "movlhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000674 [(set VR128:$dst,
675 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
676 MOVHP_shuffle_mask)))]>;
677
Evan Chengb783fa32007-07-19 01:14:50 +0000678def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000679 "movhlps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680 [(set VR128:$dst,
681 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
682 MOVHLPS_shuffle_mask)))]>;
683} // AddedComplexity
684} // isTwoAddress
685
686
687
688// Arithmetic
689
690/// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms.
691///
692/// In addition, we also have a special variant of the scalar form here to
693/// represent the associated intrinsic operation. This form is unlike the
694/// plain scalar form, in that it takes an entire vector (instead of a
695/// scalar) and leaves the top elements undefined.
696///
697/// And, we have a special variant form for a full-vector intrinsic form.
698///
699/// These four forms can each have a reg or a mem operand, so there are a
700/// total of eight "instructions".
701///
702multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr,
703 SDNode OpNode,
704 Intrinsic F32Int,
705 Intrinsic V4F32Int,
706 bit Commutable = 0> {
707 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000708 def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000709 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710 [(set FR32:$dst, (OpNode FR32:$src))]> {
711 let isCommutable = Commutable;
712 }
713
714 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000715 def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000716 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717 [(set FR32:$dst, (OpNode (load addr:$src)))]>;
718
719 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000720 def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000721 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722 [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> {
723 let isCommutable = Commutable;
724 }
725
726 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000727 def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000728 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +0000729 [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730
731 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +0000732 def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000733 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734 [(set VR128:$dst, (F32Int VR128:$src))]> {
735 let isCommutable = Commutable;
736 }
737
738 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +0000739 def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000740 !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741 [(set VR128:$dst, (F32Int sse_load_f32:$src))]>;
742
743 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +0000744 def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000745 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 [(set VR128:$dst, (V4F32Int VR128:$src))]> {
747 let isCommutable = Commutable;
748 }
749
750 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +0000751 def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000752 !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 [(set VR128:$dst, (V4F32Int (load addr:$src)))]>;
754}
755
756// Square root.
757defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt,
758 int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>;
759
760// Reciprocal approximations. Note that these typically require refinement
761// in order to obtain suitable precision.
762defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt,
763 int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>;
764defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp,
765 int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>;
766
767// Logical
768let isTwoAddress = 1 in {
769 let isCommutable = 1 in {
770 def ANDPSrr : PSI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000771 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000772 "andps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 [(set VR128:$dst, (v2i64
774 (and VR128:$src1, VR128:$src2)))]>;
775 def ORPSrr : PSI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000776 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000777 "orps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778 [(set VR128:$dst, (v2i64
779 (or VR128:$src1, VR128:$src2)))]>;
780 def XORPSrr : PSI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000781 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000782 "xorps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783 [(set VR128:$dst, (v2i64
784 (xor VR128:$src1, VR128:$src2)))]>;
785 }
786
787 def ANDPSrm : PSI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000788 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000789 "andps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000790 [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)),
791 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 def ORPSrm : PSI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000793 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000794 "orps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000795 [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)),
796 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000797 def XORPSrm : PSI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000798 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000799 "xorps\t{$src2, $dst|$dst, $src2}",
Evan Cheng8e92cd12007-07-19 23:34:10 +0000800 [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)),
801 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 def ANDNPSrr : PSI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000803 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000804 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805 [(set VR128:$dst,
806 (v2i64 (and (xor VR128:$src1,
807 (bc_v2i64 (v4i32 immAllOnesV))),
808 VR128:$src2)))]>;
809 def ANDNPSrm : PSI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000810 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000811 "andnps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 [(set VR128:$dst,
Evan Cheng8e92cd12007-07-19 23:34:10 +0000813 (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 (bc_v2i64 (v4i32 immAllOnesV))),
Evan Cheng8e92cd12007-07-19 23:34:10 +0000815 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816}
817
818let isTwoAddress = 1 in {
819 def CMPPSrri : PSIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000820 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000821 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000822 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
823 VR128:$src, imm:$cc))]>;
824 def CMPPSrmi : PSIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000825 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +0000826 "cmp${cc}ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1,
828 (load addr:$src), imm:$cc))]>;
829}
830
831// Shuffle and unpack instructions
832let isTwoAddress = 1 in {
833 let isConvertibleToThreeAddress = 1 in // Convert to pshufd
834 def SHUFPSrri : PSIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000835 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836 VR128:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000837 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838 [(set VR128:$dst,
839 (v4f32 (vector_shuffle
840 VR128:$src1, VR128:$src2,
841 SHUFP_shuffle_mask:$src3)))]>;
842 def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000843 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844 f128mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +0000845 "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 [(set VR128:$dst,
847 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000848 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849 SHUFP_shuffle_mask:$src3)))]>;
850
851 let AddedComplexity = 10 in {
852 def UNPCKHPSrr : PSI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000853 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000854 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 [(set VR128:$dst,
856 (v4f32 (vector_shuffle
857 VR128:$src1, VR128:$src2,
858 UNPCKH_shuffle_mask)))]>;
859 def UNPCKHPSrm : PSI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000860 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "unpckhps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set VR128:$dst,
863 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000864 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865 UNPCKH_shuffle_mask)))]>;
866
867 def UNPCKLPSrr : PSI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000868 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000869 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 [(set VR128:$dst,
871 (v4f32 (vector_shuffle
872 VR128:$src1, VR128:$src2,
873 UNPCKL_shuffle_mask)))]>;
874 def UNPCKLPSrm : PSI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000875 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000876 "unpcklps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 [(set VR128:$dst,
878 (v4f32 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +0000879 VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880 UNPCKL_shuffle_mask)))]>;
881 } // AddedComplexity
882} // isTwoAddress
883
884// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +0000885def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000886 "movmskps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000888def MOVMSKPDrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000889 "movmskpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890 [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>;
891
892// Prefetching loads.
893// TODO: no intrinsics for these?
Dan Gohman91888f02007-07-31 20:11:57 +0000894def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), "prefetcht0\t$src", []>;
895def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src), "prefetcht1\t$src", []>;
896def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src), "prefetcht2\t$src", []>;
897def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src), "prefetchnta\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898
899// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +0000900def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000901 "movntps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>;
903
904// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +0000905def SFENCE : PSI<0xAE, MRM7m, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906
907// MXCSR register
Evan Chengb783fa32007-07-19 01:14:50 +0000908def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000909 "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000910def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000911 "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912
913// Alias instructions that map zero vector to pxor / xorp* for sse.
914// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
915let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000916def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000917 "xorps\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 [(set VR128:$dst, (v4f32 immAllZerosV))]>;
919
920// FR32 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +0000921def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000922 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923 [(set VR128:$dst,
924 (v4f32 (scalar_to_vector FR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000925def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000926 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 [(set VR128:$dst,
928 (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>;
929
930// FIXME: may not be able to eliminate this movss with coalescing the src and
931// dest register classes are different. We really want to write this pattern
932// like this:
933// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
934// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +0000935def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000936 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(set FR32:$dst, (vector_extract (v4f32 VR128:$src),
938 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000939def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000940 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941 [(store (f32 (vector_extract (v4f32 VR128:$src),
942 (iPTR 0))), addr:$dst)]>;
943
944
945// Move to lower bits of a VR128, leaving upper bits alone.
946// Three operand (but two address) aliases.
947let isTwoAddress = 1 in {
948 def MOVLSS2PSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000949 (outs VR128:$dst), (ins VR128:$src1, FR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000950 "movss\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951
952 let AddedComplexity = 15 in
953 def MOVLPSrr : SSI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +0000954 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000955 "movss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 [(set VR128:$dst,
957 (v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
958 MOVL_shuffle_mask)))]>;
959}
960
961// Move to lower bits of a VR128 and zeroing upper bits.
962// Loading from memory automatically zeroing upper bits.
963let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +0000964def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000965 "movss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 [(set VR128:$dst, (v4f32 (vector_shuffle immAllZerosV,
967 (v4f32 (scalar_to_vector (loadf32 addr:$src))),
968 MOVL_shuffle_mask)))]>;
969
970
971//===----------------------------------------------------------------------===//
972// SSE2 Instructions
973//===----------------------------------------------------------------------===//
974
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000976def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000977 "movsd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000978let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000979def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000980 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 [(set FR64:$dst, (loadf64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000982def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000983 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984 [(store FR64:$src, addr:$dst)]>;
985
986// Conversion instructions
Evan Chengb783fa32007-07-19 01:14:50 +0000987def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000988 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 [(set GR32:$dst, (fp_to_sint FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000990def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000991 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000993def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000994 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 [(set FR32:$dst, (fround FR64:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000996def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000997 "cvtsd2ss\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000999def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001000 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(set FR64:$dst, (sint_to_fp GR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001002def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001003 "cvtsi2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
1005
1006// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001007def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001008 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 [(set FR64:$dst, (fextend FR32:$src))]>, XS,
1010 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001011def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001012 "cvtss2sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 [(set FR64:$dst, (extloadf32 addr:$src))]>, XS,
1014 Requires<[HasSSE2]>;
1015
1016// Match intrinsics which expect XMM operand(s).
Evan Chengb783fa32007-07-19 01:14:50 +00001017def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001018 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019 [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001020def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001021 "cvtsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 [(set GR32:$dst, (int_x86_sse2_cvtsd2si
1023 (load addr:$src)))]>;
1024
1025// Aliases for intrinsics
Evan Chengb783fa32007-07-19 01:14:50 +00001026def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 [(set GR32:$dst,
1029 (int_x86_sse2_cvttsd2si VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001030def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001031 "cvttsd2si\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 [(set GR32:$dst, (int_x86_sse2_cvttsd2si
1033 (load addr:$src)))]>;
1034
1035// Comparison instructions
1036let isTwoAddress = 1 in {
1037 def CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001038 (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001039 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 def CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001041 (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001042 "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043}
1044
Evan Cheng950aac02007-09-25 01:57:46 +00001045let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001046def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001047 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001048 [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001049def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001050 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001051 [(X86cmp FR64:$src1, (loadf64 addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001052 (implicit EFLAGS)]>;
1053}
1054
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055// Aliases to match intrinsics which expect XMM operand(s).
1056let isTwoAddress = 1 in {
1057 def Int_CMPSDrr : SDI<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001058 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001059 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1061 VR128:$src, imm:$cc))]>;
1062 def Int_CMPSDrm : SDI<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001063 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001064 "cmp${cc}sd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
1066 (load addr:$src), imm:$cc))]>;
1067}
1068
Evan Cheng950aac02007-09-25 01:57:46 +00001069let Defs = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001070def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001071 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001072 [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1073 (implicit EFLAGS)]>;
1074def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001075 "ucomisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001076 [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)),
1077 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078
Evan Chengb783fa32007-07-19 01:14:50 +00001079def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001080 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001081 [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)),
1082 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001083def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001084 "comisd\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00001085 [(X86comi (v2f64 VR128:$src1), (load addr:$src2)),
Evan Cheng950aac02007-09-25 01:57:46 +00001086 (implicit EFLAGS)]>;
1087} // Defs = EFLAGS]
1088
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089// Aliases of packed SSE2 instructions for scalar use. These all have names that
1090// start with 'Fs'.
1091
1092// Alias instructions that map fld0 to pxor for sse.
Dan Gohman8aef09b2007-09-07 21:32:51 +00001093let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001094def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00001095 "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096 Requires<[HasSSE2]>, TB, OpSize;
1097
1098// Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are
1099// disregarded.
Evan Chengb783fa32007-07-19 01:14:50 +00001100def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "movapd\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102
1103// Alias instruction to load FR64 from f128mem using movapd. Upper bits are
1104// disregarded.
Evan Cheng4e84e452007-08-30 05:49:43 +00001105let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001106def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman11821702007-07-27 17:16:43 +00001108 [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109
1110// Alias bitwise logical operations using SSE logical ops on packed FP values.
1111let isTwoAddress = 1 in {
1112let isCommutable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001113 def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001114 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115 [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001116 def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001117 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118 [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001119 def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001120 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>;
1122}
1123
Evan Chengb783fa32007-07-19 01:14:50 +00001124def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001125 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126 [(set FR64:$dst, (X86fand FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001127 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001128def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001129 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130 [(set FR64:$dst, (X86for FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001131 (memopfsf64 addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001132def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001133 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134 [(set FR64:$dst, (X86fxor FR64:$src1,
Dan Gohman11821702007-07-27 17:16:43 +00001135 (memopfsf64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136
1137def FsANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001138 (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001139 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140def FsANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001141 (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001142 "andnpd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143}
1144
1145/// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms.
1146///
1147/// In addition, we also have a special variant of the scalar form here to
1148/// represent the associated intrinsic operation. This form is unlike the
1149/// plain scalar form, in that it takes an entire vector (instead of a scalar)
1150/// and leaves the top elements undefined.
1151///
1152/// These three forms can each be reg+reg or reg+mem, so there are a total of
1153/// six "instructions".
1154///
1155let isTwoAddress = 1 in {
1156multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1157 SDNode OpNode, Intrinsic F64Int,
1158 bit Commutable = 0> {
1159 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001160 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001161 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1163 let isCommutable = Commutable;
1164 }
1165
1166 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001167 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001168 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1170
1171 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001172 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001173 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1175 let isCommutable = Commutable;
1176 }
1177
1178 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001179 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001180 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001181 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182
1183 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001184 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001185 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001186 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1187 let isCommutable = Commutable;
1188 }
1189
1190 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001191 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001192 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 [(set VR128:$dst, (F64Int VR128:$src1,
1194 sse_load_f64:$src2))]>;
1195}
1196}
1197
1198// Arithmetic instructions
1199defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>;
1200defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>;
1201defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>;
1202defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>;
1203
1204/// sse2_fp_binop_rm - Other SSE2 binops
1205///
1206/// This multiclass is like basic_sse2_fp_binop_rm, with the addition of
1207/// instructions for a full-vector intrinsic form. Operations that map
1208/// onto C operators don't use this form since they just use the plain
1209/// vector form instead of having a separate vector intrinsic form.
1210///
1211/// This provides a total of eight "instructions".
1212///
1213let isTwoAddress = 1 in {
1214multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr,
1215 SDNode OpNode,
1216 Intrinsic F64Int,
1217 Intrinsic V2F64Int,
1218 bit Commutable = 0> {
1219
1220 // Scalar operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001221 def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001222 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
1224 let isCommutable = Commutable;
1225 }
1226
1227 // Scalar operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001228 def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001229 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
1231
1232 // Vector operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001233 def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001234 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235 [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> {
1236 let isCommutable = Commutable;
1237 }
1238
1239 // Vector operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001240 def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001241 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001242 [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243
1244 // Intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001245 def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001246 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247 [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> {
1248 let isCommutable = Commutable;
1249 }
1250
1251 // Intrinsic operation, reg+mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001252 def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, sdmem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001253 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254 [(set VR128:$dst, (F64Int VR128:$src1,
1255 sse_load_f64:$src2))]>;
1256
1257 // Vector intrinsic operation, reg+reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001258 def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001259 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260 [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> {
1261 let isCommutable = Commutable;
1262 }
1263
1264 // Vector intrinsic operation, reg+mem.
Dan Gohmanc747be52007-08-02 21:06:40 +00001265 def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001266 !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267 [(set VR128:$dst, (V2F64Int VR128:$src1, (load addr:$src2)))]>;
1268}
1269}
1270
1271defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax,
1272 int_x86_sse2_max_sd, int_x86_sse2_max_pd>;
1273defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin,
1274 int_x86_sse2_min_sd, int_x86_sse2_min_pd>;
1275
1276//===----------------------------------------------------------------------===//
1277// SSE packed FP Instructions
1278
1279// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001280def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001281 "movapd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001282let isLoad = 1, isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001283def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001285 [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286
Evan Chengb783fa32007-07-19 01:14:50 +00001287def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001288 "movapd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001289 [(alignedstore (v2f64 VR128:$src), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290
Evan Chengb783fa32007-07-19 01:14:50 +00001291def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001292 "movupd\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001293let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001294def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001295 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001296 [(set VR128:$dst, (loadv2f64 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001297def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001299 [(store (v2f64 VR128:$src), addr:$dst)]>;
1300
1301// Intrinsic forms of MOVUPD load and store
Evan Chengb783fa32007-07-19 01:14:50 +00001302def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001303 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001304 [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001305def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001306 "movupd\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001307 [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308
1309let isTwoAddress = 1 in {
1310 let AddedComplexity = 20 in {
1311 def MOVLPDrm : PDI<0x12, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001312 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001313 "movlpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314 [(set VR128:$dst,
1315 (v2f64 (vector_shuffle VR128:$src1,
1316 (scalar_to_vector (loadf64 addr:$src2)),
1317 MOVLP_shuffle_mask)))]>;
1318 def MOVHPDrm : PDI<0x16, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001319 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001320 "movhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321 [(set VR128:$dst,
1322 (v2f64 (vector_shuffle VR128:$src1,
1323 (scalar_to_vector (loadf64 addr:$src2)),
1324 MOVHP_shuffle_mask)))]>;
1325 } // AddedComplexity
1326} // isTwoAddress
1327
Evan Chengb783fa32007-07-19 01:14:50 +00001328def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001329 "movlpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330 [(store (f64 (vector_extract (v2f64 VR128:$src),
1331 (iPTR 0))), addr:$dst)]>;
1332
1333// v2f64 extract element 1 is always custom lowered to unpack high to low
1334// and extract element 0 so the non-store version isn't too horrible.
Evan Chengb783fa32007-07-19 01:14:50 +00001335def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001336 "movhpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337 [(store (f64 (vector_extract
1338 (v2f64 (vector_shuffle VR128:$src, (undef),
1339 UNPCKH_shuffle_mask)), (iPTR 0))),
1340 addr:$dst)]>;
1341
1342// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001343def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001344 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001345 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>,
1346 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001347def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001348 "cvtdq2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349 [(set VR128:$dst, (int_x86_sse2_cvtdq2ps
Dan Gohman4a4f1512007-07-18 20:23:34 +00001350 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351 TB, Requires<[HasSSE2]>;
1352
1353// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001354def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001355 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>,
1357 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001358def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001359 "cvtdq2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360 [(set VR128:$dst, (int_x86_sse2_cvtdq2pd
Dan Gohman4a4f1512007-07-18 20:23:34 +00001361 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362 XS, Requires<[HasSSE2]>;
1363
Evan Chengb783fa32007-07-19 01:14:50 +00001364def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001365 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366 [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001367def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001368 "cvtps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369 [(set VR128:$dst, (int_x86_sse2_cvtps2dq
1370 (load addr:$src)))]>;
1371// SSE2 packed instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001372def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001373 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374 [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>,
1375 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001376def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001377 "cvttps2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378 [(set VR128:$dst, (int_x86_sse2_cvttps2dq
1379 (load addr:$src)))]>,
1380 XS, Requires<[HasSSE2]>;
1381
1382// SSE2 packed instructions with XD prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001383def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001384 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001385 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>,
1386 XD, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001387def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001388 "cvtpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389 [(set VR128:$dst, (int_x86_sse2_cvtpd2dq
1390 (load addr:$src)))]>,
1391 XD, Requires<[HasSSE2]>;
1392
Evan Chengb783fa32007-07-19 01:14:50 +00001393def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001394 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001396def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001397 "cvttpd2dq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001398 [(set VR128:$dst, (int_x86_sse2_cvttpd2dq
1399 (load addr:$src)))]>;
1400
1401// SSE2 instructions without OpSize prefix
Evan Chengb783fa32007-07-19 01:14:50 +00001402def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001403 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404 [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>,
1405 TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001406def Int_CVTPS2PDrm : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001407 "cvtps2pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408 [(set VR128:$dst, (int_x86_sse2_cvtps2pd
1409 (load addr:$src)))]>,
1410 TB, Requires<[HasSSE2]>;
1411
Evan Chengb783fa32007-07-19 01:14:50 +00001412def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001413 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001414 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001415def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001416 "cvtpd2ps\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001417 [(set VR128:$dst, (int_x86_sse2_cvtpd2ps
1418 (load addr:$src)))]>;
1419
1420// Match intrinsics which expect XMM operand(s).
1421// Aliases for intrinsics
1422let isTwoAddress = 1 in {
1423def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001424 (outs VR128:$dst), (ins VR128:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1427 GR32:$src2))]>;
1428def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001429 (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001430 "cvtsi2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001431 [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1,
1432 (loadi32 addr:$src2)))]>;
1433def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001434 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1437 VR128:$src2))]>;
1438def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001439 (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001440 "cvtsd2ss\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001441 [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1,
1442 (load addr:$src2)))]>;
1443def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001444 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001445 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1447 VR128:$src2))]>, XS,
1448 Requires<[HasSSE2]>;
1449def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001450 (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001451 "cvtss2sd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001452 [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1,
1453 (load addr:$src2)))]>, XS,
1454 Requires<[HasSSE2]>;
1455}
1456
1457// Arithmetic
1458
1459/// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms.
1460///
1461/// In addition, we also have a special variant of the scalar form here to
1462/// represent the associated intrinsic operation. This form is unlike the
1463/// plain scalar form, in that it takes an entire vector (instead of a
1464/// scalar) and leaves the top elements undefined.
1465///
1466/// And, we have a special variant form for a full-vector intrinsic form.
1467///
1468/// These four forms can each have a reg or a mem operand, so there are a
1469/// total of eight "instructions".
1470///
1471multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr,
1472 SDNode OpNode,
1473 Intrinsic F64Int,
1474 Intrinsic V2F64Int,
1475 bit Commutable = 0> {
1476 // Scalar operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001477 def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001478 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001479 [(set FR64:$dst, (OpNode FR64:$src))]> {
1480 let isCommutable = Commutable;
1481 }
1482
1483 // Scalar operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001484 def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001485 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486 [(set FR64:$dst, (OpNode (load addr:$src)))]>;
1487
1488 // Vector operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001489 def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001490 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001491 [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> {
1492 let isCommutable = Commutable;
1493 }
1494
1495 // Vector operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001496 def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001498 [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001499
1500 // Intrinsic operation, reg.
Evan Chengb783fa32007-07-19 01:14:50 +00001501 def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001502 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001503 [(set VR128:$dst, (F64Int VR128:$src))]> {
1504 let isCommutable = Commutable;
1505 }
1506
1507 // Intrinsic operation, mem.
Evan Chengb783fa32007-07-19 01:14:50 +00001508 def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001509 !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510 [(set VR128:$dst, (F64Int sse_load_f64:$src))]>;
1511
1512 // Vector intrinsic operation, reg
Evan Chengb783fa32007-07-19 01:14:50 +00001513 def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001515 [(set VR128:$dst, (V2F64Int VR128:$src))]> {
1516 let isCommutable = Commutable;
1517 }
1518
1519 // Vector intrinsic operation, mem
Dan Gohmanc747be52007-08-02 21:06:40 +00001520 def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001521 !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 [(set VR128:$dst, (V2F64Int (load addr:$src)))]>;
1523}
1524
1525// Square root.
1526defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt,
1527 int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>;
1528
1529// There is no f64 version of the reciprocal approximation instructions.
1530
1531// Logical
1532let isTwoAddress = 1 in {
1533 let isCommutable = 1 in {
1534 def ANDPDrr : PDI<0x54, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001535 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537 [(set VR128:$dst,
1538 (and (bc_v2i64 (v2f64 VR128:$src1)),
1539 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1540 def ORPDrr : PDI<0x56, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001541 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543 [(set VR128:$dst,
1544 (or (bc_v2i64 (v2f64 VR128:$src1)),
1545 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1546 def XORPDrr : PDI<0x57, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001547 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549 [(set VR128:$dst,
1550 (xor (bc_v2i64 (v2f64 VR128:$src1)),
1551 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1552 }
1553
1554 def ANDPDrm : PDI<0x54, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001555 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "andpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557 [(set VR128:$dst,
1558 (and (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001559 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 def ORPDrm : PDI<0x56, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001561 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001562 "orpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001563 [(set VR128:$dst,
1564 (or (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001565 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001566 def XORPDrm : PDI<0x57, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001567 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001568 "xorpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569 [(set VR128:$dst,
1570 (xor (bc_v2i64 (v2f64 VR128:$src1)),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001571 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 def ANDNPDrr : PDI<0x55, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001573 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575 [(set VR128:$dst,
1576 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
1577 (bc_v2i64 (v2f64 VR128:$src2))))]>;
1578 def ANDNPDrm : PDI<0x55, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001579 (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "andnpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581 [(set VR128:$dst,
1582 (and (vnot (bc_v2i64 (v2f64 VR128:$src1))),
Evan Cheng8e92cd12007-07-19 23:34:10 +00001583 (memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001584}
1585
1586let isTwoAddress = 1 in {
1587 def CMPPDrri : PDIi8<0xC2, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001588 (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001590 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1591 VR128:$src, imm:$cc))]>;
1592 def CMPPDrmi : PDIi8<0xC2, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001593 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc),
Dan Gohman91888f02007-07-31 20:11:57 +00001594 "cmp${cc}pd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595 [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1,
1596 (load addr:$src), imm:$cc))]>;
1597}
1598
1599// Shuffle and unpack instructions
1600let isTwoAddress = 1 in {
1601 def SHUFPDrri : PDIi8<0xC6, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001602 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001603 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001604 [(set VR128:$dst, (v2f64 (vector_shuffle
1605 VR128:$src1, VR128:$src2,
1606 SHUFP_shuffle_mask:$src3)))]>;
1607 def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001608 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609 f128mem:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001610 "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001611 [(set VR128:$dst,
1612 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001613 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614 SHUFP_shuffle_mask:$src3)))]>;
1615
1616 let AddedComplexity = 10 in {
1617 def UNPCKHPDrr : PDI<0x15, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001618 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620 [(set VR128:$dst,
1621 (v2f64 (vector_shuffle
1622 VR128:$src1, VR128:$src2,
1623 UNPCKH_shuffle_mask)))]>;
1624 def UNPCKHPDrm : PDI<0x15, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001625 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001626 "unpckhpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001627 [(set VR128:$dst,
1628 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001629 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001630 UNPCKH_shuffle_mask)))]>;
1631
1632 def UNPCKLPDrr : PDI<0x14, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001633 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001634 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001635 [(set VR128:$dst,
1636 (v2f64 (vector_shuffle
1637 VR128:$src1, VR128:$src2,
1638 UNPCKL_shuffle_mask)))]>;
1639 def UNPCKLPDrm : PDI<0x14, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001640 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "unpcklpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642 [(set VR128:$dst,
1643 (v2f64 (vector_shuffle
Dan Gohman7dc19012007-08-02 21:17:01 +00001644 VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645 UNPCKL_shuffle_mask)))]>;
1646 } // AddedComplexity
1647} // isTwoAddress
1648
1649
1650//===----------------------------------------------------------------------===//
1651// SSE integer instructions
1652
1653// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001654def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "movdqa\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001656let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001657def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001659 [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001660def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001661 "movdqa\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001662 [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001663let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001664def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001665 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001666 [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001668def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 "movdqu\t{$src, $dst|$dst, $src}",
Evan Cheng51a49b22007-07-20 00:27:43 +00001670 [/*(store (v2i64 VR128:$src), addr:$dst)*/]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001671 XS, Requires<[HasSSE2]>;
1672
Dan Gohman4a4f1512007-07-18 20:23:34 +00001673// Intrinsic forms of MOVDQU load and store
Evan Cheng4e84e452007-08-30 05:49:43 +00001674let isLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00001675def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001676 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001677 [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>,
1678 XS, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001679def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "movdqu\t{$src, $dst|$dst, $src}",
Dan Gohman4a4f1512007-07-18 20:23:34 +00001681 [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>,
1682 XS, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001683
1684let isTwoAddress = 1 in {
1685
1686multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
1687 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001688 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001690 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> {
1691 let isCommutable = Commutable;
1692 }
Evan Chengb783fa32007-07-19 01:14:50 +00001693 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001694 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001695 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001696 (bitconvert (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697}
1698
1699multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
1700 string OpcodeStr, Intrinsic IntId> {
Evan Chengb783fa32007-07-19 01:14:50 +00001701 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001704 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001705 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001706 [(set VR128:$dst, (IntId VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001707 (bitconvert (memopv2i64 addr:$src2))))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001708 def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001710 [(set VR128:$dst, (IntId VR128:$src1,
1711 (scalar_to_vector (i32 imm:$src2))))]>;
1712}
1713
1714
1715/// PDI_binop_rm - Simple SSE2 binary operator.
1716multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode,
1717 ValueType OpVT, bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001718 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001720 [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> {
1721 let isCommutable = Commutable;
1722 }
Evan Chengb783fa32007-07-19 01:14:50 +00001723 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725 [(set VR128:$dst, (OpVT (OpNode VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001726 (bitconvert (memopv2i64 addr:$src2)))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727}
1728
1729/// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64.
1730///
1731/// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew
1732/// to collapse (bitconvert VT to VT) into its operand.
1733///
1734multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode,
1735 bit Commutable = 0> {
Evan Chengb783fa32007-07-19 01:14:50 +00001736 def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001737 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738 [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> {
1739 let isCommutable = Commutable;
1740 }
Evan Chengb783fa32007-07-19 01:14:50 +00001741 def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohman4a4f1512007-07-18 20:23:34 +00001743 [(set VR128:$dst, (OpNode VR128:$src1,(memopv2i64 addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001744}
1745
1746} // isTwoAddress
1747
1748// 128-bit Integer Arithmetic
1749
1750defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>;
1751defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>;
1752defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>;
1753defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>;
1754
1755defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>;
1756defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>;
1757defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>;
1758defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>;
1759
1760defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>;
1761defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>;
1762defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>;
1763defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>;
1764
1765defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>;
1766defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>;
1767defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>;
1768defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>;
1769
1770defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>;
1771
1772defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>;
1773defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>;
1774defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>;
1775
1776defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>;
1777
1778defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>;
1779defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>;
1780
1781
1782defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>;
1783defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>;
1784defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>;
1785defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>;
1786defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>;
1787
1788
1789defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", int_x86_sse2_psll_w>;
1790defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", int_x86_sse2_psll_d>;
1791defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", int_x86_sse2_psll_q>;
1792
1793defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", int_x86_sse2_psrl_w>;
1794defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", int_x86_sse2_psrl_d>;
1795defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq", int_x86_sse2_psrl_q>;
1796
1797defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", int_x86_sse2_psra_w>;
1798defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad", int_x86_sse2_psra_d>;
1799// PSRAQ doesn't exist in SSE[1-3].
1800
1801// 128-bit logical shifts.
1802let isTwoAddress = 1 in {
1803 def PSLLDQri : PDIi8<0x73, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00001804 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001805 "pslldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806 def PSRLDQri : PDIi8<0x73, MRM3r,
Evan Chengb783fa32007-07-19 01:14:50 +00001807 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001808 "psrldq\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001809 // PSRADQri doesn't exist in SSE[1-3].
1810}
1811
1812let Predicates = [HasSSE2] in {
1813 def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2),
1814 (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1815 def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2),
1816 (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1817 def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)),
1818 (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>;
1819}
1820
1821// Logical
1822defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>;
1823defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>;
1824defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>;
1825
1826let isTwoAddress = 1 in {
1827 def PANDNrr : PDI<0xDF, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001828 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
1831 VR128:$src2)))]>;
1832
1833 def PANDNrm : PDI<0xDF, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001834 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "pandn\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1),
Dan Gohman7dc19012007-08-02 21:17:01 +00001837 (memopv2i64 addr:$src2))))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001838}
1839
1840// SSE2 Integer comparison
1841defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>;
1842defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>;
1843defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>;
1844defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>;
1845defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>;
1846defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>;
1847
1848// Pack instructions
1849defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>;
1850defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>;
1851defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>;
1852
1853// Shuffle and unpack instructions
1854def PSHUFDri : PDIi8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001855 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857 [(set VR128:$dst, (v4i32 (vector_shuffle
1858 VR128:$src1, (undef),
1859 PSHUFD_shuffle_mask:$src2)))]>;
1860def PSHUFDmi : PDIi8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001861 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001862 "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001863 [(set VR128:$dst, (v4i32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001864 (bc_v4i32(memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865 (undef),
1866 PSHUFD_shuffle_mask:$src2)))]>;
1867
1868// SSE2 with ImmT == Imm8 and XS prefix.
1869def PSHUFHWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001870 (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 [(set VR128:$dst, (v8i16 (vector_shuffle
1873 VR128:$src1, (undef),
1874 PSHUFHW_shuffle_mask:$src2)))]>,
1875 XS, Requires<[HasSSE2]>;
1876def PSHUFHWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001877 (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001880 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001881 (undef),
1882 PSHUFHW_shuffle_mask:$src2)))]>,
1883 XS, Requires<[HasSSE2]>;
1884
1885// SSE2 with ImmT == Imm8 and XD prefix.
1886def PSHUFLWri : Ii8<0x70, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001887 (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001888 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001889 [(set VR128:$dst, (v8i16 (vector_shuffle
1890 VR128:$src1, (undef),
1891 PSHUFLW_shuffle_mask:$src2)))]>,
1892 XD, Requires<[HasSSE2]>;
1893def PSHUFLWmi : Ii8<0x70, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001894 (outs VR128:$dst), (ins i128mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001895 "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001896 [(set VR128:$dst, (v8i16 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00001897 (bc_v8i16 (memopv2i64 addr:$src1)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898 (undef),
1899 PSHUFLW_shuffle_mask:$src2)))]>,
1900 XD, Requires<[HasSSE2]>;
1901
1902
1903let isTwoAddress = 1 in {
1904 def PUNPCKLBWrr : PDI<0x60, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001905 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(set VR128:$dst,
1908 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1909 UNPCKL_shuffle_mask)))]>;
1910 def PUNPCKLBWrm : PDI<0x60, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001911 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "punpcklbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(set VR128:$dst,
1914 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001915 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916 UNPCKL_shuffle_mask)))]>;
1917 def PUNPCKLWDrr : PDI<0x61, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001918 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001920 [(set VR128:$dst,
1921 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1922 UNPCKL_shuffle_mask)))]>;
1923 def PUNPCKLWDrm : PDI<0x61, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001924 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "punpcklwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(set VR128:$dst,
1927 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001928 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 UNPCKL_shuffle_mask)))]>;
1930 def PUNPCKLDQrr : PDI<0x62, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001931 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001932 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001933 [(set VR128:$dst,
1934 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1935 UNPCKL_shuffle_mask)))]>;
1936 def PUNPCKLDQrm : PDI<0x62, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001937 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "punpckldq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(set VR128:$dst,
1940 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001941 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942 UNPCKL_shuffle_mask)))]>;
1943 def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001944 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001946 [(set VR128:$dst,
1947 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
1948 UNPCKL_shuffle_mask)))]>;
1949 def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001950 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001951 "punpcklqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001952 [(set VR128:$dst,
1953 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001954 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001955 UNPCKL_shuffle_mask)))]>;
1956
1957 def PUNPCKHBWrr : PDI<0x68, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001958 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(set VR128:$dst,
1961 (v16i8 (vector_shuffle VR128:$src1, VR128:$src2,
1962 UNPCKH_shuffle_mask)))]>;
1963 def PUNPCKHBWrm : PDI<0x68, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001964 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001965 "punpckhbw\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001966 [(set VR128:$dst,
1967 (v16i8 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001968 (bc_v16i8 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 UNPCKH_shuffle_mask)))]>;
1970 def PUNPCKHWDrr : PDI<0x69, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001971 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 [(set VR128:$dst,
1974 (v8i16 (vector_shuffle VR128:$src1, VR128:$src2,
1975 UNPCKH_shuffle_mask)))]>;
1976 def PUNPCKHWDrm : PDI<0x69, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001977 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "punpckhwd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001979 [(set VR128:$dst,
1980 (v8i16 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001981 (bc_v8i16 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001982 UNPCKH_shuffle_mask)))]>;
1983 def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001984 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001985 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986 [(set VR128:$dst,
1987 (v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
1988 UNPCKH_shuffle_mask)))]>;
1989 def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001990 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001991 "punpckhdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992 [(set VR128:$dst,
1993 (v4i32 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00001994 (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001995 UNPCKH_shuffle_mask)))]>;
1996 def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001997 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001998 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001999 [(set VR128:$dst,
2000 (v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2001 UNPCKH_shuffle_mask)))]>;
2002 def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002003 (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "punpckhqdq\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 [(set VR128:$dst,
2006 (v2i64 (vector_shuffle VR128:$src1,
Dan Gohman4a4f1512007-07-18 20:23:34 +00002007 (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002008 UNPCKH_shuffle_mask)))]>;
2009}
2010
2011// Extract / Insert
2012def PEXTRWri : PDIi8<0xC5, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002013 (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1),
2016 (iPTR imm:$src2)))]>;
2017let isTwoAddress = 1 in {
2018 def PINSRWrri : PDIi8<0xC4, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002019 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020 GR32:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002021 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022 [(set VR128:$dst,
2023 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
2024 GR32:$src2, (iPTR imm:$src3))))]>;
2025 def PINSRWrmi : PDIi8<0xC4, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002026 (outs VR128:$dst), (ins VR128:$src1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027 i16mem:$src2, i32i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002028 "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029 [(set VR128:$dst,
2030 (v8i16 (X86pinsrw (v8i16 VR128:$src1),
2031 (i32 (anyext (loadi16 addr:$src2))),
2032 (iPTR imm:$src3))))]>;
2033}
2034
2035// Mask creation
Evan Chengb783fa32007-07-19 01:14:50 +00002036def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "pmovmskb\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038 [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>;
2039
2040// Conditional store
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002041let Uses = [EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +00002042def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask),
Dan Gohman91888f02007-07-31 20:11:57 +00002043 "maskmovdqu\t{$mask, $src|$src, $mask}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002044 [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002045
2046// Non-temporal stores
Evan Chengb783fa32007-07-19 01:14:50 +00002047def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002048 "movntpd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002050def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "movntdq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002052 [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002053def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002054 "movnti\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055 [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>,
2056 TB, Requires<[HasSSE2]>;
2057
2058// Flush cache
Evan Chengb783fa32007-07-19 01:14:50 +00002059def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061 TB, Requires<[HasSSE2]>;
2062
2063// Load, store, and memory fence
Evan Chengb783fa32007-07-19 01:14:50 +00002064def LFENCE : I<0xAE, MRM5m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002066def MFENCE : I<0xAE, MRM6m, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>;
2068
2069
2070// Alias instructions that map zero vector to pxor / xorp* for sse.
2071// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2072let isReMaterializable = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +00002073 def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "pcmpeqd\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002075 [(set VR128:$dst, (v2f64 immAllOnesV))]>;
2076
2077// FR64 to 128-bit vector conversion.
Evan Chengb783fa32007-07-19 01:14:50 +00002078def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002080 [(set VR128:$dst,
2081 (v2f64 (scalar_to_vector FR64:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002082def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(set VR128:$dst,
2085 (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>;
2086
Evan Chengb783fa32007-07-19 01:14:50 +00002087def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002088 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089 [(set VR128:$dst,
2090 (v4i32 (scalar_to_vector GR32:$src)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002091def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002092 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002093 [(set VR128:$dst,
2094 (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>;
2095
Evan Chengb783fa32007-07-19 01:14:50 +00002096def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 [(set FR32:$dst, (bitconvert GR32:$src))]>;
2099
Evan Chengb783fa32007-07-19 01:14:50 +00002100def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002101 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002102 [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>;
2103
2104// SSE2 instructions with XS prefix
Evan Chengb783fa32007-07-19 01:14:50 +00002105def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002106 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107 [(set VR128:$dst,
2108 (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS,
2109 Requires<[HasSSE2]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002110def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(store (i64 (vector_extract (v2i64 VR128:$src),
2113 (iPTR 0))), addr:$dst)]>;
2114
2115// FIXME: may not be able to eliminate this movss with coalescing the src and
2116// dest register classes are different. We really want to write this pattern
2117// like this:
2118// def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))),
2119// (f32 FR32:$src)>;
Evan Chengb783fa32007-07-19 01:14:50 +00002120def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002121 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002122 [(set FR64:$dst, (vector_extract (v2f64 VR128:$src),
2123 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002124def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002125 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126 [(store (f64 (vector_extract (v2f64 VR128:$src),
2127 (iPTR 0))), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002128def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002129 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130 [(set GR32:$dst, (vector_extract (v4i32 VR128:$src),
2131 (iPTR 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002132def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(store (i32 (vector_extract (v4i32 VR128:$src),
2135 (iPTR 0))), addr:$dst)]>;
2136
Evan Chengb783fa32007-07-19 01:14:50 +00002137def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002138 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 [(set GR32:$dst, (bitconvert FR32:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002140def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002141 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142 [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>;
2143
2144
2145// Move to lower bits of a VR128, leaving upper bits alone.
2146// Three operand (but two address) aliases.
2147let isTwoAddress = 1 in {
2148 def MOVLSD2PDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002149 (outs VR128:$dst), (ins VR128:$src1, FR64:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002150 "movsd\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151
2152 let AddedComplexity = 15 in
2153 def MOVLPDrr : SDI<0x10, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002154 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002155 "movsd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156 [(set VR128:$dst,
2157 (v2f64 (vector_shuffle VR128:$src1, VR128:$src2,
2158 MOVL_shuffle_mask)))]>;
2159}
2160
2161// Store / copy lower 64-bits of a XMM register.
Evan Chengb783fa32007-07-19 01:14:50 +00002162def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002163 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164 [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>;
2165
2166// Move to lower bits of a VR128 and zeroing upper bits.
2167// Loading from memory automatically zeroing upper bits.
2168let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002169 def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002170 "movsd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171 [(set VR128:$dst,
2172 (v2f64 (vector_shuffle immAllZerosV,
2173 (v2f64 (scalar_to_vector
2174 (loadf64 addr:$src))),
2175 MOVL_shuffle_mask)))]>;
2176
2177let AddedComplexity = 15 in
2178// movd / movq to XMM register zero-extends
Evan Chengb783fa32007-07-19 01:14:50 +00002179def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002181 [(set VR128:$dst,
2182 (v4i32 (vector_shuffle immAllZerosV,
2183 (v4i32 (scalar_to_vector GR32:$src)),
2184 MOVL_shuffle_mask)))]>;
2185let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002186def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "movd\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188 [(set VR128:$dst,
2189 (v4i32 (vector_shuffle immAllZerosV,
2190 (v4i32 (scalar_to_vector (loadi32 addr:$src))),
2191 MOVL_shuffle_mask)))]>;
2192
2193// Moving from XMM to XMM but still clear upper 64 bits.
2194let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002195def MOVZQI2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002197 [(set VR128:$dst, (int_x86_sse2_movl_dq VR128:$src))]>,
2198 XS, Requires<[HasSSE2]>;
2199let AddedComplexity = 20 in
Evan Chengb783fa32007-07-19 01:14:50 +00002200def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "movq\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202 [(set VR128:$dst, (int_x86_sse2_movl_dq
Dan Gohman4a4f1512007-07-18 20:23:34 +00002203 (bitconvert (memopv2i64 addr:$src))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204 XS, Requires<[HasSSE2]>;
2205
2206
2207//===----------------------------------------------------------------------===//
2208// SSE3 Instructions
2209//===----------------------------------------------------------------------===//
2210
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211// Move Instructions
Evan Chengb783fa32007-07-19 01:14:50 +00002212def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 [(set VR128:$dst, (v4f32 (vector_shuffle
2215 VR128:$src, (undef),
2216 MOVSHDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002217def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "movshdup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002220 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002221 MOVSHDUP_shuffle_mask)))]>;
2222
Evan Chengb783fa32007-07-19 01:14:50 +00002223def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002224 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002225 [(set VR128:$dst, (v4f32 (vector_shuffle
2226 VR128:$src, (undef),
2227 MOVSLDUP_shuffle_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002228def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002229 "movsldup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 [(set VR128:$dst, (v4f32 (vector_shuffle
Dan Gohman4a4f1512007-07-18 20:23:34 +00002231 (memopv4f32 addr:$src), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002232 MOVSLDUP_shuffle_mask)))]>;
2233
Evan Chengb783fa32007-07-19 01:14:50 +00002234def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002235 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236 [(set VR128:$dst, (v2f64 (vector_shuffle
2237 VR128:$src, (undef),
2238 SSE_splat_lo_mask)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002239def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "movddup\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002241 [(set VR128:$dst,
2242 (v2f64 (vector_shuffle
2243 (scalar_to_vector (loadf64 addr:$src)),
2244 (undef),
2245 SSE_splat_lo_mask)))]>;
2246
2247// Arithmetic
2248let isTwoAddress = 1 in {
2249 def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002250 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002251 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2253 VR128:$src2))]>;
2254 def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002255 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "addsubps\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257 [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1,
2258 (load addr:$src2)))]>;
2259 def ADDSUBPDrr : S3I<0xD0, MRMSrcReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002260 (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002262 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2263 VR128:$src2))]>;
2264 def ADDSUBPDrm : S3I<0xD0, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002265 (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002266 "addsubpd\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267 [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1,
2268 (load addr:$src2)))]>;
2269}
2270
Evan Chengb783fa32007-07-19 01:14:50 +00002271def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "lddqu\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273 [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>;
2274
2275// Horizontal ops
2276class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002277 : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002278 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002279 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>;
2280class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002281 : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283 [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (load addr:$src2))))]>;
2284class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002285 : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002287 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>;
2288class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId>
Evan Chengb783fa32007-07-19 01:14:50 +00002289 : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002290 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291 [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (load addr:$src2))))]>;
2292
2293let isTwoAddress = 1 in {
2294 def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2295 def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>;
2296 def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2297 def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>;
2298 def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2299 def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>;
2300 def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2301 def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>;
2302}
2303
2304// Thread synchronization
Evan Chengb783fa32007-07-19 01:14:50 +00002305def MONITOR : I<0xC8, RawFrm, (outs), (ins), "monitor",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002306 [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002307def MWAIT : I<0xC9, RawFrm, (outs), (ins), "mwait",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002308 [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>;
2309
2310// vector_shuffle v1, <undef> <1, 1, 3, 3>
2311let AddedComplexity = 15 in
2312def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2313 MOVSHDUP_shuffle_mask)),
2314 (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2315let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002316def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317 MOVSHDUP_shuffle_mask)),
2318 (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>;
2319
2320// vector_shuffle v1, <undef> <0, 0, 2, 2>
2321let AddedComplexity = 15 in
2322 def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2323 MOVSLDUP_shuffle_mask)),
2324 (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>;
2325let AddedComplexity = 20 in
Dan Gohman4a4f1512007-07-18 20:23:34 +00002326 def : Pat<(v4i32 (vector_shuffle (bc_v4i32 (memopv2i64 addr:$src)), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327 MOVSLDUP_shuffle_mask)),
2328 (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>;
2329
2330//===----------------------------------------------------------------------===//
2331// SSSE3 Instructions
2332//===----------------------------------------------------------------------===//
2333
Bill Wendling3b15d722007-08-11 09:52:53 +00002334// SSSE3 Instruction Templates:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002335//
Bill Wendling98680292007-08-10 06:22:27 +00002336// SS38I - SSSE3 instructions with T8 prefix.
2337// SS3AI - SSSE3 instructions with TA prefix.
Bill Wendling3b15d722007-08-11 09:52:53 +00002338//
2339// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
2340// uses the MMX registers. We put those instructions here because they better
2341// fit into the SSSE3 instruction category rather than the MMX category.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002342
Evan Chengb783fa32007-07-19 01:14:50 +00002343class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
2344 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002345 : I<o, F, outs, ins, asm, pattern>, T8, Requires<[HasSSSE3]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002346class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
2347 list<dag> pattern>
Bill Wendling98680292007-08-10 06:22:27 +00002348 : I<o, F, outs, ins, asm, pattern>, TA, Requires<[HasSSSE3]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349
Bill Wendling98680292007-08-10 06:22:27 +00002350/// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002351let isTwoAddress = 1 in {
Bill Wendling98680292007-08-10 06:22:27 +00002352 multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr,
2353 Intrinsic IntId64, Intrinsic IntId128,
2354 bit Commutable = 0> {
2355 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
2356 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2357 [(set VR64:$dst, (IntId64 VR64:$src))]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002358 let isCommutable = Commutable;
2359 }
Bill Wendling98680292007-08-10 06:22:27 +00002360 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
2361 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2362 [(set VR64:$dst,
2363 (IntId64 (bitconvert (memopv8i8 addr:$src))))]>;
2364
2365 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2366 (ins VR128:$src),
2367 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2368 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2369 OpSize {
2370 let isCommutable = Commutable;
2371 }
2372 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2373 (ins i128mem:$src),
2374 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2375 [(set VR128:$dst,
2376 (IntId128
2377 (bitconvert (memopv16i8 addr:$src))))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002378 }
2379}
2380
Bill Wendling98680292007-08-10 06:22:27 +00002381/// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16.
2382let isTwoAddress = 1 in {
2383 multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr,
2384 Intrinsic IntId64, Intrinsic IntId128,
2385 bit Commutable = 0> {
2386 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2387 (ins VR64:$src),
2388 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2389 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2390 let isCommutable = Commutable;
2391 }
2392 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2393 (ins i64mem:$src),
2394 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2395 [(set VR64:$dst,
2396 (IntId64
2397 (bitconvert (memopv4i16 addr:$src))))]>;
2398
2399 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2400 (ins VR128:$src),
2401 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2402 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2403 OpSize {
2404 let isCommutable = Commutable;
2405 }
2406 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2407 (ins i128mem:$src),
2408 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2409 [(set VR128:$dst,
2410 (IntId128
2411 (bitconvert (memopv8i16 addr:$src))))]>, OpSize;
2412 }
2413}
2414
2415/// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32.
2416let isTwoAddress = 1 in {
2417 multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr,
2418 Intrinsic IntId64, Intrinsic IntId128,
2419 bit Commutable = 0> {
2420 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2421 (ins VR64:$src),
2422 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2423 [(set VR64:$dst, (IntId64 VR64:$src))]> {
2424 let isCommutable = Commutable;
2425 }
2426 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2427 (ins i64mem:$src),
2428 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2429 [(set VR64:$dst,
2430 (IntId64
2431 (bitconvert (memopv2i32 addr:$src))))]>;
2432
2433 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2434 (ins VR128:$src),
2435 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2436 [(set VR128:$dst, (IntId128 VR128:$src))]>,
2437 OpSize {
2438 let isCommutable = Commutable;
2439 }
2440 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2441 (ins i128mem:$src),
2442 !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
2443 [(set VR128:$dst,
2444 (IntId128
2445 (bitconvert (memopv4i32 addr:$src))))]>, OpSize;
2446 }
2447}
2448
2449defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb",
2450 int_x86_ssse3_pabs_b,
2451 int_x86_ssse3_pabs_b_128>;
2452defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw",
2453 int_x86_ssse3_pabs_w,
2454 int_x86_ssse3_pabs_w_128>;
2455defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd",
2456 int_x86_ssse3_pabs_d,
2457 int_x86_ssse3_pabs_d_128>;
2458
2459/// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8.
2460let isTwoAddress = 1 in {
2461 multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr,
2462 Intrinsic IntId64, Intrinsic IntId128,
2463 bit Commutable = 0> {
2464 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2465 (ins VR64:$src1, VR64:$src2),
2466 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2467 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2468 let isCommutable = Commutable;
2469 }
2470 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2471 (ins VR64:$src1, i64mem:$src2),
2472 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2473 [(set VR64:$dst,
2474 (IntId64 VR64:$src1,
2475 (bitconvert (memopv8i8 addr:$src2))))]>;
2476
2477 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2478 (ins VR128:$src1, VR128:$src2),
2479 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2480 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2481 OpSize {
2482 let isCommutable = Commutable;
2483 }
2484 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2485 (ins VR128:$src1, i128mem:$src2),
2486 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2487 [(set VR128:$dst,
2488 (IntId128 VR128:$src1,
2489 (bitconvert (memopv16i8 addr:$src2))))]>, OpSize;
2490 }
2491}
2492
2493/// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16.
2494let isTwoAddress = 1 in {
2495 multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr,
2496 Intrinsic IntId64, Intrinsic IntId128,
2497 bit Commutable = 0> {
2498 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2499 (ins VR64:$src1, VR64:$src2),
2500 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2501 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2502 let isCommutable = Commutable;
2503 }
2504 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2505 (ins VR64:$src1, i64mem:$src2),
2506 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2507 [(set VR64:$dst,
2508 (IntId64 VR64:$src1,
2509 (bitconvert (memopv4i16 addr:$src2))))]>;
2510
2511 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2512 (ins VR128:$src1, VR128:$src2),
2513 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2514 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2515 OpSize {
2516 let isCommutable = Commutable;
2517 }
2518 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2519 (ins VR128:$src1, i128mem:$src2),
2520 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2521 [(set VR128:$dst,
2522 (IntId128 VR128:$src1,
2523 (bitconvert (memopv8i16 addr:$src2))))]>, OpSize;
2524 }
2525}
2526
2527/// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32.
2528let isTwoAddress = 1 in {
2529 multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr,
2530 Intrinsic IntId64, Intrinsic IntId128,
2531 bit Commutable = 0> {
2532 def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst),
2533 (ins VR64:$src1, VR64:$src2),
2534 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2535 [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> {
2536 let isCommutable = Commutable;
2537 }
2538 def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst),
2539 (ins VR64:$src1, i64mem:$src2),
2540 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2541 [(set VR64:$dst,
2542 (IntId64 VR64:$src1,
2543 (bitconvert (memopv2i32 addr:$src2))))]>;
2544
2545 def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst),
2546 (ins VR128:$src1, VR128:$src2),
2547 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2548 [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>,
2549 OpSize {
2550 let isCommutable = Commutable;
2551 }
2552 def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst),
2553 (ins VR128:$src1, i128mem:$src2),
2554 !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
2555 [(set VR128:$dst,
2556 (IntId128 VR128:$src1,
2557 (bitconvert (memopv4i32 addr:$src2))))]>, OpSize;
2558 }
2559}
2560
2561defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw",
2562 int_x86_ssse3_phadd_w,
2563 int_x86_ssse3_phadd_w_128, 1>;
2564defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd",
2565 int_x86_ssse3_phadd_d,
2566 int_x86_ssse3_phadd_d_128, 1>;
2567defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw",
2568 int_x86_ssse3_phadd_sw,
2569 int_x86_ssse3_phadd_sw_128, 1>;
2570defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw",
2571 int_x86_ssse3_phsub_w,
2572 int_x86_ssse3_phsub_w_128>;
2573defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd",
2574 int_x86_ssse3_phsub_d,
2575 int_x86_ssse3_phsub_d_128>;
2576defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw",
2577 int_x86_ssse3_phsub_sw,
2578 int_x86_ssse3_phsub_sw_128>;
2579defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw",
2580 int_x86_ssse3_pmadd_ub_sw,
2581 int_x86_ssse3_pmadd_ub_sw_128, 1>;
2582defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw",
2583 int_x86_ssse3_pmul_hr_sw,
2584 int_x86_ssse3_pmul_hr_sw_128, 1>;
2585defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb",
2586 int_x86_ssse3_pshuf_b,
2587 int_x86_ssse3_pshuf_b_128>;
2588defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb",
2589 int_x86_ssse3_psign_b,
2590 int_x86_ssse3_psign_b_128>;
2591defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw",
2592 int_x86_ssse3_psign_w,
2593 int_x86_ssse3_psign_w_128>;
2594defm PSIGND : SS3I_binop_rm_int_32<0x09, "psignd",
2595 int_x86_ssse3_psign_d,
2596 int_x86_ssse3_psign_d_128>;
2597
2598let isTwoAddress = 1 in {
Bill Wendling1dc817c2007-08-10 09:00:17 +00002599 def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2600 (ins VR64:$src1, VR64:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002601 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002602 [(set VR64:$dst,
2603 (int_x86_ssse3_palign_r
2604 VR64:$src1, VR64:$src2,
2605 imm:$src3))]>;
2606 def PALIGNR64rm : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
2607 (ins VR64:$src1, i64mem:$src2, i16imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002608 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002609 [(set VR64:$dst,
2610 (int_x86_ssse3_palign_r
2611 VR64:$src1,
2612 (bitconvert (memopv2i32 addr:$src2)),
2613 imm:$src3))]>;
Bill Wendling98680292007-08-10 06:22:27 +00002614
Bill Wendling1dc817c2007-08-10 09:00:17 +00002615 def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2616 (ins VR128:$src1, VR128:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002617 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002618 [(set VR128:$dst,
2619 (int_x86_ssse3_palign_r_128
2620 VR128:$src1, VR128:$src2,
2621 imm:$src3))]>, OpSize;
2622 def PALIGNR128rm : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst),
2623 (ins VR128:$src1, i128mem:$src2, i32imm:$src3),
Dale Johannesen576b27e2007-10-11 20:58:37 +00002624 "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Bill Wendling1dc817c2007-08-10 09:00:17 +00002625 [(set VR128:$dst,
2626 (int_x86_ssse3_palign_r_128
2627 VR128:$src1,
2628 (bitconvert (memopv4i32 addr:$src2)),
2629 imm:$src3))]>, OpSize;
Bill Wendling98680292007-08-10 06:22:27 +00002630}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002631
2632//===----------------------------------------------------------------------===//
2633// Non-Instruction Patterns
2634//===----------------------------------------------------------------------===//
2635
2636// 128-bit vector undef's.
Bill Wendling1dc817c2007-08-10 09:00:17 +00002637def : Pat<(v4f32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002638def : Pat<(v2f64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2639def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2640def : Pat<(v8i16 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2641def : Pat<(v4i32 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2642def : Pat<(v2i64 (undef)), (IMPLICIT_DEF_VR128)>, Requires<[HasSSE2]>;
2643
2644// 128-bit vector all zero's.
2645def : Pat<(v16i8 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2646def : Pat<(v8i16 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2647def : Pat<(v4i32 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2648def : Pat<(v2i64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2649def : Pat<(v2f64 immAllZerosV), (V_SET0)>, Requires<[HasSSE2]>;
2650
2651// 128-bit vector all one's.
2652def : Pat<(v16i8 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2653def : Pat<(v8i16 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2654def : Pat<(v4i32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2655def : Pat<(v2i64 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE2]>;
2656def : Pat<(v4f32 immAllOnesV), (V_SETALLONES)>, Requires<[HasSSE1]>;
2657
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002658
2659// Scalar to v8i16 / v16i8. The source may be a GR32, but only the lower 8 or
2660// 16-bits matter.
2661def : Pat<(v8i16 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2662 Requires<[HasSSE2]>;
2663def : Pat<(v16i8 (X86s2vec GR32:$src)), (MOVDI2PDIrr GR32:$src)>,
2664 Requires<[HasSSE2]>;
2665
2666// bit_convert
2667let Predicates = [HasSSE2] in {
2668 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
2669 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
2670 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
2671 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
2672 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
2673 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
2674 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
2675 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
2676 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
2677 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
2678 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
2679 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
2680 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
2681 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
2682 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
2683 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
2684 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
2685 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
2686 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
2687 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
2688 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
2689 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
2690 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
2691 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
2692 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
2693 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
2694 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
2695 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
2696 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
2697 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
2698}
2699
2700// Move scalar to XMM zero-extended
2701// movd to XMM register zero-extends
2702let AddedComplexity = 15 in {
2703def : Pat<(v8i16 (vector_shuffle immAllZerosV,
2704 (v8i16 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2705 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2706def : Pat<(v16i8 (vector_shuffle immAllZerosV,
2707 (v16i8 (X86s2vec GR32:$src)), MOVL_shuffle_mask)),
2708 (MOVZDI2PDIrr GR32:$src)>, Requires<[HasSSE2]>;
2709// Zeroing a VR128 then do a MOVS{S|D} to the lower bits.
2710def : Pat<(v2f64 (vector_shuffle immAllZerosV,
2711 (v2f64 (scalar_to_vector FR64:$src)), MOVL_shuffle_mask)),
2712 (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>;
2713def : Pat<(v4f32 (vector_shuffle immAllZerosV,
2714 (v4f32 (scalar_to_vector FR32:$src)), MOVL_shuffle_mask)),
2715 (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE2]>;
2716}
2717
2718// Splat v2f64 / v2i64
2719let AddedComplexity = 10 in {
2720def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2721 (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2722def : Pat<(vector_shuffle (v2f64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2723 (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2724def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), SSE_splat_lo_mask:$sm),
2725 (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2726def : Pat<(vector_shuffle (v2i64 VR128:$src), (undef), UNPCKH_shuffle_mask:$sm),
2727 (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2728}
2729
2730// Splat v4f32
2731def : Pat<(vector_shuffle (v4f32 VR128:$src), (undef), SSE_splat_mask:$sm),
2732 (SHUFPSrri VR128:$src, VR128:$src, SSE_splat_mask:$sm)>,
2733 Requires<[HasSSE1]>;
2734
2735// Special unary SHUFPSrri case.
2736// FIXME: when we want non two-address code, then we should use PSHUFD?
2737def : Pat<(vector_shuffle (v4f32 VR128:$src1), (undef),
2738 SHUFP_unary_shuffle_mask:$sm),
2739 (SHUFPSrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2740 Requires<[HasSSE1]>;
Dan Gohman7dc19012007-08-02 21:17:01 +00002741// Special unary SHUFPDrri case.
2742def : Pat<(vector_shuffle (v2f64 VR128:$src1), (undef),
2743 SHUFP_unary_shuffle_mask:$sm),
2744 (SHUFPDrri VR128:$src1, VR128:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2745 Requires<[HasSSE2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002746// Unary v4f32 shuffle with PSHUF* in order to fold a load.
Dan Gohman4a4f1512007-07-18 20:23:34 +00002747def : Pat<(vector_shuffle (memopv4f32 addr:$src1), (undef),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002748 SHUFP_unary_shuffle_mask:$sm),
2749 (PSHUFDmi addr:$src1, SHUFP_unary_shuffle_mask:$sm)>,
2750 Requires<[HasSSE2]>;
2751// Special binary v4i32 shuffle cases with SHUFPS.
2752def : Pat<(vector_shuffle (v4i32 VR128:$src1), (v4i32 VR128:$src2),
2753 PSHUFD_binary_shuffle_mask:$sm),
2754 (SHUFPSrri VR128:$src1, VR128:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2755 Requires<[HasSSE2]>;
2756def : Pat<(vector_shuffle (v4i32 VR128:$src1),
Dan Gohman4a4f1512007-07-18 20:23:34 +00002757 (bc_v4i32 (memopv2i64 addr:$src2)), PSHUFD_binary_shuffle_mask:$sm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002758 (SHUFPSrmi VR128:$src1, addr:$src2, PSHUFD_binary_shuffle_mask:$sm)>,
2759 Requires<[HasSSE2]>;
2760
2761// vector_shuffle v1, <undef>, <0, 0, 1, 1, ...>
2762let AddedComplexity = 10 in {
2763def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2764 UNPCKL_v_undef_shuffle_mask)),
2765 (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2766def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2767 UNPCKL_v_undef_shuffle_mask)),
2768 (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2769def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2770 UNPCKL_v_undef_shuffle_mask)),
2771 (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2772def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2773 UNPCKL_v_undef_shuffle_mask)),
2774 (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2775}
2776
2777// vector_shuffle v1, <undef>, <2, 2, 3, 3, ...>
2778let AddedComplexity = 10 in {
2779def : Pat<(v4f32 (vector_shuffle VR128:$src, (undef),
2780 UNPCKH_v_undef_shuffle_mask)),
2781 (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2782def : Pat<(v16i8 (vector_shuffle VR128:$src, (undef),
2783 UNPCKH_v_undef_shuffle_mask)),
2784 (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2785def : Pat<(v8i16 (vector_shuffle VR128:$src, (undef),
2786 UNPCKH_v_undef_shuffle_mask)),
2787 (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>;
2788def : Pat<(v4i32 (vector_shuffle VR128:$src, (undef),
2789 UNPCKH_v_undef_shuffle_mask)),
2790 (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>;
2791}
2792
2793let AddedComplexity = 15 in {
2794// vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS
2795def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2796 MOVHP_shuffle_mask)),
2797 (MOVLHPSrr VR128:$src1, VR128:$src2)>;
2798
2799// vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS
2800def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2801 MOVHLPS_shuffle_mask)),
2802 (MOVHLPSrr VR128:$src1, VR128:$src2)>;
2803
2804// vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS
2805def : Pat<(v4f32 (vector_shuffle VR128:$src1, (undef),
2806 MOVHLPS_v_undef_shuffle_mask)),
2807 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2808def : Pat<(v4i32 (vector_shuffle VR128:$src1, (undef),
2809 MOVHLPS_v_undef_shuffle_mask)),
2810 (MOVHLPSrr VR128:$src1, VR128:$src1)>;
2811}
2812
2813let AddedComplexity = 20 in {
2814// vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS
2815// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS
Dan Gohman4a4f1512007-07-18 20:23:34 +00002816def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002817 MOVLP_shuffle_mask)),
2818 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002819def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002820 MOVLP_shuffle_mask)),
2821 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002822def : Pat<(v4f32 (vector_shuffle VR128:$src1, (memopv4f32 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002823 MOVHP_shuffle_mask)),
2824 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002825def : Pat<(v2f64 (vector_shuffle VR128:$src1, (memopv2f64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002826 MOVHP_shuffle_mask)),
2827 (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2828
Dan Gohman4a4f1512007-07-18 20:23:34 +00002829def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002830 MOVLP_shuffle_mask)),
2831 (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002832def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002833 MOVLP_shuffle_mask)),
2834 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002835def : Pat<(v4i32 (vector_shuffle VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002836 MOVHP_shuffle_mask)),
2837 (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>;
Dan Gohman4a4f1512007-07-18 20:23:34 +00002838def : Pat<(v2i64 (vector_shuffle VR128:$src1, (memopv2i64 addr:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002839 MOVLP_shuffle_mask)),
2840 (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2841}
2842
2843let AddedComplexity = 15 in {
2844// Setting the lowest element in the vector.
2845def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2846 MOVL_shuffle_mask)),
2847 (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2848def : Pat<(v2i64 (vector_shuffle VR128:$src1, VR128:$src2,
2849 MOVL_shuffle_mask)),
2850 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2851
2852// vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd)
2853def : Pat<(v4f32 (vector_shuffle VR128:$src1, VR128:$src2,
2854 MOVLP_shuffle_mask)),
2855 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2856def : Pat<(v4i32 (vector_shuffle VR128:$src1, VR128:$src2,
2857 MOVLP_shuffle_mask)),
2858 (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2859}
2860
2861// Set lowest element and zero upper elements.
2862let AddedComplexity = 20 in
2863def : Pat<(bc_v2i64 (vector_shuffle immAllZerosV,
2864 (v2f64 (scalar_to_vector (loadf64 addr:$src))),
2865 MOVL_shuffle_mask)),
2866 (MOVZQI2PQIrm addr:$src)>, Requires<[HasSSE2]>;
2867
2868// FIXME: Temporary workaround since 2-wide shuffle is broken.
2869def : Pat<(int_x86_sse2_movs_d VR128:$src1, VR128:$src2),
2870 (v2f64 (MOVLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2871def : Pat<(int_x86_sse2_loadh_pd VR128:$src1, addr:$src2),
2872 (v2f64 (MOVHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2873def : Pat<(int_x86_sse2_loadl_pd VR128:$src1, addr:$src2),
2874 (v2f64 (MOVLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2875def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, VR128:$src2, imm:$src3),
2876 (v2f64 (SHUFPDrri VR128:$src1, VR128:$src2, imm:$src3))>,
2877 Requires<[HasSSE2]>;
2878def : Pat<(int_x86_sse2_shuf_pd VR128:$src1, (load addr:$src2), imm:$src3),
2879 (v2f64 (SHUFPDrmi VR128:$src1, addr:$src2, imm:$src3))>,
2880 Requires<[HasSSE2]>;
2881def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, VR128:$src2),
2882 (v2f64 (UNPCKHPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2883def : Pat<(int_x86_sse2_unpckh_pd VR128:$src1, (load addr:$src2)),
2884 (v2f64 (UNPCKHPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2885def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, VR128:$src2),
2886 (v2f64 (UNPCKLPDrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2887def : Pat<(int_x86_sse2_unpckl_pd VR128:$src1, (load addr:$src2)),
2888 (v2f64 (UNPCKLPDrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2889def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, VR128:$src2),
2890 (v2i64 (PUNPCKHQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2891def : Pat<(int_x86_sse2_punpckh_qdq VR128:$src1, (load addr:$src2)),
2892 (v2i64 (PUNPCKHQDQrm VR128:$src1, addr:$src2))>, Requires<[HasSSE2]>;
2893def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, VR128:$src2),
2894 (v2i64 (PUNPCKLQDQrr VR128:$src1, VR128:$src2))>, Requires<[HasSSE2]>;
2895def : Pat<(int_x86_sse2_punpckl_qdq VR128:$src1, (load addr:$src2)),
2896 (PUNPCKLQDQrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2897
2898// Some special case pandn patterns.
2899def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
2900 VR128:$src2)),
2901 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2902def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
2903 VR128:$src2)),
2904 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2905def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
2906 VR128:$src2)),
2907 (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>;
2908
2909def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002910 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2912def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002913 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002914 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2915def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))),
Dan Gohman7dc19012007-08-02 21:17:01 +00002916 (memopv2i64 addr:$src2))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002917 (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>;
2918
Evan Cheng51a49b22007-07-20 00:27:43 +00002919// Use movaps / movups for SSE integer load / store (one byte shorter).
Dan Gohman11821702007-07-27 17:16:43 +00002920def : Pat<(alignedloadv4i32 addr:$src),
2921 (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>;
2922def : Pat<(loadv4i32 addr:$src),
2923 (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>;
Evan Cheng51a49b22007-07-20 00:27:43 +00002924def : Pat<(alignedloadv2i64 addr:$src),
2925 (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>;
2926def : Pat<(loadv2i64 addr:$src),
2927 (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>;
2928
2929def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst),
2930 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2931def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst),
2932 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2933def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst),
2934 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2935def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst),
2936 (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2937def : Pat<(store (v2i64 VR128:$src), addr:$dst),
2938 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2939def : Pat<(store (v4i32 VR128:$src), addr:$dst),
2940 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2941def : Pat<(store (v8i16 VR128:$src), addr:$dst),
2942 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;
2943def : Pat<(store (v16i8 VR128:$src), addr:$dst),
2944 (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>;